-
Notifications
You must be signed in to change notification settings - Fork 428
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Use SDL_DelayNS
for lower thread jitter on non-Windows platforms
#6391
Conversation
Replaces Windows specific implementation.
This reverts commit e65231f.
Seems to work fine with SDL2 but will limit to only SDL3 for now to not mix SDL2 and SDL3.
The comments specifically mention that there is a race condition if SDL_Init is not called. Guess how many threads will call Also, this unnecessarily puts SDL code in things not related to windowing and input. I think it's better to just implement the |
I thought using DelayNS is not so bad for non-Windows platforms since Apple, Android, and Linux all use different libc, and I am not opposed of implementing |
This was my initial reaction too, I'm not sure I want SDL calls anywhere outside of windowing / input handling. Curious of @smoogipoo's opinion though. |
I share similar concerns to the above and would prefer implementing the relevant funcs ourselves. |
With three votes against I'm not sure we need any more, I see no further point to this being open at this stage. |
This PR uses
SDL_DelayNS
to improve thread pacing on all platforms except Windows where a high resolution timer was already used. As of libsdl-org/SDL@c8f5f6d,SDL_DelayNS
no longer busy-loops and instead uses the high precision OS delay functions.Tested to work the same on Windows and have lower thread jitter on Linux, but I was unable to test mobile and macOS.
Runs fine under both SDL2 and SDL3 because according to @hwsmm in the SDL3-CS bindings update ppy/SDL3-CS#165,
SDL_DelayNS
doesn't require SDL3 init, but this PR will limit to only SDL3 for now to not mix SDL2 and SDL3. When o!f switches fully to SDL3 then the Windows specific implementation can be removed asSDL_DelayNS
uses the same Windows high resolution timers.Testing: