Dear Ogre developers,
On Windows, I recently had to upgrade Sight (https://github.com/IRCAD/sight) from Ogre 1.12.10 to Ogre 14.0.1. It was a bit painful, but in the end, I managed to solve all the issues. However, I am not really happy with the last fix I had to perform, because I needed to patch Ogre sources.
The problem was the following. In SightViewer, a medical imaging viewer, we display four split views. The first view is well shown, while the three others are completely black. Looking at the command buffer in NSight, I could understand that it was completely screwed up. After hours of debugging, I found that the problem has occurred since the introduction of this new define OGRE_ENABLE_STATE_CACHE_CRITICAL OgreGL3PlusStateCacheManager.cpp @8891ed. Commenting out this define solves the issue.
I noticed there was a comment mentioning that this change was supposed to be safe for multi-context. Apparently, this is not in my case. Each view is based on a QOpenGLWidget. I know it's not the recommended way, but that's the only way I found to overlay Qt widgets on top of the Ogre 3D scenes. I perform the compositing of Qt and Ogre myself in the end. I know people have struggled for years on that topic and I am somehow proud to have solved that, and in the other side, I am not that confident about that code and I fear it could be a bit fragile, because of Qt and Ogre dealing with the same OpenGL context... Maybe it does not matter for this particular problem, but it might, so I prefer to mention it.
Well, in the end, can I kindly ask you if you know for sure if this state caching is really safe in multi-context scenarios? If yes, would you mind adding a CMake variable to disable it anyway, like the "standard" state cache? We could patched it in the vcpkg build, but I am afraid of not being able to patch it in the Debian package (which is really not up-to-date currently, I am trying to help there, but that's another story...)
Thank you in advance for your help, and above all, many thanks for this amazing 3D engine.