Before I reduce this to a reasonable example I was hoping someone might have run into this before and can shed some light on the problem.
I have a 32-bit C based application which uses one OpenGL context per window, all the contexts and windows are set up identically. The requested pixel format is 32bit color, alpha, depth buffer, accelerated. Everything works flawlessly on Windows 2000 and XP.
Everything works flawlessly on Vista and 7 until the 33rd window/context pair is created. Creating the window has no errors, creating the context has no errors, making the context current has no errors, drawing produces no errors, SwapBuffers does not generate an error. However, the OpenGL contexts fail to produce any output, with Aero the windows are white, with the classic mode they don't draw and are just screen garbage. Killing the DWM doesn't fix the problem, trying different pixel formats (single buffer, diff. depths, etc) and PFD_SUPPORT_COMPOSITION doesn't fix the problem. This is on a number of different machines with Vista/7, never XP.
I can glReadPixels the back buffer and they are the correct pixels. Rendering into a pbuffer with the same context works fine, rendering into >32 pbuffers is fine.
If I free working on-screen contexts/windows, the non-working windows start working again. It's as if Vista/7 simply stop displaying OpenGL rendering after 32 windows are on screen doing this.
If the pixel format descriptor includes PFD_SUPPORT_GDI everything is OK, but it's using the software renderer which is unacceptable.
I am wondering if this is an OS limitation or driver limitation in Vista/7. Thanks for any insight.
The limit is implementation-specific, and all you can do is to run some tests on common hardware.
I ran some tests myself and it turns out that the limit is pretty high for GeForce cards (maybe even no limit). For desktop Quadro, there was limit of 128 contexts that were able to repaint correctly, the program was able to create 128 more contexts with no errors, but the windows contained rubbish. I'm not using PFD_SUPPORT_GDI.
It was even more interesting on ATi Radeon 6950, there the redrawing stopped at window #105, and creating rendering context #200 failed.
If you want to try for yourself, the program can be found here: Max OpenGL Contexts test (there is full source code + win32 binaries). Maybe you can look at the code and track down the culprit, would be very interested hearing about it.
That's the result. One piece of advice - avoid using multiple contexts where possible. Multiple contexts can be understood in application running at mulitple monitors, but applications on a single monitor should resort to a single context. Context switching is slow. And that's not all. Applications where OpenGL windows are overlapped by another windows require hardware clipping regions. There is one hardware clipping region on GeForce, eight or more on Quadro (CAD applications often use windows and menus that overlap OpenGL window, in contrast with games). In case more regions are needed, rendering falls back to software - so again - having lots of OpenGL windows (contexts) is not a very good idea.
Note this is rather similar to Is there a limit to how many OpenGL rendering contexts you can create simultaneously?
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With