I’m using an application that renders several visualization widgets in OpenGL using GLSL. The application is heavily threaded and we started to see crashed when things using the shaders appeared in multiple windows.
Right now there is no context controls in the code, and was wondering if these crashes were because of it. If so, it there a good place to find more information on threaded OpenGL calls? I’ve tried a mutex lock on binding the GLSL calls and flushing the buffer with glFlush, but still get the crash.
One of the solution used by some canvases using OpenGL is to create a thread dedicated to the rendering with all the calls to OpenGL, and an internal API to push rendering tasks in a queue from other threads. The queue being flushed before the rendering pass.
What loicm described is in my opinion the best solution. No matter how good your threading solutions are, there is still only one physical GPU in the system - you should avoid accessing this resource at random from different threads.