aboutsummaryrefslogtreecommitdiff
path: root/src/video_core/gpu.cpp
diff options
context:
space:
mode:
authorMorph <39850852+Morph1984@users.noreply.github.com>2023-04-23 00:01:08 -0400
committerMorph <39850852+Morph1984@users.noreply.github.com>2023-06-07 21:44:42 -0400
commit2856fadaa016c6fe378c5ac377aedec156131803 (patch)
tree2bb7be86aafe9986811758b508a7581d2efe8ac4 /src/video_core/gpu.cpp
parentfb3bb638806457a064d1201ff322c4da096393af (diff)
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.cpp14
1 files changed, 7 insertions, 7 deletions
diff --git a/src/video_core/gpu.cpp b/src/video_core/gpu.cpp
index 456f733cf3..70762c51a4 100644
--- a/src/video_core/gpu.cpp
+++ b/src/video_core/gpu.cpp
@@ -194,17 +194,17 @@ struct GPU::Impl {
[[nodiscard]] u64 GetTicks() const {
// 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;
+ // The GPU clock is 614.4 MHz
+ using NsToGPUTickRatio = std::ratio<614'400'000, std::nano::den>;
+ static_assert(NsToGPUTickRatio::num == 384 && NsToGPUTickRatio::den == 625);
+
+ u64 nanoseconds = system.CoreTiming().GetGlobalTimeNs().count();
- u64 nanoseconds = system.CoreTiming().GetCPUTimeNs().count();
if (Settings::values.use_fast_gpu_time.GetValue()) {
nanoseconds /= 256;
}
- const u64 nanoseconds_num = nanoseconds / gpu_ticks_den;
- const u64 nanoseconds_rem = nanoseconds % gpu_ticks_den;
- return nanoseconds_num * gpu_ticks_num + (nanoseconds_rem * gpu_ticks_num) / gpu_ticks_den;
+
+ return nanoseconds * NsToGPUTickRatio::num / NsToGPUTickRatio::den;
}
[[nodiscard]] bool IsAsync() const {