Hello,
I'm trying to implement an A-buffer algorithm in Metal, and I am getting this error when trying to use atomic_exchange_explicit() in a fragment shader:
"Execution of the command buffer was aborted due to an error during execution. Internal Error (IOAF code 1)"
I'm trying to exchange values in a screen-size buffer of uint32's. declared as device atomic_uint. I've been able to use atomic_fetch_add_explicit on a single uint counter, but it is giving me this error when trying to operate on the larger buffer. Any idea why that would happen? Here's the shader code:
fragment void stroke_abuffer_fragment(VertexIn interpolated [[stage_in]],
const device uint& color [[ buffer(0) ]],
constant Uniforms& uniforms [[ buffer(1) ]],
device FragLink* LinkBuffer [[ buffer(3) ]],
device atomic_uint &counter[[buffer(2)]],
device atomic_uint *StartBuffer[[buffer(4)]]
) {
uint pos = int(interpolated.position.x)+int(interpolated.position.y)*uniforms.displaySize[0];
uint value = atomic_fetch_add_explicit(&counter, 1, memory_order_relaxed);
value += 1;
FragLink F;
F.color = color;
F.depth = interpolated.position.z;
F.next = atomic_exchange_explicit(&StartBuffer[pos], value, memory_order_relaxed);
LinkBuffer[value] = F;
}
Thanks
Bob