Debian Codegraph @

third_party/spirv-cross/reference/shaders-msl-no-opt/asm/comp/device-constant-array-load-store.asm.comp

raw
1 #pragma clang diagnostic ignored "-Wmissing-prototypes"
2 #pragma clang diagnostic ignored "-Wmissing-braces"
3
4 #include <metal_stdlib>
5 #include <simd/simd.h>
6
7 using namespace metal;
8
9 template<typename T, size_t Num>
10 struct spvUnsafeArray
11 {
12 T elements[Num ? Num : 1];
13
14 thread T& operator [] (size_t pos) thread
15 {
16 return elements[pos];
17 }
18 constexpr const thread T& operator [] (size_t pos) const thread
19 {
20 return elements[pos];
21 }
22
23 device T& operator [] (size_t pos) device
24 {
25 return elements[pos];
26 }
27 constexpr const device T& operator [] (size_t pos) const device
28 {
29 return elements[pos];
30 }
31
32 constexpr const constant T& operator [] (size_t pos) const constant
33 {
34 return elements[pos];
35 }
36
37 threadgroup T& operator [] (size_t pos) threadgroup
38 {
39 return elements[pos];
40 }
41 constexpr const threadgroup T& operator [] (size_t pos) const threadgroup
42 {
43 return elements[pos];
44 }
45 };
46
47 struct Block
48 {
49 uint2 _m0[2];
50 uint2 _m1[2];
51 };
52
53 struct SSBO
54 {
55 Block _m0[3];
56 };
57
58 template<typename T, uint A>
59 inline void spvArrayCopyFromConstantToStack1(thread T (&dst)[A], constant T (&src)[A])
60 {
61 for (uint i = 0; i < A; i++)
62 {
63 dst[i] = src[i];
64 }
65 }
66
67 template<typename T, uint A>
68 inline void spvArrayCopyFromConstantToThreadGroup1(threadgroup T (&dst)[A], constant T (&src)[A])
69 {
70 for (uint i = 0; i < A; i++)
71 {
72 dst[i] = src[i];
73 }
74 }
75
76 template<typename T, uint A>
77 inline void spvArrayCopyFromStackToStack1(thread T (&dst)[A], thread const T (&src)[A])
78 {
79 for (uint i = 0; i < A; i++)
80 {
81 dst[i] = src[i];
82 }
83 }
84
85 template<typename T, uint A>
86 inline void spvArrayCopyFromStackToThreadGroup1(threadgroup T (&dst)[A], thread const T (&src)[A])
87 {
88 for (uint i = 0; i < A; i++)
89 {
90 dst[i] = src[i];
91 }
92 }
93
94 template<typename T, uint A>
95 inline void spvArrayCopyFromThreadGroupToStack1(thread T (&dst)[A], threadgroup const T (&src)[A])
96 {
97 for (uint i = 0; i < A; i++)
98 {
99 dst[i] = src[i];
100 }
101 }
102
103 template<typename T, uint A>
104 inline void spvArrayCopyFromThreadGroupToThreadGroup1(threadgroup T (&dst)[A], threadgroup const T (&src)[A])
105 {
106 for (uint i = 0; i < A; i++)
107 {
108 dst[i] = src[i];
109 }
110 }
111
112 template<typename T, uint A>
113 inline void spvArrayCopyFromDeviceToDevice1(device T (&dst)[A], device const T (&src)[A])
114 {
115 for (uint i = 0; i < A; i++)
116 {
117 dst[i] = src[i];
118 }
119 }
120
121 template<typename T, uint A>
122 inline void spvArrayCopyFromConstantToDevice1(device T (&dst)[A], constant T (&src)[A])
123 {
124 for (uint i = 0; i < A; i++)
125 {
126 dst[i] = src[i];
127 }
128 }
129
130 template<typename T, uint A>
131 inline void spvArrayCopyFromStackToDevice1(device T (&dst)[A], thread const T (&src)[A])
132 {
133 for (uint i = 0; i < A; i++)
134 {
135 dst[i] = src[i];
136 }
137 }
138
139 template<typename T, uint A>
140 inline void spvArrayCopyFromThreadGroupToDevice1(device T (&dst)[A], threadgroup const T (&src)[A])
141 {
142 for (uint i = 0; i < A; i++)
143 {
144 dst[i] = src[i];
145 }
146 }
147
148 template<typename T, uint A>
149 inline void spvArrayCopyFromDeviceToStack1(thread T (&dst)[A], device const T (&src)[A])
150 {
151 for (uint i = 0; i < A; i++)
152 {
153 dst[i] = src[i];
154 }
155 }
156
157 template<typename T, uint A>
158 inline void spvArrayCopyFromDeviceToThreadGroup1(threadgroup T (&dst)[A], device const T (&src)[A])
159 {
160 for (uint i = 0; i < A; i++)
161 {
162 dst[i] = src[i];
163 }
164 }
165
166 kernel void main0(device SSBO& ssbo [[buffer(0)]], constant SSBO& ubo [[buffer(1)]])
167 {
168 threadgroup uint2 _18[2];
169 spvArrayCopyFromDeviceToDevice1(ssbo._m0[0u]._m0, ssbo._m0[0u]._m1);
170 spvArrayCopyFromConstantToDevice1(ssbo._m0[0u]._m0, ubo._m0[0u]._m1);
171 spvUnsafeArray<uint2, 2> _24;
172 spvArrayCopyFromStackToDevice1(ssbo._m0[0u]._m0, _24.elements);
173 spvArrayCopyFromThreadGroupToDevice1(ssbo._m0[0u]._m0, _18);
174 spvArrayCopyFromDeviceToThreadGroup1(_18, ssbo._m0[0u]._m1);
175 spvArrayCopyFromDeviceToStack1(_24.elements, ssbo._m0[0u]._m1);
176 spvArrayCopyFromConstantToThreadGroup1(_18, ubo._m0[0u]._m1);
177 spvArrayCopyFromConstantToStack1(_24.elements, ubo._m0[0u]._m1);
178 }
179