Indirect Compute Shader

Direct means CPU give something to GPU

Indirect means CPU tells GPU to get something in GPU


I have a maximum no. of cats (say 10000 cats).
Since they all get hungry at different times so I should only feed the cats that are hungry.


Compute Buffer and Compute Shader (20170703)

  1. CPU creates 2 compute buffers. Data buffer knows it can takes up to 10000 data.
    • Data buffer : no. of cats = 0
  2. CPU pass the number 10000 to GPU to run the direct dispatch, which will add the hungry cats to data buffer.
    • Data buffer : no. of cats = no. of hungry cats
  3. So now we have hungry cats filtered out!
  4. Pass the no. of hungry cats from data buffer to args buffer. So that we know we have to feed how many cats.
  5. Run indirect dispatch according to no. of hungry cats from args buffer. That is, too feed them!


From the arrows in the diagram you can see there is no read or write data back to CPU (which wastes time and resources) during the whole cat filtering and feeding process. It’s very good isn’t it :D?


Download unity package to try it out 🙂


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s