Hey there, I have a question about OpenGL compute shader synchronization. When Ì dispatch a compute shader via glDispatchCompute, and afterwards I use a different compute Shader via glDispatchCompute, but the data of the second shader depends on the first one, how do I synchronize this, so that it is guaranteed that the first shader finished processing before the second shader starts.
Also, can I run multiple different compute shaders at the same time?
Also, can I run multiple different compute shaders at the same time?
If you don’t put any synchronization between dispatch calls, then the two calls may overlap in execution to some extent. But otherwise, there is no way to tell the GPU to give equal time (or any particular proportion) to two separate compute shader operations.
They target all prior operations which can perform incoherent writes. That is, anything which did incoherent writes before the barrier is synchronized with anything after the barrier which consumes those writes through the specified accesses.
The synchronization is coarse-grained; OpenGL isn’t Vulkan. Though even Vulkan cannot target a specific shader or dispatch.
The function doesn’t “wait”. It simply prevents the GPU from executing later commands until the earlier, potentially conflicting commands have finished. This could introduce a temporary stall in the GPU, but I wouldn’t call that “waiting”.