diff options
| author | 2020-02-10 10:32:51 -0400 | |
|---|---|---|
| committer | 2020-02-10 10:44:54 -0400 | |
| commit | 8e9a4944dbbb4a22d149bb989faf32db0a979766 (patch) | |
| tree | 2c24fc758046e03929dcd8e42c76674580e0a34e /src/video_core/gpu.cpp | |
| parent | Maxwell3D: Correct query reporting. (diff) | |
| download | yuzu-8e9a4944dbbb4a22d149bb989faf32db0a979766.tar.gz yuzu-8e9a4944dbbb4a22d149bb989faf32db0a979766.tar.xz yuzu-8e9a4944dbbb4a22d149bb989faf32db0a979766.zip | |
GPU: Implement GPU Clock correctly.
Diffstat (limited to 'src/video_core/gpu.cpp')
| -rw-r--r-- | src/video_core/gpu.cpp | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/src/video_core/gpu.cpp b/src/video_core/gpu.cpp index 062ca83b8..4aca39faf 100644 --- a/src/video_core/gpu.cpp +++ b/src/video_core/gpu.cpp | |||
| @@ -6,6 +6,7 @@ | |||
| 6 | #include "common/microprofile.h" | 6 | #include "common/microprofile.h" |
| 7 | #include "core/core.h" | 7 | #include "core/core.h" |
| 8 | #include "core/core_timing.h" | 8 | #include "core/core_timing.h" |
| 9 | #include "core/core_timing_util.h" | ||
| 9 | #include "core/memory.h" | 10 | #include "core/memory.h" |
| 10 | #include "video_core/engines/fermi_2d.h" | 11 | #include "video_core/engines/fermi_2d.h" |
| 11 | #include "video_core/engines/kepler_compute.h" | 12 | #include "video_core/engines/kepler_compute.h" |
| @@ -122,6 +123,17 @@ bool GPU::CancelSyncptInterrupt(const u32 syncpoint_id, const u32 value) { | |||
| 122 | return true; | 123 | return true; |
| 123 | } | 124 | } |
| 124 | 125 | ||
| 126 | // This values were reversed engineered by fincs from NVN | ||
| 127 | // The gpu clock is reported in units of 385/625 nanoseconds | ||
| 128 | constexpr u64 gpu_ticks_num = 384; | ||
| 129 | constexpr u64 gpu_ticks_den = 625; | ||
| 130 | |||
| 131 | u64 GPU::GetTicks() const { | ||
| 132 | const u64 cpu_ticks = system.CoreTiming().GetTicks(); | ||
| 133 | const u64 nanoseconds = Core::Timing::CyclesToNs(cpu_ticks).count(); | ||
| 134 | return (nanoseconds * gpu_ticks_num) / gpu_ticks_den; | ||
| 135 | } | ||
| 136 | |||
| 125 | void GPU::FlushCommands() { | 137 | void GPU::FlushCommands() { |
| 126 | renderer.Rasterizer().FlushCommands(); | 138 | renderer.Rasterizer().FlushCommands(); |
| 127 | } | 139 | } |
| @@ -340,7 +352,7 @@ void GPU::ProcessSemaphoreTriggerMethod() { | |||
| 340 | block.sequence = regs.semaphore_sequence; | 352 | block.sequence = regs.semaphore_sequence; |
| 341 | // TODO(Kmather73): Generate a real GPU timestamp and write it here instead of | 353 | // TODO(Kmather73): Generate a real GPU timestamp and write it here instead of |
| 342 | // CoreTiming | 354 | // CoreTiming |
| 343 | block.timestamp = system.CoreTiming().GetTicks(); | 355 | block.timestamp = GetTicks(); |
| 344 | memory_manager->WriteBlock(regs.semaphore_address.SemaphoreAddress(), &block, | 356 | memory_manager->WriteBlock(regs.semaphore_address.SemaphoreAddress(), &block, |
| 345 | sizeof(block)); | 357 | sizeof(block)); |
| 346 | } else { | 358 | } else { |