OpenGL no more than 32 screens with Vista / 7

Before I reduce it to a reasonable example, I was hoping that someone might run into this earlier and shed light on the problem.

I have a 32-bit C-based application that uses one OpenGL context for each window, all contexts and windows are configured the same way. The requested pixel format is 32-bit color, alpha, depth buffer, accelerated. Everything works flawlessly on Windows 2000 and XP.

Everything worked flawlessly in Vista and 7 until the 33rd pair of windows / contexts was created. Creating a window has no errors, creating a context has no errors, as a result of which the context current has no errors, the picture does not create errors, SwapBuffers does not generate an error. However, OpenGL contexts cannot produce any output, with Aero white, classic mode drawing, and screen garbage. Killing DWM does not fix the problem, trying to use different pixel formats (one buffer, depth difference, etc.), while PFD_SUPPORT_COMPOSITION does not fix the problem. This is on different machines with Vista / 7, never XP.

I can glReadPixels back buffer, and they are correct pixels. Rendering in pbuffer with the same context works fine, rendering in> 32 pbuffers is great.

If I work freely on screen contexts / windows, non-working windows will start working again. As if Vista / 7 just stopped displaying OpenGL rendering after 32 windows were displayed on the screen.

If the pixel format descriptor includes PFD_SUPPORT_GDI, everything is fine, but using a software renderer that is unacceptable.

I am wondering if this is an OS limitation or a driver limitation in Vista / 7. Thank you for understanding.

+7
source share
1 answer

The limit is implementation specific, and all you can do is run some tests on common hardware.

I conducted some tests myself, and it turned out that the limit for GeForce cards is quite high (perhaps even without restrictions). For desktop Quadro, there was a limit of 128 contexts that could be redrawn correctly, the program was able to create another 128 contexts without errors, but the windows contained garbage. I do not use PFD_SUPPORT_GDI.

This was even more interesting on the ATi Radeon 6950, where the redrawing stopped at window # 105, and the creation of rendering context # 200 failed.

If you want to try it yourself, the program can be found here: Max OpenGL Contexts test (there is full source code + win32 binaries). Perhaps you can look at the code and track down the culprit, it would be very interesting to hear about it.

This is the result. One tip is to avoid using multiple contexts where possible. Several contexts can be understood in an application running on multi-level monitors, but applications on the same monitor must resort to the same context. Context switching is slow. And that's not it. Applications in which OpenGL windows overlap with other windows require hardware clipping areas. On GeForce, there is one hardware clipping area, eight or more on Quadro (CAD applications often use windows and menus that overlap the OpenGL window, unlike games). If more regions are required, rendering returns to the software - so again - having a large number of OpenGL windows (contexts) is not a good idea.

Note that this is similar to Is there a limit to the number of OpenGL rendering contexts you can create at the same time?

+2
source

All Articles