Debian Codegraph @

third_party/spirv-cross/reference/shaders-msl/comp/global-invocation-id.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 myBlock
9 {
10 int a;
11 float b[1];
12 };
13
14 // Implementation of the GLSL mod() function, which is slightly different than Metal fmod()
15 template<typename Tx, typename Ty>
16 inline Tx mod(Tx x, Ty y)
17 {
18 return x - y * floor(x / y);
19 }
20
21 kernel void main0(device myBlock& myStorage [[buffer(0)]], uint3 gl_GlobalInvocationID [[thread_position_in_grid]])
22 {
23 myStorage.a = (myStorage.a + 1) % 256;
24 myStorage.b[gl_GlobalInvocationID.x] = mod(myStorage.b[gl_GlobalInvocationID.x] + 0.0199999995529651641845703125, 1.0);
25 }
26