summaryrefslogtreecommitdiff
path: root/src/video_core
diff options
context:
space:
mode:
authorGravatar Morph2023-05-28 17:45:47 -0400
committerGravatar Morph2023-06-07 21:44:42 -0400
commit907507886d755fa56099713c4b8f05bb640a8b7d (patch)
treea6ef3a8dfa9ba4aab797ab4985e078aba4b89fd2 /src/video_core
parenttime: Use compile time division for TimeSpanType conversion (diff)
downloadyuzu-907507886d755fa56099713c4b8f05bb640a8b7d.tar.gz
yuzu-907507886d755fa56099713c4b8f05bb640a8b7d.tar.xz
yuzu-907507886d755fa56099713c4b8f05bb640a8b7d.zip
(wall, native)_clock: Add GetGPUTick
Allows us to directly calculate the GPU tick without double conversion to and from the host clock tick.
Diffstat (limited to 'src/video_core')
-rw-r--r--src/video_core/gpu.cpp11
1 files changed, 3 insertions, 8 deletions
diff --git a/src/video_core/gpu.cpp b/src/video_core/gpu.cpp
index 70762c51a..db385076d 100644
--- a/src/video_core/gpu.cpp
+++ b/src/video_core/gpu.cpp
@@ -193,18 +193,13 @@ struct GPU::Impl {
193 } 193 }
194 194
195 [[nodiscard]] u64 GetTicks() const { 195 [[nodiscard]] u64 GetTicks() const {
196 // This values were reversed engineered by fincs from NVN 196 u64 gpu_tick = system.CoreTiming().GetGPUTicks();
197 // The GPU clock is 614.4 MHz
198 using NsToGPUTickRatio = std::ratio<614'400'000, std::nano::den>;
199 static_assert(NsToGPUTickRatio::num == 384 && NsToGPUTickRatio::den == 625);
200
201 u64 nanoseconds = system.CoreTiming().GetGlobalTimeNs().count();
202 197
203 if (Settings::values.use_fast_gpu_time.GetValue()) { 198 if (Settings::values.use_fast_gpu_time.GetValue()) {
204 nanoseconds /= 256; 199 gpu_tick /= 256;
205 } 200 }
206 201
207 return nanoseconds * NsToGPUTickRatio::num / NsToGPUTickRatio::den; 202 return gpu_tick;
208 } 203 }
209 204
210 [[nodiscard]] bool IsAsync() const { 205 [[nodiscard]] bool IsAsync() const {