Do you have to wait for a dispatched compute buffer to be complete before you can read the RWbuffer?
Why is this code returning an error in the console?
public ComputeShader cs;
int kernelMain, kernelSwapBuffer;
void OnEnable()
{
kernelMain = cs.FindKernel("CSMain");
kernelSwapBuffer = cs.FindKernel("SwapBuffer");
#pragma kernel CSMain
#pragma kernel SwapBuffer
RWStructuredBuffer<float> output;
StructuredBuffer<float> buffer;
int width;
int height;
StructuredBuffer<float> emitters;
StructuredBuffer<float> obstacles;
[numthreads(8,8,1)]
void CSMain (uint2 id : SV_DispatchThreadID)
{
int em = emitters[id.x + width * id.y];
float p = em
+ buffer[id.x + 1 + width * id.y]
+ buffer[id.x - 1 + width * id.y]
+ buffer[id.x + width * (id.y + 1)]
+ buffer[id.x + width * (id.y - 1)]
;
output[id.x] = p * obstacles[id.x + width * id.y];
}
[numthreads(64,1,1)]
void SwapBuffer (uint2 id : SV_DispatchThreadID)
{
buffer[id.x] = output[id.x];
}