Hi,
I noticed SDL2 leaves the Windows timer resolution alone, so SDL_Delay(1)
will sleep for ~15ms (on recent windows versions, afaik), whereas SDL 1.2
set the resolution to 1ms at startup (in SDL_StartTicks).
This is different from both OS X 10.10 and Ubuntu 14.04, where I’m seeing
~1ms resolution for SDL_Delay(1) with SDL2 from hg.
Just wondering if it’s planned to leave SDL2/Windows with the default 15ms
resolution?
I’m aware that timeBeginPeriod(1) is frowned upon due to the increased
power usage (e.g. in this blog post
), but even that article points out that timeBeginPeriod(1) + Sleep(1) are
useful for throttling games to 30 FPS. In my case, I help maintain some
legacy code that uses SDL_Delay(1) to throttle a mainloop to 72fps
(Quakespasm).
I think it might be nice to bring the default resolution up to 1ms on
SDL2/Windows, matching the other platforms, and maybe have a hint to
request not to do that for low-power games.
Thoughts? I could put together a patch for that if there’s interest.
That codepath also means that SDL_HINT_TIMER_RESOLUTION doesn?t actually do anything at all unless QueryPerformanceCounter fails, which isn?t what I expected (since the timer resolution also affects SDL_Delay, not just SDL_GetTicks.)> On Apr 14, 2015, at 8:29 PM, Eric Wasylishen wrote:
Hi,
I noticed SDL2 leaves the Windows timer resolution alone, so SDL_Delay(1) will sleep for ~15ms (on recent windows versions, afaik), whereas SDL 1.2 set the resolution to 1ms at startup (in SDL_StartTicks).
That codepath also means that SDL_HINT_TIMER_RESOLUTION doesn?t actually do
anything at all unless QueryPerformanceCounter fails, which isn?t what I
expected (since the timer resolution also affects SDL_Delay, not just
SDL_GetTicks.)
That’d mean that either the scheduler is way more accurate than I
thought or something else is calling it, because when I messed with it
SDL_Delay(1) would not cause my game to miss frames no matter what
(and we know how SDL_Delay can easily wreck timing, since the value
passed is the minimum wait).
That codepath also means that SDL_HINT_TIMER_RESOLUTION doesn?t actually do anything at all unless QueryPerformanceCounter fails, which isn?t what I expected (since the timer resolution also affects SDL_Delay, not just SDL_GetTicks.)
On Apr 14, 2015, at 8:29 PM, Eric Wasylishen <ewasylishen at gmail.com <mailto:ewasylishen at gmail.com>> wrote:
Hi,
I noticed SDL2 leaves the Windows timer resolution alone, so SDL_Delay(1) will sleep for ~15ms (on recent windows versions, afaik), whereas SDL 1.2 set the resolution to 1ms at startup (in SDL_StartTicks).
Ryan Gordon has pushed some commits to SDL today which fix this, I think.
Thanks, the resolution on Windows now defaults to 1ms, and SDL_HINT_TIMER_RESOLUTION
can be used to raise that, so that addresses my concerns :-)On Mon, Apr 20, 2015 at 1:17 PM, Alex Szpakowski wrote: