Forum Discussion
hesham
11 years agoProtege
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!
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
- ChameleonHonored Guest.. The function
glfwSwapInterval(1);
After glfwMakeContextCurrent will turn VSync on (called once during initialisation). - jhericoAdventurer
"Chameleon" wrote:
.. The functionglfwSwapInterval(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 - heshamProtegeThanks 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.
- heshamProtegeTo 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. - heshamProtegeActually 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!
Quick Links
- Horizon Developer Support
- Quest User Forums
- Troubleshooting Forum for problems with a game or app
- Quest Support for problems with your device
Other Meta Support
Related Content
- 6 months ago