diff options
| author | 2023-04-23 00:01:08 -0400 | |
|---|---|---|
| committer | 2023-06-07 21:44:42 -0400 | |
| commit | 8e56a84566036cfff0aa5c3d80ae1b051d2bd0bf (patch) | |
| tree | 2bb7be86aafe9986811758b508a7581d2efe8ac4 /src/video_core/gpu.cpp | |
| parent | nvnflinger: Acquire lock prior to signaling the vsync variable (diff) | |
| download | yuzu-8e56a84566036cfff0aa5c3d80ae1b051d2bd0bf.tar.gz yuzu-8e56a84566036cfff0aa5c3d80ae1b051d2bd0bf.tar.xz yuzu-8e56a84566036cfff0aa5c3d80ae1b051d2bd0bf.zip | |
core_timing: Use CNTPCT as the guest CPU tick
Previously, we were mixing the raw CPU frequency and CNTFRQ.
The raw CPU frequency (1020 MHz) should've never been used as CNTPCT (whose frequency is CNTFRQ) is the only counter available.
Diffstat (limited to 'src/video_core/gpu.cpp')
| -rw-r--r-- | src/video_core/gpu.cpp | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/src/video_core/gpu.cpp b/src/video_core/gpu.cpp index 456f733cf..70762c51a 100644 --- a/src/video_core/gpu.cpp +++ b/src/video_core/gpu.cpp | |||
| @@ -194,17 +194,17 @@ struct GPU::Impl { | |||
| 194 | 194 | ||
| 195 | [[nodiscard]] u64 GetTicks() const { | 195 | [[nodiscard]] u64 GetTicks() const { |
| 196 | // This values were reversed engineered by fincs from NVN | 196 | // This values were reversed engineered by fincs from NVN |
| 197 | // The gpu clock is reported in units of 385/625 nanoseconds | 197 | // The GPU clock is 614.4 MHz |
| 198 | constexpr u64 gpu_ticks_num = 384; | 198 | using NsToGPUTickRatio = std::ratio<614'400'000, std::nano::den>; |
| 199 | constexpr u64 gpu_ticks_den = 625; | 199 | static_assert(NsToGPUTickRatio::num == 384 && NsToGPUTickRatio::den == 625); |
| 200 | |||
| 201 | u64 nanoseconds = system.CoreTiming().GetGlobalTimeNs().count(); | ||
| 200 | 202 | ||
| 201 | u64 nanoseconds = system.CoreTiming().GetCPUTimeNs().count(); | ||
| 202 | if (Settings::values.use_fast_gpu_time.GetValue()) { | 203 | if (Settings::values.use_fast_gpu_time.GetValue()) { |
| 203 | nanoseconds /= 256; | 204 | nanoseconds /= 256; |
| 204 | } | 205 | } |
| 205 | const u64 nanoseconds_num = nanoseconds / gpu_ticks_den; | 206 | |
| 206 | const u64 nanoseconds_rem = nanoseconds % gpu_ticks_den; | 207 | return nanoseconds * NsToGPUTickRatio::num / NsToGPUTickRatio::den; |
| 207 | return nanoseconds_num * gpu_ticks_num + (nanoseconds_rem * gpu_ticks_num) / gpu_ticks_den; | ||
| 208 | } | 208 | } |
| 209 | 209 | ||
| 210 | [[nodiscard]] bool IsAsync() const { | 210 | [[nodiscard]] bool IsAsync() const { |