PDA

View Full Version : SwapBuffers bad performence



spirox
02-12-2013, 11:21 PM
Hello,
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_VERSION: 4.2.0
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?

thank you

AHeumann
02-13-2013, 01:02 AM
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.

spirox
02-13-2013, 02:22 AM
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:
//Initialiaztion
hdc = GetDC(MainPanel->Handle);
SetPixelFormatDescriptor(hdc);
hrc = wglCreateContext(hdc);
wglMakeCurrent(hdc, hrc);
SetPixelFormatDescriptor(hdc);
typedef BOOL (APIENTRY *PFNWGLSWAPINTERVALFARPROC)( int );

//Disable VSync
PFNWGLSWAPINTERVALFARPROC wglSwapIntervalEXT = 0;
const char *extensions = glGetString( GL_EXTENSIONS );
if( strstr( extensions, "WGL_EXT_swap_control" ) == 0 )
return;
else {
wglSwapIntervalEXT = (PFNWGLSWAPINTERVALFARPROC)wglGetProcAddress( "wglSwapIntervalEXT" );
if( wglSwapIntervalEXT )
wglSwapIntervalEXT(0);//disabling
}

Dan Bartlett
02-13-2013, 03:50 AM
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.

AHeumann
02-13-2013, 04:03 AM
The code looks good.

Do you have multiple windows? wglSwapIntervalEXT() is setting the swap interval for the window/DC associated with the current context.

spirox
02-13-2013, 11:58 AM
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.
Is there realy no way how to configure it from application?