OpenGL VSync problem
Edit: I just found out that the problem described below only occurs when the DWM is turned off, i.e. when you use a basis desktop design (Win7/64). With Aero activated, all seems to work. Anyway, I will have to solve the problem because Aero of course is not always guaranteed to be active.
I need multiple independent windows (applications) that do OpenGL rendering at the same time.
On different machines I notice the same strange behaviour of VSync'd OpenGL applications, that can easily be reproduced running the very simple "OpenGL Window Example" that comes with the Qt installation:
If one instance of it is started, the coloured triangle turns completely smooth with 60fps. For every further instance, the framerate slows down proportionally, e.g. 4 instances of this sample program generate 15 fps each.
This is obviously not a problem of the graphics performance (in my case AMD 7850, which is able to do many thousand of those rendering loops per second), but of some kind of global lock that seems to be held from the moment the rendering starts until the moment that the front and back buffer are actually swapped (i.e. each 17ms). With a few instances of the demo running, the whole system becomes kind of sticky.
The effect is independent of the number of Frame Buffers used (QSurfaceFormat::TripleBuffer etc.).
Calling QSurfaceFormat::setSwapInterval() with higher values (which leads to an accordingly lower framerate), results in extremely high response times for the whole system when running a single instance of this simple demo. This is certainly not the intention of the VSync mechanism.
The only way to get acceptable performance is to switch VSync off (QSurfaceFormat::setSwapInterval(0)) and to try syncing manually to the vertical retrace, which in turn consumes much CPU power.
I'm an experienced Direct3D programmer, what doesn't help that much here. I need help from experienced OpenGL experts. Thank you!
I have experienced problems wih qt+opengl+vsync aswell. The problem is that opengl blocks the main gui thread while waiting for a v-blank signal. Only solution I have found is to run OpenGL in a different thread. Unfortunately this doesn't seem to work in qt5 anymore so I have to use qt4.8. I even made a thread of this problem https://forum.qt.io/topic/55119/opengl-in-a-different-thread-in-qt5/2. I have come to the conclusion that qt, opengl and threading just don't mix well.