How do I get the hidden counter value of a structured buffer as quickly as possible?
Within a render block, I'm doing the following:
- Dispatch a compute shader that increments the hidden counter of a GpuBuffer.
- In C#, read the hidden counter value of that buffer.
- Dispatch another compute shader using the value of that hidden counter as the number of X threads.
The problem I have is that when reading the hidden counter value for the first time, it is always zero. I must wait until the next frame until the value is available.
Is it expected that the first value returned is zero?
- If not, I can make an issue.
- If so, should any caller of GpuBuffer.CopyStructureCount just keep checking every frame for when the value returned is greater than zero?
Is there (or will there be) a way for me to perform an
indirect dispatch to work around this limitation in the future?
- If not, I can make a feature request for that.
- I believe this would allow me to skip reading back the hidden counter value entirely.