diff options
| author | 2021-01-15 23:01:42 -0800 | |
|---|---|---|
| committer | 2021-01-15 23:01:42 -0800 | |
| commit | a7fd61fcce4634b8e849ab65a732080e77fad902 (patch) | |
| tree | 843fb62264d5acf24a243d564de7492be660fa2e /src/common/x64/native_clock.h | |
| parent | Merge pull request #5336 from lioncash/tree (diff) | |
| parent | X86/NativeClock: Reimplement RTDSC access to be lock free. (diff) | |
| download | yuzu-a7fd61fcce4634b8e849ab65a732080e77fad902.tar.gz yuzu-a7fd61fcce4634b8e849ab65a732080e77fad902.tar.xz yuzu-a7fd61fcce4634b8e849ab65a732080e77fad902.zip | |
Merge pull request #5275 from FernandoS27/fast-native-clock
X86/NativeClock: Improve performance of clock calculations on hot path.
Diffstat (limited to 'src/common/x64/native_clock.h')
| -rw-r--r-- | src/common/x64/native_clock.h | 21 |
1 files changed, 17 insertions, 4 deletions
diff --git a/src/common/x64/native_clock.h b/src/common/x64/native_clock.h index 6d1e32ac8..7cbd400d2 100644 --- a/src/common/x64/native_clock.h +++ b/src/common/x64/native_clock.h | |||
| @@ -6,7 +6,6 @@ | |||
| 6 | 6 | ||
| 7 | #include <optional> | 7 | #include <optional> |
| 8 | 8 | ||
| 9 | #include "common/spin_lock.h" | ||
| 10 | #include "common/wall_clock.h" | 9 | #include "common/wall_clock.h" |
| 11 | 10 | ||
| 12 | namespace Common { | 11 | namespace Common { |
| @@ -32,14 +31,28 @@ public: | |||
| 32 | private: | 31 | private: |
| 33 | u64 GetRTSC(); | 32 | u64 GetRTSC(); |
| 34 | 33 | ||
| 34 | union alignas(16) TimePoint { | ||
| 35 | TimePoint() : pack{} {} | ||
| 36 | u128 pack{}; | ||
| 37 | struct Inner { | ||
| 38 | u64 last_measure{}; | ||
| 39 | u64 accumulated_ticks{}; | ||
| 40 | } inner; | ||
| 41 | }; | ||
| 42 | |||
| 35 | /// value used to reduce the native clocks accuracy as some apss rely on | 43 | /// value used to reduce the native clocks accuracy as some apss rely on |
| 36 | /// undefined behavior where the level of accuracy in the clock shouldn't | 44 | /// undefined behavior where the level of accuracy in the clock shouldn't |
| 37 | /// be higher. | 45 | /// be higher. |
| 38 | static constexpr u64 inaccuracy_mask = ~(UINT64_C(0x400) - 1); | 46 | static constexpr u64 inaccuracy_mask = ~(UINT64_C(0x400) - 1); |
| 39 | 47 | ||
| 40 | SpinLock rtsc_serialize{}; | 48 | TimePoint time_point; |
| 41 | u64 last_measure{}; | 49 | // factors |
| 42 | u64 accumulated_ticks{}; | 50 | u64 clock_rtsc_factor{}; |
| 51 | u64 cpu_rtsc_factor{}; | ||
| 52 | u64 ns_rtsc_factor{}; | ||
| 53 | u64 us_rtsc_factor{}; | ||
| 54 | u64 ms_rtsc_factor{}; | ||
| 55 | |||
| 43 | u64 rtsc_frequency; | 56 | u64 rtsc_frequency; |
| 44 | }; | 57 | }; |
| 45 | } // namespace X64 | 58 | } // namespace X64 |