I have an application that uses two compute shaders. Shader #1
produces data x
and stores it in A
, bound as an Append Buffer. Shader #2
runs on all of x
from A
, bound as a consume buffer.
I would like to extend this by adding Shader #3
, which runs on all of x
in A
, producing y
into a new buffer B
- but I still want Shader #2
to run on x
as before.
That is, I want to run an operation on all elements of an append/consume buffer, but without 'consuming' them.
If I understand correctly, consuming an element just decreases a hidden counter, so I should be able to consume a buffer many times by storing the count when full, and resetting it between the shader invocations that consume from it.
The problem is that my platform - Unity - has only one method for this (SetCounterValue()
) which requires me to pass in the new counter value. That is, I need to get the counter value to CPU memory before re-setting it, which will force a synchronisation between the GPU/CPU and reduce performance.
Is it possible to set the counter value of a consume buffer entirely on the GPU?
If not, is it possible to iterate over a consume buffer without using consume?
(It has occured to me to just bind the buffer as a regular UAV resource and iterate that way, but the documentation is ambiguous as to whether this is supported. E.g. does "these resources do not use resource variables." refer to the resource itself, or the view?)