Hi,
I have a large application using SDL2 running on linux and windows.
On Windows, close analysis of timings show that the call to SDL_RenderPresent() occasionally takes 16ms rather than <= 4ms. This happens about 8% of the time. No other delays are ever seen (i.e. nothing between 5ms and 15ms)
(I was using 2.0.12, but have moved to hg 2.0.13 to include https://bugzilla.libsdl.org/show_bug.cgi?id=5171
Compiling from source and including otther timing checks in
video/windows/SDL_windowsframebuffer.c
the 16ms can be seen within
WIN_UpdateWindowFramebuffer()
and specifically the call to BitBlt()
so this would therefore seem to be a Windows issue.
Tests show similar issues with direct3d11 driver, and with/out SDL_RENDERER_PRESENTVSYNC
A similar problem appears to have been reported here: https://social.msdn.microsoft.com/Forums/windowsdesktop/en-US/2cbe4674-e744-41d6-bc61-3c8e381aa942/how-to-make-bitblt-faster-for-copying-screen?forum=windowsdirectshowdevelopment
As a (probably very dangerous) experiment I have replaced my SDL_RendererPresent with:
unsigned int rpcallback(unsigned int timer, void *ref)
{
SDL_Renderer *renderer = (SDL_Renderer *)ref;
SDL_RenderPresent(renderer);
return 0;
}
...
SDL_AddTimer(1, rpcallback, renderer);
and it does work, but seems unwise
Q1) is this is a viable solution? thread safety would seem to be at risk.
Q2) The 16ms delay hasn’t disappeared completely, the AddTimer() call occasional shows the same delay (0.1% of the time) [ irrelevant if Q1 is ill-advised ]
Q3) is there same aspect of the app that is triggering this behaviour as small stand-alone tests do not appear to show the problem.
Thanks