diff options
author | Morph <39850852+Morph1984@users.noreply.github.com> | 2023-06-08 03:38:28 +0200 |
---|---|---|
committer | Morph <39850852+Morph1984@users.noreply.github.com> | 2023-06-08 03:44:42 +0200 |
commit | 2e1e7254436b032f133372c76d9484aa756d56df (patch) | |
tree | ce55efc11d5dee53a87532b77ce85d3e0d2b2a76 /src/common | |
parent | (wall, native)_clock: Add GetGPUTick (diff) | |
download | yuzu-2e1e7254436b032f133372c76d9484aa756d56df.tar yuzu-2e1e7254436b032f133372c76d9484aa756d56df.tar.gz yuzu-2e1e7254436b032f133372c76d9484aa756d56df.tar.bz2 yuzu-2e1e7254436b032f133372c76d9484aa756d56df.tar.lz yuzu-2e1e7254436b032f133372c76d9484aa756d56df.tar.xz yuzu-2e1e7254436b032f133372c76d9484aa756d56df.tar.zst yuzu-2e1e7254436b032f133372c76d9484aa756d56df.zip |
Diffstat (limited to 'src/common')
-rw-r--r-- | src/common/wall_clock.h | 36 |
1 files changed, 20 insertions, 16 deletions
diff --git a/src/common/wall_clock.h b/src/common/wall_clock.h index fcfdd637c..f45d3d8c5 100644 --- a/src/common/wall_clock.h +++ b/src/common/wall_clock.h @@ -13,8 +13,9 @@ namespace Common { class WallClock { public: - static constexpr u64 CNTFRQ = 19'200'000; // CNTPCT_EL0 Frequency = 19.2 MHz - static constexpr u64 GPUTickFreq = 614'400'000; // GM20B GPU Tick Frequency = 614.4 MHz + static constexpr u64 CNTFRQ = 19'200'000; // CNTPCT_EL0 Frequency = 19.2 MHz + static constexpr u64 GPUTickFreq = 614'400'000; // GM20B GPU Tick Frequency = 614.4 MHz + static constexpr u64 CPUTickFreq = 1'020'000'000; // T210/4 A57 CPU Tick Frequency = 1020.0 MHz virtual ~WallClock() = default; @@ -46,28 +47,26 @@ public: return ns * NsToCNTPCTRatio::num / NsToCNTPCTRatio::den; } - static inline u64 USToCNTPCT(u64 us) { - return us * UsToCNTPCTRatio::num / UsToCNTPCTRatio::den; - } - static inline u64 NSToGPUTick(u64 ns) { return ns * NsToGPUTickRatio::num / NsToGPUTickRatio::den; } - static inline u64 CNTPCTToNS(u64 cntpct) { - return cntpct * NsToCNTPCTRatio::den / NsToCNTPCTRatio::num; + // Cycle Timing + + static inline u64 CPUTickToNS(u64 cpu_tick) { + return cpu_tick * CPUTickToNsRatio::num / CPUTickToNsRatio::den; } - static inline u64 CNTPCTToUS(u64 cntpct) { - return cntpct * UsToCNTPCTRatio::den / UsToCNTPCTRatio::num; + static inline u64 CPUTickToUS(u64 cpu_tick) { + return cpu_tick * CPUTickToUsRatio::num / CPUTickToUsRatio::den; } - static inline u64 GPUTickToNS(u64 gpu_tick) { - return gpu_tick * NsToGPUTickRatio::den / NsToGPUTickRatio::num; + static inline u64 CPUTickToCNTPCT(u64 cpu_tick) { + return cpu_tick * CPUTickToCNTPCTRatio::num / CPUTickToCNTPCTRatio::den; } - static inline u64 CNTPCTToGPUTick(u64 cntpct) { - return cntpct * CNTPCTToGPUTickRatio::num / CNTPCTToGPUTickRatio::den; + static inline u64 CPUTickToGPUTick(u64 cpu_tick) { + return cpu_tick * CPUTickToGPUTickRatio::num / CPUTickToGPUTickRatio::den; } protected: @@ -78,9 +77,14 @@ protected: using NsToUsRatio = std::ratio_divide<std::nano, std::micro>; using NsToMsRatio = std::ratio_divide<std::nano, std::milli>; using NsToCNTPCTRatio = std::ratio<CNTFRQ, std::nano::den>; - using UsToCNTPCTRatio = std::ratio<CNTFRQ, std::micro::den>; using NsToGPUTickRatio = std::ratio<GPUTickFreq, std::nano::den>; - using CNTPCTToGPUTickRatio = std::ratio<GPUTickFreq, CNTFRQ>; + + // Cycle Timing + + using CPUTickToNsRatio = std::ratio<std::nano::den, CPUTickFreq>; + using CPUTickToUsRatio = std::ratio<std::micro::den, CPUTickFreq>; + using CPUTickToCNTPCTRatio = std::ratio<CNTFRQ, CPUTickFreq>; + using CPUTickToGPUTickRatio = std::ratio<GPUTickFreq, CPUTickFreq>; }; std::unique_ptr<WallClock> CreateOptimalClock(); |