Debian Codegraph @

third_party/spirv-cross/reference/shaders-msl/asm/comp/buffer-write.asm.comp

raw
1 #pragma clang diagnostic ignored "-Wmissing-prototypes"
2
3 #include <metal_stdlib>
4 #include <simd/simd.h>
5
6 using namespace metal;
7
8 struct cb
9 {
10 float value;
11 };
12
13 // Returns 2D texture coords corresponding to 1D texel buffer coords
14 static inline __attribute__((always_inline))
15 uint2 spvTexelBufferCoord(uint tc)
16 {
17 return uint2(tc % 4096, tc / 4096);
18 }
19
20 kernel void main0(constant cb& _6 [[buffer(0)]], texture2d<float, access::write> _buffer [[texture(0)]], uint3 gl_WorkGroupID [[threadgroup_position_in_grid]], uint gl_LocalInvocationIndex [[thread_index_in_threadgroup]])
21 {
22 _buffer.write(float4(_6.value), spvTexelBufferCoord(((32u * gl_WorkGroupID.x) + gl_LocalInvocationIndex)));
23 }
24