Texture sharing from multiple threads

Does openGL offers implicit synchronization for texture access between multiple threads with 2 different contexts? or do i need sync objects ? When does it offer implicit synchronization ? within single context?


Sync objects and glFlush(), or you can use glFinish() to wait until all prior commands on that context have completed.

You can’t use a single context in multiple threads concurrently, so synchronisation isn’t an issue there.

The semantics are spelled out in recent versions of the specification. See “Determining Completion of changes to an object” in GL4.5.

TLDR; you don’t need sync objects, the producer must flush, and the consumer must bind:

thread A on ctx A:
    write to texture (via fbo, etc)
    1) glFlush() (or equivalent to ensure command buffer is submitted, glFlushRenderAPPLE etc)
    <your app's threading primitive to signal work>
thread B on shared ctx B:
    2) glBind* (or re-attach to container object, fbo etc)
    read from texture (sample, etc) 

(*AFAICT this precludes bindless API.)