yuzu-emu
/
yuzu-mainline
Archived
1
0
Fork 0

GPU: Implement GPU Clock correctly.

This commit is contained in:
Fernando Sahmkow 2020-02-10 10:32:51 -04:00 committed by FernandoS27
parent 0cb3bcfbb7
commit 8e9a4944db
3 changed files with 17 additions and 2 deletions

View File

@ -9,6 +9,7 @@
#include "core/core_timing.h" #include "core/core_timing.h"
#include "video_core/engines/maxwell_3d.h" #include "video_core/engines/maxwell_3d.h"
#include "video_core/engines/shader_type.h" #include "video_core/engines/shader_type.h"
#include "video_core/gpu.h"
#include "video_core/memory_manager.h" #include "video_core/memory_manager.h"
#include "video_core/rasterizer_interface.h" #include "video_core/rasterizer_interface.h"
#include "video_core/textures/texture.h" #include "video_core/textures/texture.h"
@ -533,7 +534,7 @@ void Maxwell3D::StampQueryResult(u64 payload, bool long_query) {
LongQueryResult query_result{}; LongQueryResult query_result{};
query_result.value = payload; query_result.value = payload;
// TODO(Subv): Generate a real GPU timestamp and write it here instead of CoreTiming // TODO(Subv): Generate a real GPU timestamp and write it here instead of CoreTiming
query_result.timestamp = system.CoreTiming().GetTicks(); query_result.timestamp = system.GPU().GetTicks();
memory_manager.WriteBlock(sequence_address, &query_result, sizeof(query_result)); memory_manager.WriteBlock(sequence_address, &query_result, sizeof(query_result));
} else { } else {
memory_manager.Write<u32>(sequence_address, static_cast<u32>(payload)); memory_manager.Write<u32>(sequence_address, static_cast<u32>(payload));

View File

@ -6,6 +6,7 @@
#include "common/microprofile.h" #include "common/microprofile.h"
#include "core/core.h" #include "core/core.h"
#include "core/core_timing.h" #include "core/core_timing.h"
#include "core/core_timing_util.h"
#include "core/memory.h" #include "core/memory.h"
#include "video_core/engines/fermi_2d.h" #include "video_core/engines/fermi_2d.h"
#include "video_core/engines/kepler_compute.h" #include "video_core/engines/kepler_compute.h"
@ -122,6 +123,17 @@ bool GPU::CancelSyncptInterrupt(const u32 syncpoint_id, const u32 value) {
return true; return true;
} }
// This values were reversed engineered by fincs from NVN
// The gpu clock is reported in units of 385/625 nanoseconds
constexpr u64 gpu_ticks_num = 384;
constexpr u64 gpu_ticks_den = 625;
u64 GPU::GetTicks() const {
const u64 cpu_ticks = system.CoreTiming().GetTicks();
const u64 nanoseconds = Core::Timing::CyclesToNs(cpu_ticks).count();
return (nanoseconds * gpu_ticks_num) / gpu_ticks_den;
}
void GPU::FlushCommands() { void GPU::FlushCommands() {
renderer.Rasterizer().FlushCommands(); renderer.Rasterizer().FlushCommands();
} }
@ -340,7 +352,7 @@ void GPU::ProcessSemaphoreTriggerMethod() {
block.sequence = regs.semaphore_sequence; block.sequence = regs.semaphore_sequence;
// TODO(Kmather73): Generate a real GPU timestamp and write it here instead of // TODO(Kmather73): Generate a real GPU timestamp and write it here instead of
// CoreTiming // CoreTiming
block.timestamp = system.CoreTiming().GetTicks(); block.timestamp = GetTicks();
memory_manager->WriteBlock(regs.semaphore_address.SemaphoreAddress(), &block, memory_manager->WriteBlock(regs.semaphore_address.SemaphoreAddress(), &block,
sizeof(block)); sizeof(block));
} else { } else {

View File

@ -192,6 +192,8 @@ public:
bool CancelSyncptInterrupt(u32 syncpoint_id, u32 value); bool CancelSyncptInterrupt(u32 syncpoint_id, u32 value);
u64 GetTicks() const;
std::unique_lock<std::mutex> LockSync() { std::unique_lock<std::mutex> LockSync() {
return std::unique_lock{sync_mutex}; return std::unique_lock{sync_mutex};
} }