cute_framework icon indicating copy to clipboard operation
cute_framework copied to clipboard

More accurate target framerate is needed

Open RandyGaul opened this issue 2 years ago • 1 comments

The current implementation of targeting a render framerate using sleeps is so inaccurate it causes unacceptable visual jumps. This implementation needs to be revamped, potentially with a mixture of sleep + spinlocks, or maybe other native solutions, in order to work in an acceptable manner.

Another potential solution is to remove this feature entirely and just rely on hardware vsync. This would be the easiest solution, but, would be less flexible in terms of targeting whatever framerate the user wants.

RandyGaul avatar Jul 15 '23 02:07 RandyGaul

Relevant links

https://blat-blatnik.github.io/computerBear/making-accurate-sleep-function/

https://learn.microsoft.com/en-us/windows/win32/api/synchapi/nf-synchapi-createwaitabletimerexw

https://hero.handmade.network/forums/game-discussion/t/8612-what_does_timebeginperiod_actually_do#27120

https://github.com/MicrosoftDocs/win32/blob/docs/desktop-src/directcomp/compositor-clock/compositor-clock.md

jonstvns avatar Aug 14 '23 06:08 jonstvns

Seems more accurate than before. Only tested on my laptop so far, which has some wild sleep times and still manages locking in fairly well.

https://github.com/RandyGaul/cute_framework/commit/a49a9843904c77661189ffafb305df495444ac5d

RandyGaul avatar Aug 08 '24 10:08 RandyGaul