diff options
| author | 2020-02-13 20:18:26 -0500 | |
|---|---|---|
| committer | 2020-02-13 20:18:26 -0500 | |
| commit | 3563af2364a08db21e95ca1ac344f34251bfa27b (patch) | |
| tree | 36cc82478d46104db82f64b3bd8f14bb53cb6763 /src/video_core/gpu.cpp | |
| parent | Merge pull request #3405 from lioncash/thread (diff) | |
| parent | GPU: Address Feedback. (diff) | |
| download | yuzu-3563af2364a08db21e95ca1ac344f34251bfa27b.tar.gz yuzu-3563af2364a08db21e95ca1ac344f34251bfa27b.tar.xz yuzu-3563af2364a08db21e95ca1ac344f34251bfa27b.zip | |
Merge pull request #3395 from FernandoS27/queries
GPU: Refactor queries implementation and correct GPU Clock.
Diffstat (limited to 'src/video_core/gpu.cpp')
| -rw-r--r-- | src/video_core/gpu.cpp | 16 |
1 files changed, 15 insertions, 1 deletions
diff --git a/src/video_core/gpu.cpp b/src/video_core/gpu.cpp index 062ca83b8..4419ab735 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,19 @@ bool GPU::CancelSyncptInterrupt(const u32 syncpoint_id, const u32 value) { | |||
| 122 | return true; | 123 | return true; |
| 123 | } | 124 | } |
| 124 | 125 | ||
| 126 | u64 GPU::GetTicks() const { | ||
| 127 | // This values were reversed engineered by fincs from NVN | ||
| 128 | // The gpu clock is reported in units of 385/625 nanoseconds | ||
| 129 | constexpr u64 gpu_ticks_num = 384; | ||
| 130 | constexpr u64 gpu_ticks_den = 625; | ||
| 131 | |||
| 132 | const u64 cpu_ticks = system.CoreTiming().GetTicks(); | ||
| 133 | const u64 nanoseconds = Core::Timing::CyclesToNs(cpu_ticks).count(); | ||
| 134 | const u64 nanoseconds_num = nanoseconds / gpu_ticks_den; | ||
| 135 | const u64 nanoseconds_rem = nanoseconds % gpu_ticks_den; | ||
| 136 | return nanoseconds_num * gpu_ticks_num + (nanoseconds_rem * gpu_ticks_num) / gpu_ticks_den; | ||
| 137 | } | ||
| 138 | |||
| 125 | void GPU::FlushCommands() { | 139 | void GPU::FlushCommands() { |
| 126 | renderer.Rasterizer().FlushCommands(); | 140 | renderer.Rasterizer().FlushCommands(); |
| 127 | } | 141 | } |
| @@ -340,7 +354,7 @@ void GPU::ProcessSemaphoreTriggerMethod() { | |||
| 340 | block.sequence = regs.semaphore_sequence; | 354 | block.sequence = regs.semaphore_sequence; |
| 341 | // TODO(Kmather73): Generate a real GPU timestamp and write it here instead of | 355 | // TODO(Kmather73): Generate a real GPU timestamp and write it here instead of |
| 342 | // CoreTiming | 356 | // CoreTiming |
| 343 | block.timestamp = system.CoreTiming().GetTicks(); | 357 | block.timestamp = GetTicks(); |
| 344 | memory_manager->WriteBlock(regs.semaphore_address.SemaphoreAddress(), &block, | 358 | memory_manager->WriteBlock(regs.semaphore_address.SemaphoreAddress(), &block, |
| 345 | sizeof(block)); | 359 | sizeof(block)); |
| 346 | } else { | 360 | } else { |