#Will my code wait for the compute shader to finish its calculations ?

1 messages · Page 1 of 1 (latest)

soft hinge
#

If i dispatch a compute shader in a c# script, will the script wait unitll the shader is done before it continues or am I risking stuff overwriting itself if i put a dispatch into a for loop ?

lavish radish
#

you're executing the same kernel 4 times in a row, loop or not that would have been an issue

the script does not wait; the graphics engine puts all the dispatches in order depending on their resource dependencies

I assume the dispatches are pipelined based on their dependencies, that is they're all executed in the order you dispatch them (assuming they all read/write to the same dependency, i.e. gridBuffer), but may overlap (execute in parallel) if they are not depending on one another through resource writes

see also https://discussions.unity.com/t/check-if-a-computeshader-dispatch-command-is-completed-on-gpu-before-doing-second-kernel-dispatch/606394/19

soft hinge
#

thank you

#

If i have a bunch of itterations my cpu slows down, is there a way to run the forloop on the gpu but keep it in sync? Cause im updating a grid in 4 steps and i need to update the grid for n iterations and I can only start with the next once the previous is finished otherwise the paralel computation will override the same grid entries