• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1#version 320 es
2
3#extension GL_KHR_shader_subgroup_arithmetic: enable
4
5layout (local_size_x = 8) in;
6
7layout(binding = 0) buffer Buffers
8{
9    vec4  f4;
10    ivec4 i4;
11    uvec4 u4;
12} data[4];
13
14void main()
15{
16    uint invocation = (gl_SubgroupInvocationID + gl_SubgroupSize) % 4u;
17
18    data[0].f4.x   = subgroupAdd(data[0].f4.x);
19    data[0].f4.xy  = subgroupAdd(data[1].f4.xy);
20    data[0].f4.xyz = subgroupAdd(data[2].f4.xyz);
21    data[0].f4     = subgroupAdd(data[3].f4);
22
23    data[1].i4.x   = subgroupAdd(data[0].i4.x);
24    data[1].i4.xy  = subgroupAdd(data[1].i4.xy);
25    data[1].i4.xyz = subgroupAdd(data[2].i4.xyz);
26    data[1].i4     = subgroupAdd(data[3].i4);
27
28    data[2].u4.x   = subgroupAdd(data[0].u4.x);
29    data[2].u4.xy  = subgroupAdd(data[1].u4.xy);
30    data[2].u4.xyz = subgroupAdd(data[2].u4.xyz);
31    data[2].u4     = subgroupAdd(data[3].u4);
32
33    data[3].f4.x   = subgroupMul(data[0].f4.x);
34    data[3].f4.xy  = subgroupMul(data[1].f4.xy);
35    data[3].f4.xyz = subgroupMul(data[2].f4.xyz);
36    data[3].f4     = subgroupMul(data[3].f4);
37
38    data[0].i4.x   = subgroupMul(data[0].i4.x);
39    data[0].i4.xy  = subgroupMul(data[1].i4.xy);
40    data[0].i4.xyz = subgroupMul(data[2].i4.xyz);
41    data[0].i4     = subgroupMul(data[3].i4);
42
43    data[1].u4.x   = subgroupMul(data[0].u4.x);
44    data[1].u4.xy  = subgroupMul(data[1].u4.xy);
45    data[1].u4.xyz = subgroupMul(data[2].u4.xyz);
46    data[1].u4     = subgroupMul(data[3].u4);
47
48    data[2].f4.x   = subgroupMin(data[0].f4.x);
49    data[2].f4.xy  = subgroupMin(data[1].f4.xy);
50    data[2].f4.xyz = subgroupMin(data[2].f4.xyz);
51    data[2].f4     = subgroupMin(data[3].f4);
52
53    data[3].i4.x   = subgroupMin(data[0].i4.x);
54    data[3].i4.xy  = subgroupMin(data[1].i4.xy);
55    data[3].i4.xyz = subgroupMin(data[2].i4.xyz);
56    data[3].i4     = subgroupMin(data[3].i4);
57
58    data[0].u4.x   = subgroupMin(data[0].u4.x);
59    data[0].u4.xy  = subgroupMin(data[1].u4.xy);
60    data[0].u4.xyz = subgroupMin(data[2].u4.xyz);
61    data[0].u4     = subgroupMin(data[3].u4);
62
63    data[1].f4.x   = subgroupMax(data[0].f4.x);
64    data[1].f4.xy  = subgroupMax(data[1].f4.xy);
65    data[1].f4.xyz = subgroupMax(data[2].f4.xyz);
66    data[1].f4     = subgroupMax(data[3].f4);
67
68    data[2].i4.x   = subgroupMax(data[0].i4.x);
69    data[2].i4.xy  = subgroupMax(data[1].i4.xy);
70    data[2].i4.xyz = subgroupMax(data[2].i4.xyz);
71    data[2].i4     = subgroupMax(data[3].i4);
72
73    data[3].u4.x   = subgroupMax(data[0].u4.x);
74    data[3].u4.xy  = subgroupMax(data[1].u4.xy);
75    data[3].u4.xyz = subgroupMax(data[2].u4.xyz);
76    data[3].u4     = subgroupMax(data[3].u4);
77
78    data[0].i4.x   = subgroupAnd(data[0].i4.x);
79    data[0].i4.xy  = subgroupAnd(data[1].i4.xy);
80    data[0].i4.xyz = subgroupAnd(data[2].i4.xyz);
81    data[0].i4     = subgroupAnd(data[3].i4);
82
83    data[1].u4.x   = subgroupAnd(data[0].u4.x);
84    data[1].u4.xy  = subgroupAnd(data[1].u4.xy);
85    data[1].u4.xyz = subgroupAnd(data[2].u4.xyz);
86    data[1].u4     = subgroupAnd(data[3].u4);
87
88    data[2].i4.x   =   int(subgroupAnd(data[0].i4.x < 0));
89    data[2].i4.xy  = ivec2(subgroupAnd(lessThan(data[1].i4.xy, ivec2(0))));
90    data[2].i4.xyz = ivec3(subgroupAnd(lessThan(data[1].i4.xyz, ivec3(0))));
91    data[2].i4     = ivec4(subgroupAnd(lessThan(data[1].i4, ivec4(0))));
92
93    data[3].i4.x   = subgroupOr(data[0].i4.x);
94    data[3].i4.xy  = subgroupOr(data[1].i4.xy);
95    data[3].i4.xyz = subgroupOr(data[2].i4.xyz);
96    data[3].i4     = subgroupOr(data[3].i4);
97
98    data[0].u4.x   = subgroupOr(data[0].u4.x);
99    data[0].u4.xy  = subgroupOr(data[1].u4.xy);
100    data[0].u4.xyz = subgroupOr(data[2].u4.xyz);
101    data[0].u4     = subgroupOr(data[3].u4);
102
103    data[1].i4.x   =   int(subgroupOr(data[0].i4.x < 0));
104    data[1].i4.xy  = ivec2(subgroupOr(lessThan(data[1].i4.xy, ivec2(0))));
105    data[1].i4.xyz = ivec3(subgroupOr(lessThan(data[1].i4.xyz, ivec3(0))));
106    data[1].i4     = ivec4(subgroupOr(lessThan(data[1].i4, ivec4(0))));
107
108    data[2].i4.x   = subgroupXor(data[0].i4.x);
109    data[2].i4.xy  = subgroupXor(data[1].i4.xy);
110    data[2].i4.xyz = subgroupXor(data[2].i4.xyz);
111    data[2].i4     = subgroupXor(data[3].i4);
112
113    data[3].u4.x   = subgroupXor(data[0].u4.x);
114    data[3].u4.xy  = subgroupXor(data[1].u4.xy);
115    data[3].u4.xyz = subgroupXor(data[2].u4.xyz);
116    data[3].u4     = subgroupXor(data[3].u4);
117
118    data[0].i4.x   =   int(subgroupXor(data[0].i4.x < 0));
119    data[0].i4.xy  = ivec2(subgroupXor(lessThan(data[1].i4.xy, ivec2(0))));
120    data[0].i4.xyz = ivec3(subgroupXor(lessThan(data[1].i4.xyz, ivec3(0))));
121    data[0].i4     = ivec4(subgroupXor(lessThan(data[1].i4, ivec4(0))));
122
123    data[1].f4.x   = subgroupInclusiveAdd(data[0].f4.x);
124    data[1].f4.xy  = subgroupInclusiveAdd(data[1].f4.xy);
125    data[1].f4.xyz = subgroupInclusiveAdd(data[2].f4.xyz);
126    data[1].f4     = subgroupInclusiveAdd(data[3].f4);
127
128    data[2].i4.x   = subgroupInclusiveAdd(data[0].i4.x);
129    data[2].i4.xy  = subgroupInclusiveAdd(data[1].i4.xy);
130    data[2].i4.xyz = subgroupInclusiveAdd(data[2].i4.xyz);
131    data[2].i4     = subgroupInclusiveAdd(data[3].i4);
132
133    data[3].u4.x   = subgroupInclusiveAdd(data[0].u4.x);
134    data[3].u4.xy  = subgroupInclusiveAdd(data[1].u4.xy);
135    data[3].u4.xyz = subgroupInclusiveAdd(data[2].u4.xyz);
136    data[3].u4     = subgroupInclusiveAdd(data[3].u4);
137
138    data[0].f4.x   = subgroupInclusiveMul(data[0].f4.x);
139    data[0].f4.xy  = subgroupInclusiveMul(data[1].f4.xy);
140    data[0].f4.xyz = subgroupInclusiveMul(data[2].f4.xyz);
141    data[0].f4     = subgroupInclusiveMul(data[3].f4);
142
143    data[1].i4.x   = subgroupInclusiveMul(data[0].i4.x);
144    data[1].i4.xy  = subgroupInclusiveMul(data[1].i4.xy);
145    data[1].i4.xyz = subgroupInclusiveMul(data[2].i4.xyz);
146    data[1].i4     = subgroupInclusiveMul(data[3].i4);
147
148    data[2].u4.x   = subgroupInclusiveMul(data[0].u4.x);
149    data[2].u4.xy  = subgroupInclusiveMul(data[1].u4.xy);
150    data[2].u4.xyz = subgroupInclusiveMul(data[2].u4.xyz);
151    data[2].u4     = subgroupInclusiveMul(data[3].u4);
152
153    data[3].f4.x   = subgroupInclusiveMin(data[0].f4.x);
154    data[3].f4.xy  = subgroupInclusiveMin(data[1].f4.xy);
155    data[3].f4.xyz = subgroupInclusiveMin(data[2].f4.xyz);
156    data[3].f4     = subgroupInclusiveMin(data[3].f4);
157
158    data[0].i4.x   = subgroupInclusiveMin(data[0].i4.x);
159    data[0].i4.xy  = subgroupInclusiveMin(data[1].i4.xy);
160    data[0].i4.xyz = subgroupInclusiveMin(data[2].i4.xyz);
161    data[0].i4     = subgroupInclusiveMin(data[3].i4);
162
163    data[1].u4.x   = subgroupInclusiveMin(data[0].u4.x);
164    data[1].u4.xy  = subgroupInclusiveMin(data[1].u4.xy);
165    data[1].u4.xyz = subgroupInclusiveMin(data[2].u4.xyz);
166    data[1].u4     = subgroupInclusiveMin(data[3].u4);
167
168    data[2].f4.x   = subgroupInclusiveMax(data[0].f4.x);
169    data[2].f4.xy  = subgroupInclusiveMax(data[1].f4.xy);
170    data[2].f4.xyz = subgroupInclusiveMax(data[2].f4.xyz);
171    data[2].f4     = subgroupInclusiveMax(data[3].f4);
172
173    data[3].i4.x   = subgroupInclusiveMax(data[0].i4.x);
174    data[3].i4.xy  = subgroupInclusiveMax(data[1].i4.xy);
175    data[3].i4.xyz = subgroupInclusiveMax(data[2].i4.xyz);
176    data[3].i4     = subgroupInclusiveMax(data[3].i4);
177
178    data[0].u4.x   = subgroupInclusiveMax(data[0].u4.x);
179    data[0].u4.xy  = subgroupInclusiveMax(data[1].u4.xy);
180    data[0].u4.xyz = subgroupInclusiveMax(data[2].u4.xyz);
181    data[0].u4     = subgroupInclusiveMax(data[3].u4);
182
183    data[1].i4.x   = subgroupInclusiveAnd(data[0].i4.x);
184    data[1].i4.xy  = subgroupInclusiveAnd(data[1].i4.xy);
185    data[1].i4.xyz = subgroupInclusiveAnd(data[2].i4.xyz);
186    data[1].i4     = subgroupInclusiveAnd(data[3].i4);
187
188    data[2].u4.x   = subgroupInclusiveAnd(data[0].u4.x);
189    data[2].u4.xy  = subgroupInclusiveAnd(data[1].u4.xy);
190    data[2].u4.xyz = subgroupInclusiveAnd(data[2].u4.xyz);
191    data[2].u4     = subgroupInclusiveAnd(data[3].u4);
192
193    data[3].i4.x   =   int(subgroupInclusiveAnd(data[0].i4.x < 0));
194    data[3].i4.xy  = ivec2(subgroupInclusiveAnd(lessThan(data[1].i4.xy, ivec2(0))));
195    data[3].i4.xyz = ivec3(subgroupInclusiveAnd(lessThan(data[1].i4.xyz, ivec3(0))));
196    data[3].i4     = ivec4(subgroupInclusiveAnd(lessThan(data[1].i4, ivec4(0))));
197
198    data[0].i4.x   = subgroupInclusiveOr(data[0].i4.x);
199    data[0].i4.xy  = subgroupInclusiveOr(data[1].i4.xy);
200    data[0].i4.xyz = subgroupInclusiveOr(data[2].i4.xyz);
201    data[0].i4     = subgroupInclusiveOr(data[3].i4);
202
203    data[1].u4.x   = subgroupInclusiveOr(data[0].u4.x);
204    data[1].u4.xy  = subgroupInclusiveOr(data[1].u4.xy);
205    data[1].u4.xyz = subgroupInclusiveOr(data[2].u4.xyz);
206    data[1].u4     = subgroupInclusiveOr(data[3].u4);
207
208    data[2].i4.x   =   int(subgroupInclusiveOr(data[0].i4.x < 0));
209    data[2].i4.xy  = ivec2(subgroupInclusiveOr(lessThan(data[1].i4.xy, ivec2(0))));
210    data[2].i4.xyz = ivec3(subgroupInclusiveOr(lessThan(data[1].i4.xyz, ivec3(0))));
211    data[2].i4     = ivec4(subgroupInclusiveOr(lessThan(data[1].i4, ivec4(0))));
212
213    data[3].i4.x   = subgroupInclusiveXor(data[0].i4.x);
214    data[3].i4.xy  = subgroupInclusiveXor(data[1].i4.xy);
215    data[3].i4.xyz = subgroupInclusiveXor(data[2].i4.xyz);
216    data[3].i4     = subgroupInclusiveXor(data[3].i4);
217
218    data[0].u4.x   = subgroupInclusiveXor(data[0].u4.x);
219    data[0].u4.xy  = subgroupInclusiveXor(data[1].u4.xy);
220    data[0].u4.xyz = subgroupInclusiveXor(data[2].u4.xyz);
221    data[0].u4     = subgroupInclusiveXor(data[3].u4);
222
223    data[1].i4.x   =   int(subgroupInclusiveXor(data[0].i4.x < 0));
224    data[1].i4.xy  = ivec2(subgroupInclusiveXor(lessThan(data[1].i4.xy, ivec2(0))));
225    data[1].i4.xyz = ivec3(subgroupInclusiveXor(lessThan(data[1].i4.xyz, ivec3(0))));
226    data[1].i4     = ivec4(subgroupInclusiveXor(lessThan(data[1].i4, ivec4(0))));
227
228    data[2].f4.x   = subgroupExclusiveAdd(data[0].f4.x);
229    data[2].f4.xy  = subgroupExclusiveAdd(data[1].f4.xy);
230    data[2].f4.xyz = subgroupExclusiveAdd(data[2].f4.xyz);
231    data[2].f4     = subgroupExclusiveAdd(data[3].f4);
232
233    data[3].i4.x   = subgroupExclusiveAdd(data[0].i4.x);
234    data[3].i4.xy  = subgroupExclusiveAdd(data[1].i4.xy);
235    data[3].i4.xyz = subgroupExclusiveAdd(data[2].i4.xyz);
236    data[3].i4     = subgroupExclusiveAdd(data[3].i4);
237
238    data[0].u4.x   = subgroupExclusiveAdd(data[0].u4.x);
239    data[0].u4.xy  = subgroupExclusiveAdd(data[1].u4.xy);
240    data[0].u4.xyz = subgroupExclusiveAdd(data[2].u4.xyz);
241    data[0].u4     = subgroupExclusiveAdd(data[3].u4);
242
243    data[1].f4.x   = subgroupExclusiveMul(data[0].f4.x);
244    data[1].f4.xy  = subgroupExclusiveMul(data[1].f4.xy);
245    data[1].f4.xyz = subgroupExclusiveMul(data[2].f4.xyz);
246    data[1].f4     = subgroupExclusiveMul(data[3].f4);
247
248    data[2].i4.x   = subgroupExclusiveMul(data[0].i4.x);
249    data[2].i4.xy  = subgroupExclusiveMul(data[1].i4.xy);
250    data[2].i4.xyz = subgroupExclusiveMul(data[2].i4.xyz);
251    data[2].i4     = subgroupExclusiveMul(data[3].i4);
252
253    data[3].u4.x   = subgroupExclusiveMul(data[0].u4.x);
254    data[3].u4.xy  = subgroupExclusiveMul(data[1].u4.xy);
255    data[3].u4.xyz = subgroupExclusiveMul(data[2].u4.xyz);
256    data[3].u4     = subgroupExclusiveMul(data[3].u4);
257
258    data[0].f4.x   = subgroupExclusiveMin(data[0].f4.x);
259    data[0].f4.xy  = subgroupExclusiveMin(data[1].f4.xy);
260    data[0].f4.xyz = subgroupExclusiveMin(data[2].f4.xyz);
261    data[0].f4     = subgroupExclusiveMin(data[3].f4);
262
263    data[1].i4.x   = subgroupExclusiveMin(data[0].i4.x);
264    data[1].i4.xy  = subgroupExclusiveMin(data[1].i4.xy);
265    data[1].i4.xyz = subgroupExclusiveMin(data[2].i4.xyz);
266    data[1].i4     = subgroupExclusiveMin(data[3].i4);
267
268    data[2].u4.x   = subgroupExclusiveMin(data[0].u4.x);
269    data[2].u4.xy  = subgroupExclusiveMin(data[1].u4.xy);
270    data[2].u4.xyz = subgroupExclusiveMin(data[2].u4.xyz);
271    data[2].u4     = subgroupExclusiveMin(data[3].u4);
272
273    data[3].f4.x   = subgroupExclusiveMax(data[0].f4.x);
274    data[3].f4.xy  = subgroupExclusiveMax(data[1].f4.xy);
275    data[3].f4.xyz = subgroupExclusiveMax(data[2].f4.xyz);
276    data[3].f4     = subgroupExclusiveMax(data[3].f4);
277
278    data[0].i4.x   = subgroupExclusiveMax(data[0].i4.x);
279    data[0].i4.xy  = subgroupExclusiveMax(data[1].i4.xy);
280    data[0].i4.xyz = subgroupExclusiveMax(data[2].i4.xyz);
281    data[0].i4     = subgroupExclusiveMax(data[3].i4);
282
283    data[1].u4.x   = subgroupExclusiveMax(data[0].u4.x);
284    data[1].u4.xy  = subgroupExclusiveMax(data[1].u4.xy);
285    data[1].u4.xyz = subgroupExclusiveMax(data[2].u4.xyz);
286    data[1].u4     = subgroupExclusiveMax(data[3].u4);
287
288    data[2].i4.x   = subgroupExclusiveAnd(data[0].i4.x);
289    data[2].i4.xy  = subgroupExclusiveAnd(data[1].i4.xy);
290    data[2].i4.xyz = subgroupExclusiveAnd(data[2].i4.xyz);
291    data[2].i4     = subgroupExclusiveAnd(data[3].i4);
292
293    data[3].u4.x   = subgroupExclusiveAnd(data[0].u4.x);
294    data[3].u4.xy  = subgroupExclusiveAnd(data[1].u4.xy);
295    data[3].u4.xyz = subgroupExclusiveAnd(data[2].u4.xyz);
296    data[3].u4     = subgroupExclusiveAnd(data[3].u4);
297
298    data[0].i4.x   =   int(subgroupExclusiveAnd(data[0].i4.x < 0));
299    data[0].i4.xy  = ivec2(subgroupExclusiveAnd(lessThan(data[1].i4.xy, ivec2(0))));
300    data[0].i4.xyz = ivec3(subgroupExclusiveAnd(lessThan(data[1].i4.xyz, ivec3(0))));
301    data[0].i4     = ivec4(subgroupExclusiveAnd(lessThan(data[1].i4, ivec4(0))));
302
303    data[1].i4.x   = subgroupExclusiveOr(data[0].i4.x);
304    data[1].i4.xy  = subgroupExclusiveOr(data[1].i4.xy);
305    data[1].i4.xyz = subgroupExclusiveOr(data[2].i4.xyz);
306    data[1].i4     = subgroupExclusiveOr(data[3].i4);
307
308    data[2].u4.x   = subgroupExclusiveOr(data[0].u4.x);
309    data[2].u4.xy  = subgroupExclusiveOr(data[1].u4.xy);
310    data[2].u4.xyz = subgroupExclusiveOr(data[2].u4.xyz);
311    data[2].u4     = subgroupExclusiveOr(data[3].u4);
312
313    data[3].i4.x   =   int(subgroupExclusiveOr(data[0].i4.x < 0));
314    data[3].i4.xy  = ivec2(subgroupExclusiveOr(lessThan(data[1].i4.xy, ivec2(0))));
315    data[3].i4.xyz = ivec3(subgroupExclusiveOr(lessThan(data[1].i4.xyz, ivec3(0))));
316    data[3].i4     = ivec4(subgroupExclusiveOr(lessThan(data[1].i4, ivec4(0))));
317
318    data[0].i4.x   = subgroupExclusiveXor(data[0].i4.x);
319    data[0].i4.xy  = subgroupExclusiveXor(data[1].i4.xy);
320    data[0].i4.xyz = subgroupExclusiveXor(data[2].i4.xyz);
321    data[0].i4     = subgroupExclusiveXor(data[3].i4);
322
323    data[1].u4.x   = subgroupExclusiveXor(data[0].u4.x);
324    data[1].u4.xy  = subgroupExclusiveXor(data[1].u4.xy);
325    data[1].u4.xyz = subgroupExclusiveXor(data[2].u4.xyz);
326    data[1].u4     = subgroupExclusiveXor(data[3].u4);
327
328    data[2].i4.x   =   int(subgroupExclusiveXor(data[0].i4.x < 0));
329    data[2].i4.xy  = ivec2(subgroupExclusiveXor(lessThan(data[1].i4.xy, ivec2(0))));
330    data[2].i4.xyz = ivec3(subgroupExclusiveXor(lessThan(data[1].i4.xyz, ivec3(0))));
331    data[2].i4     = ivec4(subgroupExclusiveXor(lessThan(data[1].i4, ivec4(0))));
332}
333