openglegl

setting texture parameter across opengl contexts


This is a follow-up question to this SO answer.

If I have the following setup

eglMakeCurrent(,,,contextA); 
glCreateTextures(,texHandles);
...

eglMakeCurrent(,,,contextB);
glTextureParameterf(texHandles[0],,);

where contextA and contextB are shared contexts. Assuming that everything in the above snippet is correctly setup in accordance to the OpenGL spec. Should the call to set texture parameter succeed since texture object is not a container object?


Solution

  • Object state changes propagate between contexts in accord with the rules in Section 5.3 of the standard. These are quite detailed and complex. But in general, propagating such changes requires two things: ensuring that the function's setting the state have completed execution, and explicitly binding the object (directly or indirectly) in the new context.

    So in order to use the object in context B, you must first ensure the completion of the creation operation in context A. And a CPU mutex alone isn't sufficient; you need to use glFinish or wait on a sync object in context A (the sending context). And this command must "happen before" context B's use of it.

    To access the updates to the stored state of the object, context B must bind that object (after the above wait has completed for context A). DSA functions do not act as binding operations, so even if you want to use DSA, you must bind the object's first.