diff options
| author | 2020-02-25 12:28:55 -0400 | |
|---|---|---|
| committer | 2020-06-27 11:35:10 -0400 | |
| commit | 18dcb0934217628711c5b1d22fd6d7635e683e3f (patch) | |
| tree | 426f78eb11aa79e0d1c7470b966fbae8ea8e3e6d /src/common/x64 | |
| parent | AudioCore: Use nanoseconds instead of cycles for buffer time. (diff) | |
| download | yuzu-18dcb0934217628711c5b1d22fd6d7635e683e3f.tar.gz yuzu-18dcb0934217628711c5b1d22fd6d7635e683e3f.tar.xz yuzu-18dcb0934217628711c5b1d22fd6d7635e683e3f.zip | |
HostTiming: Pause the hardware clock on pause.
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 | 2 |
2 files changed, 9 insertions, 0 deletions
diff --git a/src/common/x64/native_clock.cpp b/src/common/x64/native_clock.cpp index 26d4d0ba6..926f92ff8 100644 --- a/src/common/x64/native_clock.cpp +++ b/src/common/x64/native_clock.cpp | |||
| @@ -65,6 +65,13 @@ u64 NativeClock::GetRTSC() { | |||
| 65 | return accumulated_ticks; | 65 | return accumulated_ticks; |
| 66 | } | 66 | } |
| 67 | 67 | ||
| 68 | void NativeClock::Pause(bool is_paused) { | ||
| 69 | if (!is_paused) { | ||
| 70 | _mm_mfence(); | ||
| 71 | last_measure = __rdtsc(); | ||
| 72 | } | ||
| 73 | } | ||
| 74 | |||
| 68 | std::chrono::nanoseconds NativeClock::GetTimeNS() { | 75 | std::chrono::nanoseconds NativeClock::GetTimeNS() { |
| 69 | const u64 rtsc_value = GetRTSC(); | 76 | const u64 rtsc_value = GetRTSC(); |
| 70 | return std::chrono::nanoseconds{MultiplyAndDivide64(rtsc_value, 1000000000, rtsc_frequency)}; | 77 | return std::chrono::nanoseconds{MultiplyAndDivide64(rtsc_value, 1000000000, rtsc_frequency)}; |
diff --git a/src/common/x64/native_clock.h b/src/common/x64/native_clock.h index b58cf9f5a..3851f8fc2 100644 --- a/src/common/x64/native_clock.h +++ b/src/common/x64/native_clock.h | |||
| @@ -26,6 +26,8 @@ public: | |||
| 26 | 26 | ||
| 27 | u64 GetCPUCycles() override; | 27 | u64 GetCPUCycles() override; |
| 28 | 28 | ||
| 29 | void Pause(bool is_paused) override; | ||
| 30 | |||
| 29 | private: | 31 | private: |
| 30 | u64 GetRTSC(); | 32 | u64 GetRTSC(); |
| 31 | 33 | ||