Debian Codegraph @

third_party/spirv-cross/reference/shaders-msl/asm/comp/variable-pointers-2.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 foo
9 {
10 int a[128];
11 uint b;
12 float2 c;
13 };
14
15 struct bar
16 {
17 int d;
18 };
19
20 static inline __attribute__((always_inline))
21 device foo* select_buffer(device foo& a, constant bar& cb)
22 {
23 return (cb.d != 0) ? &a : nullptr;
24 }
25
26 static inline __attribute__((always_inline))
27 thread uint3* select_input(thread uint3& gl_GlobalInvocationID, thread uint3& gl_LocalInvocationID, constant bar& cb)
28 {
29 return (cb.d != 0) ? &gl_GlobalInvocationID : &gl_LocalInvocationID;
30 }
31
32 kernel void main0(device foo& buf [[buffer(0)]], constant bar& cb [[buffer(1)]], uint3 gl_GlobalInvocationID [[thread_position_in_grid]], uint3 gl_LocalInvocationID [[thread_position_in_threadgroup]])
33 {
34 device foo* _46 = select_buffer(buf, cb);
35 device foo* _45 = _46;
36 thread uint3* _47 = select_input(gl_GlobalInvocationID, gl_LocalInvocationID, cb);
37 device foo* _48 = _45;
38 device int* _52;
39 device int* _55;
40 _52 = &_48->a[0u];
41 _55 = &buf.a[0u];
42 int _57;
43 int _58;
44 for (;;)
45 {
46 _57 = *_52;
47 _58 = *_55;
48 if (_57 != _58)
49 {
50 int _66 = (_57 + _58) + int((*_47).x);
51 *_52 = _66;
52 *_55 = _66;
53 _52 = &_52[1u];
54 _55 = &_55[1u];
55 continue;
56 }
57 else
58 {
59 break;
60 }
61 }
62 }
63