Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Dispatch same compute shader multiple times

Tags:

opengl

glsl

Is it possible and safe to call glDispatchCompute() for same compute shader multiple times or I have to always wait untill the shader finishes and then dispatch again?

like image 968
Michaelt LoL Avatar asked Aug 15 '26 13:08

Michaelt LoL


1 Answers

So long as there is no memory dependency between the two dispatch operations (ie: you're not accessing data written by a previous dispatch), it should be fine. Otherwise, you will need to invoke glMemoryBarrier, with bits appropriate to the way the next dispatch will access the data.

Changes to actual uniform variables (through glUniform or glProgramUniform) between the two dispatches are fine. Changes to UBO data is fine so long as you're modifying the buffer's data through actual API calls (glBufferSubData or call glMapBufferRange between the dispatches). If you're modifying the buffer's data through a pointer to persistently mapped buffer data, then you need to do a full CPU/GPU sync before you can modify any bytes that were being read by the previous dispatch calls.

like image 173
Nicol Bolas Avatar answered Aug 17 '26 14:08

Nicol Bolas



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!