directx 12 – read and increase global counter in compute shader in directx12
there is UAV BufferA
and ComputeShaderA
every time ComputeShaderA
gets dispatch()
ed it will write into a different section of BufferA
like
//BufferA size = 3MB
commandlist->dipatch(1024,0,0); //modifies 1st 1MB of BufferA
commandlist->ResourceBarrier(1, &brrUAV);
commandlist->dipatch(1024,0,0); //modifies 2nd 1MB of BufferA
commandlist->ResourceBarrier(1, &brrUAV);
commandlist->dipatch(1024,0,0); //modifies 3rd 1MB of BufferA
so ComputeShaderA
reads one float
in GPU memory that represents a Counter
I created another ComputeShaderB
that increases that Counter
and runs every time ComputeShaderA
finishes
but having to run two shaders is slow, is there a way for ComputeShaderA
to read and increase Counter
without data race? which will make ComputeShaderB
useless
Read more here: Source link