How to save a unified OpenGL program object for each context instead of one program?

I am working on a multi-threaded OpenGL linking mechanism. I have a set of shaders that I share between several contexts. For performance reasons, I would like to avoid compiling a separate instance of each shader program for each thread.

But if several threads use the same program object, and I try to set different forms in each thread, the homogeneous values ​​are mixed, because the same values ​​are stored together with the common program object.

So far I see my options as:

  • compile a separate program object for each thread (which wastes time and resources) or
  • for each common program object, serialize the process of setting up uniforms and rendering (which greatly deprives the benefits of multithreading)

Or is there a better way? (Ie, is there a way to store Unified OpenGL software objects for each context instead of one program?)

Edit: I need to support users through Mac OS 10.6 for a few more months, so until then I have been stuck in OpenGL 2.1 and all extensions are available in Mac OS 10.6. ARB_separate_shader_objectsappears on Mac OS 10.8 if I understand correctly.

+3
source share

All Articles