SwapBuffers bad performence
I have test application that periodicaly rendering scene when new data arive. Scene contains one quad with one texture no lights, no shaders. In each render i update texture with glTexSubImage2D (512B) one line of scene and call swapbuffers but call takes long time. "Long time" means longer time on Windodw7 laptop than on Windows XP laptop - i developed application on this pc.
PC WIN_7: Core i7, NVIDIA NVS 5500M, SwapBuffers takes 20ms
GL_VENDOR: NVIDIA Corporation
PC WIN_XP: DualCore, ATI MOBILITY RADEON 38500
SwapBuffers takes 5ms
Where can be problem? Why is SwapBuffers has so bad performence on better pc? Is it problem in WIN7/WINXP on NVIDIA/ATI?
Is there any general recommendation to discover this discrepancy?
NVIDIA drivers by default synchronize swaps to vblank, ATI driver do not. The 20ms look like vblank synchronization is enabled.
You can change the synchronization on swap using the WGL_EXT_swap_control extension or the control panel of the driver.
Thank you to your advice. Vsync disabling working in graphics card control panel only. But not from code.
How to disable Vsync throught the code? Where is mistake?
My code is this:
hdc = GetDC(MainPanel->Handle);
hrc = wglCreateContext(hdc);
typedef BOOL (APIENTRY *PFNWGLSWAPINTERVALFARPROC)( int );
PFNWGLSWAPINTERVALFARPROC wglSwapIntervalEXT = 0;
const char *extensions = glGetString( GL_EXTENSIONS );
if( strstr( extensions, "WGL_EXT_swap_control" ) == 0 )
wglSwapIntervalEXT = (PFNWGLSWAPINTERVALFARPROC)wglGetProcAddress( "wglSwapIntervalEXT" );
if( wglSwapIntervalEXT )
If the graphics card control panel is set to something like "force vsync on" or "force vsync off", you won't be able to turn it on and off in code. Only if it is "application controlled" will the code work.
OK I understand. I set vsync off in cards applcation.
Originally Posted by Dan Bartlett
Is there realy no way how to configure it from application?
The code looks good.
Do you have multiple windows? wglSwapIntervalEXT() is setting the swap interval for the window/DC associated with the current context.