QOpenGLWidget VSync
-
@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!
-
@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.
-
@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.
-
@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.
-
Its been a long time since this thread was started but I think it makes sense to post the updates here. I put together a basic project with native OpenGL and also using Qt's QOffscreenSurface and QWindow classes.
The github repository can be found here:
https://github.com/rtavakko/VSync
In this setup there is a single renderer that render to an FBO texture using its own thread and 3 display windows that share the GUI thread with all of them sharing OpenGL contexts together.
On my machine I see a clear lag with VSync on when there are 2 or more display windows. Turning VSync off clears the lag. The calcualted FPS values do not indicate any issues in either case which doesn't help but I see a clear difference when I start the application with say 2 displays and then close one of them.
I have my internal laptop display and an RCA RT1970 (both running at 1920x1080 - 60Hz) and both connected to my integrated Intel HD 530 GPU. My discrete GPU is an NVIDIA GeForce GTX 950M and I'm running Qt 5.12.0 MSVC2017 64 bit.
I'll dig in further myself also with other machines but if anyone has any ideas on what could be causing this, it would really help debug further.
Cheers!
-
This post is deleted!
-
This post is deleted!