mirror of
https://github.com/yuzu-emu/yuzu-android.git
synced 2025-06-12 22:57:57 -05:00
core_timing: Use CNTPCT as the guest CPU tick
Previously, we were mixing the raw CPU frequency and CNTFRQ. The raw CPU frequency (1020 MHz) should've never been used as CNTPCT (whose frequency is CNTFRQ) is the only counter available.
This commit is contained in:
@ -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();
|
||||
|
Reference in New Issue
Block a user