diff options
author | Morph <39850852+Morph1984@users.noreply.github.com> | 2023-04-23 06:01:08 +0200 |
---|---|---|
committer | Morph <39850852+Morph1984@users.noreply.github.com> | 2023-06-08 03:44:42 +0200 |
commit | 8e56a84566036cfff0aa5c3d80ae1b051d2bd0bf (patch) | |
tree | 2bb7be86aafe9986811758b508a7581d2efe8ac4 /src/common/wall_clock.h | |
parent | nvnflinger: Acquire lock prior to signaling the vsync variable (diff) | |
download | yuzu-8e56a84566036cfff0aa5c3d80ae1b051d2bd0bf.tar yuzu-8e56a84566036cfff0aa5c3d80ae1b051d2bd0bf.tar.gz yuzu-8e56a84566036cfff0aa5c3d80ae1b051d2bd0bf.tar.bz2 yuzu-8e56a84566036cfff0aa5c3d80ae1b051d2bd0bf.tar.lz yuzu-8e56a84566036cfff0aa5c3d80ae1b051d2bd0bf.tar.xz yuzu-8e56a84566036cfff0aa5c3d80ae1b051d2bd0bf.tar.zst yuzu-8e56a84566036cfff0aa5c3d80ae1b051d2bd0bf.zip |
Diffstat (limited to '')
-rw-r--r-- | src/common/wall_clock.h | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/src/common/wall_clock.h b/src/common/wall_clock.h index a73e6e644..56c18ca25 100644 --- a/src/common/wall_clock.h +++ b/src/common/wall_clock.h @@ -38,6 +38,22 @@ public: /// @returns Whether the clock directly uses the host's hardware clock. virtual bool IsNative() const = 0; + static inline u64 NSToCNTPCT(u64 ns) { + return ns * NsToCNTPCTRatio::num / NsToCNTPCTRatio::den; + } + + static inline u64 USToCNTPCT(u64 us) { + return us * UsToCNTPCTRatio::num / UsToCNTPCTRatio::den; + } + + static inline u64 CNTPCTToNS(u64 cntpct) { + return cntpct * NsToCNTPCTRatio::den / NsToCNTPCTRatio::num; + } + + static inline u64 CNTPCTToUS(u64 cntpct) { + return cntpct * UsToCNTPCTRatio::den / UsToCNTPCTRatio::num; + } + protected: using NsRatio = std::nano; using UsRatio = std::micro; @@ -46,6 +62,7 @@ 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>; }; std::unique_ptr<WallClock> CreateOptimalClock(); |