perf(startup): let Windows relax the system timer resolution
On Windows SDL3 raises the global timer resolution with timeBeginPeriod(1) and holds it for the whole process lifetime, which keeps the system on a 1 ms tick and costs power for no benefit here. - A startup hint now asks SDL to leave the system timer alone. Nothing in the app needs sub-15 ms waits: vsync paces drawing, the idle wait is 200 ms, and background sleeps are 50 ms or longer. The hint is Windows-only in effect and is ignored elsewhere; an environment override that turns it off is harmless. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -2428,6 +2428,10 @@ int main(int argc, char* argv[])
|
||||
|
||||
static bool InitSDL()
|
||||
{
|
||||
// SDL3 otherwise holds timeBeginPeriod(1) for the process lifetime on Windows. Nothing here needs
|
||||
// sub-15 ms waits (vsync pacing, the 200 ms idle wait, >=50 ms thread sleeps), so let the system
|
||||
// timer relax. Ignored on non-Windows platforms; a false return (env override) is harmless.
|
||||
SDL_SetHint(SDL_HINT_TIMER_RESOLUTION, "0");
|
||||
if (!SDL_Init(SDL_INIT_VIDEO | SDL_INIT_GAMEPAD)) {
|
||||
fprintf(stderr, "Error: SDL_Init(): %s\n", SDL_GetError());
|
||||
return false;
|
||||
|
||||
Reference in New Issue
Block a user