diff options
| author | 2023-05-28 17:45:47 -0400 | |
|---|---|---|
| committer | 2023-06-07 21:44:42 -0400 | |
| commit | 907507886d755fa56099713c4b8f05bb640a8b7d (patch) | |
| tree | a6ef3a8dfa9ba4aab797ab4985e078aba4b89fd2 /src/common/wall_clock.cpp | |
| parent | time: Use compile time division for TimeSpanType conversion (diff) | |
| download | yuzu-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 '')
| -rw-r--r-- | src/common/wall_clock.cpp | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/src/common/wall_clock.cpp b/src/common/wall_clock.cpp index ad8db06b0..dc0dcbd68 100644 --- a/src/common/wall_clock.cpp +++ b/src/common/wall_clock.cpp | |||
| @@ -32,6 +32,10 @@ public: | |||
| 32 | return GetHostTicksElapsed() * NsToCNTPCTRatio::num / NsToCNTPCTRatio::den; | 32 | return GetHostTicksElapsed() * NsToCNTPCTRatio::num / NsToCNTPCTRatio::den; |
| 33 | } | 33 | } |
| 34 | 34 | ||
| 35 | u64 GetGPUTick() const override { | ||
| 36 | return GetHostTicksElapsed() * NsToGPUTickRatio::num / NsToGPUTickRatio::den; | ||
| 37 | } | ||
| 38 | |||
| 35 | u64 GetHostTicksNow() const override { | 39 | u64 GetHostTicksNow() const override { |
| 36 | return static_cast<u64>(SteadyClock::Now().time_since_epoch().count()); | 40 | return static_cast<u64>(SteadyClock::Now().time_since_epoch().count()); |
| 37 | } | 41 | } |
| @@ -52,12 +56,12 @@ std::unique_ptr<WallClock> CreateOptimalClock() { | |||
| 52 | #ifdef ARCHITECTURE_x86_64 | 56 | #ifdef ARCHITECTURE_x86_64 |
| 53 | const auto& caps = GetCPUCaps(); | 57 | const auto& caps = GetCPUCaps(); |
| 54 | 58 | ||
| 55 | if (caps.invariant_tsc && caps.tsc_frequency >= WallClock::CNTFRQ) { | 59 | if (caps.invariant_tsc && caps.tsc_frequency >= WallClock::GPUTickFreq) { |
| 56 | return std::make_unique<X64::NativeClock>(caps.tsc_frequency); | 60 | return std::make_unique<X64::NativeClock>(caps.tsc_frequency); |
| 57 | } else { | 61 | } else { |
| 58 | // Fallback to StandardWallClock if the hardware TSC | 62 | // Fallback to StandardWallClock if the hardware TSC |
| 59 | // - Is not invariant | 63 | // - Is not invariant |
| 60 | // - Is not more precise than CNTFRQ | 64 | // - Is not more precise than GPUTickFreq |
| 61 | return std::make_unique<StandardWallClock>(); | 65 | return std::make_unique<StandardWallClock>(); |
| 62 | } | 66 | } |
| 63 | #else | 67 | #else |