Search Unity

Synchronizing Compute Shaders

Discussion in 'Shaders' started by MadWatch, Nov 6, 2019.

  1. MadWatch

    MadWatch

    Joined:
    May 26, 2016
    Posts:
    112
    Hello Everyone

    I apologize for the dumb question but I couldn't find any answer to that anywhere.

    If I do
    Code (CSharp):
    1. commandBuffer.DispatchCompute(Program, MyKernel1, x, y, z);
    2. commandBuffer.DispatchCompute(Program, MyKernel2, x, y, z);
    Does that mean that MyKernel2 will only be executed AFTER MyKernel1 has completed?

    If I do
    Code (CSharp):
    1. commandBuffer.DispatchCompute(Program, MyKernel, x, y, z);
    2. commandBuffer.DrawProceduralIndirect(matrix, material, 0, MeshTopology.Triangles, argBuffer, 0, properties);
    Does that mean that the draw procedural will occur only AFTER MyKernel has completed?

    If the answer to these questions is "no", then is there a way to make it so?

    Thank you very much.
     
  2. Olmi

    Olmi

    Joined:
    Nov 29, 2012
    Posts:
    1,553
    My understanding has been that Unity waits until the Dispatch is done. I'm not sure if commandBuffer Dispatch and compute shaders Dispatch work the exact same way, but at least some of my compute shader tests have been working well enough when I've imagined it to be functioning that way :). But I haven't found solid information about that either.