I need to process a dynamic number of buffers using a compute shader. Problem, I don't know how to do this and there's sparse information on them online.
As the number is dynamic I can't just do
RWStructuredBuffer _Buffer1
RWStructuredBuffer _Buffer2
RWStructuredBuffer _Buffer3
At first I tried to
for(int i = 0; i < buffers.length; i++)
{
compute.SetBuffer(0, "_BufferToProcess", buffers[i]);
compute.Dispatch(0, 64, 1, 1);
}
But quickly realized that because I'm setting buffers in a loop and Dispatch schedules, the shader will only process the last buffer.
Then I tried to Instantiate() multiple copies of the shader and set their buffer accordingly but that didn't work either.
I really don't want to convert multiple buffers into a single one as the data is dynamic, which means I'll need to resize it on every change. Would it be possible for a compute shader to process multiple buffers in one frame? Or is it not a good design to begin with?
↧