#pragma clang diagnostic ignored "-Wmissing-prototypes" #pragma clang diagnostic ignored "-Wunused-variable" #include #include #include using namespace metal; struct u0_counters { uint c; }; // Returns 2D texture coords corresponding to 1D texel buffer coords uint2 spvTexelBufferCoord(uint tc) { return uint2(tc % 4096, tc / 4096); } kernel void main0(device u0_counters& u0_counter [[buffer(0)]], texture2d u0 [[texture(0)]], uint3 gl_GlobalInvocationID [[thread_position_in_grid]]) { uint _29 = atomic_fetch_sub_explicit((volatile device atomic_uint*)&u0_counter.c, 1, memory_order_relaxed); u0.write(uint4(uint(int(gl_GlobalInvocationID.x))), spvTexelBufferCoord(as_type(as_type(_29)))); }