Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

QOpenGLWidget VSync



  • Hi guys,

    I have 3 basic QOpenGLWidgets in a GUI application sharing the GUI thread. It seems that unless I disable Vsync for my shared context, the widgets don't exceed a stable fps of 20 fps (default refresh rate of 60 Hz / 3). I came across this page which gives the same explanation:

    https://stackoverflow.com/questions/22636284/qt-how-to-properly-handle-vsync-and-multiple-qglwidgets

    Are OpenGL widgets sharing a single widget treated as a single widget? Is there a way to get around this without forcing off VSync?

    Cheers!



  • What version of Qt is your application using?

    According to the link you sent, it is a known Qt 5.0 but should be fixed on Qt 5.3



  • @mcleary I'm using 5.12.0 MINGW. I'm not sure if that is the issue but my set up is pretty basic. I don't really have a lot going on just drawing a textured quad in each widget. With VSync off, there are no problems but with the default settings, I can't get stable fps.



  • Have you tried to use two or maybe four widgets to see if the relation between number of widgets and fps is linear?

    Another suggestion would be to use the MSVC version just to rule out the toolchain as the problem.



  • This post is deleted!


  • @mcleary It looks like I'm having the same issue as the original thread I posted but what I'm seeing is refresh rate divided between windows that contain widgets. The details of my setup and testing are:

    • QT GUI application with 3 QOpenGLWidgets (derived class called Display) as children of the main window (part of the designer form); these are used as preview widgets for textures produced by an FBO
    • 1 QOpenGLWidget as a child of the main window; this renders 3 textures in an FBO and sends them out to the preview displays
    • 1 QOpenGLWidget as part of the designer form of a QDialog window (not a child of the main window); this displays one of the textures above and is

    It seems that the refresh rate is divided between the 3 preview widgets (counted as one, since reducing their number does not improve fps until they are taken out completely), the renderer widget and the output widget. When the preview widgets are taken out, the fps of the output display is 30. The renderer widget is getting the other 30 it seems.

    So it looks like refresh rate is divided between the top windows with the renderer being considered a top window somehow even though its a child of the main window.

    I am super confused at this point.

    Either way what I'm trying to do is share a context between 2 top level windows. If anyone has any advice on how to correctly do this I would appreciate that.



  • Any thoughts on this guys? I've verified the same thing on my machine with various QT OpenGL examples. The top level windows divide the refresh rate between them. If I have two QMainWindows for example, each will render at 30 fps with the default 60 Hz refresh rate. Each one can have many child widgets all running at the same 30 fps rate.

    I have a feeling I will need to create a context for each top level window. Any thoughts on how and where (in main?) to do this. Does the top level window need to be a QWindow for this to work?

    Cheers!



  • Unfortunately I also don't know how to proceed and would need to see the application. Could you share one of the examples you mentioned?



  • Sure. I modified the qopenglwindow and qopenglwidget example adding an extra window. Qopenglwidget is easier to do since it displays framerate and also you can add child widgets on the fly.



  • I'll see if I can try it today. Will report back.



  • Is it that what you're talking about? As you can see, all widgets are running at 60fps.

    Capture.PNG



  • @mcleary Thanks for trying it, thats exactly it! I added a second top level window in main and that caused the framerate for both winows and their child widgets to be divided in half.

    I just finished modifying the contextinfo example also creating two RenderWindow objects contained by two QWidgets in a single window and the two render at the correct 60 Hz refresh rate since each has a separate context. I think that's what I'll need to do but I'm not sure if this just my machine or its Windows or its just the way it is overall.



  • @rtavakko I also tried creating a new top level window but I still have no problems. Hopefully you can find the problem



  • @mcleary Thanks again for trying it! I also ran the same code with two top level widgets on another PC and it worked ok so I'm guessing this is something with my laptop. I'm not sure if its still recommended to give each OpenGL widget its own context to make sure the code runs the same way on different PCs.



  • @rtavakko If you absolutely need to share the contexts then I guess you should try to find the problem with your laptop. Which graphics processor do you have on the laptop? Is the driver updated?



  • @mcleary Good point. I updated the drivers recently (about a month ago). My laptop specs are:

    GPU: GeForce GTX 950M
    OS + Driver: Windows 10, driver NVIDIA 4.5.0 385.54
    Qt version: 5.12.0 MINGW (64 bit)

    I also have an Intel HD Graphics 530 (NVIDIA Optimus tech) for the built-in display which may have something to do with this. I've set my GTX 950M for OpenGL rendering and as the high-performance card. I'll dig a little deeper to see what could be the issue and update the thread.



  • @rtavakko You could also try the MSVC build of Qt. I don't know if you are willing to install Visual Studio just to test this but it might be worth a shot.



  • @mcleary I tried the QT MSVC 2017 compiler with the same results. My Optimus setup has betrayed me before...



  • Could you provide more details of your issue, such as screenshot of FPS, Monitor type, and the application you run. Note there are a set of applications can override v-sync settings in-app McDVOICE



  • @Patterson sure, I will get more details on this and post here