Closed bjornbytes closed 1 year ago
Confirmed that lovr.timer.sleep
has 15ms resolution on windows (though it's a global property on some versions of windows so it depends).
Initial test of the high resolution timer is successful and allows for sleeps down to 500us resolution.
Zero-duration sleeps should still use Sleep
though because it only yields for a few hundred nanoseconds whereas a zero-duration high-resolution sleep will still wait for 500us.
There's a new flag
CREATE_WAITABLE_TIMER_HIGH_RESOLUTION
that can be used withCreateWaitableTimerExW
on Windows. This can be used to sleep for a more precise duration compared toSleep
, which only has around 1ms precision and will sometimes sleep for a long time. LÖVR currently uses a 0-millisecond sleep at the end of each frame intended as a "yield", which I don't think would benefit from this. It would only really be useful for Lua code that useslovr.timer.sleep
for short durations.Available on Windows 10 1803, so there would need to be a fallback to
Sleep
.