Skip to main content
Up and Coming
November 1, 2014

OpenGL 0.4.3 VSync to 75hz Possible? Hitting 400-1000FPS...

Hi,

I can get everything to run smoothly in OpenGL in both extended and direct modes using the 0.4.3 SDK. The only problem I seem to be having is that my code isn't rate-limited as it is very simple so my framerate calculation is showing it running at a silly 400-1000FPS which is much higher than the 75Hz required. Either my calculation is wrong, or I'm using more CPU than necessary and begs the question if there is a way to VSync directly and limit my framerate. I'm using GLFW to create the windows.

It is possible that the Oculus SDK gives a special OpenGL context and doesn't glFinish frames unless it decides to render them and so I end up clearing the screen and re-rendering a few times before it decides it wants to glFinish and only then do I pay the high price of stalling and warping. Just a guess here.

Thanks!

    5 replies

    Participant
    November 1, 2014
    .. The function
    glfwSwapInterval(1);

    After glfwMakeContextCurrent will turn VSync on (called once during initialisation).
    Inspiring
    November 2, 2014
    "Chameleon" wrote:
    .. The function
    glfwSwapInterval(1);

    After glfwMakeContextCurrent will turn VSync on (called once during initialisation).


    If you're using SDK based rendering, it doesn't matter what you set this value to. The Oculus SDK will call the platform specific VSync function during EndFrame() based on whether the no-vsync flag has been set. By default it will set enable the vsync to 1, but adding the flag will cause it to be set to 0. See https://github.com/jherico/OculusSDK/blob/master/LibOVR/Src/CAPI/GL/CAPI_GL_DistortionRenderer.cpp#L377
    Brad Davis - Developer for High Fidelity Co-author of Oculus Rift in Action
    heshamAuthor
    Up and Coming
    November 2, 2014
    Thanks for the replies. The thing is should the VSync actually limit my framerate to 75FPS in the draw loop or is it running on a separate thread and just taking the last rendered image so I will need to do the limiting myself? The view on the headset seems pretty smooth and VSynced, but I can see my draw loop is just going too fast. I would like to slow it down to save power and not overheat graphics cards, especially on laptops, if 75Hz (or 90Hz in the future) is all that is needed.
    Ibex 3D VR Desktop for the Oculus Rift: http://hwahba.com/ibex - https://bitbucket.org/druidsbane/ibex
    heshamAuthor
    Up and Coming
    November 2, 2014
    To add to this, I tried putting a sleep in the draw thread after the EndFrame call to limit the refresh and it became extremely jumpy. If I take it out everything runs smoothly on my laptop but at the cost of turning the fan way up and eventually probably overheating after a few minutes.

    I wonder if the silky smoothness is just b/c there are enough frames if I run at 400FPS (375 to be exact on my laptop) that it feels smooth but that it isn't really as optimal as it could be. When I put a sleep in the code the FPS was around 180 but the jitteriness was there. I wonder why other apps running in Direct mode or Extended seem to report 75FPS. To be fair those are D3D apps and mine is OpenGL-based so there might be some work there.
    Ibex 3D VR Desktop for the Oculus Rift: http://hwahba.com/ibex - https://bitbucket.org/druidsbane/ibex
    heshamAuthor
    Up and Coming
    November 3, 2014
    Actually that was a bug in my FPS calculations (375=75FPS * 5, silly bug, I did hit 2000FPS but that was without VSync on my desktop). Turns out I am VSynced to 75FPS when things are running smoothly and I need to work out those times that I'm not. Thanks for pointing out that code and the help you guys have offered!
    Ibex 3D VR Desktop for the Oculus Rift: http://hwahba.com/ibex - https://bitbucket.org/druidsbane/ibex