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/x64 | |
| 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 'src/common/x64')
| -rw-r--r-- | src/common/x64/native_clock.cpp | 7 | ||||
| -rw-r--r-- | src/common/x64/native_clock.h | 3 |
2 files changed, 9 insertions, 1 deletions
diff --git a/src/common/x64/native_clock.cpp b/src/common/x64/native_clock.cpp index 5d1eb0590..7d2a26bd9 100644 --- a/src/common/x64/native_clock.cpp +++ b/src/common/x64/native_clock.cpp | |||
| @@ -12,7 +12,8 @@ NativeClock::NativeClock(u64 rdtsc_frequency_) | |||
| 12 | ns_rdtsc_factor{GetFixedPoint64Factor(NsRatio::den, rdtsc_frequency)}, | 12 | ns_rdtsc_factor{GetFixedPoint64Factor(NsRatio::den, rdtsc_frequency)}, |
| 13 | us_rdtsc_factor{GetFixedPoint64Factor(UsRatio::den, rdtsc_frequency)}, | 13 | us_rdtsc_factor{GetFixedPoint64Factor(UsRatio::den, rdtsc_frequency)}, |
| 14 | ms_rdtsc_factor{GetFixedPoint64Factor(MsRatio::den, rdtsc_frequency)}, | 14 | ms_rdtsc_factor{GetFixedPoint64Factor(MsRatio::den, rdtsc_frequency)}, |
| 15 | cntpct_rdtsc_factor{GetFixedPoint64Factor(CNTFRQ, rdtsc_frequency)} {} | 15 | cntpct_rdtsc_factor{GetFixedPoint64Factor(CNTFRQ, rdtsc_frequency)}, |
| 16 | gputick_rdtsc_factor{GetFixedPoint64Factor(GPUTickFreq, rdtsc_frequency)} {} | ||
| 16 | 17 | ||
| 17 | std::chrono::nanoseconds NativeClock::GetTimeNS() const { | 18 | std::chrono::nanoseconds NativeClock::GetTimeNS() const { |
| 18 | return std::chrono::nanoseconds{MultiplyHigh(GetHostTicksElapsed(), ns_rdtsc_factor)}; | 19 | return std::chrono::nanoseconds{MultiplyHigh(GetHostTicksElapsed(), ns_rdtsc_factor)}; |
| @@ -30,6 +31,10 @@ u64 NativeClock::GetCNTPCT() const { | |||
| 30 | return MultiplyHigh(GetHostTicksElapsed(), cntpct_rdtsc_factor); | 31 | return MultiplyHigh(GetHostTicksElapsed(), cntpct_rdtsc_factor); |
| 31 | } | 32 | } |
| 32 | 33 | ||
| 34 | u64 NativeClock::GetGPUTick() const { | ||
| 35 | return MultiplyHigh(GetHostTicksElapsed(), gputick_rdtsc_factor); | ||
| 36 | } | ||
| 37 | |||
| 33 | u64 NativeClock::GetHostTicksNow() const { | 38 | u64 NativeClock::GetHostTicksNow() const { |
| 34 | return FencedRDTSC(); | 39 | return FencedRDTSC(); |
| 35 | } | 40 | } |
diff --git a/src/common/x64/native_clock.h b/src/common/x64/native_clock.h index d6f8626c1..334415eff 100644 --- a/src/common/x64/native_clock.h +++ b/src/common/x64/native_clock.h | |||
| @@ -19,6 +19,8 @@ public: | |||
| 19 | 19 | ||
| 20 | u64 GetCNTPCT() const override; | 20 | u64 GetCNTPCT() const override; |
| 21 | 21 | ||
| 22 | u64 GetGPUTick() const override; | ||
| 23 | |||
| 22 | u64 GetHostTicksNow() const override; | 24 | u64 GetHostTicksNow() const override; |
| 23 | 25 | ||
| 24 | u64 GetHostTicksElapsed() const override; | 26 | u64 GetHostTicksElapsed() const override; |
| @@ -33,6 +35,7 @@ private: | |||
| 33 | u64 us_rdtsc_factor; | 35 | u64 us_rdtsc_factor; |
| 34 | u64 ms_rdtsc_factor; | 36 | u64 ms_rdtsc_factor; |
| 35 | u64 cntpct_rdtsc_factor; | 37 | u64 cntpct_rdtsc_factor; |
| 38 | u64 gputick_rdtsc_factor; | ||
| 36 | }; | 39 | }; |
| 37 | 40 | ||
| 38 | } // namespace Common::X64 | 41 | } // namespace Common::X64 |