mirror of
https://github.com/cemu-project/Cemu.git
synced 2024-11-29 12:34:17 +01:00
MacOS+Linux: Use CLOCK_MONOTONIC_RAW over CLOCK_MONOTONIC (#313)
On MacOS this fixes the framerate being too high due to discontinuities in the timer that drives the emulated vsync. It also fixes behavior of the GetTickCount() wrapper.
This commit is contained in:
parent
a28d67bafd
commit
3fb4b5e26c
@ -4,6 +4,6 @@
|
|||||||
uint32_t GetTickCount()
|
uint32_t GetTickCount()
|
||||||
{
|
{
|
||||||
struct timespec ts;
|
struct timespec ts;
|
||||||
clock_gettime(CLOCK_MONOTONIC, &ts);
|
clock_gettime(CLOCK_MONOTONIC_RAW, &ts);
|
||||||
return (1000 * ts.tv_sec + ts.tv_nsec / 1000000);
|
return (1000 * ts.tv_sec + ts.tv_nsec / 1000000);
|
||||||
}
|
}
|
@ -9,7 +9,7 @@ HighResolutionTimer HighResolutionTimer::now()
|
|||||||
return HighResolutionTimer(pc.QuadPart);
|
return HighResolutionTimer(pc.QuadPart);
|
||||||
#else
|
#else
|
||||||
timespec pc;
|
timespec pc;
|
||||||
clock_gettime(CLOCK_MONOTONIC, &pc);
|
clock_gettime(CLOCK_MONOTONIC_RAW, &pc);
|
||||||
uint64 nsec = (uint64)pc.tv_sec * (uint64)1000000000 + (uint64)pc.tv_nsec;
|
uint64 nsec = (uint64)pc.tv_sec * (uint64)1000000000 + (uint64)pc.tv_nsec;
|
||||||
return HighResolutionTimer(nsec);
|
return HighResolutionTimer(nsec);
|
||||||
#endif
|
#endif
|
||||||
@ -28,7 +28,7 @@ uint64 HighResolutionTimer::m_freq = []() -> uint64 {
|
|||||||
return (uint64)(freq.QuadPart);
|
return (uint64)(freq.QuadPart);
|
||||||
#else
|
#else
|
||||||
timespec pc;
|
timespec pc;
|
||||||
clock_getres(CLOCK_MONOTONIC, &pc);
|
clock_getres(CLOCK_MONOTONIC_RAW, &pc);
|
||||||
return (uint64)1000000000 / (uint64)pc.tv_nsec;
|
return (uint64)1000000000 / (uint64)pc.tv_nsec;
|
||||||
#endif
|
#endif
|
||||||
}();
|
}();
|
||||||
|
Loading…
Reference in New Issue
Block a user