vkCmdDispatch but with range?

Is there a way to dispatch only a range of local workgroups?

For example, I normally dispatch with something like vkCmdDispatch(128, 64, 1). However sometimes I know from the data that only [[64, 65, 66], [32, 33, 34], 1] are going to do useful work and everything else is going to early abort and do nothing.

What’s the most effective way to deal with this without dispatching the universe?

Thanks.

Call dispatch with the size of your range as argument (i.e. (3, 3, 1) for your example) and supply an offset (64, 32, 0) via push constant or uniform to the compute shader where it is added to the work group indices to access the range of data you want.

Yeah, that’s what I had planned on doing. I was just wondering if there was a better/different way.

I believe vkCmdDispatchBase is what you are looking for

1 Like

That looks like precisely what I need. Thanks.