Debian Codegraph @

third_party/spirv-cross/reference/shaders-msl/comp/composite-array-initialization.force-native-array.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 Data
9 {
10 float a;
11 float b;
12 };
13
14 constant float X_tmp [[function_constant(0)]];
15 constant float X = is_function_constant_defined(X_tmp) ? X_tmp : 4.0;
16
17 struct Data_1
18 {
19 float a;
20 float b;
21 };
22
23 struct SSBO
24 {
25 Data_1 outdata[1];
26 };
27
28 constant uint3 gl_WorkGroupSize [[maybe_unused]] = uint3(2u, 1u, 1u);
29
30 constant Data _25[2] = { Data{ 1.0, 2.0 }, Data{ 3.0, 4.0 } };
31
32 template<typename T, uint A>
33 inline void spvArrayCopyFromConstantToStack1(thread T (&dst)[A], constant T (&src)[A])
34 {
35 for (uint i = 0; i < A; i++)
36 {
37 dst[i] = src[i];
38 }
39 }
40
41 template<typename T, uint A>
42 inline void spvArrayCopyFromConstantToThreadGroup1(threadgroup T (&dst)[A], constant T (&src)[A])
43 {
44 for (uint i = 0; i < A; i++)
45 {
46 dst[i] = src[i];
47 }
48 }
49
50 template<typename T, uint A>
51 inline void spvArrayCopyFromStackToStack1(thread T (&dst)[A], thread const T (&src)[A])
52 {
53 for (uint i = 0; i < A; i++)
54 {
55 dst[i] = src[i];
56 }
57 }
58
59 template<typename T, uint A>
60 inline void spvArrayCopyFromStackToThreadGroup1(threadgroup T (&dst)[A], thread const T (&src)[A])
61 {
62 for (uint i = 0; i < A; i++)
63 {
64 dst[i] = src[i];
65 }
66 }
67
68 template<typename T, uint A>
69 inline void spvArrayCopyFromThreadGroupToStack1(thread T (&dst)[A], threadgroup const T (&src)[A])
70 {
71 for (uint i = 0; i < A; i++)
72 {
73 dst[i] = src[i];
74 }
75 }
76
77 template<typename T, uint A>
78 inline void spvArrayCopyFromThreadGroupToThreadGroup1(threadgroup T (&dst)[A], threadgroup const T (&src)[A])
79 {
80 for (uint i = 0; i < A; i++)
81 {
82 dst[i] = src[i];
83 }
84 }
85
86 template<typename T, uint A>
87 inline void spvArrayCopyFromDeviceToDevice1(device T (&dst)[A], device const T (&src)[A])
88 {
89 for (uint i = 0; i < A; i++)
90 {
91 dst[i] = src[i];
92 }
93 }
94
95 template<typename T, uint A>
96 inline void spvArrayCopyFromConstantToDevice1(device T (&dst)[A], constant T (&src)[A])
97 {
98 for (uint i = 0; i < A; i++)
99 {
100 dst[i] = src[i];
101 }
102 }
103
104 template<typename T, uint A>
105 inline void spvArrayCopyFromStackToDevice1(device T (&dst)[A], thread const T (&src)[A])
106 {
107 for (uint i = 0; i < A; i++)
108 {
109 dst[i] = src[i];
110 }
111 }
112
113 template<typename T, uint A>
114 inline void spvArrayCopyFromThreadGroupToDevice1(device T (&dst)[A], threadgroup const T (&src)[A])
115 {
116 for (uint i = 0; i < A; i++)
117 {
118 dst[i] = src[i];
119 }
120 }
121
122 template<typename T, uint A>
123 inline void spvArrayCopyFromDeviceToStack1(thread T (&dst)[A], device const T (&src)[A])
124 {
125 for (uint i = 0; i < A; i++)
126 {
127 dst[i] = src[i];
128 }
129 }
130
131 template<typename T, uint A>
132 inline void spvArrayCopyFromDeviceToThreadGroup1(threadgroup T (&dst)[A], device const T (&src)[A])
133 {
134 for (uint i = 0; i < A; i++)
135 {
136 dst[i] = src[i];
137 }
138 }
139
140 static inline __attribute__((always_inline))
141 Data combine(thread const Data& a, thread const Data& b)
142 {
143 return Data{ a.a + b.a, a.b + b.b };
144 }
145
146 kernel void main0(device SSBO& _53 [[buffer(0)]], uint3 gl_WorkGroupID [[threadgroup_position_in_grid]], uint3 gl_LocalInvocationID [[thread_position_in_threadgroup]])
147 {
148 Data data[2] = { Data{ 1.0, 2.0 }, Data{ 3.0, 4.0 } };
149 Data _31[2] = { Data{ X, 2.0 }, Data{ 3.0, 5.0 } };
150 Data data2[2];
151 spvArrayCopyFromStackToStack1(data2, _31);
152 Data param = data[gl_LocalInvocationID.x];
153 Data param_1 = data2[gl_LocalInvocationID.x];
154 Data _73 = combine(param, param_1);
155 _53.outdata[gl_WorkGroupID.x].a = _73.a;
156 _53.outdata[gl_WorkGroupID.x].b = _73.b;
157 }
158