Part of the Khronos Group
OpenGL.org

The Industry's Foundation for High Performance Graphics

from games to virtual reality, mobile phones to supercomputers

Results 1 to 6 of 6

Thread: SwapBuffers bad performence

  1. #1
    Junior Member Newbie
    Join Date
    Dec 2011
    Posts
    5

    SwapBuffers bad performence

    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

  2. #2
    Junior Member Newbie
    Join Date
    Jan 2013
    Posts
    11
    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.

  3. #3
    Junior Member Newbie
    Join Date
    Dec 2011
    Posts
    5
    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
    }

  4. #4
    Member Regular Contributor
    Join Date
    Aug 2008
    Posts
    445
    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.

  5. #5
    Junior Member Newbie
    Join Date
    Jan 2013
    Posts
    11
    The code looks good.

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

  6. #6
    Junior Member Newbie
    Join Date
    Dec 2011
    Posts
    5
    Quote Originally Posted by Dan Bartlett View Post
    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?

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •