PDA

View Full Version : Texture sharing from multiple threads



debonair
10-20-2016, 11:07 PM
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?

GClements
10-21-2016, 02:14 AM
Does openGL offers implicit synchronization for texture access between multiple threads with 2 different contexts?
No.

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


When does it offer implicit synchronization ? within single context?
You can't use a single context in multiple threads concurrently, so synchronisation isn't an issue there.

arekkusu
10-21-2016, 10:16 AM
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.)