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?
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With