Fix missing dependency on sparse binds
[platform/upstream/VK-GL-CTS.git] / external / vulkancts / modules / vulkan / image / vktImageAtomicSpirvShaders.cpp
1 /*------------------------------------------------------------------------
2  * Vulkan Conformance Tests
3  * ------------------------
4  *
5  * Copyright (c) 2020 Valve Corporation.
6  * Copyright (c) 2020 The Khronos Group Inc.
7  *
8  * Licensed under the Apache License, Version 2.0 (the "License");
9  * you may not use this file except in compliance with the License.
10  * You may obtain a copy of the License at
11  *
12  *      http://www.apache.org/licenses/LICENSE-2.0
13  *
14  * Unless required by applicable law or agreed to in writing, software
15  * distributed under the License is distributed on an "AS IS" BASIS,
16  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17  * See the License for the specific language governing permissions and
18  * limitations under the License.
19  *
20  *//*!
21  * \file
22  * \brief Helper SPIR-V shaders for some image atomic operations.
23  *//*--------------------------------------------------------------------*/
24
25 #include "vktImageAtomicSpirvShaders.hpp"
26
27 #include <array>
28 #include <map>
29
30 namespace vkt
31 {
32 namespace image
33 {
34
35 namespace
36 {
37
38 const std::string kShader_1d_r32ui_end_result = R"(
39 ; The SPIR-V shader below is based on the following GLSL shader, but OpAtomicIAdd has been
40 ; replaced with a template parameter and the last argument for it has been made optional.
41 ;
42 ; #version 440
43 ; precision highp uimage1D;
44 ;
45 ; layout (local_size_x = 1, local_size_y = 1, local_size_z = 1) in;
46 ; layout (r32ui, binding=0) coherent uniform uimage1D u_resultImage;
47 ;
48 ; void main (void)
49 ; {
50 ;     int gx = int(gl_GlobalInvocationID.x);
51 ;     int gy = int(gl_GlobalInvocationID.y);
52 ;     int gz = int(gl_GlobalInvocationID.z);
53 ;     imageAtomicAdd(u_resultImage, gx % 64, uint(gx*gx + gy*gy + gz*gz));
54 ; }
55 ;
56 ; SPIR-V
57 ; Version: 1.0
58 ; Generator: Khronos Glslang Reference Front End; 7
59 ; Bound: 50
60 ; Schema: 0
61 OpCapability Shader
62 OpCapability Image1D
63 %1 = OpExtInstImport "GLSL.std.450"
64 OpMemoryModel Logical GLSL450
65 OpEntryPoint GLCompute %4 "main" %12
66 OpExecutionMode %4 LocalSize 1 1 1
67 OpDecorate %12 BuiltIn GlobalInvocationId
68 OpDecorate %30 DescriptorSet 0
69 OpDecorate %30 Binding 0
70 OpDecorate %30 Coherent
71 OpDecorate %49 BuiltIn WorkgroupSize
72 %2 = OpTypeVoid
73 %3 = OpTypeFunction %2
74 %6 = OpTypeInt 32 1
75 %7 = OpTypePointer Function %6
76 %9 = OpTypeInt 32 0
77 %10 = OpTypeVector %9 3
78 %11 = OpTypePointer Input %10
79 %12 = OpVariable %11 Input
80 %13 = OpConstant %9 0
81 %14 = OpTypePointer Input %9
82 %19 = OpConstant %9 1
83 %24 = OpConstant %9 2
84 %28 = OpTypeImage %9 1D 0 0 0 2 R32ui
85 %29 = OpTypePointer UniformConstant %28
86 %30 = OpVariable %29 UniformConstant
87 %32 = OpConstant %6 64
88 %46 = OpTypePointer Image %9
89 %49 = OpConstantComposite %10 %19 %19 %19
90 %4 = OpFunction %2 None %3
91 %5 = OpLabel
92 %8 = OpVariable %7 Function
93 %18 = OpVariable %7 Function
94 %23 = OpVariable %7 Function
95 %15 = OpAccessChain %14 %12 %13
96 %16 = OpLoad %9 %15
97 %17 = OpBitcast %6 %16
98 OpStore %8 %17
99 %20 = OpAccessChain %14 %12 %19
100 %21 = OpLoad %9 %20
101 %22 = OpBitcast %6 %21
102 OpStore %18 %22
103 %25 = OpAccessChain %14 %12 %24
104 %26 = OpLoad %9 %25
105 %27 = OpBitcast %6 %26
106 OpStore %23 %27
107 %31 = OpLoad %6 %8
108 %33 = OpSMod %6 %31 %32
109 %34 = OpLoad %6 %8
110 %35 = OpLoad %6 %8
111 %36 = OpIMul %6 %34 %35
112 %37 = OpLoad %6 %18
113 %38 = OpLoad %6 %18
114 %39 = OpIMul %6 %37 %38
115 %40 = OpIAdd %6 %36 %39
116 %41 = OpLoad %6 %23
117 %42 = OpLoad %6 %23
118 %43 = OpIMul %6 %41 %42
119 %44 = OpIAdd %6 %40 %43
120 %45 = OpBitcast %9 %44
121 %47 = OpImageTexelPointer %46 %30 %33 %13
122 %48 = ${OPNAME} %9 %47 %19 %13 ${LASTARG:default=%45}
123 OpReturn
124 OpFunctionEnd
125 )";
126
127 const std::string kShader_1d_r32ui_intermediate_values = R"(
128 ; The SPIR-V shader below is based on the following GLSL shader, but OpAtomicIAdd has been
129 ; replaced with a template parameter and the last argument for it has been made optional.
130 ;
131 ; #version 440
132 ; precision highp uimage1D;
133 ;
134 ; layout (local_size_x = 1, local_size_y = 1, local_size_z = 1) in;
135 ; layout (r32ui, binding=0) coherent uniform uimage1D u_resultImage;
136 ; layout (r32ui, binding=1) writeonly uniform uimage1D u_intermValuesImage;
137 ;
138 ; void main (void)
139 ; {
140 ;     int gx = int(gl_GlobalInvocationID.x);
141 ;     int gy = int(gl_GlobalInvocationID.y);
142 ;     int gz = int(gl_GlobalInvocationID.z);
143 ;     imageStore(u_intermValuesImage, gx, uvec4(imageAtomicAdd(u_resultImage, gx % 64, uint(gx*gx + gy*gy + gz*gz))));
144 ; }
145 ;
146 ; SPIR-V
147 ; Version: 1.0
148 ; Generator: Khronos Glslang Reference Front End; 7
149 ; Bound: 55
150 ; Schema: 0
151 OpCapability Shader
152 OpCapability Image1D
153 %1 = OpExtInstImport "GLSL.std.450"
154 OpMemoryModel Logical GLSL450
155 OpEntryPoint GLCompute %4 "main" %12
156 OpExecutionMode %4 LocalSize 1 1 1
157 OpDecorate %12 BuiltIn GlobalInvocationId
158 OpDecorate %30 DescriptorSet 0
159 OpDecorate %30 Binding 1
160 OpDecorate %30 NonReadable
161 OpDecorate %33 DescriptorSet 0
162 OpDecorate %33 Binding 0
163 OpDecorate %33 Coherent
164 OpDecorate %54 BuiltIn WorkgroupSize
165 %2 = OpTypeVoid
166 %3 = OpTypeFunction %2
167 %6 = OpTypeInt 32 1
168 %7 = OpTypePointer Function %6
169 %9 = OpTypeInt 32 0
170 %10 = OpTypeVector %9 3
171 %11 = OpTypePointer Input %10
172 %12 = OpVariable %11 Input
173 %13 = OpConstant %9 0
174 %14 = OpTypePointer Input %9
175 %19 = OpConstant %9 1
176 %24 = OpConstant %9 2
177 %28 = OpTypeImage %9 1D 0 0 0 2 R32ui
178 %29 = OpTypePointer UniformConstant %28
179 %30 = OpVariable %29 UniformConstant
180 %33 = OpVariable %29 UniformConstant
181 %35 = OpConstant %6 64
182 %49 = OpTypePointer Image %9
183 %52 = OpTypeVector %9 4
184 %54 = OpConstantComposite %10 %19 %19 %19
185 %4 = OpFunction %2 None %3
186 %5 = OpLabel
187 %8 = OpVariable %7 Function
188 %18 = OpVariable %7 Function
189 %23 = OpVariable %7 Function
190 %15 = OpAccessChain %14 %12 %13
191 %16 = OpLoad %9 %15
192 %17 = OpBitcast %6 %16
193 OpStore %8 %17
194 %20 = OpAccessChain %14 %12 %19
195 %21 = OpLoad %9 %20
196 %22 = OpBitcast %6 %21
197 OpStore %18 %22
198 %25 = OpAccessChain %14 %12 %24
199 %26 = OpLoad %9 %25
200 %27 = OpBitcast %6 %26
201 OpStore %23 %27
202 %31 = OpLoad %28 %30
203 %32 = OpLoad %6 %8
204 %34 = OpLoad %6 %8
205 %36 = OpSMod %6 %34 %35
206 %37 = OpLoad %6 %8
207 %38 = OpLoad %6 %8
208 %39 = OpIMul %6 %37 %38
209 %40 = OpLoad %6 %18
210 %41 = OpLoad %6 %18
211 %42 = OpIMul %6 %40 %41
212 %43 = OpIAdd %6 %39 %42
213 %44 = OpLoad %6 %23
214 %45 = OpLoad %6 %23
215 %46 = OpIMul %6 %44 %45
216 %47 = OpIAdd %6 %43 %46
217 %48 = OpBitcast %9 %47
218 %50 = OpImageTexelPointer %49 %33 %36 %13
219 %51 = ${OPNAME} %9 %50 %19 %13 ${LASTARG:default=%48}
220 %53 = OpCompositeConstruct %52 %51 %51 %51 %51
221 OpImageWrite %31 %32 %53
222 OpReturn
223 OpFunctionEnd
224 )";
225
226 const std::string kShader_1d_r32i_end_result = R"(
227 ; The SPIR-V shader below is based on the following GLSL shader, but OpAtomicIAdd has been
228 ; replaced with a template parameter and the last argument for it has been made optional.
229 ;
230 ; #version 440
231 ; precision highp iimage1D;
232 ;
233 ; layout (local_size_x = 1, local_size_y = 1, local_size_z = 1) in;
234 ; layout (r32i, binding=0) coherent uniform iimage1D u_resultImage;
235 ;
236 ; void main (void)
237 ; {
238 ;     int gx = int(gl_GlobalInvocationID.x);
239 ;     int gy = int(gl_GlobalInvocationID.y);
240 ;     int gz = int(gl_GlobalInvocationID.z);
241 ;     imageAtomicAdd(u_resultImage, gx % 64, int(gx*gx + gy*gy + gz*gz));
242 ; }
243 ;
244 ; SPIR-V
245 ; Version: 1.0
246 ; Generator: Khronos Glslang Reference Front End; 7
247 ; Bound: 49
248 ; Schema: 0
249 OpCapability Shader
250 OpCapability Image1D
251 %1 = OpExtInstImport "GLSL.std.450"
252 OpMemoryModel Logical GLSL450
253 OpEntryPoint GLCompute %4 "main" %12
254 OpExecutionMode %4 LocalSize 1 1 1
255 OpDecorate %12 BuiltIn GlobalInvocationId
256 OpDecorate %30 DescriptorSet 0
257 OpDecorate %30 Binding 0
258 OpDecorate %30 Coherent
259 OpDecorate %48 BuiltIn WorkgroupSize
260 %2 = OpTypeVoid
261 %3 = OpTypeFunction %2
262 %6 = OpTypeInt 32 1
263 %7 = OpTypePointer Function %6
264 %9 = OpTypeInt 32 0
265 %10 = OpTypeVector %9 3
266 %11 = OpTypePointer Input %10
267 %12 = OpVariable %11 Input
268 %13 = OpConstant %9 0
269 %14 = OpTypePointer Input %9
270 %19 = OpConstant %9 1
271 %24 = OpConstant %9 2
272 %28 = OpTypeImage %6 1D 0 0 0 2 R32i
273 %29 = OpTypePointer UniformConstant %28
274 %30 = OpVariable %29 UniformConstant
275 %32 = OpConstant %6 64
276 %45 = OpTypePointer Image %6
277 %48 = OpConstantComposite %10 %19 %19 %19
278 %4 = OpFunction %2 None %3
279 %5 = OpLabel
280 %8 = OpVariable %7 Function
281 %18 = OpVariable %7 Function
282 %23 = OpVariable %7 Function
283 %15 = OpAccessChain %14 %12 %13
284 %16 = OpLoad %9 %15
285 %17 = OpBitcast %6 %16
286 OpStore %8 %17
287 %20 = OpAccessChain %14 %12 %19
288 %21 = OpLoad %9 %20
289 %22 = OpBitcast %6 %21
290 OpStore %18 %22
291 %25 = OpAccessChain %14 %12 %24
292 %26 = OpLoad %9 %25
293 %27 = OpBitcast %6 %26
294 OpStore %23 %27
295 %31 = OpLoad %6 %8
296 %33 = OpSMod %6 %31 %32
297 %34 = OpLoad %6 %8
298 %35 = OpLoad %6 %8
299 %36 = OpIMul %6 %34 %35
300 %37 = OpLoad %6 %18
301 %38 = OpLoad %6 %18
302 %39 = OpIMul %6 %37 %38
303 %40 = OpIAdd %6 %36 %39
304 %41 = OpLoad %6 %23
305 %42 = OpLoad %6 %23
306 %43 = OpIMul %6 %41 %42
307 %44 = OpIAdd %6 %40 %43
308 %46 = OpImageTexelPointer %45 %30 %33 %13
309 %47 = ${OPNAME} %6 %46 %19 %13 ${LASTARG:default=%44}
310 OpReturn
311 OpFunctionEnd
312 )";
313
314 const std::string kShader_1d_r32i_intermediate_values = R"(
315 ; The SPIR-V shader below is based on the following GLSL shader, but OpAtomicIAdd has been
316 ; replaced with a template parameter and the last argument for it has been made optional.
317 ;
318 ; #version 440
319 ; precision highp iimage1D;
320 ;
321 ; layout (local_size_x = 1, local_size_y = 1, local_size_z = 1) in;
322 ; layout (r32i, binding=0) coherent uniform iimage1D u_resultImage;
323 ; layout (r32i, binding=1) writeonly uniform iimage1D u_intermValuesImage;
324 ;
325 ; void main (void)
326 ; {
327 ;     int gx = int(gl_GlobalInvocationID.x);
328 ;     int gy = int(gl_GlobalInvocationID.y);
329 ;     int gz = int(gl_GlobalInvocationID.z);
330 ;     imageStore(u_intermValuesImage, gx, ivec4(imageAtomicAdd(u_resultImage, gx % 64, int(gx*gx + gy*gy + gz*gz))));
331 ; }
332 ;
333 ; SPIR-V
334 ; Version: 1.0
335 ; Generator: Khronos Glslang Reference Front End; 7
336 ; Bound: 54
337 ; Schema: 0
338 OpCapability Shader
339 OpCapability Image1D
340 %1 = OpExtInstImport "GLSL.std.450"
341 OpMemoryModel Logical GLSL450
342 OpEntryPoint GLCompute %4 "main" %12
343 OpExecutionMode %4 LocalSize 1 1 1
344 OpDecorate %12 BuiltIn GlobalInvocationId
345 OpDecorate %30 DescriptorSet 0
346 OpDecorate %30 Binding 1
347 OpDecorate %30 NonReadable
348 OpDecorate %33 DescriptorSet 0
349 OpDecorate %33 Binding 0
350 OpDecorate %33 Coherent
351 OpDecorate %53 BuiltIn WorkgroupSize
352 %2 = OpTypeVoid
353 %3 = OpTypeFunction %2
354 %6 = OpTypeInt 32 1
355 %7 = OpTypePointer Function %6
356 %9 = OpTypeInt 32 0
357 %10 = OpTypeVector %9 3
358 %11 = OpTypePointer Input %10
359 %12 = OpVariable %11 Input
360 %13 = OpConstant %9 0
361 %14 = OpTypePointer Input %9
362 %19 = OpConstant %9 1
363 %24 = OpConstant %9 2
364 %28 = OpTypeImage %6 1D 0 0 0 2 R32i
365 %29 = OpTypePointer UniformConstant %28
366 %30 = OpVariable %29 UniformConstant
367 %33 = OpVariable %29 UniformConstant
368 %35 = OpConstant %6 64
369 %48 = OpTypePointer Image %6
370 %51 = OpTypeVector %6 4
371 %53 = OpConstantComposite %10 %19 %19 %19
372 %4 = OpFunction %2 None %3
373 %5 = OpLabel
374 %8 = OpVariable %7 Function
375 %18 = OpVariable %7 Function
376 %23 = OpVariable %7 Function
377 %15 = OpAccessChain %14 %12 %13
378 %16 = OpLoad %9 %15
379 %17 = OpBitcast %6 %16
380 OpStore %8 %17
381 %20 = OpAccessChain %14 %12 %19
382 %21 = OpLoad %9 %20
383 %22 = OpBitcast %6 %21
384 OpStore %18 %22
385 %25 = OpAccessChain %14 %12 %24
386 %26 = OpLoad %9 %25
387 %27 = OpBitcast %6 %26
388 OpStore %23 %27
389 %31 = OpLoad %28 %30
390 %32 = OpLoad %6 %8
391 %34 = OpLoad %6 %8
392 %36 = OpSMod %6 %34 %35
393 %37 = OpLoad %6 %8
394 %38 = OpLoad %6 %8
395 %39 = OpIMul %6 %37 %38
396 %40 = OpLoad %6 %18
397 %41 = OpLoad %6 %18
398 %42 = OpIMul %6 %40 %41
399 %43 = OpIAdd %6 %39 %42
400 %44 = OpLoad %6 %23
401 %45 = OpLoad %6 %23
402 %46 = OpIMul %6 %44 %45
403 %47 = OpIAdd %6 %43 %46
404 %49 = OpImageTexelPointer %48 %33 %36 %13
405 %50 = ${OPNAME} %6 %49 %19 %13 ${LASTARG:default=%47}
406 %52 = OpCompositeConstruct %51 %50 %50 %50 %50
407 OpImageWrite %31 %32 %52
408 OpReturn
409 OpFunctionEnd
410 )";
411
412 const std::string kShader_1d_array_r32ui_end_result = R"(
413 ; The SPIR-V shader below is based on the following GLSL shader, but OpAtomicIAdd has been
414 ; replaced with a template parameter and the last argument for it has been made optional.
415 ;
416 ; #version 440
417 ; precision highp uimage1DArray;
418 ;
419 ; layout (local_size_x = 1, local_size_y = 1, local_size_z = 1) in;
420 ; layout (r32ui, binding=0) coherent uniform uimage1DArray u_resultImage;
421 ;
422 ; void main (void)
423 ; {
424 ;     int gx = int(gl_GlobalInvocationID.x);
425 ;     int gy = int(gl_GlobalInvocationID.y);
426 ;     int gz = int(gl_GlobalInvocationID.z);
427 ;     imageAtomicAdd(u_resultImage, ivec2(gx % 64,gy), uint(gx*gx + gy*gy + gz*gz));
428 ; }
429 ;
430 ; SPIR-V
431 ; Version: 1.0
432 ; Generator: Khronos Glslang Reference Front End; 7
433 ; Bound: 53
434 ; Schema: 0
435 OpCapability Shader
436 OpCapability Image1D
437 %1 = OpExtInstImport "GLSL.std.450"
438 OpMemoryModel Logical GLSL450
439 OpEntryPoint GLCompute %4 "main" %12
440 OpExecutionMode %4 LocalSize 1 1 1
441 OpDecorate %12 BuiltIn GlobalInvocationId
442 OpDecorate %30 DescriptorSet 0
443 OpDecorate %30 Binding 0
444 OpDecorate %30 Coherent
445 OpDecorate %52 BuiltIn WorkgroupSize
446 %2 = OpTypeVoid
447 %3 = OpTypeFunction %2
448 %6 = OpTypeInt 32 1
449 %7 = OpTypePointer Function %6
450 %9 = OpTypeInt 32 0
451 %10 = OpTypeVector %9 3
452 %11 = OpTypePointer Input %10
453 %12 = OpVariable %11 Input
454 %13 = OpConstant %9 0
455 %14 = OpTypePointer Input %9
456 %19 = OpConstant %9 1
457 %24 = OpConstant %9 2
458 %28 = OpTypeImage %9 1D 0 1 0 2 R32ui
459 %29 = OpTypePointer UniformConstant %28
460 %30 = OpVariable %29 UniformConstant
461 %32 = OpConstant %6 64
462 %35 = OpTypeVector %6 2
463 %49 = OpTypePointer Image %9
464 %52 = OpConstantComposite %10 %19 %19 %19
465 %4 = OpFunction %2 None %3
466 %5 = OpLabel
467 %8 = OpVariable %7 Function
468 %18 = OpVariable %7 Function
469 %23 = OpVariable %7 Function
470 %15 = OpAccessChain %14 %12 %13
471 %16 = OpLoad %9 %15
472 %17 = OpBitcast %6 %16
473 OpStore %8 %17
474 %20 = OpAccessChain %14 %12 %19
475 %21 = OpLoad %9 %20
476 %22 = OpBitcast %6 %21
477 OpStore %18 %22
478 %25 = OpAccessChain %14 %12 %24
479 %26 = OpLoad %9 %25
480 %27 = OpBitcast %6 %26
481 OpStore %23 %27
482 %31 = OpLoad %6 %8
483 %33 = OpSMod %6 %31 %32
484 %34 = OpLoad %6 %18
485 %36 = OpCompositeConstruct %35 %33 %34
486 %37 = OpLoad %6 %8
487 %38 = OpLoad %6 %8
488 %39 = OpIMul %6 %37 %38
489 %40 = OpLoad %6 %18
490 %41 = OpLoad %6 %18
491 %42 = OpIMul %6 %40 %41
492 %43 = OpIAdd %6 %39 %42
493 %44 = OpLoad %6 %23
494 %45 = OpLoad %6 %23
495 %46 = OpIMul %6 %44 %45
496 %47 = OpIAdd %6 %43 %46
497 %48 = OpBitcast %9 %47
498 %50 = OpImageTexelPointer %49 %30 %36 %13
499 %51 = ${OPNAME} %9 %50 %19 %13 ${LASTARG:default=%48}
500 OpReturn
501 OpFunctionEnd
502 )";
503
504 const std::string kShader_1d_array_r32ui_intermediate_values = R"(
505 ; The SPIR-V shader below is based on the following GLSL shader, but OpAtomicIAdd has been
506 ; replaced with a template parameter and the last argument for it has been made optional.
507 ;
508 ; #version 440
509 ; precision highp uimage1DArray;
510 ;
511 ; layout (local_size_x = 1, local_size_y = 1, local_size_z = 1) in;
512 ; layout (r32ui, binding=0) coherent uniform uimage1DArray u_resultImage;
513 ; layout (r32ui, binding=1) writeonly uniform uimage1DArray u_intermValuesImage;
514 ;
515 ; void main (void)
516 ; {
517 ;     int gx = int(gl_GlobalInvocationID.x);
518 ;     int gy = int(gl_GlobalInvocationID.y);
519 ;     int gz = int(gl_GlobalInvocationID.z);
520 ;     imageStore(u_intermValuesImage, ivec2(gx,gy), uvec4(imageAtomicAdd(u_resultImage, ivec2(gx % 64,gy), uint(gx*gx + gy*gy + gz*gz))));
521 ; }
522 ;
523 ; SPIR-V
524 ; Version: 1.0
525 ; Generator: Khronos Glslang Reference Front End; 7
526 ; Bound: 60
527 ; Schema: 0
528 OpCapability Shader
529 OpCapability Image1D
530 %1 = OpExtInstImport "GLSL.std.450"
531 OpMemoryModel Logical GLSL450
532 OpEntryPoint GLCompute %4 "main" %12
533 OpExecutionMode %4 LocalSize 1 1 1
534 OpDecorate %12 BuiltIn GlobalInvocationId
535 OpDecorate %30 DescriptorSet 0
536 OpDecorate %30 Binding 1
537 OpDecorate %30 NonReadable
538 OpDecorate %36 DescriptorSet 0
539 OpDecorate %36 Binding 0
540 OpDecorate %36 Coherent
541 OpDecorate %59 BuiltIn WorkgroupSize
542 %2 = OpTypeVoid
543 %3 = OpTypeFunction %2
544 %6 = OpTypeInt 32 1
545 %7 = OpTypePointer Function %6
546 %9 = OpTypeInt 32 0
547 %10 = OpTypeVector %9 3
548 %11 = OpTypePointer Input %10
549 %12 = OpVariable %11 Input
550 %13 = OpConstant %9 0
551 %14 = OpTypePointer Input %9
552 %19 = OpConstant %9 1
553 %24 = OpConstant %9 2
554 %28 = OpTypeImage %9 1D 0 1 0 2 R32ui
555 %29 = OpTypePointer UniformConstant %28
556 %30 = OpVariable %29 UniformConstant
557 %34 = OpTypeVector %6 2
558 %36 = OpVariable %29 UniformConstant
559 %38 = OpConstant %6 64
560 %54 = OpTypePointer Image %9
561 %57 = OpTypeVector %9 4
562 %59 = OpConstantComposite %10 %19 %19 %19
563 %4 = OpFunction %2 None %3
564 %5 = OpLabel
565 %8 = OpVariable %7 Function
566 %18 = OpVariable %7 Function
567 %23 = OpVariable %7 Function
568 %15 = OpAccessChain %14 %12 %13
569 %16 = OpLoad %9 %15
570 %17 = OpBitcast %6 %16
571 OpStore %8 %17
572 %20 = OpAccessChain %14 %12 %19
573 %21 = OpLoad %9 %20
574 %22 = OpBitcast %6 %21
575 OpStore %18 %22
576 %25 = OpAccessChain %14 %12 %24
577 %26 = OpLoad %9 %25
578 %27 = OpBitcast %6 %26
579 OpStore %23 %27
580 %31 = OpLoad %28 %30
581 %32 = OpLoad %6 %8
582 %33 = OpLoad %6 %18
583 %35 = OpCompositeConstruct %34 %32 %33
584 %37 = OpLoad %6 %8
585 %39 = OpSMod %6 %37 %38
586 %40 = OpLoad %6 %18
587 %41 = OpCompositeConstruct %34 %39 %40
588 %42 = OpLoad %6 %8
589 %43 = OpLoad %6 %8
590 %44 = OpIMul %6 %42 %43
591 %45 = OpLoad %6 %18
592 %46 = OpLoad %6 %18
593 %47 = OpIMul %6 %45 %46
594 %48 = OpIAdd %6 %44 %47
595 %49 = OpLoad %6 %23
596 %50 = OpLoad %6 %23
597 %51 = OpIMul %6 %49 %50
598 %52 = OpIAdd %6 %48 %51
599 %53 = OpBitcast %9 %52
600 %55 = OpImageTexelPointer %54 %36 %41 %13
601 %56 = ${OPNAME} %9 %55 %19 %13 ${LASTARG:default=%53}
602 %58 = OpCompositeConstruct %57 %56 %56 %56 %56
603 OpImageWrite %31 %35 %58
604 OpReturn
605 OpFunctionEnd
606 )";
607
608 const std::string kShader_1d_array_r32i_end_result = R"(
609 ; The SPIR-V shader below is based on the following GLSL shader, but OpAtomicIAdd has been
610 ; replaced with a template parameter and the last argument for it has been made optional.
611 ;
612 ; #version 440
613 ; precision highp iimage1DArray;
614 ;
615 ; layout (local_size_x = 1, local_size_y = 1, local_size_z = 1) in;
616 ; layout (r32i, binding=0) coherent uniform iimage1DArray u_resultImage;
617 ;
618 ; void main (void)
619 ; {
620 ;     int gx = int(gl_GlobalInvocationID.x);
621 ;     int gy = int(gl_GlobalInvocationID.y);
622 ;     int gz = int(gl_GlobalInvocationID.z);
623 ;     imageAtomicAdd(u_resultImage, ivec2(gx % 64,gy), int(gx*gx + gy*gy + gz*gz));
624 ; }
625 ;
626 ; SPIR-V
627 ; Version: 1.0
628 ; Generator: Khronos Glslang Reference Front End; 7
629 ; Bound: 52
630 ; Schema: 0
631 OpCapability Shader
632 OpCapability Image1D
633 %1 = OpExtInstImport "GLSL.std.450"
634 OpMemoryModel Logical GLSL450
635 OpEntryPoint GLCompute %4 "main" %12
636 OpExecutionMode %4 LocalSize 1 1 1
637 OpDecorate %12 BuiltIn GlobalInvocationId
638 OpDecorate %30 DescriptorSet 0
639 OpDecorate %30 Binding 0
640 OpDecorate %30 Coherent
641 OpDecorate %51 BuiltIn WorkgroupSize
642 %2 = OpTypeVoid
643 %3 = OpTypeFunction %2
644 %6 = OpTypeInt 32 1
645 %7 = OpTypePointer Function %6
646 %9 = OpTypeInt 32 0
647 %10 = OpTypeVector %9 3
648 %11 = OpTypePointer Input %10
649 %12 = OpVariable %11 Input
650 %13 = OpConstant %9 0
651 %14 = OpTypePointer Input %9
652 %19 = OpConstant %9 1
653 %24 = OpConstant %9 2
654 %28 = OpTypeImage %6 1D 0 1 0 2 R32i
655 %29 = OpTypePointer UniformConstant %28
656 %30 = OpVariable %29 UniformConstant
657 %32 = OpConstant %6 64
658 %35 = OpTypeVector %6 2
659 %48 = OpTypePointer Image %6
660 %51 = OpConstantComposite %10 %19 %19 %19
661 %4 = OpFunction %2 None %3
662 %5 = OpLabel
663 %8 = OpVariable %7 Function
664 %18 = OpVariable %7 Function
665 %23 = OpVariable %7 Function
666 %15 = OpAccessChain %14 %12 %13
667 %16 = OpLoad %9 %15
668 %17 = OpBitcast %6 %16
669 OpStore %8 %17
670 %20 = OpAccessChain %14 %12 %19
671 %21 = OpLoad %9 %20
672 %22 = OpBitcast %6 %21
673 OpStore %18 %22
674 %25 = OpAccessChain %14 %12 %24
675 %26 = OpLoad %9 %25
676 %27 = OpBitcast %6 %26
677 OpStore %23 %27
678 %31 = OpLoad %6 %8
679 %33 = OpSMod %6 %31 %32
680 %34 = OpLoad %6 %18
681 %36 = OpCompositeConstruct %35 %33 %34
682 %37 = OpLoad %6 %8
683 %38 = OpLoad %6 %8
684 %39 = OpIMul %6 %37 %38
685 %40 = OpLoad %6 %18
686 %41 = OpLoad %6 %18
687 %42 = OpIMul %6 %40 %41
688 %43 = OpIAdd %6 %39 %42
689 %44 = OpLoad %6 %23
690 %45 = OpLoad %6 %23
691 %46 = OpIMul %6 %44 %45
692 %47 = OpIAdd %6 %43 %46
693 %49 = OpImageTexelPointer %48 %30 %36 %13
694 %50 = ${OPNAME} %6 %49 %19 %13 ${LASTARG:default=%47}
695 OpReturn
696 OpFunctionEnd
697 )";
698
699 const std::string kShader_1d_array_r32i_intermediate_values = R"(
700 ; The SPIR-V shader below is based on the following GLSL shader, but OpAtomicIAdd has been
701 ; replaced with a template parameter and the last argument for it has been made optional.
702 ;
703 ; #version 440
704 ; precision highp iimage1DArray;
705 ;
706 ; layout (local_size_x = 1, local_size_y = 1, local_size_z = 1) in;
707 ; layout (r32i, binding=0) coherent uniform iimage1DArray u_resultImage;
708 ; layout (r32i, binding=1) writeonly uniform iimage1DArray u_intermValuesImage;
709 ;
710 ; void main (void)
711 ; {
712 ;     int gx = int(gl_GlobalInvocationID.x);
713 ;     int gy = int(gl_GlobalInvocationID.y);
714 ;     int gz = int(gl_GlobalInvocationID.z);
715 ;     imageStore(u_intermValuesImage, ivec2(gx,gy), ivec4(imageAtomicAdd(u_resultImage, ivec2(gx % 64,gy), int(gx*gx + gy*gy + gz*gz))));
716 ; }
717 ;
718 ; SPIR-V
719 ; Version: 1.0
720 ; Generator: Khronos Glslang Reference Front End; 7
721 ; Bound: 59
722 ; Schema: 0
723 OpCapability Shader
724 OpCapability Image1D
725 %1 = OpExtInstImport "GLSL.std.450"
726 OpMemoryModel Logical GLSL450
727 OpEntryPoint GLCompute %4 "main" %12
728 OpExecutionMode %4 LocalSize 1 1 1
729 OpDecorate %12 BuiltIn GlobalInvocationId
730 OpDecorate %30 DescriptorSet 0
731 OpDecorate %30 Binding 1
732 OpDecorate %30 NonReadable
733 OpDecorate %36 DescriptorSet 0
734 OpDecorate %36 Binding 0
735 OpDecorate %36 Coherent
736 OpDecorate %58 BuiltIn WorkgroupSize
737 %2 = OpTypeVoid
738 %3 = OpTypeFunction %2
739 %6 = OpTypeInt 32 1
740 %7 = OpTypePointer Function %6
741 %9 = OpTypeInt 32 0
742 %10 = OpTypeVector %9 3
743 %11 = OpTypePointer Input %10
744 %12 = OpVariable %11 Input
745 %13 = OpConstant %9 0
746 %14 = OpTypePointer Input %9
747 %19 = OpConstant %9 1
748 %24 = OpConstant %9 2
749 %28 = OpTypeImage %6 1D 0 1 0 2 R32i
750 %29 = OpTypePointer UniformConstant %28
751 %30 = OpVariable %29 UniformConstant
752 %34 = OpTypeVector %6 2
753 %36 = OpVariable %29 UniformConstant
754 %38 = OpConstant %6 64
755 %53 = OpTypePointer Image %6
756 %56 = OpTypeVector %6 4
757 %58 = OpConstantComposite %10 %19 %19 %19
758 %4 = OpFunction %2 None %3
759 %5 = OpLabel
760 %8 = OpVariable %7 Function
761 %18 = OpVariable %7 Function
762 %23 = OpVariable %7 Function
763 %15 = OpAccessChain %14 %12 %13
764 %16 = OpLoad %9 %15
765 %17 = OpBitcast %6 %16
766 OpStore %8 %17
767 %20 = OpAccessChain %14 %12 %19
768 %21 = OpLoad %9 %20
769 %22 = OpBitcast %6 %21
770 OpStore %18 %22
771 %25 = OpAccessChain %14 %12 %24
772 %26 = OpLoad %9 %25
773 %27 = OpBitcast %6 %26
774 OpStore %23 %27
775 %31 = OpLoad %28 %30
776 %32 = OpLoad %6 %8
777 %33 = OpLoad %6 %18
778 %35 = OpCompositeConstruct %34 %32 %33
779 %37 = OpLoad %6 %8
780 %39 = OpSMod %6 %37 %38
781 %40 = OpLoad %6 %18
782 %41 = OpCompositeConstruct %34 %39 %40
783 %42 = OpLoad %6 %8
784 %43 = OpLoad %6 %8
785 %44 = OpIMul %6 %42 %43
786 %45 = OpLoad %6 %18
787 %46 = OpLoad %6 %18
788 %47 = OpIMul %6 %45 %46
789 %48 = OpIAdd %6 %44 %47
790 %49 = OpLoad %6 %23
791 %50 = OpLoad %6 %23
792 %51 = OpIMul %6 %49 %50
793 %52 = OpIAdd %6 %48 %51
794 %54 = OpImageTexelPointer %53 %36 %41 %13
795 %55 = ${OPNAME} %6 %54 %19 %13 ${LASTARG:default=%52}
796 %57 = OpCompositeConstruct %56 %55 %55 %55 %55
797 OpImageWrite %31 %35 %57
798 OpReturn
799 OpFunctionEnd
800 )";
801
802 const std::string kShader_2d_r32ui_end_result = R"(
803 ; The SPIR-V shader below is based on the following GLSL shader, but OpAtomicIAdd has been
804 ; replaced with a template parameter and the last argument for it has been made optional.
805 ;
806 ; #version 440
807 ; precision highp uimage2D;
808 ;
809 ; layout (local_size_x = 1, local_size_y = 1, local_size_z = 1) in;
810 ; layout (r32ui, binding=0) coherent uniform uimage2D u_resultImage;
811 ;
812 ; void main (void)
813 ; {
814 ;     int gx = int(gl_GlobalInvocationID.x);
815 ;     int gy = int(gl_GlobalInvocationID.y);
816 ;     int gz = int(gl_GlobalInvocationID.z);
817 ;     imageAtomicAdd(u_resultImage, ivec2(gx % 64,gy), uint(gx*gx + gy*gy + gz*gz));
818 ; }
819 ;
820 ; SPIR-V
821 ; Version: 1.0
822 ; Generator: Khronos Glslang Reference Front End; 7
823 ; Bound: 53
824 ; Schema: 0
825 OpCapability Shader
826 %1 = OpExtInstImport "GLSL.std.450"
827 OpMemoryModel Logical GLSL450
828 OpEntryPoint GLCompute %4 "main" %12
829 OpExecutionMode %4 LocalSize 1 1 1
830 OpDecorate %12 BuiltIn GlobalInvocationId
831 OpDecorate %30 DescriptorSet 0
832 OpDecorate %30 Binding 0
833 OpDecorate %30 Coherent
834 OpDecorate %52 BuiltIn WorkgroupSize
835 %2 = OpTypeVoid
836 %3 = OpTypeFunction %2
837 %6 = OpTypeInt 32 1
838 %7 = OpTypePointer Function %6
839 %9 = OpTypeInt 32 0
840 %10 = OpTypeVector %9 3
841 %11 = OpTypePointer Input %10
842 %12 = OpVariable %11 Input
843 %13 = OpConstant %9 0
844 %14 = OpTypePointer Input %9
845 %19 = OpConstant %9 1
846 %24 = OpConstant %9 2
847 %28 = OpTypeImage %9 2D 0 0 0 2 R32ui
848 %29 = OpTypePointer UniformConstant %28
849 %30 = OpVariable %29 UniformConstant
850 %32 = OpConstant %6 64
851 %35 = OpTypeVector %6 2
852 %49 = OpTypePointer Image %9
853 %52 = OpConstantComposite %10 %19 %19 %19
854 %4 = OpFunction %2 None %3
855 %5 = OpLabel
856 %8 = OpVariable %7 Function
857 %18 = OpVariable %7 Function
858 %23 = OpVariable %7 Function
859 %15 = OpAccessChain %14 %12 %13
860 %16 = OpLoad %9 %15
861 %17 = OpBitcast %6 %16
862 OpStore %8 %17
863 %20 = OpAccessChain %14 %12 %19
864 %21 = OpLoad %9 %20
865 %22 = OpBitcast %6 %21
866 OpStore %18 %22
867 %25 = OpAccessChain %14 %12 %24
868 %26 = OpLoad %9 %25
869 %27 = OpBitcast %6 %26
870 OpStore %23 %27
871 %31 = OpLoad %6 %8
872 %33 = OpSMod %6 %31 %32
873 %34 = OpLoad %6 %18
874 %36 = OpCompositeConstruct %35 %33 %34
875 %37 = OpLoad %6 %8
876 %38 = OpLoad %6 %8
877 %39 = OpIMul %6 %37 %38
878 %40 = OpLoad %6 %18
879 %41 = OpLoad %6 %18
880 %42 = OpIMul %6 %40 %41
881 %43 = OpIAdd %6 %39 %42
882 %44 = OpLoad %6 %23
883 %45 = OpLoad %6 %23
884 %46 = OpIMul %6 %44 %45
885 %47 = OpIAdd %6 %43 %46
886 %48 = OpBitcast %9 %47
887 %50 = OpImageTexelPointer %49 %30 %36 %13
888 %51 = ${OPNAME} %9 %50 %19 %13 ${LASTARG:default=%48}
889 OpReturn
890 OpFunctionEnd
891 )";
892
893 const std::string kShader_2d_r32ui_intermediate_values = R"(
894 ; The SPIR-V shader below is based on the following GLSL shader, but OpAtomicIAdd has been
895 ; replaced with a template parameter and the last argument for it has been made optional.
896 ;
897 ; #version 440
898 ; precision highp uimage2D;
899 ;
900 ; layout (local_size_x = 1, local_size_y = 1, local_size_z = 1) in;
901 ; layout (r32ui, binding=0) coherent uniform uimage2D u_resultImage;
902 ; layout (r32ui, binding=1) writeonly uniform uimage2D u_intermValuesImage;
903 ;
904 ; void main (void)
905 ; {
906 ;     int gx = int(gl_GlobalInvocationID.x);
907 ;     int gy = int(gl_GlobalInvocationID.y);
908 ;     int gz = int(gl_GlobalInvocationID.z);
909 ;     imageStore(u_intermValuesImage, ivec2(gx,gy), uvec4(imageAtomicAdd(u_resultImage, ivec2(gx % 64,gy), uint(gx*gx + gy*gy + gz*gz))));
910 ; }
911 ;
912 ; SPIR-V
913 ; Version: 1.0
914 ; Generator: Khronos Glslang Reference Front End; 7
915 ; Bound: 60
916 ; Schema: 0
917 OpCapability Shader
918 %1 = OpExtInstImport "GLSL.std.450"
919 OpMemoryModel Logical GLSL450
920 OpEntryPoint GLCompute %4 "main" %12
921 OpExecutionMode %4 LocalSize 1 1 1
922 OpDecorate %12 BuiltIn GlobalInvocationId
923 OpDecorate %30 DescriptorSet 0
924 OpDecorate %30 Binding 1
925 OpDecorate %30 NonReadable
926 OpDecorate %36 DescriptorSet 0
927 OpDecorate %36 Binding 0
928 OpDecorate %36 Coherent
929 OpDecorate %59 BuiltIn WorkgroupSize
930 %2 = OpTypeVoid
931 %3 = OpTypeFunction %2
932 %6 = OpTypeInt 32 1
933 %7 = OpTypePointer Function %6
934 %9 = OpTypeInt 32 0
935 %10 = OpTypeVector %9 3
936 %11 = OpTypePointer Input %10
937 %12 = OpVariable %11 Input
938 %13 = OpConstant %9 0
939 %14 = OpTypePointer Input %9
940 %19 = OpConstant %9 1
941 %24 = OpConstant %9 2
942 %28 = OpTypeImage %9 2D 0 0 0 2 R32ui
943 %29 = OpTypePointer UniformConstant %28
944 %30 = OpVariable %29 UniformConstant
945 %34 = OpTypeVector %6 2
946 %36 = OpVariable %29 UniformConstant
947 %38 = OpConstant %6 64
948 %54 = OpTypePointer Image %9
949 %57 = OpTypeVector %9 4
950 %59 = OpConstantComposite %10 %19 %19 %19
951 %4 = OpFunction %2 None %3
952 %5 = OpLabel
953 %8 = OpVariable %7 Function
954 %18 = OpVariable %7 Function
955 %23 = OpVariable %7 Function
956 %15 = OpAccessChain %14 %12 %13
957 %16 = OpLoad %9 %15
958 %17 = OpBitcast %6 %16
959 OpStore %8 %17
960 %20 = OpAccessChain %14 %12 %19
961 %21 = OpLoad %9 %20
962 %22 = OpBitcast %6 %21
963 OpStore %18 %22
964 %25 = OpAccessChain %14 %12 %24
965 %26 = OpLoad %9 %25
966 %27 = OpBitcast %6 %26
967 OpStore %23 %27
968 %31 = OpLoad %28 %30
969 %32 = OpLoad %6 %8
970 %33 = OpLoad %6 %18
971 %35 = OpCompositeConstruct %34 %32 %33
972 %37 = OpLoad %6 %8
973 %39 = OpSMod %6 %37 %38
974 %40 = OpLoad %6 %18
975 %41 = OpCompositeConstruct %34 %39 %40
976 %42 = OpLoad %6 %8
977 %43 = OpLoad %6 %8
978 %44 = OpIMul %6 %42 %43
979 %45 = OpLoad %6 %18
980 %46 = OpLoad %6 %18
981 %47 = OpIMul %6 %45 %46
982 %48 = OpIAdd %6 %44 %47
983 %49 = OpLoad %6 %23
984 %50 = OpLoad %6 %23
985 %51 = OpIMul %6 %49 %50
986 %52 = OpIAdd %6 %48 %51
987 %53 = OpBitcast %9 %52
988 %55 = OpImageTexelPointer %54 %36 %41 %13
989 %56 = ${OPNAME} %9 %55 %19 %13 ${LASTARG:default=%53}
990 %58 = OpCompositeConstruct %57 %56 %56 %56 %56
991 OpImageWrite %31 %35 %58
992 OpReturn
993 OpFunctionEnd
994 )";
995
996 const std::string kShader_2d_r32i_end_result = R"(
997 ; The SPIR-V shader below is based on the following GLSL shader, but OpAtomicIAdd has been
998 ; replaced with a template parameter and the last argument for it has been made optional.
999 ;
1000 ; #version 440
1001 ; precision highp iimage2D;
1002 ;
1003 ; layout (local_size_x = 1, local_size_y = 1, local_size_z = 1) in;
1004 ; layout (r32i, binding=0) coherent uniform iimage2D u_resultImage;
1005 ;
1006 ; void main (void)
1007 ; {
1008 ;     int gx = int(gl_GlobalInvocationID.x);
1009 ;     int gy = int(gl_GlobalInvocationID.y);
1010 ;     int gz = int(gl_GlobalInvocationID.z);
1011 ;     imageAtomicAdd(u_resultImage, ivec2(gx % 64,gy), int(gx*gx + gy*gy + gz*gz));
1012 ; }
1013 ;
1014 ; SPIR-V
1015 ; Version: 1.0
1016 ; Generator: Khronos Glslang Reference Front End; 7
1017 ; Bound: 52
1018 ; Schema: 0
1019 OpCapability Shader
1020 %1 = OpExtInstImport "GLSL.std.450"
1021 OpMemoryModel Logical GLSL450
1022 OpEntryPoint GLCompute %4 "main" %12
1023 OpExecutionMode %4 LocalSize 1 1 1
1024 OpDecorate %12 BuiltIn GlobalInvocationId
1025 OpDecorate %30 DescriptorSet 0
1026 OpDecorate %30 Binding 0
1027 OpDecorate %30 Coherent
1028 OpDecorate %51 BuiltIn WorkgroupSize
1029 %2 = OpTypeVoid
1030 %3 = OpTypeFunction %2
1031 %6 = OpTypeInt 32 1
1032 %7 = OpTypePointer Function %6
1033 %9 = OpTypeInt 32 0
1034 %10 = OpTypeVector %9 3
1035 %11 = OpTypePointer Input %10
1036 %12 = OpVariable %11 Input
1037 %13 = OpConstant %9 0
1038 %14 = OpTypePointer Input %9
1039 %19 = OpConstant %9 1
1040 %24 = OpConstant %9 2
1041 %28 = OpTypeImage %6 2D 0 0 0 2 R32i
1042 %29 = OpTypePointer UniformConstant %28
1043 %30 = OpVariable %29 UniformConstant
1044 %32 = OpConstant %6 64
1045 %35 = OpTypeVector %6 2
1046 %48 = OpTypePointer Image %6
1047 %51 = OpConstantComposite %10 %19 %19 %19
1048 %4 = OpFunction %2 None %3
1049 %5 = OpLabel
1050 %8 = OpVariable %7 Function
1051 %18 = OpVariable %7 Function
1052 %23 = OpVariable %7 Function
1053 %15 = OpAccessChain %14 %12 %13
1054 %16 = OpLoad %9 %15
1055 %17 = OpBitcast %6 %16
1056 OpStore %8 %17
1057 %20 = OpAccessChain %14 %12 %19
1058 %21 = OpLoad %9 %20
1059 %22 = OpBitcast %6 %21
1060 OpStore %18 %22
1061 %25 = OpAccessChain %14 %12 %24
1062 %26 = OpLoad %9 %25
1063 %27 = OpBitcast %6 %26
1064 OpStore %23 %27
1065 %31 = OpLoad %6 %8
1066 %33 = OpSMod %6 %31 %32
1067 %34 = OpLoad %6 %18
1068 %36 = OpCompositeConstruct %35 %33 %34
1069 %37 = OpLoad %6 %8
1070 %38 = OpLoad %6 %8
1071 %39 = OpIMul %6 %37 %38
1072 %40 = OpLoad %6 %18
1073 %41 = OpLoad %6 %18
1074 %42 = OpIMul %6 %40 %41
1075 %43 = OpIAdd %6 %39 %42
1076 %44 = OpLoad %6 %23
1077 %45 = OpLoad %6 %23
1078 %46 = OpIMul %6 %44 %45
1079 %47 = OpIAdd %6 %43 %46
1080 %49 = OpImageTexelPointer %48 %30 %36 %13
1081 %50 = ${OPNAME} %6 %49 %19 %13 ${LASTARG:default=%47}
1082 OpReturn
1083 OpFunctionEnd
1084 )";
1085
1086 const std::string kShader_2d_r32i_intermediate_values = R"(
1087 ; The SPIR-V shader below is based on the following GLSL shader, but OpAtomicIAdd has been
1088 ; replaced with a template parameter and the last argument for it has been made optional.
1089 ;
1090 ; #version 440
1091 ; precision highp iimage2D;
1092 ;
1093 ; layout (local_size_x = 1, local_size_y = 1, local_size_z = 1) in;
1094 ; layout (r32i, binding=0) coherent uniform iimage2D u_resultImage;
1095 ; layout (r32i, binding=1) writeonly uniform iimage2D u_intermValuesImage;
1096 ;
1097 ; void main (void)
1098 ; {
1099 ;     int gx = int(gl_GlobalInvocationID.x);
1100 ;     int gy = int(gl_GlobalInvocationID.y);
1101 ;     int gz = int(gl_GlobalInvocationID.z);
1102 ;     imageStore(u_intermValuesImage, ivec2(gx,gy), ivec4(imageAtomicAdd(u_resultImage, ivec2(gx % 64,gy), int(gx*gx + gy*gy + gz*gz))));
1103 ; }
1104 ;
1105 ; SPIR-V
1106 ; Version: 1.0
1107 ; Generator: Khronos Glslang Reference Front End; 7
1108 ; Bound: 59
1109 ; Schema: 0
1110 OpCapability Shader
1111 %1 = OpExtInstImport "GLSL.std.450"
1112 OpMemoryModel Logical GLSL450
1113 OpEntryPoint GLCompute %4 "main" %12
1114 OpExecutionMode %4 LocalSize 1 1 1
1115 OpDecorate %12 BuiltIn GlobalInvocationId
1116 OpDecorate %30 DescriptorSet 0
1117 OpDecorate %30 Binding 1
1118 OpDecorate %30 NonReadable
1119 OpDecorate %36 DescriptorSet 0
1120 OpDecorate %36 Binding 0
1121 OpDecorate %36 Coherent
1122 OpDecorate %58 BuiltIn WorkgroupSize
1123 %2 = OpTypeVoid
1124 %3 = OpTypeFunction %2
1125 %6 = OpTypeInt 32 1
1126 %7 = OpTypePointer Function %6
1127 %9 = OpTypeInt 32 0
1128 %10 = OpTypeVector %9 3
1129 %11 = OpTypePointer Input %10
1130 %12 = OpVariable %11 Input
1131 %13 = OpConstant %9 0
1132 %14 = OpTypePointer Input %9
1133 %19 = OpConstant %9 1
1134 %24 = OpConstant %9 2
1135 %28 = OpTypeImage %6 2D 0 0 0 2 R32i
1136 %29 = OpTypePointer UniformConstant %28
1137 %30 = OpVariable %29 UniformConstant
1138 %34 = OpTypeVector %6 2
1139 %36 = OpVariable %29 UniformConstant
1140 %38 = OpConstant %6 64
1141 %53 = OpTypePointer Image %6
1142 %56 = OpTypeVector %6 4
1143 %58 = OpConstantComposite %10 %19 %19 %19
1144 %4 = OpFunction %2 None %3
1145 %5 = OpLabel
1146 %8 = OpVariable %7 Function
1147 %18 = OpVariable %7 Function
1148 %23 = OpVariable %7 Function
1149 %15 = OpAccessChain %14 %12 %13
1150 %16 = OpLoad %9 %15
1151 %17 = OpBitcast %6 %16
1152 OpStore %8 %17
1153 %20 = OpAccessChain %14 %12 %19
1154 %21 = OpLoad %9 %20
1155 %22 = OpBitcast %6 %21
1156 OpStore %18 %22
1157 %25 = OpAccessChain %14 %12 %24
1158 %26 = OpLoad %9 %25
1159 %27 = OpBitcast %6 %26
1160 OpStore %23 %27
1161 %31 = OpLoad %28 %30
1162 %32 = OpLoad %6 %8
1163 %33 = OpLoad %6 %18
1164 %35 = OpCompositeConstruct %34 %32 %33
1165 %37 = OpLoad %6 %8
1166 %39 = OpSMod %6 %37 %38
1167 %40 = OpLoad %6 %18
1168 %41 = OpCompositeConstruct %34 %39 %40
1169 %42 = OpLoad %6 %8
1170 %43 = OpLoad %6 %8
1171 %44 = OpIMul %6 %42 %43
1172 %45 = OpLoad %6 %18
1173 %46 = OpLoad %6 %18
1174 %47 = OpIMul %6 %45 %46
1175 %48 = OpIAdd %6 %44 %47
1176 %49 = OpLoad %6 %23
1177 %50 = OpLoad %6 %23
1178 %51 = OpIMul %6 %49 %50
1179 %52 = OpIAdd %6 %48 %51
1180 %54 = OpImageTexelPointer %53 %36 %41 %13
1181 %55 = ${OPNAME} %6 %54 %19 %13 ${LASTARG:default=%52}
1182 %57 = OpCompositeConstruct %56 %55 %55 %55 %55
1183 OpImageWrite %31 %35 %57
1184 OpReturn
1185 OpFunctionEnd
1186 )";
1187
1188 const std::string kShader_2d_array_r32ui_end_result = R"(
1189 ; The SPIR-V shader below is based on the following GLSL shader, but OpAtomicIAdd has been
1190 ; replaced with a template parameter and the last argument for it has been made optional.
1191 ;
1192 ; #version 440
1193 ; precision highp uimage2DArray;
1194 ;
1195 ; layout (local_size_x = 1, local_size_y = 1, local_size_z = 1) in;
1196 ; layout (r32ui, binding=0) coherent uniform uimage2DArray u_resultImage;
1197 ;
1198 ; void main (void)
1199 ; {
1200 ;     int gx = int(gl_GlobalInvocationID.x);
1201 ;     int gy = int(gl_GlobalInvocationID.y);
1202 ;     int gz = int(gl_GlobalInvocationID.z);
1203 ;     imageAtomicAdd(u_resultImage, ivec3(gx % 64,gy,gz), uint(gx*gx + gy*gy + gz*gz));
1204 ; }
1205 ;
1206 ; SPIR-V
1207 ; Version: 1.0
1208 ; Generator: Khronos Glslang Reference Front End; 7
1209 ; Bound: 54
1210 ; Schema: 0
1211 OpCapability Shader
1212 %1 = OpExtInstImport "GLSL.std.450"
1213 OpMemoryModel Logical GLSL450
1214 OpEntryPoint GLCompute %4 "main" %12
1215 OpExecutionMode %4 LocalSize 1 1 1
1216 OpDecorate %12 BuiltIn GlobalInvocationId
1217 OpDecorate %30 DescriptorSet 0
1218 OpDecorate %30 Binding 0
1219 OpDecorate %30 Coherent
1220 OpDecorate %53 BuiltIn WorkgroupSize
1221 %2 = OpTypeVoid
1222 %3 = OpTypeFunction %2
1223 %6 = OpTypeInt 32 1
1224 %7 = OpTypePointer Function %6
1225 %9 = OpTypeInt 32 0
1226 %10 = OpTypeVector %9 3
1227 %11 = OpTypePointer Input %10
1228 %12 = OpVariable %11 Input
1229 %13 = OpConstant %9 0
1230 %14 = OpTypePointer Input %9
1231 %19 = OpConstant %9 1
1232 %24 = OpConstant %9 2
1233 %28 = OpTypeImage %9 2D 0 1 0 2 R32ui
1234 %29 = OpTypePointer UniformConstant %28
1235 %30 = OpVariable %29 UniformConstant
1236 %32 = OpConstant %6 64
1237 %36 = OpTypeVector %6 3
1238 %50 = OpTypePointer Image %9
1239 %53 = OpConstantComposite %10 %19 %19 %19
1240 %4 = OpFunction %2 None %3
1241 %5 = OpLabel
1242 %8 = OpVariable %7 Function
1243 %18 = OpVariable %7 Function
1244 %23 = OpVariable %7 Function
1245 %15 = OpAccessChain %14 %12 %13
1246 %16 = OpLoad %9 %15
1247 %17 = OpBitcast %6 %16
1248 OpStore %8 %17
1249 %20 = OpAccessChain %14 %12 %19
1250 %21 = OpLoad %9 %20
1251 %22 = OpBitcast %6 %21
1252 OpStore %18 %22
1253 %25 = OpAccessChain %14 %12 %24
1254 %26 = OpLoad %9 %25
1255 %27 = OpBitcast %6 %26
1256 OpStore %23 %27
1257 %31 = OpLoad %6 %8
1258 %33 = OpSMod %6 %31 %32
1259 %34 = OpLoad %6 %18
1260 %35 = OpLoad %6 %23
1261 %37 = OpCompositeConstruct %36 %33 %34 %35
1262 %38 = OpLoad %6 %8
1263 %39 = OpLoad %6 %8
1264 %40 = OpIMul %6 %38 %39
1265 %41 = OpLoad %6 %18
1266 %42 = OpLoad %6 %18
1267 %43 = OpIMul %6 %41 %42
1268 %44 = OpIAdd %6 %40 %43
1269 %45 = OpLoad %6 %23
1270 %46 = OpLoad %6 %23
1271 %47 = OpIMul %6 %45 %46
1272 %48 = OpIAdd %6 %44 %47
1273 %49 = OpBitcast %9 %48
1274 %51 = OpImageTexelPointer %50 %30 %37 %13
1275 %52 = ${OPNAME} %9 %51 %19 %13 ${LASTARG:default=%49}
1276 OpReturn
1277 OpFunctionEnd
1278 )";
1279
1280 const std::string kShader_2d_array_r32ui_intermediate_values = R"(
1281 ; The SPIR-V shader below is based on the following GLSL shader, but OpAtomicIAdd has been
1282 ; replaced with a template parameter and the last argument for it has been made optional.
1283 ;
1284 ; #version 440
1285 ; precision highp uimage2DArray;
1286 ;
1287 ; layout (local_size_x = 1, local_size_y = 1, local_size_z = 1) in;
1288 ; layout (r32ui, binding=0) coherent uniform uimage2DArray u_resultImage;
1289 ; layout (r32ui, binding=1) writeonly uniform uimage2DArray u_intermValuesImage;
1290 ;
1291 ; void main (void)
1292 ; {
1293 ;     int gx = int(gl_GlobalInvocationID.x);
1294 ;     int gy = int(gl_GlobalInvocationID.y);
1295 ;     int gz = int(gl_GlobalInvocationID.z);
1296 ;     imageStore(u_intermValuesImage, ivec3(gx,gy,gz), uvec4(imageAtomicAdd(u_resultImage, ivec3(gx % 64,gy,gz), uint(gx*gx + gy*gy + gz*gz))));
1297 ; }
1298 ;
1299 ; SPIR-V
1300 ; Version: 1.0
1301 ; Generator: Khronos Glslang Reference Front End; 7
1302 ; Bound: 62
1303 ; Schema: 0
1304 OpCapability Shader
1305 %1 = OpExtInstImport "GLSL.std.450"
1306 OpMemoryModel Logical GLSL450
1307 OpEntryPoint GLCompute %4 "main" %12
1308 OpExecutionMode %4 LocalSize 1 1 1
1309 OpDecorate %12 BuiltIn GlobalInvocationId
1310 OpDecorate %30 DescriptorSet 0
1311 OpDecorate %30 Binding 1
1312 OpDecorate %30 NonReadable
1313 OpDecorate %37 DescriptorSet 0
1314 OpDecorate %37 Binding 0
1315 OpDecorate %37 Coherent
1316 OpDecorate %61 BuiltIn WorkgroupSize
1317 %2 = OpTypeVoid
1318 %3 = OpTypeFunction %2
1319 %6 = OpTypeInt 32 1
1320 %7 = OpTypePointer Function %6
1321 %9 = OpTypeInt 32 0
1322 %10 = OpTypeVector %9 3
1323 %11 = OpTypePointer Input %10
1324 %12 = OpVariable %11 Input
1325 %13 = OpConstant %9 0
1326 %14 = OpTypePointer Input %9
1327 %19 = OpConstant %9 1
1328 %24 = OpConstant %9 2
1329 %28 = OpTypeImage %9 2D 0 1 0 2 R32ui
1330 %29 = OpTypePointer UniformConstant %28
1331 %30 = OpVariable %29 UniformConstant
1332 %35 = OpTypeVector %6 3
1333 %37 = OpVariable %29 UniformConstant
1334 %39 = OpConstant %6 64
1335 %56 = OpTypePointer Image %9
1336 %59 = OpTypeVector %9 4
1337 %61 = OpConstantComposite %10 %19 %19 %19
1338 %4 = OpFunction %2 None %3
1339 %5 = OpLabel
1340 %8 = OpVariable %7 Function
1341 %18 = OpVariable %7 Function
1342 %23 = OpVariable %7 Function
1343 %15 = OpAccessChain %14 %12 %13
1344 %16 = OpLoad %9 %15
1345 %17 = OpBitcast %6 %16
1346 OpStore %8 %17
1347 %20 = OpAccessChain %14 %12 %19
1348 %21 = OpLoad %9 %20
1349 %22 = OpBitcast %6 %21
1350 OpStore %18 %22
1351 %25 = OpAccessChain %14 %12 %24
1352 %26 = OpLoad %9 %25
1353 %27 = OpBitcast %6 %26
1354 OpStore %23 %27
1355 %31 = OpLoad %28 %30
1356 %32 = OpLoad %6 %8
1357 %33 = OpLoad %6 %18
1358 %34 = OpLoad %6 %23
1359 %36 = OpCompositeConstruct %35 %32 %33 %34
1360 %38 = OpLoad %6 %8
1361 %40 = OpSMod %6 %38 %39
1362 %41 = OpLoad %6 %18
1363 %42 = OpLoad %6 %23
1364 %43 = OpCompositeConstruct %35 %40 %41 %42
1365 %44 = OpLoad %6 %8
1366 %45 = OpLoad %6 %8
1367 %46 = OpIMul %6 %44 %45
1368 %47 = OpLoad %6 %18
1369 %48 = OpLoad %6 %18
1370 %49 = OpIMul %6 %47 %48
1371 %50 = OpIAdd %6 %46 %49
1372 %51 = OpLoad %6 %23
1373 %52 = OpLoad %6 %23
1374 %53 = OpIMul %6 %51 %52
1375 %54 = OpIAdd %6 %50 %53
1376 %55 = OpBitcast %9 %54
1377 %57 = OpImageTexelPointer %56 %37 %43 %13
1378 %58 = ${OPNAME} %9 %57 %19 %13 ${LASTARG:default=%55}
1379 %60 = OpCompositeConstruct %59 %58 %58 %58 %58
1380 OpImageWrite %31 %36 %60
1381 OpReturn
1382 OpFunctionEnd
1383 )";
1384
1385 const std::string kShader_2d_array_r32i_end_result = R"(
1386 ; The SPIR-V shader below is based on the following GLSL shader, but OpAtomicIAdd has been
1387 ; replaced with a template parameter and the last argument for it has been made optional.
1388 ;
1389 ; #version 440
1390 ; precision highp iimage2DArray;
1391 ;
1392 ; layout (local_size_x = 1, local_size_y = 1, local_size_z = 1) in;
1393 ; layout (r32i, binding=0) coherent uniform iimage2DArray u_resultImage;
1394 ;
1395 ; void main (void)
1396 ; {
1397 ;     int gx = int(gl_GlobalInvocationID.x);
1398 ;     int gy = int(gl_GlobalInvocationID.y);
1399 ;     int gz = int(gl_GlobalInvocationID.z);
1400 ;     imageAtomicAdd(u_resultImage, ivec3(gx % 64,gy,gz), int(gx*gx + gy*gy + gz*gz));
1401 ; }
1402 ;
1403 ; SPIR-V
1404 ; Version: 1.0
1405 ; Generator: Khronos Glslang Reference Front End; 7
1406 ; Bound: 53
1407 ; Schema: 0
1408 OpCapability Shader
1409 %1 = OpExtInstImport "GLSL.std.450"
1410 OpMemoryModel Logical GLSL450
1411 OpEntryPoint GLCompute %4 "main" %12
1412 OpExecutionMode %4 LocalSize 1 1 1
1413 OpDecorate %12 BuiltIn GlobalInvocationId
1414 OpDecorate %30 DescriptorSet 0
1415 OpDecorate %30 Binding 0
1416 OpDecorate %30 Coherent
1417 OpDecorate %52 BuiltIn WorkgroupSize
1418 %2 = OpTypeVoid
1419 %3 = OpTypeFunction %2
1420 %6 = OpTypeInt 32 1
1421 %7 = OpTypePointer Function %6
1422 %9 = OpTypeInt 32 0
1423 %10 = OpTypeVector %9 3
1424 %11 = OpTypePointer Input %10
1425 %12 = OpVariable %11 Input
1426 %13 = OpConstant %9 0
1427 %14 = OpTypePointer Input %9
1428 %19 = OpConstant %9 1
1429 %24 = OpConstant %9 2
1430 %28 = OpTypeImage %6 2D 0 1 0 2 R32i
1431 %29 = OpTypePointer UniformConstant %28
1432 %30 = OpVariable %29 UniformConstant
1433 %32 = OpConstant %6 64
1434 %36 = OpTypeVector %6 3
1435 %49 = OpTypePointer Image %6
1436 %52 = OpConstantComposite %10 %19 %19 %19
1437 %4 = OpFunction %2 None %3
1438 %5 = OpLabel
1439 %8 = OpVariable %7 Function
1440 %18 = OpVariable %7 Function
1441 %23 = OpVariable %7 Function
1442 %15 = OpAccessChain %14 %12 %13
1443 %16 = OpLoad %9 %15
1444 %17 = OpBitcast %6 %16
1445 OpStore %8 %17
1446 %20 = OpAccessChain %14 %12 %19
1447 %21 = OpLoad %9 %20
1448 %22 = OpBitcast %6 %21
1449 OpStore %18 %22
1450 %25 = OpAccessChain %14 %12 %24
1451 %26 = OpLoad %9 %25
1452 %27 = OpBitcast %6 %26
1453 OpStore %23 %27
1454 %31 = OpLoad %6 %8
1455 %33 = OpSMod %6 %31 %32
1456 %34 = OpLoad %6 %18
1457 %35 = OpLoad %6 %23
1458 %37 = OpCompositeConstruct %36 %33 %34 %35
1459 %38 = OpLoad %6 %8
1460 %39 = OpLoad %6 %8
1461 %40 = OpIMul %6 %38 %39
1462 %41 = OpLoad %6 %18
1463 %42 = OpLoad %6 %18
1464 %43 = OpIMul %6 %41 %42
1465 %44 = OpIAdd %6 %40 %43
1466 %45 = OpLoad %6 %23
1467 %46 = OpLoad %6 %23
1468 %47 = OpIMul %6 %45 %46
1469 %48 = OpIAdd %6 %44 %47
1470 %50 = OpImageTexelPointer %49 %30 %37 %13
1471 %51 = ${OPNAME} %6 %50 %19 %13 ${LASTARG:default=%48}
1472 OpReturn
1473 OpFunctionEnd
1474 )";
1475
1476 const std::string kShader_2d_array_r32i_intermediate_values = R"(
1477 ; The SPIR-V shader below is based on the following GLSL shader, but OpAtomicIAdd has been
1478 ; replaced with a template parameter and the last argument for it has been made optional.
1479 ;
1480 ; #version 440
1481 ; precision highp iimage2DArray;
1482 ;
1483 ; layout (local_size_x = 1, local_size_y = 1, local_size_z = 1) in;
1484 ; layout (r32i, binding=0) coherent uniform iimage2DArray u_resultImage;
1485 ; layout (r32i, binding=1) writeonly uniform iimage2DArray u_intermValuesImage;
1486 ;
1487 ; void main (void)
1488 ; {
1489 ;     int gx = int(gl_GlobalInvocationID.x);
1490 ;     int gy = int(gl_GlobalInvocationID.y);
1491 ;     int gz = int(gl_GlobalInvocationID.z);
1492 ;     imageStore(u_intermValuesImage, ivec3(gx,gy,gz), ivec4(imageAtomicAdd(u_resultImage, ivec3(gx % 64,gy,gz), int(gx*gx + gy*gy + gz*gz))));
1493 ; }
1494 ;
1495 ; SPIR-V
1496 ; Version: 1.0
1497 ; Generator: Khronos Glslang Reference Front End; 7
1498 ; Bound: 61
1499 ; Schema: 0
1500 OpCapability Shader
1501 %1 = OpExtInstImport "GLSL.std.450"
1502 OpMemoryModel Logical GLSL450
1503 OpEntryPoint GLCompute %4 "main" %12
1504 OpExecutionMode %4 LocalSize 1 1 1
1505 OpDecorate %12 BuiltIn GlobalInvocationId
1506 OpDecorate %30 DescriptorSet 0
1507 OpDecorate %30 Binding 1
1508 OpDecorate %30 NonReadable
1509 OpDecorate %37 DescriptorSet 0
1510 OpDecorate %37 Binding 0
1511 OpDecorate %37 Coherent
1512 OpDecorate %60 BuiltIn WorkgroupSize
1513 %2 = OpTypeVoid
1514 %3 = OpTypeFunction %2
1515 %6 = OpTypeInt 32 1
1516 %7 = OpTypePointer Function %6
1517 %9 = OpTypeInt 32 0
1518 %10 = OpTypeVector %9 3
1519 %11 = OpTypePointer Input %10
1520 %12 = OpVariable %11 Input
1521 %13 = OpConstant %9 0
1522 %14 = OpTypePointer Input %9
1523 %19 = OpConstant %9 1
1524 %24 = OpConstant %9 2
1525 %28 = OpTypeImage %6 2D 0 1 0 2 R32i
1526 %29 = OpTypePointer UniformConstant %28
1527 %30 = OpVariable %29 UniformConstant
1528 %35 = OpTypeVector %6 3
1529 %37 = OpVariable %29 UniformConstant
1530 %39 = OpConstant %6 64
1531 %55 = OpTypePointer Image %6
1532 %58 = OpTypeVector %6 4
1533 %60 = OpConstantComposite %10 %19 %19 %19
1534 %4 = OpFunction %2 None %3
1535 %5 = OpLabel
1536 %8 = OpVariable %7 Function
1537 %18 = OpVariable %7 Function
1538 %23 = OpVariable %7 Function
1539 %15 = OpAccessChain %14 %12 %13
1540 %16 = OpLoad %9 %15
1541 %17 = OpBitcast %6 %16
1542 OpStore %8 %17
1543 %20 = OpAccessChain %14 %12 %19
1544 %21 = OpLoad %9 %20
1545 %22 = OpBitcast %6 %21
1546 OpStore %18 %22
1547 %25 = OpAccessChain %14 %12 %24
1548 %26 = OpLoad %9 %25
1549 %27 = OpBitcast %6 %26
1550 OpStore %23 %27
1551 %31 = OpLoad %28 %30
1552 %32 = OpLoad %6 %8
1553 %33 = OpLoad %6 %18
1554 %34 = OpLoad %6 %23
1555 %36 = OpCompositeConstruct %35 %32 %33 %34
1556 %38 = OpLoad %6 %8
1557 %40 = OpSMod %6 %38 %39
1558 %41 = OpLoad %6 %18
1559 %42 = OpLoad %6 %23
1560 %43 = OpCompositeConstruct %35 %40 %41 %42
1561 %44 = OpLoad %6 %8
1562 %45 = OpLoad %6 %8
1563 %46 = OpIMul %6 %44 %45
1564 %47 = OpLoad %6 %18
1565 %48 = OpLoad %6 %18
1566 %49 = OpIMul %6 %47 %48
1567 %50 = OpIAdd %6 %46 %49
1568 %51 = OpLoad %6 %23
1569 %52 = OpLoad %6 %23
1570 %53 = OpIMul %6 %51 %52
1571 %54 = OpIAdd %6 %50 %53
1572 %56 = OpImageTexelPointer %55 %37 %43 %13
1573 %57 = ${OPNAME} %6 %56 %19 %13 ${LASTARG:default=%54}
1574 %59 = OpCompositeConstruct %58 %57 %57 %57 %57
1575 OpImageWrite %31 %36 %59
1576 OpReturn
1577 OpFunctionEnd
1578 )";
1579
1580 const std::string kShader_3d_r32ui_end_result = R"(
1581 ; The SPIR-V shader below is based on the following GLSL shader, but OpAtomicIAdd has been
1582 ; replaced with a template parameter and the last argument for it has been made optional.
1583 ;
1584 ; #version 440
1585 ; precision highp uimage3D;
1586 ;
1587 ; layout (local_size_x = 1, local_size_y = 1, local_size_z = 1) in;
1588 ; layout (r32ui, binding=0) coherent uniform uimage3D u_resultImage;
1589 ;
1590 ; void main (void)
1591 ; {
1592 ;     int gx = int(gl_GlobalInvocationID.x);
1593 ;     int gy = int(gl_GlobalInvocationID.y);
1594 ;     int gz = int(gl_GlobalInvocationID.z);
1595 ;     imageAtomicAdd(u_resultImage, ivec3(gx % 48,gy,gz), uint(gx*gx + gy*gy + gz*gz));
1596 ; }
1597 ;
1598 ; SPIR-V
1599 ; Version: 1.0
1600 ; Generator: Khronos Glslang Reference Front End; 7
1601 ; Bound: 54
1602 ; Schema: 0
1603 OpCapability Shader
1604 %1 = OpExtInstImport "GLSL.std.450"
1605 OpMemoryModel Logical GLSL450
1606 OpEntryPoint GLCompute %4 "main" %12
1607 OpExecutionMode %4 LocalSize 1 1 1
1608 OpDecorate %12 BuiltIn GlobalInvocationId
1609 OpDecorate %30 DescriptorSet 0
1610 OpDecorate %30 Binding 0
1611 OpDecorate %30 Coherent
1612 OpDecorate %53 BuiltIn WorkgroupSize
1613 %2 = OpTypeVoid
1614 %3 = OpTypeFunction %2
1615 %6 = OpTypeInt 32 1
1616 %7 = OpTypePointer Function %6
1617 %9 = OpTypeInt 32 0
1618 %10 = OpTypeVector %9 3
1619 %11 = OpTypePointer Input %10
1620 %12 = OpVariable %11 Input
1621 %13 = OpConstant %9 0
1622 %14 = OpTypePointer Input %9
1623 %19 = OpConstant %9 1
1624 %24 = OpConstant %9 2
1625 %28 = OpTypeImage %9 3D 0 0 0 2 R32ui
1626 %29 = OpTypePointer UniformConstant %28
1627 %30 = OpVariable %29 UniformConstant
1628 %32 = OpConstant %6 48
1629 %36 = OpTypeVector %6 3
1630 %50 = OpTypePointer Image %9
1631 %53 = OpConstantComposite %10 %19 %19 %19
1632 %4 = OpFunction %2 None %3
1633 %5 = OpLabel
1634 %8 = OpVariable %7 Function
1635 %18 = OpVariable %7 Function
1636 %23 = OpVariable %7 Function
1637 %15 = OpAccessChain %14 %12 %13
1638 %16 = OpLoad %9 %15
1639 %17 = OpBitcast %6 %16
1640 OpStore %8 %17
1641 %20 = OpAccessChain %14 %12 %19
1642 %21 = OpLoad %9 %20
1643 %22 = OpBitcast %6 %21
1644 OpStore %18 %22
1645 %25 = OpAccessChain %14 %12 %24
1646 %26 = OpLoad %9 %25
1647 %27 = OpBitcast %6 %26
1648 OpStore %23 %27
1649 %31 = OpLoad %6 %8
1650 %33 = OpSMod %6 %31 %32
1651 %34 = OpLoad %6 %18
1652 %35 = OpLoad %6 %23
1653 %37 = OpCompositeConstruct %36 %33 %34 %35
1654 %38 = OpLoad %6 %8
1655 %39 = OpLoad %6 %8
1656 %40 = OpIMul %6 %38 %39
1657 %41 = OpLoad %6 %18
1658 %42 = OpLoad %6 %18
1659 %43 = OpIMul %6 %41 %42
1660 %44 = OpIAdd %6 %40 %43
1661 %45 = OpLoad %6 %23
1662 %46 = OpLoad %6 %23
1663 %47 = OpIMul %6 %45 %46
1664 %48 = OpIAdd %6 %44 %47
1665 %49 = OpBitcast %9 %48
1666 %51 = OpImageTexelPointer %50 %30 %37 %13
1667 %52 = ${OPNAME} %9 %51 %19 %13 ${LASTARG:default=%49}
1668 OpReturn
1669 OpFunctionEnd
1670 )";
1671
1672 const std::string kShader_3d_r32ui_intermediate_values = R"(
1673 ; The SPIR-V shader below is based on the following GLSL shader, but OpAtomicIAdd has been
1674 ; replaced with a template parameter and the last argument for it has been made optional.
1675 ;
1676 ; #version 440
1677 ; precision highp uimage3D;
1678 ;
1679 ; layout (local_size_x = 1, local_size_y = 1, local_size_z = 1) in;
1680 ; layout (r32ui, binding=0) coherent uniform uimage3D u_resultImage;
1681 ; layout (r32ui, binding=1) writeonly uniform uimage3D u_intermValuesImage;
1682 ;
1683 ; void main (void)
1684 ; {
1685 ;     int gx = int(gl_GlobalInvocationID.x);
1686 ;     int gy = int(gl_GlobalInvocationID.y);
1687 ;     int gz = int(gl_GlobalInvocationID.z);
1688 ;     imageStore(u_intermValuesImage, ivec3(gx,gy,gz), uvec4(imageAtomicAdd(u_resultImage, ivec3(gx % 48,gy,gz), uint(gx*gx + gy*gy + gz*gz))));
1689 ; }
1690 ;
1691 ; SPIR-V
1692 ; Version: 1.0
1693 ; Generator: Khronos Glslang Reference Front End; 7
1694 ; Bound: 62
1695 ; Schema: 0
1696 OpCapability Shader
1697 %1 = OpExtInstImport "GLSL.std.450"
1698 OpMemoryModel Logical GLSL450
1699 OpEntryPoint GLCompute %4 "main" %12
1700 OpExecutionMode %4 LocalSize 1 1 1
1701 OpDecorate %12 BuiltIn GlobalInvocationId
1702 OpDecorate %30 DescriptorSet 0
1703 OpDecorate %30 Binding 1
1704 OpDecorate %30 NonReadable
1705 OpDecorate %37 DescriptorSet 0
1706 OpDecorate %37 Binding 0
1707 OpDecorate %37 Coherent
1708 OpDecorate %61 BuiltIn WorkgroupSize
1709 %2 = OpTypeVoid
1710 %3 = OpTypeFunction %2
1711 %6 = OpTypeInt 32 1
1712 %7 = OpTypePointer Function %6
1713 %9 = OpTypeInt 32 0
1714 %10 = OpTypeVector %9 3
1715 %11 = OpTypePointer Input %10
1716 %12 = OpVariable %11 Input
1717 %13 = OpConstant %9 0
1718 %14 = OpTypePointer Input %9
1719 %19 = OpConstant %9 1
1720 %24 = OpConstant %9 2
1721 %28 = OpTypeImage %9 3D 0 0 0 2 R32ui
1722 %29 = OpTypePointer UniformConstant %28
1723 %30 = OpVariable %29 UniformConstant
1724 %35 = OpTypeVector %6 3
1725 %37 = OpVariable %29 UniformConstant
1726 %39 = OpConstant %6 48
1727 %56 = OpTypePointer Image %9
1728 %59 = OpTypeVector %9 4
1729 %61 = OpConstantComposite %10 %19 %19 %19
1730 %4 = OpFunction %2 None %3
1731 %5 = OpLabel
1732 %8 = OpVariable %7 Function
1733 %18 = OpVariable %7 Function
1734 %23 = OpVariable %7 Function
1735 %15 = OpAccessChain %14 %12 %13
1736 %16 = OpLoad %9 %15
1737 %17 = OpBitcast %6 %16
1738 OpStore %8 %17
1739 %20 = OpAccessChain %14 %12 %19
1740 %21 = OpLoad %9 %20
1741 %22 = OpBitcast %6 %21
1742 OpStore %18 %22
1743 %25 = OpAccessChain %14 %12 %24
1744 %26 = OpLoad %9 %25
1745 %27 = OpBitcast %6 %26
1746 OpStore %23 %27
1747 %31 = OpLoad %28 %30
1748 %32 = OpLoad %6 %8
1749 %33 = OpLoad %6 %18
1750 %34 = OpLoad %6 %23
1751 %36 = OpCompositeConstruct %35 %32 %33 %34
1752 %38 = OpLoad %6 %8
1753 %40 = OpSMod %6 %38 %39
1754 %41 = OpLoad %6 %18
1755 %42 = OpLoad %6 %23
1756 %43 = OpCompositeConstruct %35 %40 %41 %42
1757 %44 = OpLoad %6 %8
1758 %45 = OpLoad %6 %8
1759 %46 = OpIMul %6 %44 %45
1760 %47 = OpLoad %6 %18
1761 %48 = OpLoad %6 %18
1762 %49 = OpIMul %6 %47 %48
1763 %50 = OpIAdd %6 %46 %49
1764 %51 = OpLoad %6 %23
1765 %52 = OpLoad %6 %23
1766 %53 = OpIMul %6 %51 %52
1767 %54 = OpIAdd %6 %50 %53
1768 %55 = OpBitcast %9 %54
1769 %57 = OpImageTexelPointer %56 %37 %43 %13
1770 %58 = ${OPNAME} %9 %57 %19 %13 ${LASTARG:default=%55}
1771 %60 = OpCompositeConstruct %59 %58 %58 %58 %58
1772 OpImageWrite %31 %36 %60
1773 OpReturn
1774 OpFunctionEnd
1775 )";
1776
1777 const std::string kShader_3d_r32i_end_result = R"(
1778 ; The SPIR-V shader below is based on the following GLSL shader, but OpAtomicIAdd has been
1779 ; replaced with a template parameter and the last argument for it has been made optional.
1780 ;
1781 ; #version 440
1782 ; precision highp iimage3D;
1783 ;
1784 ; layout (local_size_x = 1, local_size_y = 1, local_size_z = 1) in;
1785 ; layout (r32i, binding=0) coherent uniform iimage3D u_resultImage;
1786 ;
1787 ; void main (void)
1788 ; {
1789 ;     int gx = int(gl_GlobalInvocationID.x);
1790 ;     int gy = int(gl_GlobalInvocationID.y);
1791 ;     int gz = int(gl_GlobalInvocationID.z);
1792 ;     imageAtomicAdd(u_resultImage, ivec3(gx % 48,gy,gz), int(gx*gx + gy*gy + gz*gz));
1793 ; }
1794 ;
1795 ; SPIR-V
1796 ; Version: 1.0
1797 ; Generator: Khronos Glslang Reference Front End; 7
1798 ; Bound: 53
1799 ; Schema: 0
1800 OpCapability Shader
1801 %1 = OpExtInstImport "GLSL.std.450"
1802 OpMemoryModel Logical GLSL450
1803 OpEntryPoint GLCompute %4 "main" %12
1804 OpExecutionMode %4 LocalSize 1 1 1
1805 OpDecorate %12 BuiltIn GlobalInvocationId
1806 OpDecorate %30 DescriptorSet 0
1807 OpDecorate %30 Binding 0
1808 OpDecorate %30 Coherent
1809 OpDecorate %52 BuiltIn WorkgroupSize
1810 %2 = OpTypeVoid
1811 %3 = OpTypeFunction %2
1812 %6 = OpTypeInt 32 1
1813 %7 = OpTypePointer Function %6
1814 %9 = OpTypeInt 32 0
1815 %10 = OpTypeVector %9 3
1816 %11 = OpTypePointer Input %10
1817 %12 = OpVariable %11 Input
1818 %13 = OpConstant %9 0
1819 %14 = OpTypePointer Input %9
1820 %19 = OpConstant %9 1
1821 %24 = OpConstant %9 2
1822 %28 = OpTypeImage %6 3D 0 0 0 2 R32i
1823 %29 = OpTypePointer UniformConstant %28
1824 %30 = OpVariable %29 UniformConstant
1825 %32 = OpConstant %6 48
1826 %36 = OpTypeVector %6 3
1827 %49 = OpTypePointer Image %6
1828 %52 = OpConstantComposite %10 %19 %19 %19
1829 %4 = OpFunction %2 None %3
1830 %5 = OpLabel
1831 %8 = OpVariable %7 Function
1832 %18 = OpVariable %7 Function
1833 %23 = OpVariable %7 Function
1834 %15 = OpAccessChain %14 %12 %13
1835 %16 = OpLoad %9 %15
1836 %17 = OpBitcast %6 %16
1837 OpStore %8 %17
1838 %20 = OpAccessChain %14 %12 %19
1839 %21 = OpLoad %9 %20
1840 %22 = OpBitcast %6 %21
1841 OpStore %18 %22
1842 %25 = OpAccessChain %14 %12 %24
1843 %26 = OpLoad %9 %25
1844 %27 = OpBitcast %6 %26
1845 OpStore %23 %27
1846 %31 = OpLoad %6 %8
1847 %33 = OpSMod %6 %31 %32
1848 %34 = OpLoad %6 %18
1849 %35 = OpLoad %6 %23
1850 %37 = OpCompositeConstruct %36 %33 %34 %35
1851 %38 = OpLoad %6 %8
1852 %39 = OpLoad %6 %8
1853 %40 = OpIMul %6 %38 %39
1854 %41 = OpLoad %6 %18
1855 %42 = OpLoad %6 %18
1856 %43 = OpIMul %6 %41 %42
1857 %44 = OpIAdd %6 %40 %43
1858 %45 = OpLoad %6 %23
1859 %46 = OpLoad %6 %23
1860 %47 = OpIMul %6 %45 %46
1861 %48 = OpIAdd %6 %44 %47
1862 %50 = OpImageTexelPointer %49 %30 %37 %13
1863 %51 = ${OPNAME} %6 %50 %19 %13 ${LASTARG:default=%48}
1864 OpReturn
1865 OpFunctionEnd
1866 )";
1867
1868 const std::string kShader_3d_r32i_intermediate_values = R"(
1869 ; The SPIR-V shader below is based on the following GLSL shader, but OpAtomicIAdd has been
1870 ; replaced with a template parameter and the last argument for it has been made optional.
1871 ;
1872 ; #version 440
1873 ; precision highp iimage3D;
1874 ;
1875 ; layout (local_size_x = 1, local_size_y = 1, local_size_z = 1) in;
1876 ; layout (r32i, binding=0) coherent uniform iimage3D u_resultImage;
1877 ; layout (r32i, binding=1) writeonly uniform iimage3D u_intermValuesImage;
1878 ;
1879 ; void main (void)
1880 ; {
1881 ;     int gx = int(gl_GlobalInvocationID.x);
1882 ;     int gy = int(gl_GlobalInvocationID.y);
1883 ;     int gz = int(gl_GlobalInvocationID.z);
1884 ;     imageStore(u_intermValuesImage, ivec3(gx,gy,gz), ivec4(imageAtomicAdd(u_resultImage, ivec3(gx % 48,gy,gz), int(gx*gx + gy*gy + gz*gz))));
1885 ; }
1886 ;
1887 ; SPIR-V
1888 ; Version: 1.0
1889 ; Generator: Khronos Glslang Reference Front End; 7
1890 ; Bound: 61
1891 ; Schema: 0
1892 OpCapability Shader
1893 %1 = OpExtInstImport "GLSL.std.450"
1894 OpMemoryModel Logical GLSL450
1895 OpEntryPoint GLCompute %4 "main" %12
1896 OpExecutionMode %4 LocalSize 1 1 1
1897 OpDecorate %12 BuiltIn GlobalInvocationId
1898 OpDecorate %30 DescriptorSet 0
1899 OpDecorate %30 Binding 1
1900 OpDecorate %30 NonReadable
1901 OpDecorate %37 DescriptorSet 0
1902 OpDecorate %37 Binding 0
1903 OpDecorate %37 Coherent
1904 OpDecorate %60 BuiltIn WorkgroupSize
1905 %2 = OpTypeVoid
1906 %3 = OpTypeFunction %2
1907 %6 = OpTypeInt 32 1
1908 %7 = OpTypePointer Function %6
1909 %9 = OpTypeInt 32 0
1910 %10 = OpTypeVector %9 3
1911 %11 = OpTypePointer Input %10
1912 %12 = OpVariable %11 Input
1913 %13 = OpConstant %9 0
1914 %14 = OpTypePointer Input %9
1915 %19 = OpConstant %9 1
1916 %24 = OpConstant %9 2
1917 %28 = OpTypeImage %6 3D 0 0 0 2 R32i
1918 %29 = OpTypePointer UniformConstant %28
1919 %30 = OpVariable %29 UniformConstant
1920 %35 = OpTypeVector %6 3
1921 %37 = OpVariable %29 UniformConstant
1922 %39 = OpConstant %6 48
1923 %55 = OpTypePointer Image %6
1924 %58 = OpTypeVector %6 4
1925 %60 = OpConstantComposite %10 %19 %19 %19
1926 %4 = OpFunction %2 None %3
1927 %5 = OpLabel
1928 %8 = OpVariable %7 Function
1929 %18 = OpVariable %7 Function
1930 %23 = OpVariable %7 Function
1931 %15 = OpAccessChain %14 %12 %13
1932 %16 = OpLoad %9 %15
1933 %17 = OpBitcast %6 %16
1934 OpStore %8 %17
1935 %20 = OpAccessChain %14 %12 %19
1936 %21 = OpLoad %9 %20
1937 %22 = OpBitcast %6 %21
1938 OpStore %18 %22
1939 %25 = OpAccessChain %14 %12 %24
1940 %26 = OpLoad %9 %25
1941 %27 = OpBitcast %6 %26
1942 OpStore %23 %27
1943 %31 = OpLoad %28 %30
1944 %32 = OpLoad %6 %8
1945 %33 = OpLoad %6 %18
1946 %34 = OpLoad %6 %23
1947 %36 = OpCompositeConstruct %35 %32 %33 %34
1948 %38 = OpLoad %6 %8
1949 %40 = OpSMod %6 %38 %39
1950 %41 = OpLoad %6 %18
1951 %42 = OpLoad %6 %23
1952 %43 = OpCompositeConstruct %35 %40 %41 %42
1953 %44 = OpLoad %6 %8
1954 %45 = OpLoad %6 %8
1955 %46 = OpIMul %6 %44 %45
1956 %47 = OpLoad %6 %18
1957 %48 = OpLoad %6 %18
1958 %49 = OpIMul %6 %47 %48
1959 %50 = OpIAdd %6 %46 %49
1960 %51 = OpLoad %6 %23
1961 %52 = OpLoad %6 %23
1962 %53 = OpIMul %6 %51 %52
1963 %54 = OpIAdd %6 %50 %53
1964 %56 = OpImageTexelPointer %55 %37 %43 %13
1965 %57 = ${OPNAME} %6 %56 %19 %13 ${LASTARG:default=%54}
1966 %59 = OpCompositeConstruct %58 %57 %57 %57 %57
1967 OpImageWrite %31 %36 %59
1968 OpReturn
1969 OpFunctionEnd
1970 )";
1971
1972 const std::string kShader_cube_r32ui_end_result = R"(
1973 ; The SPIR-V shader below is based on the following GLSL shader, but OpAtomicIAdd has been
1974 ; replaced with a template parameter and the last argument for it has been made optional.
1975 ;
1976 ; #version 440
1977 ; precision highp uimageCube;
1978 ;
1979 ; layout (local_size_x = 1, local_size_y = 1, local_size_z = 1) in;
1980 ; layout (r32ui, binding=0) coherent uniform uimageCube u_resultImage;
1981 ;
1982 ; void main (void)
1983 ; {
1984 ;     int gx = int(gl_GlobalInvocationID.x);
1985 ;     int gy = int(gl_GlobalInvocationID.y);
1986 ;     int gz = int(gl_GlobalInvocationID.z);
1987 ;     imageAtomicAdd(u_resultImage, ivec3(gx % 64,gy,gz), uint(gx*gx + gy*gy + gz*gz));
1988 ; }
1989 ;
1990 ; SPIR-V
1991 ; Version: 1.0
1992 ; Generator: Khronos Glslang Reference Front End; 7
1993 ; Bound: 54
1994 ; Schema: 0
1995 OpCapability Shader
1996 %1 = OpExtInstImport "GLSL.std.450"
1997 OpMemoryModel Logical GLSL450
1998 OpEntryPoint GLCompute %4 "main" %12
1999 OpExecutionMode %4 LocalSize 1 1 1
2000 OpDecorate %12 BuiltIn GlobalInvocationId
2001 OpDecorate %30 DescriptorSet 0
2002 OpDecorate %30 Binding 0
2003 OpDecorate %30 Coherent
2004 OpDecorate %53 BuiltIn WorkgroupSize
2005 %2 = OpTypeVoid
2006 %3 = OpTypeFunction %2
2007 %6 = OpTypeInt 32 1
2008 %7 = OpTypePointer Function %6
2009 %9 = OpTypeInt 32 0
2010 %10 = OpTypeVector %9 3
2011 %11 = OpTypePointer Input %10
2012 %12 = OpVariable %11 Input
2013 %13 = OpConstant %9 0
2014 %14 = OpTypePointer Input %9
2015 %19 = OpConstant %9 1
2016 %24 = OpConstant %9 2
2017 %28 = OpTypeImage %9 Cube 0 0 0 2 R32ui
2018 %29 = OpTypePointer UniformConstant %28
2019 %30 = OpVariable %29 UniformConstant
2020 %32 = OpConstant %6 64
2021 %36 = OpTypeVector %6 3
2022 %50 = OpTypePointer Image %9
2023 %53 = OpConstantComposite %10 %19 %19 %19
2024 %4 = OpFunction %2 None %3
2025 %5 = OpLabel
2026 %8 = OpVariable %7 Function
2027 %18 = OpVariable %7 Function
2028 %23 = OpVariable %7 Function
2029 %15 = OpAccessChain %14 %12 %13
2030 %16 = OpLoad %9 %15
2031 %17 = OpBitcast %6 %16
2032 OpStore %8 %17
2033 %20 = OpAccessChain %14 %12 %19
2034 %21 = OpLoad %9 %20
2035 %22 = OpBitcast %6 %21
2036 OpStore %18 %22
2037 %25 = OpAccessChain %14 %12 %24
2038 %26 = OpLoad %9 %25
2039 %27 = OpBitcast %6 %26
2040 OpStore %23 %27
2041 %31 = OpLoad %6 %8
2042 %33 = OpSMod %6 %31 %32
2043 %34 = OpLoad %6 %18
2044 %35 = OpLoad %6 %23
2045 %37 = OpCompositeConstruct %36 %33 %34 %35
2046 %38 = OpLoad %6 %8
2047 %39 = OpLoad %6 %8
2048 %40 = OpIMul %6 %38 %39
2049 %41 = OpLoad %6 %18
2050 %42 = OpLoad %6 %18
2051 %43 = OpIMul %6 %41 %42
2052 %44 = OpIAdd %6 %40 %43
2053 %45 = OpLoad %6 %23
2054 %46 = OpLoad %6 %23
2055 %47 = OpIMul %6 %45 %46
2056 %48 = OpIAdd %6 %44 %47
2057 %49 = OpBitcast %9 %48
2058 %51 = OpImageTexelPointer %50 %30 %37 %13
2059 %52 = ${OPNAME} %9 %51 %19 %13 ${LASTARG:default=%49}
2060 OpReturn
2061 OpFunctionEnd
2062 )";
2063
2064 const std::string kShader_cube_r32ui_intermediate_values = R"(
2065 ; The SPIR-V shader below is based on the following GLSL shader, but OpAtomicIAdd has been
2066 ; replaced with a template parameter and the last argument for it has been made optional.
2067 ;
2068 ; #version 440
2069 ; precision highp uimageCube;
2070 ;
2071 ; layout (local_size_x = 1, local_size_y = 1, local_size_z = 1) in;
2072 ; layout (r32ui, binding=0) coherent uniform uimageCube u_resultImage;
2073 ; layout (r32ui, binding=1) writeonly uniform uimageCube u_intermValuesImage;
2074 ;
2075 ; void main (void)
2076 ; {
2077 ;     int gx = int(gl_GlobalInvocationID.x);
2078 ;     int gy = int(gl_GlobalInvocationID.y);
2079 ;     int gz = int(gl_GlobalInvocationID.z);
2080 ;     imageStore(u_intermValuesImage, ivec3(gx,gy,gz), uvec4(imageAtomicAdd(u_resultImage, ivec3(gx % 64,gy,gz), uint(gx*gx + gy*gy + gz*gz))));
2081 ; }
2082 ;
2083 ; SPIR-V
2084 ; Version: 1.0
2085 ; Generator: Khronos Glslang Reference Front End; 7
2086 ; Bound: 62
2087 ; Schema: 0
2088 OpCapability Shader
2089 %1 = OpExtInstImport "GLSL.std.450"
2090 OpMemoryModel Logical GLSL450
2091 OpEntryPoint GLCompute %4 "main" %12
2092 OpExecutionMode %4 LocalSize 1 1 1
2093 OpDecorate %12 BuiltIn GlobalInvocationId
2094 OpDecorate %30 DescriptorSet 0
2095 OpDecorate %30 Binding 1
2096 OpDecorate %30 NonReadable
2097 OpDecorate %37 DescriptorSet 0
2098 OpDecorate %37 Binding 0
2099 OpDecorate %37 Coherent
2100 OpDecorate %61 BuiltIn WorkgroupSize
2101 %2 = OpTypeVoid
2102 %3 = OpTypeFunction %2
2103 %6 = OpTypeInt 32 1
2104 %7 = OpTypePointer Function %6
2105 %9 = OpTypeInt 32 0
2106 %10 = OpTypeVector %9 3
2107 %11 = OpTypePointer Input %10
2108 %12 = OpVariable %11 Input
2109 %13 = OpConstant %9 0
2110 %14 = OpTypePointer Input %9
2111 %19 = OpConstant %9 1
2112 %24 = OpConstant %9 2
2113 %28 = OpTypeImage %9 Cube 0 0 0 2 R32ui
2114 %29 = OpTypePointer UniformConstant %28
2115 %30 = OpVariable %29 UniformConstant
2116 %35 = OpTypeVector %6 3
2117 %37 = OpVariable %29 UniformConstant
2118 %39 = OpConstant %6 64
2119 %56 = OpTypePointer Image %9
2120 %59 = OpTypeVector %9 4
2121 %61 = OpConstantComposite %10 %19 %19 %19
2122 %4 = OpFunction %2 None %3
2123 %5 = OpLabel
2124 %8 = OpVariable %7 Function
2125 %18 = OpVariable %7 Function
2126 %23 = OpVariable %7 Function
2127 %15 = OpAccessChain %14 %12 %13
2128 %16 = OpLoad %9 %15
2129 %17 = OpBitcast %6 %16
2130 OpStore %8 %17
2131 %20 = OpAccessChain %14 %12 %19
2132 %21 = OpLoad %9 %20
2133 %22 = OpBitcast %6 %21
2134 OpStore %18 %22
2135 %25 = OpAccessChain %14 %12 %24
2136 %26 = OpLoad %9 %25
2137 %27 = OpBitcast %6 %26
2138 OpStore %23 %27
2139 %31 = OpLoad %28 %30
2140 %32 = OpLoad %6 %8
2141 %33 = OpLoad %6 %18
2142 %34 = OpLoad %6 %23
2143 %36 = OpCompositeConstruct %35 %32 %33 %34
2144 %38 = OpLoad %6 %8
2145 %40 = OpSMod %6 %38 %39
2146 %41 = OpLoad %6 %18
2147 %42 = OpLoad %6 %23
2148 %43 = OpCompositeConstruct %35 %40 %41 %42
2149 %44 = OpLoad %6 %8
2150 %45 = OpLoad %6 %8
2151 %46 = OpIMul %6 %44 %45
2152 %47 = OpLoad %6 %18
2153 %48 = OpLoad %6 %18
2154 %49 = OpIMul %6 %47 %48
2155 %50 = OpIAdd %6 %46 %49
2156 %51 = OpLoad %6 %23
2157 %52 = OpLoad %6 %23
2158 %53 = OpIMul %6 %51 %52
2159 %54 = OpIAdd %6 %50 %53
2160 %55 = OpBitcast %9 %54
2161 %57 = OpImageTexelPointer %56 %37 %43 %13
2162 %58 = ${OPNAME} %9 %57 %19 %13 ${LASTARG:default=%55}
2163 %60 = OpCompositeConstruct %59 %58 %58 %58 %58
2164 OpImageWrite %31 %36 %60
2165 OpReturn
2166 OpFunctionEnd
2167 )";
2168
2169 const std::string kShader_cube_r32i_end_result = R"(
2170 ; The SPIR-V shader below is based on the following GLSL shader, but OpAtomicIAdd has been
2171 ; replaced with a template parameter and the last argument for it has been made optional.
2172 ;
2173 ; #version 440
2174 ; precision highp iimageCube;
2175 ;
2176 ; layout (local_size_x = 1, local_size_y = 1, local_size_z = 1) in;
2177 ; layout (r32i, binding=0) coherent uniform iimageCube u_resultImage;
2178 ;
2179 ; void main (void)
2180 ; {
2181 ;     int gx = int(gl_GlobalInvocationID.x);
2182 ;     int gy = int(gl_GlobalInvocationID.y);
2183 ;     int gz = int(gl_GlobalInvocationID.z);
2184 ;     imageAtomicAdd(u_resultImage, ivec3(gx % 64,gy,gz), int(gx*gx + gy*gy + gz*gz));
2185 ; }
2186 ;
2187 ; SPIR-V
2188 ; Version: 1.0
2189 ; Generator: Khronos Glslang Reference Front End; 7
2190 ; Bound: 53
2191 ; Schema: 0
2192 OpCapability Shader
2193 %1 = OpExtInstImport "GLSL.std.450"
2194 OpMemoryModel Logical GLSL450
2195 OpEntryPoint GLCompute %4 "main" %12
2196 OpExecutionMode %4 LocalSize 1 1 1
2197 OpDecorate %12 BuiltIn GlobalInvocationId
2198 OpDecorate %30 DescriptorSet 0
2199 OpDecorate %30 Binding 0
2200 OpDecorate %30 Coherent
2201 OpDecorate %52 BuiltIn WorkgroupSize
2202 %2 = OpTypeVoid
2203 %3 = OpTypeFunction %2
2204 %6 = OpTypeInt 32 1
2205 %7 = OpTypePointer Function %6
2206 %9 = OpTypeInt 32 0
2207 %10 = OpTypeVector %9 3
2208 %11 = OpTypePointer Input %10
2209 %12 = OpVariable %11 Input
2210 %13 = OpConstant %9 0
2211 %14 = OpTypePointer Input %9
2212 %19 = OpConstant %9 1
2213 %24 = OpConstant %9 2
2214 %28 = OpTypeImage %6 Cube 0 0 0 2 R32i
2215 %29 = OpTypePointer UniformConstant %28
2216 %30 = OpVariable %29 UniformConstant
2217 %32 = OpConstant %6 64
2218 %36 = OpTypeVector %6 3
2219 %49 = OpTypePointer Image %6
2220 %52 = OpConstantComposite %10 %19 %19 %19
2221 %4 = OpFunction %2 None %3
2222 %5 = OpLabel
2223 %8 = OpVariable %7 Function
2224 %18 = OpVariable %7 Function
2225 %23 = OpVariable %7 Function
2226 %15 = OpAccessChain %14 %12 %13
2227 %16 = OpLoad %9 %15
2228 %17 = OpBitcast %6 %16
2229 OpStore %8 %17
2230 %20 = OpAccessChain %14 %12 %19
2231 %21 = OpLoad %9 %20
2232 %22 = OpBitcast %6 %21
2233 OpStore %18 %22
2234 %25 = OpAccessChain %14 %12 %24
2235 %26 = OpLoad %9 %25
2236 %27 = OpBitcast %6 %26
2237 OpStore %23 %27
2238 %31 = OpLoad %6 %8
2239 %33 = OpSMod %6 %31 %32
2240 %34 = OpLoad %6 %18
2241 %35 = OpLoad %6 %23
2242 %37 = OpCompositeConstruct %36 %33 %34 %35
2243 %38 = OpLoad %6 %8
2244 %39 = OpLoad %6 %8
2245 %40 = OpIMul %6 %38 %39
2246 %41 = OpLoad %6 %18
2247 %42 = OpLoad %6 %18
2248 %43 = OpIMul %6 %41 %42
2249 %44 = OpIAdd %6 %40 %43
2250 %45 = OpLoad %6 %23
2251 %46 = OpLoad %6 %23
2252 %47 = OpIMul %6 %45 %46
2253 %48 = OpIAdd %6 %44 %47
2254 %50 = OpImageTexelPointer %49 %30 %37 %13
2255 %51 = ${OPNAME} %6 %50 %19 %13 ${LASTARG:default=%48}
2256 OpReturn
2257 OpFunctionEnd
2258 )";
2259
2260 const std::string kShader_cube_r32i_intermediate_values = R"(
2261 ; The SPIR-V shader below is based on the following GLSL shader, but OpAtomicIAdd has been
2262 ; replaced with a template parameter and the last argument for it has been made optional.
2263 ;
2264 ; #version 440
2265 ; precision highp iimageCube;
2266 ;
2267 ; layout (local_size_x = 1, local_size_y = 1, local_size_z = 1) in;
2268 ; layout (r32i, binding=0) coherent uniform iimageCube u_resultImage;
2269 ; layout (r32i, binding=1) writeonly uniform iimageCube u_intermValuesImage;
2270 ;
2271 ; void main (void)
2272 ; {
2273 ;     int gx = int(gl_GlobalInvocationID.x);
2274 ;     int gy = int(gl_GlobalInvocationID.y);
2275 ;     int gz = int(gl_GlobalInvocationID.z);
2276 ;     imageStore(u_intermValuesImage, ivec3(gx,gy,gz), ivec4(imageAtomicAdd(u_resultImage, ivec3(gx % 64,gy,gz), int(gx*gx + gy*gy + gz*gz))));
2277 ; }
2278 ;
2279 ; SPIR-V
2280 ; Version: 1.0
2281 ; Generator: Khronos Glslang Reference Front End; 7
2282 ; Bound: 61
2283 ; Schema: 0
2284 OpCapability Shader
2285 %1 = OpExtInstImport "GLSL.std.450"
2286 OpMemoryModel Logical GLSL450
2287 OpEntryPoint GLCompute %4 "main" %12
2288 OpExecutionMode %4 LocalSize 1 1 1
2289 OpDecorate %12 BuiltIn GlobalInvocationId
2290 OpDecorate %30 DescriptorSet 0
2291 OpDecorate %30 Binding 1
2292 OpDecorate %30 NonReadable
2293 OpDecorate %37 DescriptorSet 0
2294 OpDecorate %37 Binding 0
2295 OpDecorate %37 Coherent
2296 OpDecorate %60 BuiltIn WorkgroupSize
2297 %2 = OpTypeVoid
2298 %3 = OpTypeFunction %2
2299 %6 = OpTypeInt 32 1
2300 %7 = OpTypePointer Function %6
2301 %9 = OpTypeInt 32 0
2302 %10 = OpTypeVector %9 3
2303 %11 = OpTypePointer Input %10
2304 %12 = OpVariable %11 Input
2305 %13 = OpConstant %9 0
2306 %14 = OpTypePointer Input %9
2307 %19 = OpConstant %9 1
2308 %24 = OpConstant %9 2
2309 %28 = OpTypeImage %6 Cube 0 0 0 2 R32i
2310 %29 = OpTypePointer UniformConstant %28
2311 %30 = OpVariable %29 UniformConstant
2312 %35 = OpTypeVector %6 3
2313 %37 = OpVariable %29 UniformConstant
2314 %39 = OpConstant %6 64
2315 %55 = OpTypePointer Image %6
2316 %58 = OpTypeVector %6 4
2317 %60 = OpConstantComposite %10 %19 %19 %19
2318 %4 = OpFunction %2 None %3
2319 %5 = OpLabel
2320 %8 = OpVariable %7 Function
2321 %18 = OpVariable %7 Function
2322 %23 = OpVariable %7 Function
2323 %15 = OpAccessChain %14 %12 %13
2324 %16 = OpLoad %9 %15
2325 %17 = OpBitcast %6 %16
2326 OpStore %8 %17
2327 %20 = OpAccessChain %14 %12 %19
2328 %21 = OpLoad %9 %20
2329 %22 = OpBitcast %6 %21
2330 OpStore %18 %22
2331 %25 = OpAccessChain %14 %12 %24
2332 %26 = OpLoad %9 %25
2333 %27 = OpBitcast %6 %26
2334 OpStore %23 %27
2335 %31 = OpLoad %28 %30
2336 %32 = OpLoad %6 %8
2337 %33 = OpLoad %6 %18
2338 %34 = OpLoad %6 %23
2339 %36 = OpCompositeConstruct %35 %32 %33 %34
2340 %38 = OpLoad %6 %8
2341 %40 = OpSMod %6 %38 %39
2342 %41 = OpLoad %6 %18
2343 %42 = OpLoad %6 %23
2344 %43 = OpCompositeConstruct %35 %40 %41 %42
2345 %44 = OpLoad %6 %8
2346 %45 = OpLoad %6 %8
2347 %46 = OpIMul %6 %44 %45
2348 %47 = OpLoad %6 %18
2349 %48 = OpLoad %6 %18
2350 %49 = OpIMul %6 %47 %48
2351 %50 = OpIAdd %6 %46 %49
2352 %51 = OpLoad %6 %23
2353 %52 = OpLoad %6 %23
2354 %53 = OpIMul %6 %51 %52
2355 %54 = OpIAdd %6 %50 %53
2356 %56 = OpImageTexelPointer %55 %37 %43 %13
2357 %57 = ${OPNAME} %6 %56 %19 %13 ${LASTARG:default=%54}
2358 %59 = OpCompositeConstruct %58 %57 %57 %57 %57
2359 OpImageWrite %31 %36 %59
2360 OpReturn
2361 OpFunctionEnd
2362 )";
2363
2364 const std::string kShader_cube_array_r32ui_end_result = R"(
2365 ; The SPIR-V shader below is based on the following GLSL shader, but OpAtomicIAdd has been
2366 ; replaced with a template parameter and the last argument for it has been made optional.
2367 ;
2368 ; #version 440
2369 ; precision highp uimageCubeArray;
2370 ;
2371 ; layout (local_size_x = 1, local_size_y = 1, local_size_z = 1) in;
2372 ; layout (r32ui, binding=0) coherent uniform uimageCubeArray u_resultImage;
2373 ;
2374 ; void main (void)
2375 ; {
2376 ;     int gx = int(gl_GlobalInvocationID.x);
2377 ;     int gy = int(gl_GlobalInvocationID.y);
2378 ;     int gz = int(gl_GlobalInvocationID.z);
2379 ;     imageAtomicAdd(u_resultImage, ivec3(gx % 64,gy,gz), uint(gx*gx + gy*gy + gz*gz));
2380 ; }
2381 ;
2382 ; SPIR-V
2383 ; Version: 1.0
2384 ; Generator: Khronos Glslang Reference Front End; 7
2385 ; Bound: 54
2386 ; Schema: 0
2387 OpCapability Shader
2388 OpCapability ImageCubeArray
2389 %1 = OpExtInstImport "GLSL.std.450"
2390 OpMemoryModel Logical GLSL450
2391 OpEntryPoint GLCompute %4 "main" %12
2392 OpExecutionMode %4 LocalSize 1 1 1
2393 OpDecorate %12 BuiltIn GlobalInvocationId
2394 OpDecorate %30 DescriptorSet 0
2395 OpDecorate %30 Binding 0
2396 OpDecorate %30 Coherent
2397 OpDecorate %53 BuiltIn WorkgroupSize
2398 %2 = OpTypeVoid
2399 %3 = OpTypeFunction %2
2400 %6 = OpTypeInt 32 1
2401 %7 = OpTypePointer Function %6
2402 %9 = OpTypeInt 32 0
2403 %10 = OpTypeVector %9 3
2404 %11 = OpTypePointer Input %10
2405 %12 = OpVariable %11 Input
2406 %13 = OpConstant %9 0
2407 %14 = OpTypePointer Input %9
2408 %19 = OpConstant %9 1
2409 %24 = OpConstant %9 2
2410 %28 = OpTypeImage %9 Cube 0 1 0 2 R32ui
2411 %29 = OpTypePointer UniformConstant %28
2412 %30 = OpVariable %29 UniformConstant
2413 %32 = OpConstant %6 64
2414 %36 = OpTypeVector %6 3
2415 %50 = OpTypePointer Image %9
2416 %53 = OpConstantComposite %10 %19 %19 %19
2417 %4 = OpFunction %2 None %3
2418 %5 = OpLabel
2419 %8 = OpVariable %7 Function
2420 %18 = OpVariable %7 Function
2421 %23 = OpVariable %7 Function
2422 %15 = OpAccessChain %14 %12 %13
2423 %16 = OpLoad %9 %15
2424 %17 = OpBitcast %6 %16
2425 OpStore %8 %17
2426 %20 = OpAccessChain %14 %12 %19
2427 %21 = OpLoad %9 %20
2428 %22 = OpBitcast %6 %21
2429 OpStore %18 %22
2430 %25 = OpAccessChain %14 %12 %24
2431 %26 = OpLoad %9 %25
2432 %27 = OpBitcast %6 %26
2433 OpStore %23 %27
2434 %31 = OpLoad %6 %8
2435 %33 = OpSMod %6 %31 %32
2436 %34 = OpLoad %6 %18
2437 %35 = OpLoad %6 %23
2438 %37 = OpCompositeConstruct %36 %33 %34 %35
2439 %38 = OpLoad %6 %8
2440 %39 = OpLoad %6 %8
2441 %40 = OpIMul %6 %38 %39
2442 %41 = OpLoad %6 %18
2443 %42 = OpLoad %6 %18
2444 %43 = OpIMul %6 %41 %42
2445 %44 = OpIAdd %6 %40 %43
2446 %45 = OpLoad %6 %23
2447 %46 = OpLoad %6 %23
2448 %47 = OpIMul %6 %45 %46
2449 %48 = OpIAdd %6 %44 %47
2450 %49 = OpBitcast %9 %48
2451 %51 = OpImageTexelPointer %50 %30 %37 %13
2452 %52 = ${OPNAME} %9 %51 %19 %13 ${LASTARG:default=%49}
2453 OpReturn
2454 OpFunctionEnd
2455 )";
2456
2457 const std::string kShader_cube_array_r32ui_intermediate_values = R"(
2458 ; The SPIR-V shader below is based on the following GLSL shader, but OpAtomicIAdd has been
2459 ; replaced with a template parameter and the last argument for it has been made optional.
2460 ;
2461 ; #version 440
2462 ; precision highp uimageCubeArray;
2463 ;
2464 ; layout (local_size_x = 1, local_size_y = 1, local_size_z = 1) in;
2465 ; layout (r32ui, binding=0) coherent uniform uimageCubeArray u_resultImage;
2466 ; layout (r32ui, binding=1) writeonly uniform uimageCubeArray u_intermValuesImage;
2467 ;
2468 ; void main (void)
2469 ; {
2470 ;     int gx = int(gl_GlobalInvocationID.x);
2471 ;     int gy = int(gl_GlobalInvocationID.y);
2472 ;     int gz = int(gl_GlobalInvocationID.z);
2473 ;     imageStore(u_intermValuesImage, ivec3(gx,gy,gz), uvec4(imageAtomicAdd(u_resultImage, ivec3(gx % 64,gy,gz), uint(gx*gx + gy*gy + gz*gz))));
2474 ; }
2475 ;
2476 ; SPIR-V
2477 ; Version: 1.0
2478 ; Generator: Khronos Glslang Reference Front End; 7
2479 ; Bound: 62
2480 ; Schema: 0
2481 OpCapability Shader
2482 OpCapability ImageCubeArray
2483 %1 = OpExtInstImport "GLSL.std.450"
2484 OpMemoryModel Logical GLSL450
2485 OpEntryPoint GLCompute %4 "main" %12
2486 OpExecutionMode %4 LocalSize 1 1 1
2487 OpDecorate %12 BuiltIn GlobalInvocationId
2488 OpDecorate %30 DescriptorSet 0
2489 OpDecorate %30 Binding 1
2490 OpDecorate %30 NonReadable
2491 OpDecorate %37 DescriptorSet 0
2492 OpDecorate %37 Binding 0
2493 OpDecorate %37 Coherent
2494 OpDecorate %61 BuiltIn WorkgroupSize
2495 %2 = OpTypeVoid
2496 %3 = OpTypeFunction %2
2497 %6 = OpTypeInt 32 1
2498 %7 = OpTypePointer Function %6
2499 %9 = OpTypeInt 32 0
2500 %10 = OpTypeVector %9 3
2501 %11 = OpTypePointer Input %10
2502 %12 = OpVariable %11 Input
2503 %13 = OpConstant %9 0
2504 %14 = OpTypePointer Input %9
2505 %19 = OpConstant %9 1
2506 %24 = OpConstant %9 2
2507 %28 = OpTypeImage %9 Cube 0 1 0 2 R32ui
2508 %29 = OpTypePointer UniformConstant %28
2509 %30 = OpVariable %29 UniformConstant
2510 %35 = OpTypeVector %6 3
2511 %37 = OpVariable %29 UniformConstant
2512 %39 = OpConstant %6 64
2513 %56 = OpTypePointer Image %9
2514 %59 = OpTypeVector %9 4
2515 %61 = OpConstantComposite %10 %19 %19 %19
2516 %4 = OpFunction %2 None %3
2517 %5 = OpLabel
2518 %8 = OpVariable %7 Function
2519 %18 = OpVariable %7 Function
2520 %23 = OpVariable %7 Function
2521 %15 = OpAccessChain %14 %12 %13
2522 %16 = OpLoad %9 %15
2523 %17 = OpBitcast %6 %16
2524 OpStore %8 %17
2525 %20 = OpAccessChain %14 %12 %19
2526 %21 = OpLoad %9 %20
2527 %22 = OpBitcast %6 %21
2528 OpStore %18 %22
2529 %25 = OpAccessChain %14 %12 %24
2530 %26 = OpLoad %9 %25
2531 %27 = OpBitcast %6 %26
2532 OpStore %23 %27
2533 %31 = OpLoad %28 %30
2534 %32 = OpLoad %6 %8
2535 %33 = OpLoad %6 %18
2536 %34 = OpLoad %6 %23
2537 %36 = OpCompositeConstruct %35 %32 %33 %34
2538 %38 = OpLoad %6 %8
2539 %40 = OpSMod %6 %38 %39
2540 %41 = OpLoad %6 %18
2541 %42 = OpLoad %6 %23
2542 %43 = OpCompositeConstruct %35 %40 %41 %42
2543 %44 = OpLoad %6 %8
2544 %45 = OpLoad %6 %8
2545 %46 = OpIMul %6 %44 %45
2546 %47 = OpLoad %6 %18
2547 %48 = OpLoad %6 %18
2548 %49 = OpIMul %6 %47 %48
2549 %50 = OpIAdd %6 %46 %49
2550 %51 = OpLoad %6 %23
2551 %52 = OpLoad %6 %23
2552 %53 = OpIMul %6 %51 %52
2553 %54 = OpIAdd %6 %50 %53
2554 %55 = OpBitcast %9 %54
2555 %57 = OpImageTexelPointer %56 %37 %43 %13
2556 %58 = ${OPNAME} %9 %57 %19 %13 ${LASTARG:default=%55}
2557 %60 = OpCompositeConstruct %59 %58 %58 %58 %58
2558 OpImageWrite %31 %36 %60
2559 OpReturn
2560 OpFunctionEnd
2561 )";
2562
2563 const std::string kShader_cube_array_r32i_end_result = R"(
2564 ; The SPIR-V shader below is based on the following GLSL shader, but OpAtomicIAdd has been
2565 ; replaced with a template parameter and the last argument for it has been made optional.
2566 ;
2567 ; #version 440
2568 ; precision highp iimageCubeArray;
2569 ;
2570 ; layout (local_size_x = 1, local_size_y = 1, local_size_z = 1) in;
2571 ; layout (r32i, binding=0) coherent uniform iimageCubeArray u_resultImage;
2572 ;
2573 ; void main (void)
2574 ; {
2575 ;     int gx = int(gl_GlobalInvocationID.x);
2576 ;     int gy = int(gl_GlobalInvocationID.y);
2577 ;     int gz = int(gl_GlobalInvocationID.z);
2578 ;     imageAtomicAdd(u_resultImage, ivec3(gx % 64,gy,gz), int(gx*gx + gy*gy + gz*gz));
2579 ; }
2580 ;
2581 ; SPIR-V
2582 ; Version: 1.0
2583 ; Generator: Khronos Glslang Reference Front End; 7
2584 ; Bound: 53
2585 ; Schema: 0
2586 OpCapability Shader
2587 OpCapability ImageCubeArray
2588 %1 = OpExtInstImport "GLSL.std.450"
2589 OpMemoryModel Logical GLSL450
2590 OpEntryPoint GLCompute %4 "main" %12
2591 OpExecutionMode %4 LocalSize 1 1 1
2592 OpDecorate %12 BuiltIn GlobalInvocationId
2593 OpDecorate %30 DescriptorSet 0
2594 OpDecorate %30 Binding 0
2595 OpDecorate %30 Coherent
2596 OpDecorate %52 BuiltIn WorkgroupSize
2597 %2 = OpTypeVoid
2598 %3 = OpTypeFunction %2
2599 %6 = OpTypeInt 32 1
2600 %7 = OpTypePointer Function %6
2601 %9 = OpTypeInt 32 0
2602 %10 = OpTypeVector %9 3
2603 %11 = OpTypePointer Input %10
2604 %12 = OpVariable %11 Input
2605 %13 = OpConstant %9 0
2606 %14 = OpTypePointer Input %9
2607 %19 = OpConstant %9 1
2608 %24 = OpConstant %9 2
2609 %28 = OpTypeImage %6 Cube 0 1 0 2 R32i
2610 %29 = OpTypePointer UniformConstant %28
2611 %30 = OpVariable %29 UniformConstant
2612 %32 = OpConstant %6 64
2613 %36 = OpTypeVector %6 3
2614 %49 = OpTypePointer Image %6
2615 %52 = OpConstantComposite %10 %19 %19 %19
2616 %4 = OpFunction %2 None %3
2617 %5 = OpLabel
2618 %8 = OpVariable %7 Function
2619 %18 = OpVariable %7 Function
2620 %23 = OpVariable %7 Function
2621 %15 = OpAccessChain %14 %12 %13
2622 %16 = OpLoad %9 %15
2623 %17 = OpBitcast %6 %16
2624 OpStore %8 %17
2625 %20 = OpAccessChain %14 %12 %19
2626 %21 = OpLoad %9 %20
2627 %22 = OpBitcast %6 %21
2628 OpStore %18 %22
2629 %25 = OpAccessChain %14 %12 %24
2630 %26 = OpLoad %9 %25
2631 %27 = OpBitcast %6 %26
2632 OpStore %23 %27
2633 %31 = OpLoad %6 %8
2634 %33 = OpSMod %6 %31 %32
2635 %34 = OpLoad %6 %18
2636 %35 = OpLoad %6 %23
2637 %37 = OpCompositeConstruct %36 %33 %34 %35
2638 %38 = OpLoad %6 %8
2639 %39 = OpLoad %6 %8
2640 %40 = OpIMul %6 %38 %39
2641 %41 = OpLoad %6 %18
2642 %42 = OpLoad %6 %18
2643 %43 = OpIMul %6 %41 %42
2644 %44 = OpIAdd %6 %40 %43
2645 %45 = OpLoad %6 %23
2646 %46 = OpLoad %6 %23
2647 %47 = OpIMul %6 %45 %46
2648 %48 = OpIAdd %6 %44 %47
2649 %50 = OpImageTexelPointer %49 %30 %37 %13
2650 %51 = ${OPNAME} %6 %50 %19 %13 ${LASTARG:default=%48}
2651 OpReturn
2652 OpFunctionEnd
2653 )";
2654
2655 const std::string kShader_cube_array_r32i_intermediate_values = R"(
2656 ; The SPIR-V shader below is based on the following GLSL shader, but OpAtomicIAdd has been
2657 ; replaced with a template parameter and the last argument for it has been made optional.
2658 ;
2659 ; #version 440
2660 ; precision highp iimageCubeArray;
2661 ;
2662 ; layout (local_size_x = 1, local_size_y = 1, local_size_z = 1) in;
2663 ; layout (r32i, binding=0) coherent uniform iimageCubeArray u_resultImage;
2664 ; layout (r32i, binding=1) writeonly uniform iimageCubeArray u_intermValuesImage;
2665 ;
2666 ; void main (void)
2667 ; {
2668 ;     int gx = int(gl_GlobalInvocationID.x);
2669 ;     int gy = int(gl_GlobalInvocationID.y);
2670 ;     int gz = int(gl_GlobalInvocationID.z);
2671 ;     imageStore(u_intermValuesImage, ivec3(gx,gy,gz), ivec4(imageAtomicAdd(u_resultImage, ivec3(gx % 64,gy,gz), int(gx*gx + gy*gy + gz*gz))));
2672 ; }
2673 ;
2674 ; SPIR-V
2675 ; Version: 1.0
2676 ; Generator: Khronos Glslang Reference Front End; 7
2677 ; Bound: 61
2678 ; Schema: 0
2679 OpCapability Shader
2680 OpCapability ImageCubeArray
2681 %1 = OpExtInstImport "GLSL.std.450"
2682 OpMemoryModel Logical GLSL450
2683 OpEntryPoint GLCompute %4 "main" %12
2684 OpExecutionMode %4 LocalSize 1 1 1
2685 OpDecorate %12 BuiltIn GlobalInvocationId
2686 OpDecorate %30 DescriptorSet 0
2687 OpDecorate %30 Binding 1
2688 OpDecorate %30 NonReadable
2689 OpDecorate %37 DescriptorSet 0
2690 OpDecorate %37 Binding 0
2691 OpDecorate %37 Coherent
2692 OpDecorate %60 BuiltIn WorkgroupSize
2693 %2 = OpTypeVoid
2694 %3 = OpTypeFunction %2
2695 %6 = OpTypeInt 32 1
2696 %7 = OpTypePointer Function %6
2697 %9 = OpTypeInt 32 0
2698 %10 = OpTypeVector %9 3
2699 %11 = OpTypePointer Input %10
2700 %12 = OpVariable %11 Input
2701 %13 = OpConstant %9 0
2702 %14 = OpTypePointer Input %9
2703 %19 = OpConstant %9 1
2704 %24 = OpConstant %9 2
2705 %28 = OpTypeImage %6 Cube 0 1 0 2 R32i
2706 %29 = OpTypePointer UniformConstant %28
2707 %30 = OpVariable %29 UniformConstant
2708 %35 = OpTypeVector %6 3
2709 %37 = OpVariable %29 UniformConstant
2710 %39 = OpConstant %6 64
2711 %55 = OpTypePointer Image %6
2712 %58 = OpTypeVector %6 4
2713 %60 = OpConstantComposite %10 %19 %19 %19
2714 %4 = OpFunction %2 None %3
2715 %5 = OpLabel
2716 %8 = OpVariable %7 Function
2717 %18 = OpVariable %7 Function
2718 %23 = OpVariable %7 Function
2719 %15 = OpAccessChain %14 %12 %13
2720 %16 = OpLoad %9 %15
2721 %17 = OpBitcast %6 %16
2722 OpStore %8 %17
2723 %20 = OpAccessChain %14 %12 %19
2724 %21 = OpLoad %9 %20
2725 %22 = OpBitcast %6 %21
2726 OpStore %18 %22
2727 %25 = OpAccessChain %14 %12 %24
2728 %26 = OpLoad %9 %25
2729 %27 = OpBitcast %6 %26
2730 OpStore %23 %27
2731 %31 = OpLoad %28 %30
2732 %32 = OpLoad %6 %8
2733 %33 = OpLoad %6 %18
2734 %34 = OpLoad %6 %23
2735 %36 = OpCompositeConstruct %35 %32 %33 %34
2736 %38 = OpLoad %6 %8
2737 %40 = OpSMod %6 %38 %39
2738 %41 = OpLoad %6 %18
2739 %42 = OpLoad %6 %23
2740 %43 = OpCompositeConstruct %35 %40 %41 %42
2741 %44 = OpLoad %6 %8
2742 %45 = OpLoad %6 %8
2743 %46 = OpIMul %6 %44 %45
2744 %47 = OpLoad %6 %18
2745 %48 = OpLoad %6 %18
2746 %49 = OpIMul %6 %47 %48
2747 %50 = OpIAdd %6 %46 %49
2748 %51 = OpLoad %6 %23
2749 %52 = OpLoad %6 %23
2750 %53 = OpIMul %6 %51 %52
2751 %54 = OpIAdd %6 %50 %53
2752 %56 = OpImageTexelPointer %55 %37 %43 %13
2753 %57 = ${OPNAME} %6 %56 %19 %13 ${LASTARG:default=%54}
2754 %59 = OpCompositeConstruct %58 %57 %57 %57 %57
2755 OpImageWrite %31 %36 %59
2756 OpReturn
2757 OpFunctionEnd
2758 )";
2759
2760 const std::string kShader_image_buffer_r32ui_end_result = R"(
2761 ; The SPIR-V shader below is based on the following GLSL shader, but OpAtomicIAdd has been
2762 ; replaced with a template parameter and the last argument for it has been made optional.
2763 ;
2764 ;#version 440
2765 ;precision highp uimageBuffer;
2766 ;
2767 ;layout (local_size_x = 1, local_size_y = 1, local_size_z = 1) in;
2768 ;layout (r32ui, binding=0) coherent uniform uimageBuffer u_resultImage;
2769 ;
2770 ;void main (void)
2771 ;{
2772 ;    int gx = int(gl_GlobalInvocationID.x);
2773 ;    int gy = int(gl_GlobalInvocationID.y);
2774 ;    int gz = int(gl_GlobalInvocationID.z);
2775 ;    imageAtomicAdd(u_resultImage, gx % 64, uint(gx*gx + gy*gy + gz*gz));
2776 ;}
2777 ;
2778 ; SPIR-V
2779 ; Version: 1.0
2780 ; Generator: Khronos Glslang Reference Front End; 8
2781 ; Bound: 50
2782 ; Schema: 0
2783 OpCapability Shader
2784 OpCapability ImageBuffer
2785 %1 = OpExtInstImport "GLSL.std.450"
2786 OpMemoryModel Logical GLSL450
2787 OpEntryPoint GLCompute %4 "main" %12
2788 OpExecutionMode %4 LocalSize 1 1 1
2789 OpDecorate %12 BuiltIn GlobalInvocationId
2790 OpDecorate %30 DescriptorSet 0
2791 OpDecorate %30 Binding 0
2792 OpDecorate %30 Coherent
2793 OpDecorate %49 BuiltIn WorkgroupSize
2794 %2 = OpTypeVoid
2795 %3 = OpTypeFunction %2
2796 %6 = OpTypeInt 32 1
2797 %7 = OpTypePointer Function %6
2798 %9 = OpTypeInt 32 0
2799 %10 = OpTypeVector %9 3
2800 %11 = OpTypePointer Input %10
2801 %12 = OpVariable %11 Input
2802 %13 = OpConstant %9 0
2803 %14 = OpTypePointer Input %9
2804 %19 = OpConstant %9 1
2805 %24 = OpConstant %9 2
2806 %28 = OpTypeImage %9 Buffer 0 0 0 2 R32ui
2807 %29 = OpTypePointer UniformConstant %28
2808 %30 = OpVariable %29 UniformConstant
2809 %32 = OpConstant %6 64
2810 %46 = OpTypePointer Image %9
2811 %49 = OpConstantComposite %10 %19 %19 %19
2812 %4 = OpFunction %2 None %3
2813 %5 = OpLabel
2814 %8 = OpVariable %7 Function
2815 %18 = OpVariable %7 Function
2816 %23 = OpVariable %7 Function
2817 %15 = OpAccessChain %14 %12 %13
2818 %16 = OpLoad %9 %15
2819 %17 = OpBitcast %6 %16
2820 OpStore %8 %17
2821 %20 = OpAccessChain %14 %12 %19
2822 %21 = OpLoad %9 %20
2823 %22 = OpBitcast %6 %21
2824 OpStore %18 %22
2825 %25 = OpAccessChain %14 %12 %24
2826 %26 = OpLoad %9 %25
2827 %27 = OpBitcast %6 %26
2828 OpStore %23 %27
2829 %31 = OpLoad %6 %8
2830 %33 = OpSMod %6 %31 %32
2831 %34 = OpLoad %6 %8
2832 %35 = OpLoad %6 %8
2833 %36 = OpIMul %6 %34 %35
2834 %37 = OpLoad %6 %18
2835 %38 = OpLoad %6 %18
2836 %39 = OpIMul %6 %37 %38
2837 %40 = OpIAdd %6 %36 %39
2838 %41 = OpLoad %6 %23
2839 %42 = OpLoad %6 %23
2840 %43 = OpIMul %6 %41 %42
2841 %44 = OpIAdd %6 %40 %43
2842 %45 = OpBitcast %9 %44
2843 %47 = OpImageTexelPointer %46 %30 %33 %13
2844 %48 = ${OPNAME} %9 %47 %19 %13 ${LASTARG:default=%45}
2845 OpReturn
2846 OpFunctionEnd
2847 )";
2848
2849 const std::string kShader_image_buffer_r32ui_intermediate_values = R"(
2850 ; The SPIR-V shader below is based on the following GLSL shader, but OpAtomicIAdd has been
2851 ; replaced with a template parameter and the last argument for it has been made optional.
2852 ;
2853 ;#version 440
2854 ;precision highp uimageBuffer;
2855 ;
2856 ;layout (local_size_x = 1, local_size_y = 1, local_size_z = 1) in;
2857 ;layout (r32ui, binding=0) coherent uniform uimageBuffer u_resultImage;
2858 ;layout (r32ui, binding=1) writeonly uniform uimageBuffer u_intermValuesImage;
2859 ;
2860 ;void main (void)
2861 ;{
2862 ;   int gx = int(gl_GlobalInvocationID.x);
2863 ;   int gy = int(gl_GlobalInvocationID.y);
2864 ;   int gz = int(gl_GlobalInvocationID.z);
2865 ;   imageStore(u_intermValuesImage, gx, uvec4(imageAtomicAdd(u_resultImage, gx % 64, uint(gx*gx + gy*gy + gz*gz))));
2866 ;}
2867 ;
2868 ; SPIR-V
2869 ; Version: 1.0
2870 ; Generator: Khronos Glslang Reference Front End; 8
2871 ; Bound: 55
2872 ; Schema: 0
2873 OpCapability Shader
2874 OpCapability ImageBuffer
2875 %1 = OpExtInstImport "GLSL.std.450"
2876 OpMemoryModel Logical GLSL450
2877 OpEntryPoint GLCompute %4 "main" %12
2878 OpExecutionMode %4 LocalSize 1 1 1
2879 OpDecorate %12 BuiltIn GlobalInvocationId
2880 OpDecorate %30 DescriptorSet 0
2881 OpDecorate %30 Binding 1
2882 OpDecorate %30 NonReadable
2883 OpDecorate %33 DescriptorSet 0
2884 OpDecorate %33 Binding 0
2885 OpDecorate %33 Coherent
2886 OpDecorate %54 BuiltIn WorkgroupSize
2887 %2 = OpTypeVoid
2888 %3 = OpTypeFunction %2
2889 %6 = OpTypeInt 32 1
2890 %7 = OpTypePointer Function %6
2891 %9 = OpTypeInt 32 0
2892 %10 = OpTypeVector %9 3
2893 %11 = OpTypePointer Input %10
2894 %12 = OpVariable %11 Input
2895 %13 = OpConstant %9 0
2896 %14 = OpTypePointer Input %9
2897 %19 = OpConstant %9 1
2898 %24 = OpConstant %9 2
2899 %28 = OpTypeImage %9 Buffer 0 0 0 2 R32ui
2900 %29 = OpTypePointer UniformConstant %28
2901 %30 = OpVariable %29 UniformConstant
2902 %33 = OpVariable %29 UniformConstant
2903 %35 = OpConstant %6 64
2904 %49 = OpTypePointer Image %9
2905 %52 = OpTypeVector %9 4
2906 %54 = OpConstantComposite %10 %19 %19 %19
2907 %4 = OpFunction %2 None %3
2908 %5 = OpLabel
2909 %8 = OpVariable %7 Function
2910 %18 = OpVariable %7 Function
2911 %23 = OpVariable %7 Function
2912 %15 = OpAccessChain %14 %12 %13
2913 %16 = OpLoad %9 %15
2914 %17 = OpBitcast %6 %16
2915 OpStore %8 %17
2916 %20 = OpAccessChain %14 %12 %19
2917 %21 = OpLoad %9 %20
2918 %22 = OpBitcast %6 %21
2919 OpStore %18 %22
2920 %25 = OpAccessChain %14 %12 %24
2921 %26 = OpLoad %9 %25
2922 %27 = OpBitcast %6 %26
2923 OpStore %23 %27
2924 %31 = OpLoad %28 %30
2925 %32 = OpLoad %6 %8
2926 %34 = OpLoad %6 %8
2927 %36 = OpSMod %6 %34 %35
2928 %37 = OpLoad %6 %8
2929 %38 = OpLoad %6 %8
2930 %39 = OpIMul %6 %37 %38
2931 %40 = OpLoad %6 %18
2932 %41 = OpLoad %6 %18
2933 %42 = OpIMul %6 %40 %41
2934 %43 = OpIAdd %6 %39 %42
2935 %44 = OpLoad %6 %23
2936 %45 = OpLoad %6 %23
2937 %46 = OpIMul %6 %44 %45
2938 %47 = OpIAdd %6 %43 %46
2939 %48 = OpBitcast %9 %47
2940 %50 = OpImageTexelPointer %49 %33 %36 %13
2941 %51 = ${OPNAME} %9 %50 %19 %13 ${LASTARG:default=%48}
2942 %53 = OpCompositeConstruct %52 %51 %51 %51 %51
2943 OpImageWrite %31 %32 %53
2944 OpReturn
2945 OpFunctionEnd
2946 )";
2947
2948 const std::string kShader_image_buffer_r32i_end_result = R"(
2949 ; The SPIR-V shader below is based on the following GLSL shader, but OpAtomicIAdd has been
2950 ; replaced with a template parameter and the last argument for it has been made optional.
2951 ;
2952 ;#version 440
2953 ;precision highp iimageBuffer;
2954 ;
2955 ;layout (local_size_x = 1, local_size_y = 1, local_size_z = 1) in;
2956 ;layout (r32i, binding=0) coherent uniform iimageBuffer u_resultImage;
2957 ;
2958 ;void main (void)
2959 ;{
2960 ;    int gx = int(gl_GlobalInvocationID.x);
2961 ;    int gy = int(gl_GlobalInvocationID.y);
2962 ;    int gz = int(gl_GlobalInvocationID.z);
2963 ;    imageAtomicAdd(u_resultImage, gx % 64, int(gx*gx + gy*gy + gz*gz));
2964 ;}
2965 ;
2966 ; SPIR-V
2967 ; Version: 1.0
2968 ; Generator: Khronos Glslang Reference Front End; 8
2969 ; Bound: 49
2970 ; Schema: 0
2971 OpCapability Shader
2972 OpCapability ImageBuffer
2973 %1 = OpExtInstImport "GLSL.std.450"
2974 OpMemoryModel Logical GLSL450
2975 OpEntryPoint GLCompute %4 "main" %12
2976 OpExecutionMode %4 LocalSize 1 1 1
2977 OpDecorate %12 BuiltIn GlobalInvocationId
2978 OpDecorate %30 DescriptorSet 0
2979 OpDecorate %30 Binding 0
2980 OpDecorate %30 Coherent
2981 OpDecorate %48 BuiltIn WorkgroupSize
2982 %2 = OpTypeVoid
2983 %3 = OpTypeFunction %2
2984 %6 = OpTypeInt 32 1
2985 %7 = OpTypePointer Function %6
2986 %9 = OpTypeInt 32 0
2987 %10 = OpTypeVector %9 3
2988 %11 = OpTypePointer Input %10
2989 %12 = OpVariable %11 Input
2990 %13 = OpConstant %9 0
2991 %14 = OpTypePointer Input %9
2992 %19 = OpConstant %9 1
2993 %24 = OpConstant %9 2
2994 %28 = OpTypeImage %6 Buffer 0 0 0 2 R32i
2995 %29 = OpTypePointer UniformConstant %28
2996 %30 = OpVariable %29 UniformConstant
2997 %32 = OpConstant %6 64
2998 %45 = OpTypePointer Image %6
2999 %48 = OpConstantComposite %10 %19 %19 %19
3000 %4 = OpFunction %2 None %3
3001 %5 = OpLabel
3002 %8 = OpVariable %7 Function
3003 %18 = OpVariable %7 Function
3004 %23 = OpVariable %7 Function
3005 %15 = OpAccessChain %14 %12 %13
3006 %16 = OpLoad %9 %15
3007 %17 = OpBitcast %6 %16
3008 OpStore %8 %17
3009 %20 = OpAccessChain %14 %12 %19
3010 %21 = OpLoad %9 %20
3011 %22 = OpBitcast %6 %21
3012 OpStore %18 %22
3013 %25 = OpAccessChain %14 %12 %24
3014 %26 = OpLoad %9 %25
3015 %27 = OpBitcast %6 %26
3016 OpStore %23 %27
3017 %31 = OpLoad %6 %8
3018 %33 = OpSMod %6 %31 %32
3019 %34 = OpLoad %6 %8
3020 %35 = OpLoad %6 %8
3021 %36 = OpIMul %6 %34 %35
3022 %37 = OpLoad %6 %18
3023 %38 = OpLoad %6 %18
3024 %39 = OpIMul %6 %37 %38
3025 %40 = OpIAdd %6 %36 %39
3026 %41 = OpLoad %6 %23
3027 %42 = OpLoad %6 %23
3028 %43 = OpIMul %6 %41 %42
3029 %44 = OpIAdd %6 %40 %43
3030 %46 = OpImageTexelPointer %45 %30 %33 %13
3031 %47 = ${OPNAME} %6 %46 %19 %13 ${LASTARG:default=%44}
3032 OpReturn
3033 OpFunctionEnd
3034 )";
3035
3036 const std::string kShader_image_buffer_r32i_intermediate_values = R"(
3037 ; The SPIR-V shader below is based on the following GLSL shader, but OpAtomicIAdd has been
3038 ; replaced with a template parameter and the last argument for it has been made optional.
3039 ;
3040 ;#version 440
3041 ;precision highp iimageBuffer;
3042 ;
3043 ;layout (local_size_x = 1, local_size_y = 1, local_size_z = 1) in;
3044 ;layout (r32i, binding=0) coherent uniform iimageBuffer u_resultImage;
3045 ;layout (r32i, binding=1) writeonly uniform iimageBuffer u_intermValuesImage;
3046 ;
3047 ;void main (void)
3048 ;{
3049 ;    int gx = int(gl_GlobalInvocationID.x);
3050 ;    int gy = int(gl_GlobalInvocationID.y);
3051 ;    int gz = int(gl_GlobalInvocationID.z);
3052 ;    imageStore(u_intermValuesImage, gx, ivec4(imageAtomicAdd(u_resultImage, gx % 64, int(gx*gx + gy*gy + gz*gz))));
3053 ;}
3054 ;
3055 ; SPIR-V
3056 ; Version: 1.0
3057 ; Generator: Khronos Glslang Reference Front End; 8
3058 ; Bound: 54
3059 ; Schema: 0
3060 OpCapability Shader
3061 OpCapability ImageBuffer
3062 %1 = OpExtInstImport "GLSL.std.450"
3063 OpMemoryModel Logical GLSL450
3064 OpEntryPoint GLCompute %4 "main" %12
3065 OpExecutionMode %4 LocalSize 1 1 1
3066 OpDecorate %12 BuiltIn GlobalInvocationId
3067 OpDecorate %30 DescriptorSet 0
3068 OpDecorate %30 Binding 1
3069 OpDecorate %30 NonReadable
3070 OpDecorate %33 DescriptorSet 0
3071 OpDecorate %33 Binding 0
3072 OpDecorate %33 Coherent
3073 OpDecorate %53 BuiltIn WorkgroupSize
3074 %2 = OpTypeVoid
3075 %3 = OpTypeFunction %2
3076 %6 = OpTypeInt 32 1
3077 %7 = OpTypePointer Function %6
3078 %9 = OpTypeInt 32 0
3079 %10 = OpTypeVector %9 3
3080 %11 = OpTypePointer Input %10
3081 %12 = OpVariable %11 Input
3082 %13 = OpConstant %9 0
3083 %14 = OpTypePointer Input %9
3084 %19 = OpConstant %9 1
3085 %24 = OpConstant %9 2
3086 %28 = OpTypeImage %6 Buffer 0 0 0 2 R32i
3087 %29 = OpTypePointer UniformConstant %28
3088 %30 = OpVariable %29 UniformConstant
3089 %33 = OpVariable %29 UniformConstant
3090 %35 = OpConstant %6 64
3091 %48 = OpTypePointer Image %6
3092 %51 = OpTypeVector %6 4
3093 %53 = OpConstantComposite %10 %19 %19 %19
3094 %4 = OpFunction %2 None %3
3095 %5 = OpLabel
3096 %8 = OpVariable %7 Function
3097 %18 = OpVariable %7 Function
3098 %23 = OpVariable %7 Function
3099 %15 = OpAccessChain %14 %12 %13
3100 %16 = OpLoad %9 %15
3101 %17 = OpBitcast %6 %16
3102 OpStore %8 %17
3103 %20 = OpAccessChain %14 %12 %19
3104 %21 = OpLoad %9 %20
3105 %22 = OpBitcast %6 %21
3106 OpStore %18 %22
3107 %25 = OpAccessChain %14 %12 %24
3108 %26 = OpLoad %9 %25
3109 %27 = OpBitcast %6 %26
3110 OpStore %23 %27
3111 %31 = OpLoad %28 %30
3112 %32 = OpLoad %6 %8
3113 %34 = OpLoad %6 %8
3114 %36 = OpSMod %6 %34 %35
3115 %37 = OpLoad %6 %8
3116 %38 = OpLoad %6 %8
3117 %39 = OpIMul %6 %37 %38
3118 %40 = OpLoad %6 %18
3119 %41 = OpLoad %6 %18
3120 %42 = OpIMul %6 %40 %41
3121 %43 = OpIAdd %6 %39 %42
3122 %44 = OpLoad %6 %23
3123 %45 = OpLoad %6 %23
3124 %46 = OpIMul %6 %44 %45
3125 %47 = OpIAdd %6 %43 %46
3126 %49 = OpImageTexelPointer %48 %33 %36 %13
3127 %50 = ${OPNAME} %6 %49 %19 %13 ${LASTARG:default=%47}
3128 %52 = OpCompositeConstruct %51 %50 %50 %50 %50
3129 OpImageWrite %31 %32 %52
3130 OpReturn
3131 OpFunctionEnd
3132 )";
3133
3134 const std::string kShader_1d_r64ui_end_result = R"(
3135 ; The SPIR-V shader below is based on the following GLSL shader, but OpAtomicIAdd has been
3136 ; replaced with a template parameter and the last argument for it has been made optional.
3137 ;
3138 ; #version 440
3139 ; precision highp uimage1D;
3140 ;
3141 ; #extension GL_EXT_shader_explicit_arithmetic_types_int64 : require
3142 ; #extension GL_EXT_shader_image_int64 : require
3143 ;
3144 ; layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in;
3145 ; layout(r64ui, binding = 0) coherent uniform uimage1D u_resultImage;
3146 ; void main(void)
3147 ; {
3148 ;    int gx = int(gl_GlobalInvocationID.x);
3149 ;    int gy = int(gl_GlobalInvocationID.y);
3150 ;    int gz = int(gl_GlobalInvocationID.z);
3151 ;    imageAtomicAdd(u_resultImage, gx % 64, uint(gx*gx + gy*gy + gz*gz));
3152 ; }
3153 ;
3154 ; SPIR - V
3155 ; Version: 1.3
3156 ; Generator: Khronos Glslang Reference Front End; 8
3157 ; Bound: 53
3158 ; Schema: 0
3159 OpCapability Shader
3160 OpCapability Int64
3161 OpCapability Int64Atomics
3162 OpCapability Image1D
3163 OpCapability Int64ImageEXT
3164 OpExtension "SPV_EXT_shader_image_int64"
3165 %1 = OpExtInstImport "GLSL.std.450"
3166 OpMemoryModel Logical GLSL450
3167 OpEntryPoint GLCompute %4 "main" %12
3168 OpExecutionMode %4 LocalSize 1 1 1
3169 OpDecorate %12 BuiltIn GlobalInvocationId
3170 OpDecorate %31 DescriptorSet 0
3171 OpDecorate %31 Binding 0
3172 OpDecorate %31 Coherent
3173 OpDecorate %52 BuiltIn WorkgroupSize
3174 %2 = OpTypeVoid
3175 %3 = OpTypeFunction %2
3176 %6 = OpTypeInt 32 1
3177 %7 = OpTypePointer Function %6
3178 %9 = OpTypeInt 32 0
3179 %10 = OpTypeVector %9 3
3180 %11 = OpTypePointer Input %10
3181 %12 = OpVariable %11 Input
3182 %13 = OpConstant %9 0
3183 %14 = OpTypePointer Input %9
3184 %19 = OpConstant %9 1
3185 %24 = OpConstant %9 2
3186 %28 = OpTypeInt 64 0
3187 %29 = OpTypeImage %28 1D 0 0 0 2 R64ui
3188 %30 = OpTypePointer UniformConstant %29
3189 %31 = OpVariable %30 UniformConstant
3190 %33 = OpConstant %6 64
3191 %46 = OpTypeInt 64 1
3192 %49 = OpTypePointer Image %28
3193 %52 = OpConstantComposite %10 %19 %19 %19
3194 %4 = OpFunction %2 None %3
3195 %5 = OpLabel
3196 %8 = OpVariable %7 Function
3197 %18 = OpVariable %7 Function
3198 %23 = OpVariable %7 Function
3199 %15 = OpAccessChain %14 %12 %13
3200 %16 = OpLoad %9 %15
3201 %17 = OpBitcast %6 %16
3202 OpStore %8 %17
3203 %20 = OpAccessChain %14 %12 %19
3204 %21 = OpLoad %9 %20
3205 %22 = OpBitcast %6 %21
3206 OpStore %18 %22
3207 %25 = OpAccessChain %14 %12 %24
3208 %26 = OpLoad %9 %25
3209 %27 = OpBitcast %6 %26
3210 OpStore %23 %27
3211 %32 = OpLoad %6 %8
3212 %34 = OpSMod %6 %32 %33
3213 %35 = OpLoad %6 %8
3214 %36 = OpLoad %6 %8
3215 %37 = OpIMul %6 %35 %36
3216 %38 = OpLoad %6 %18
3217 %39 = OpLoad %6 %18
3218 %40 = OpIMul %6 %38 %39
3219 %41 = OpIAdd %6 %37 %40
3220 %42 = OpLoad %6 %23
3221 %43 = OpLoad %6 %23
3222 %44 = OpIMul %6 %42 %43
3223 %45 = OpIAdd %6 %41 %44
3224 %47 = OpSConvert %46 %45
3225 %48 = OpBitcast %28 %47
3226 %50 = OpImageTexelPointer %49 %31 %34 %13
3227 %51 = ${OPNAME} %28 %50 %19 %13 ${LASTARG:default=%48}
3228 OpReturn
3229 OpFunctionEnd
3230 )";
3231
3232 const std::string kShader_1d_r64ui_intermediate_values = R"(
3233 ; The SPIR-V shader below is based on the following GLSL shader, but OpAtomicIAdd has been
3234 ; replaced with a template parameter and the last argument for it has been made optional.
3235 ;
3236 ; #version 440
3237 ; precision highp uimage1D;
3238 ; #extension GL_EXT_shader_explicit_arithmetic_types_int64 : require
3239 ; #extension GL_EXT_shader_image_int64 : require
3240 ;
3241 ; layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in;
3242 ; layout(r64ui, binding = 0) coherent uniform uimage1D u_resultImage;
3243 ; layout(r64ui, binding = 1) writeonly uniform uimage1D u_intermValuesImage;
3244 ;
3245 ; void main(void)
3246 ; {
3247 ;   int gx = int(gl_GlobalInvocationID.x);
3248 ;   int gy = int(gl_GlobalInvocationID.y);
3249 ;   int gz = int(gl_GlobalInvocationID.z);
3250 ;   imageStore(u_intermValuesImage, gx, u64vec4(imageAtomicAdd(u_resultImage, gx % 64, uint(gx*gx + gy*gy + gz*gz))));
3251 ; }
3252 ;
3253 ; SPIR - V
3254 ; Version: 1.3
3255 ; Generator: Khronos Glslang Reference Front End; 8
3256 ; Bound: 58
3257 ; Schema: 0
3258 OpCapability Shader
3259 OpCapability Int64
3260 OpCapability Int64Atomics
3261 OpCapability Image1D
3262 OpCapability Int64ImageEXT
3263 OpExtension "SPV_EXT_shader_image_int64"
3264 %1 = OpExtInstImport "GLSL.std.450"
3265 OpMemoryModel Logical GLSL450
3266 OpEntryPoint GLCompute %4 "main" %12
3267 OpExecutionMode %4 LocalSize 1 1 1
3268 OpDecorate %12 BuiltIn GlobalInvocationId
3269 OpDecorate %31 DescriptorSet 0
3270 OpDecorate %31 Binding 1
3271 OpDecorate %31 NonReadable
3272 OpDecorate %34 DescriptorSet 0
3273 OpDecorate %34 Binding 0
3274 OpDecorate %34 Coherent
3275 OpDecorate %57 BuiltIn WorkgroupSize
3276 %2 = OpTypeVoid
3277 %3 = OpTypeFunction %2
3278 %6 = OpTypeInt 32 1
3279 %7 = OpTypePointer Function %6
3280 %9 = OpTypeInt 32 0
3281 %10 = OpTypeVector %9 3
3282 %11 = OpTypePointer Input %10
3283 %12 = OpVariable %11 Input
3284 %13 = OpConstant %9 0
3285 %14 = OpTypePointer Input %9
3286 %19 = OpConstant %9 1
3287 %24 = OpConstant %9 2
3288 %28 = OpTypeInt 64 0
3289 %29 = OpTypeImage %28 1D 0 0 0 2 R64ui
3290 %30 = OpTypePointer UniformConstant %29
3291 %31 = OpVariable %30 UniformConstant
3292 %34 = OpVariable %30 UniformConstant
3293 %36 = OpConstant %6 64
3294 %49 = OpTypeInt 64 1
3295 %52 = OpTypePointer Image %28
3296 %55 = OpTypeVector %28 4
3297 %57 = OpConstantComposite %10 %19 %19 %19
3298 %4 = OpFunction %2 None %3
3299 %5 = OpLabel
3300 %8 = OpVariable %7 Function
3301 %18 = OpVariable %7 Function
3302 %23 = OpVariable %7 Function
3303 %15 = OpAccessChain %14 %12 %13
3304 %16 = OpLoad %9 %15
3305 %17 = OpBitcast %6 %16
3306 OpStore %8 %17
3307 %20 = OpAccessChain %14 %12 %19
3308 %21 = OpLoad %9 %20
3309 %22 = OpBitcast %6 %21
3310 OpStore %18 %22
3311 %25 = OpAccessChain %14 %12 %24
3312 %26 = OpLoad %9 %25
3313 %27 = OpBitcast %6 %26
3314 OpStore %23 %27
3315 %32 = OpLoad %29 %31
3316 %33 = OpLoad %6 %8
3317 %35 = OpLoad %6 %8
3318 %37 = OpSMod %6 %35 %36
3319 %38 = OpLoad %6 %8
3320 %39 = OpLoad %6 %8
3321 %40 = OpIMul %6 %38 %39
3322 %41 = OpLoad %6 %18
3323 %42 = OpLoad %6 %18
3324 %43 = OpIMul %6 %41 %42
3325 %44 = OpIAdd %6 %40 %43
3326 %45 = OpLoad %6 %23
3327 %46 = OpLoad %6 %23
3328 %47 = OpIMul %6 %45 %46
3329 %48 = OpIAdd %6 %44 %47
3330 %50 = OpSConvert %49 %48
3331 %51 = OpBitcast %28 %50
3332 %53 = OpImageTexelPointer %52 %34 %37 %13
3333 %54 = ${OPNAME} %28 %53 %19 %13 ${LASTARG:default=%51}
3334 %56 = OpCompositeConstruct %55 %54 %54 %54 %54
3335 OpImageWrite %32 %33 %56
3336 OpReturn
3337 OpFunctionEnd
3338 )";
3339
3340 const std::string kShader_1d_r64i_end_result = R"(
3341 ; The SPIR-V shader below is based on the following GLSL shader, but OpAtomicIAdd has been
3342 ; replaced with a template parameter and the last argument for it has been made optional.
3343 ;
3344 ;#version 440
3345 ;precision highp iimage1D;
3346 ;#extension GL_EXT_shader_explicit_arithmetic_types_int64 : require
3347 ;#extension GL_EXT_shader_image_int64 : require
3348 ;
3349 ;layout (local_size_x = 1, local_size_y = 1, local_size_z = 1) in;
3350 ;layout (r64i, binding=0) coherent uniform iimage1D u_resultImage;
3351 ;
3352 ;void main (void)
3353 ;{
3354 ;   int gx = int(gl_GlobalInvocationID.x);
3355 ;   int gy = int(gl_GlobalInvocationID.y);
3356 ;   int gz = int(gl_GlobalInvocationID.z);
3357 ;   imageAtomicAdd(u_resultImage, gx % 64, int(gx*gx + gy*gy + gz*gz));
3358 ;}
3359 ;
3360 ; SPIR-V
3361 ; Version: 1.3
3362 ; Generator: Khronos Glslang Reference Front End; 8
3363 ; Bound: 51
3364 ; Schema: 0
3365 OpCapability Shader
3366 OpCapability Int64
3367 OpCapability Int64Atomics
3368 OpCapability Image1D
3369 OpCapability Int64ImageEXT
3370 OpExtension "SPV_EXT_shader_image_int64"
3371 %1 = OpExtInstImport "GLSL.std.450"
3372 OpMemoryModel Logical GLSL450
3373 OpEntryPoint GLCompute %4 "main" %12
3374 OpExecutionMode %4 LocalSize 1 1 1
3375 OpDecorate %12 BuiltIn GlobalInvocationId
3376 OpDecorate %31 DescriptorSet 0
3377 OpDecorate %31 Binding 0
3378 OpDecorate %31 Coherent
3379 OpDecorate %50 BuiltIn WorkgroupSize
3380 %2 = OpTypeVoid
3381 %3 = OpTypeFunction %2
3382 %6 = OpTypeInt 32 1
3383 %7 = OpTypePointer Function %6
3384 %9 = OpTypeInt 32 0
3385 %10 = OpTypeVector %9 3
3386 %11 = OpTypePointer Input %10
3387 %12 = OpVariable %11 Input
3388 %13 = OpConstant %9 0
3389 %14 = OpTypePointer Input %9
3390 %19 = OpConstant %9 1
3391 %24 = OpConstant %9 2
3392 %28 = OpTypeInt 64 1
3393 %29 = OpTypeImage %28 1D 0 0 0 2 R64i
3394 %30 = OpTypePointer UniformConstant %29
3395 %31 = OpVariable %30 UniformConstant
3396 %33 = OpConstant %6 64
3397 %47 = OpTypePointer Image %28
3398 %50 = OpConstantComposite %10 %19 %19 %19
3399 %4 = OpFunction %2 None %3
3400 %5 = OpLabel
3401 %8 = OpVariable %7 Function
3402 %18 = OpVariable %7 Function
3403 %23 = OpVariable %7 Function
3404 %15 = OpAccessChain %14 %12 %13
3405 %16 = OpLoad %9 %15
3406 %17 = OpBitcast %6 %16
3407 OpStore %8 %17
3408 %20 = OpAccessChain %14 %12 %19
3409 %21 = OpLoad %9 %20
3410 %22 = OpBitcast %6 %21
3411 OpStore %18 %22
3412 %25 = OpAccessChain %14 %12 %24
3413 %26 = OpLoad %9 %25
3414 %27 = OpBitcast %6 %26
3415 OpStore %23 %27
3416 %32 = OpLoad %6 %8
3417 %34 = OpSMod %6 %32 %33
3418 %35 = OpLoad %6 %8
3419 %36 = OpLoad %6 %8
3420 %37 = OpIMul %6 %35 %36
3421 %38 = OpLoad %6 %18
3422 %39 = OpLoad %6 %18
3423 %40 = OpIMul %6 %38 %39
3424 %41 = OpIAdd %6 %37 %40
3425 %42 = OpLoad %6 %23
3426 %43 = OpLoad %6 %23
3427 %44 = OpIMul %6 %42 %43
3428 %45 = OpIAdd %6 %41 %44
3429 %46 = OpSConvert %28 %45
3430 %48 = OpImageTexelPointer %47 %31 %34 %13
3431 %49 = ${OPNAME} %28 %48 %19 %13 ${LASTARG:default=%46}
3432 OpReturn
3433 OpFunctionEnd
3434 )";
3435
3436 const std::string kShader_1d_r64i_intermediate_values = R"(
3437 ; The SPIR-V shader below is based on the following GLSL shader, but OpAtomicIAdd has been
3438 ; replaced with a template parameter and the last argument for it has been made optional.
3439 ;
3440 ;#version 440
3441 ;precision highp iimage1D;
3442 ;#extension GL_EXT_shader_explicit_arithmetic_types_int64 : require
3443 ;#extension GL_EXT_shader_image_int64 : require
3444 ;
3445 ;layout (local_size_x = 1, local_size_y = 1, local_size_z = 1) in;
3446 ;layout (r64i, binding=0) coherent uniform iimage1D u_resultImage;
3447 ;layout (r64i, binding=1) writeonly uniform iimage1D u_intermValuesImage;
3448 ;
3449 ;void main (void)
3450 ;{
3451 ;   int gx = int(gl_GlobalInvocationID.x);
3452 ;   int gy = int(gl_GlobalInvocationID.y);
3453 ;   int gz = int(gl_GlobalInvocationID.z);
3454 ;   imageStore(u_intermValuesImage, gx, i64vec4(imageAtomicAdd(u_resultImage, gx % 64, int(gx*gx + gy*gy + gz*gz))));
3455 ;}
3456 ;
3457 ; SPIR-V
3458 ; Version: 1.3
3459 ; Generator: Khronos Glslang Reference Front End; 8
3460 ; Bound: 56
3461 ; Schema: 0
3462 OpCapability Shader
3463 OpCapability Int64
3464 OpCapability Int64Atomics
3465 OpCapability Image1D
3466 OpCapability Int64ImageEXT
3467 OpExtension "SPV_EXT_shader_image_int64"
3468 %1 = OpExtInstImport "GLSL.std.450"
3469 OpMemoryModel Logical GLSL450
3470 OpEntryPoint GLCompute %4 "main" %12
3471 OpExecutionMode %4 LocalSize 1 1 1
3472 OpDecorate %12 BuiltIn GlobalInvocationId
3473 OpDecorate %31 DescriptorSet 0
3474 OpDecorate %31 Binding 1
3475 OpDecorate %31 NonReadable
3476 OpDecorate %34 DescriptorSet 0
3477 OpDecorate %34 Binding 0
3478 OpDecorate %34 Coherent
3479 OpDecorate %55 BuiltIn WorkgroupSize
3480 %2 = OpTypeVoid
3481 %3 = OpTypeFunction %2
3482 %6 = OpTypeInt 32 1
3483 %7 = OpTypePointer Function %6
3484 %9 = OpTypeInt 32 0
3485 %10 = OpTypeVector %9 3
3486 %11 = OpTypePointer Input %10
3487 %12 = OpVariable %11 Input
3488 %13 = OpConstant %9 0
3489 %14 = OpTypePointer Input %9
3490 %19 = OpConstant %9 1
3491 %24 = OpConstant %9 2
3492 %28 = OpTypeInt 64 1
3493 %29 = OpTypeImage %28 1D 0 0 0 2 R64i
3494 %30 = OpTypePointer UniformConstant %29
3495 %31 = OpVariable %30 UniformConstant
3496 %34 = OpVariable %30 UniformConstant
3497 %36 = OpConstant %6 64
3498 %50 = OpTypePointer Image %28
3499 %53 = OpTypeVector %28 4
3500 %55 = OpConstantComposite %10 %19 %19 %19
3501 %4 = OpFunction %2 None %3
3502 %5 = OpLabel
3503 %8 = OpVariable %7 Function
3504 %18 = OpVariable %7 Function
3505 %23 = OpVariable %7 Function
3506 %15 = OpAccessChain %14 %12 %13
3507 %16 = OpLoad %9 %15
3508 %17 = OpBitcast %6 %16
3509 OpStore %8 %17
3510 %20 = OpAccessChain %14 %12 %19
3511 %21 = OpLoad %9 %20
3512 %22 = OpBitcast %6 %21
3513 OpStore %18 %22
3514 %25 = OpAccessChain %14 %12 %24
3515 %26 = OpLoad %9 %25
3516 %27 = OpBitcast %6 %26
3517 OpStore %23 %27
3518 %32 = OpLoad %29 %31
3519 %33 = OpLoad %6 %8
3520 %35 = OpLoad %6 %8
3521 %37 = OpSMod %6 %35 %36
3522 %38 = OpLoad %6 %8
3523 %39 = OpLoad %6 %8
3524 %40 = OpIMul %6 %38 %39
3525 %41 = OpLoad %6 %18
3526 %42 = OpLoad %6 %18
3527 %43 = OpIMul %6 %41 %42
3528 %44 = OpIAdd %6 %40 %43
3529 %45 = OpLoad %6 %23
3530 %46 = OpLoad %6 %23
3531 %47 = OpIMul %6 %45 %46
3532 %48 = OpIAdd %6 %44 %47
3533 %49 = OpSConvert %28 %48
3534 %51 = OpImageTexelPointer %50 %34 %37 %13
3535 %52 = ${OPNAME} %28 %51 %19 %13 ${LASTARG:default=%49}
3536 %54 = OpCompositeConstruct %53 %52 %52 %52 %52
3537 OpImageWrite %32 %33 %54
3538 OpReturn
3539 OpFunctionEnd
3540 )";
3541
3542 const std::string kShader_1d_array_r64ui_end_result = R"(
3543 ; The SPIR-V shader below is based on the following GLSL shader, but OpAtomicIAdd has been
3544 ; replaced with a template parameter and the last argument for it has been made optional.
3545 ;
3546 ;#version 440
3547 ;precision highp uimage1DArray;
3548 ;#extension GL_EXT_shader_explicit_arithmetic_types_int64 : require
3549 ;#extension GL_EXT_shader_image_int64 : require
3550 ;
3551 ;layout (local_size_x = 1, local_size_y = 1, local_size_z = 1) in;
3552 ;layout (r64ui, binding=0) coherent uniform uimage1DArray u_resultImage;
3553 ;
3554 ;void main (void)
3555 ;{
3556 ;   int gx = int(gl_GlobalInvocationID.x);
3557 ;   int gy = int(gl_GlobalInvocationID.y);
3558 ;   int gz = int(gl_GlobalInvocationID.z);
3559 ;   imageAtomicAdd(u_resultImage, ivec2(gx % 64,gy), uint(gx*gx + gy*gy + gz*gz));
3560 ;}
3561 ;
3562 ; SPIR-V
3563 ; Version: 1.3
3564 ; Generator: Khronos Glslang Reference Front End; 8
3565 ; Bound: 56
3566 ; Schema: 0
3567 OpCapability Shader
3568 OpCapability Int64
3569 OpCapability Int64Atomics
3570 OpCapability Image1D
3571 OpCapability Int64ImageEXT
3572 OpExtension "SPV_EXT_shader_image_int64"
3573 %1 = OpExtInstImport "GLSL.std.450"
3574 OpMemoryModel Logical GLSL450
3575 OpEntryPoint GLCompute %4 "main" %12
3576 OpExecutionMode %4 LocalSize 1 1 1
3577 OpDecorate %12 BuiltIn GlobalInvocationId
3578 OpDecorate %31 DescriptorSet 0
3579 OpDecorate %31 Binding 0
3580 OpDecorate %31 Coherent
3581 OpDecorate %55 BuiltIn WorkgroupSize
3582 %2 = OpTypeVoid
3583 %3 = OpTypeFunction %2
3584 %6 = OpTypeInt 32 1
3585 %7 = OpTypePointer Function %6
3586 %9 = OpTypeInt 32 0
3587 %10 = OpTypeVector %9 3
3588 %11 = OpTypePointer Input %10
3589 %12 = OpVariable %11 Input
3590 %13 = OpConstant %9 0
3591 %14 = OpTypePointer Input %9
3592 %19 = OpConstant %9 1
3593 %24 = OpConstant %9 2
3594 %28 = OpTypeInt 64 0
3595 %29 = OpTypeImage %28 1D 0 1 0 2 R64ui
3596 %30 = OpTypePointer UniformConstant %29
3597 %31 = OpVariable %30 UniformConstant
3598 %33 = OpConstant %6 64
3599 %36 = OpTypeVector %6 2
3600 %49 = OpTypeInt 64 1
3601 %52 = OpTypePointer Image %28
3602 %55 = OpConstantComposite %10 %19 %19 %19
3603 %4 = OpFunction %2 None %3
3604 %5 = OpLabel
3605 %8 = OpVariable %7 Function
3606 %18 = OpVariable %7 Function
3607 %23 = OpVariable %7 Function
3608 %15 = OpAccessChain %14 %12 %13
3609 %16 = OpLoad %9 %15
3610 %17 = OpBitcast %6 %16
3611 OpStore %8 %17
3612 %20 = OpAccessChain %14 %12 %19
3613 %21 = OpLoad %9 %20
3614 %22 = OpBitcast %6 %21
3615 OpStore %18 %22
3616 %25 = OpAccessChain %14 %12 %24
3617 %26 = OpLoad %9 %25
3618 %27 = OpBitcast %6 %26
3619 OpStore %23 %27
3620 %32 = OpLoad %6 %8
3621 %34 = OpSMod %6 %32 %33
3622 %35 = OpLoad %6 %18
3623 %37 = OpCompositeConstruct %36 %34 %35
3624 %38 = OpLoad %6 %8
3625 %39 = OpLoad %6 %8
3626 %40 = OpIMul %6 %38 %39
3627 %41 = OpLoad %6 %18
3628 %42 = OpLoad %6 %18
3629 %43 = OpIMul %6 %41 %42
3630 %44 = OpIAdd %6 %40 %43
3631 %45 = OpLoad %6 %23
3632 %46 = OpLoad %6 %23
3633 %47 = OpIMul %6 %45 %46
3634 %48 = OpIAdd %6 %44 %47
3635 %50 = OpSConvert %49 %48
3636 %51 = OpBitcast %28 %50
3637 %53 = OpImageTexelPointer %52 %31 %37 %13
3638 %54 = ${OPNAME} %28 %53 %19 %13 ${LASTARG:default=%51}
3639 OpReturn
3640 OpFunctionEnd
3641 )";
3642
3643 const std::string kShader_1d_array_r64ui_intermediate_values = R"(
3644 ; The SPIR-V shader below is based on the following GLSL shader, but OpAtomicIAdd has been
3645 ; replaced with a template parameter and the last argument for it has been made optional.
3646 ;
3647 ;#version 440
3648 ;precision highp uimage1DArray;
3649 ;#extension GL_EXT_shader_explicit_arithmetic_types_int64 : require
3650 ;#extension GL_EXT_shader_image_int64 : require
3651 ;
3652 ;layout (local_size_x = 1, local_size_y = 1, local_size_z = 1) in;
3653 ;layout (r64ui, binding=0) coherent uniform uimage1DArray u_resultImage;
3654 ;layout (r64ui, binding=1) writeonly uniform uimage1DArray u_intermValuesImage;
3655 ;
3656 ;void main (void)
3657 ;{
3658 ;int gx = int(gl_GlobalInvocationID.x);
3659 ;int gy = int(gl_GlobalInvocationID.y);
3660 ;int gz = int(gl_GlobalInvocationID.z);
3661 ;imageStore(u_intermValuesImage, ivec2(gx,gy), u64vec4(imageAtomicAdd(u_resultImage, ivec2(gx % 64,gy), uint(gx*gx + gy*gy + gz*gz))));
3662 ;}
3663 ;
3664 ; SPIR-V
3665 ; Version: 1.3
3666 ; Generator: Khronos Glslang Reference Front End; 8
3667 ; Bound: 63
3668 ; Schema: 0
3669 OpCapability Shader
3670 OpCapability Int64
3671 OpCapability Int64Atomics
3672 OpCapability Image1D
3673 OpCapability Int64ImageEXT
3674 OpExtension "SPV_EXT_shader_image_int64"
3675 %1 = OpExtInstImport "GLSL.std.450"
3676 OpMemoryModel Logical GLSL450
3677 OpEntryPoint GLCompute %4 "main" %12
3678 OpExecutionMode %4 LocalSize 1 1 1
3679 OpDecorate %12 BuiltIn GlobalInvocationId
3680 OpDecorate %31 DescriptorSet 0
3681 OpDecorate %31 Binding 1
3682 OpDecorate %31 NonReadable
3683 OpDecorate %37 DescriptorSet 0
3684 OpDecorate %37 Binding 0
3685 OpDecorate %37 Coherent
3686 OpDecorate %62 BuiltIn WorkgroupSize
3687 %2 = OpTypeVoid
3688 %3 = OpTypeFunction %2
3689 %6 = OpTypeInt 32 1
3690 %7 = OpTypePointer Function %6
3691 %9 = OpTypeInt 32 0
3692 %10 = OpTypeVector %9 3
3693 %11 = OpTypePointer Input %10
3694 %12 = OpVariable %11 Input
3695 %13 = OpConstant %9 0
3696 %14 = OpTypePointer Input %9
3697 %19 = OpConstant %9 1
3698 %24 = OpConstant %9 2
3699 %28 = OpTypeInt 64 0
3700 %29 = OpTypeImage %28 1D 0 1 0 2 R64ui
3701 %30 = OpTypePointer UniformConstant %29
3702 %31 = OpVariable %30 UniformConstant
3703 %35 = OpTypeVector %6 2
3704 %37 = OpVariable %30 UniformConstant
3705 %39 = OpConstant %6 64
3706 %54 = OpTypeInt 64 1
3707 %57 = OpTypePointer Image %28
3708 %60 = OpTypeVector %28 4
3709 %62 = OpConstantComposite %10 %19 %19 %19
3710 %4 = OpFunction %2 None %3
3711 %5 = OpLabel
3712 %8 = OpVariable %7 Function
3713 %18 = OpVariable %7 Function
3714 %23 = OpVariable %7 Function
3715 %15 = OpAccessChain %14 %12 %13
3716 %16 = OpLoad %9 %15
3717 %17 = OpBitcast %6 %16
3718 OpStore %8 %17
3719 %20 = OpAccessChain %14 %12 %19
3720 %21 = OpLoad %9 %20
3721 %22 = OpBitcast %6 %21
3722 OpStore %18 %22
3723 %25 = OpAccessChain %14 %12 %24
3724 %26 = OpLoad %9 %25
3725 %27 = OpBitcast %6 %26
3726 OpStore %23 %27
3727 %32 = OpLoad %29 %31
3728 %33 = OpLoad %6 %8
3729 %34 = OpLoad %6 %18
3730 %36 = OpCompositeConstruct %35 %33 %34
3731 %38 = OpLoad %6 %8
3732 %40 = OpSMod %6 %38 %39
3733 %41 = OpLoad %6 %18
3734 %42 = OpCompositeConstruct %35 %40 %41
3735 %43 = OpLoad %6 %8
3736 %44 = OpLoad %6 %8
3737 %45 = OpIMul %6 %43 %44
3738 %46 = OpLoad %6 %18
3739 %47 = OpLoad %6 %18
3740 %48 = OpIMul %6 %46 %47
3741 %49 = OpIAdd %6 %45 %48
3742 %50 = OpLoad %6 %23
3743 %51 = OpLoad %6 %23
3744 %52 = OpIMul %6 %50 %51
3745 %53 = OpIAdd %6 %49 %52
3746 %55 = OpSConvert %54 %53
3747 %56 = OpBitcast %28 %55
3748 %58 = OpImageTexelPointer %57 %37 %42 %13
3749 %59 = ${OPNAME} %28 %58 %19 %13 ${LASTARG:default=%56}
3750 %61 = OpCompositeConstruct %60 %59 %59 %59 %59
3751 OpImageWrite %32 %36 %61
3752 OpReturn
3753 OpFunctionEnd
3754 )";
3755
3756 const std::string kShader_1d_array_r64i_end_result = R"(
3757 ; The SPIR-V shader below is based on the following GLSL shader, but OpAtomicIAdd has been
3758 ; replaced with a template parameter and the last argument for it has been made optional.
3759 ;
3760 ; #version 440
3761 ; precision highp iimage1DArray;
3762 ; #extension GL_EXT_shader_explicit_arithmetic_types_int64 : require
3763 ; #extension GL_EXT_shader_image_int64 : require
3764 ;
3765 ; layout (local_size_x = 1, local_size_y = 1, local_size_z = 1) in;
3766 ; layout (r64i, binding=0) coherent uniform iimage1DArray u_resultImage;
3767 ;
3768 ; void main (void)
3769 ; {
3770 ;    int gx = int(gl_GlobalInvocationID.x);
3771 ;    int gy = int(gl_GlobalInvocationID.y);
3772 ;    int gz = int(gl_GlobalInvocationID.z);
3773 ;    imageAtomicAdd(u_resultImage, ivec2(gx % 64,gy), int(gx*gx + gy*gy + gz*gz));
3774 ; }
3775 ;
3776 ; SPIR-V
3777 ; Version: 1.3
3778 ; Generator: Khronos Glslang Reference Front End; 8
3779 ; Bound: 54
3780 ; Schema: 0
3781 OpCapability Shader
3782 OpCapability Int64
3783 OpCapability Int64Atomics
3784 OpCapability Image1D
3785 OpCapability Int64ImageEXT
3786 OpExtension "SPV_EXT_shader_image_int64"
3787 %1 = OpExtInstImport "GLSL.std.450"
3788 OpMemoryModel Logical GLSL450
3789 OpEntryPoint GLCompute %4 "main" %12
3790 OpExecutionMode %4 LocalSize 1 1 1
3791 OpDecorate %12 BuiltIn GlobalInvocationId
3792 OpDecorate %31 DescriptorSet 0
3793 OpDecorate %31 Binding 0
3794 OpDecorate %31 Coherent
3795 OpDecorate %53 BuiltIn WorkgroupSize
3796 %2 = OpTypeVoid
3797 %3 = OpTypeFunction %2
3798 %6 = OpTypeInt 32 1
3799 %7 = OpTypePointer Function %6
3800 %9 = OpTypeInt 32 0
3801 %10 = OpTypeVector %9 3
3802 %11 = OpTypePointer Input %10
3803 %12 = OpVariable %11 Input
3804 %13 = OpConstant %9 0
3805 %14 = OpTypePointer Input %9
3806 %19 = OpConstant %9 1
3807 %24 = OpConstant %9 2
3808 %28 = OpTypeInt 64 1
3809 %29 = OpTypeImage %28 1D 0 1 0 2 R64i
3810 %30 = OpTypePointer UniformConstant %29
3811 %31 = OpVariable %30 UniformConstant
3812 %33 = OpConstant %6 64
3813 %36 = OpTypeVector %6 2
3814 %50 = OpTypePointer Image %28
3815 %53 = OpConstantComposite %10 %19 %19 %19
3816 %4 = OpFunction %2 None %3
3817 %5 = OpLabel
3818 %8 = OpVariable %7 Function
3819 %18 = OpVariable %7 Function
3820 %23 = OpVariable %7 Function
3821 %15 = OpAccessChain %14 %12 %13
3822 %16 = OpLoad %9 %15
3823 %17 = OpBitcast %6 %16
3824 OpStore %8 %17
3825 %20 = OpAccessChain %14 %12 %19
3826 %21 = OpLoad %9 %20
3827 %22 = OpBitcast %6 %21
3828 OpStore %18 %22
3829 %25 = OpAccessChain %14 %12 %24
3830 %26 = OpLoad %9 %25
3831 %27 = OpBitcast %6 %26
3832 OpStore %23 %27
3833 %32 = OpLoad %6 %8
3834 %34 = OpSMod %6 %32 %33
3835 %35 = OpLoad %6 %18
3836 %37 = OpCompositeConstruct %36 %34 %35
3837 %38 = OpLoad %6 %8
3838 %39 = OpLoad %6 %8
3839 %40 = OpIMul %6 %38 %39
3840 %41 = OpLoad %6 %18
3841 %42 = OpLoad %6 %18
3842 %43 = OpIMul %6 %41 %42
3843 %44 = OpIAdd %6 %40 %43
3844 %45 = OpLoad %6 %23
3845 %46 = OpLoad %6 %23
3846 %47 = OpIMul %6 %45 %46
3847 %48 = OpIAdd %6 %44 %47
3848 %49 = OpSConvert %28 %48
3849 %51 = OpImageTexelPointer %50 %31 %37 %13
3850 %52 = ${OPNAME} %28 %51 %19 %13 ${LASTARG:default=%49}
3851 OpReturn
3852 OpFunctionEnd
3853 )";
3854
3855 const std::string kShader_1d_array_r64i_intermediate_values = R"(
3856 ; The SPIR-V shader below is based on the following GLSL shader, but OpAtomicIAdd has been
3857 ; replaced with a template parameter and the last argument for it has been made optional.
3858 ;
3859 ; #version 440
3860 ; precision highp iimage1DArray;
3861 ; #extension GL_EXT_shader_explicit_arithmetic_types_int64 : require
3862 ; #extension GL_EXT_shader_image_int64 : require
3863 ;
3864 ; layout (local_size_x = 1, local_size_y = 1, local_size_z = 1) in;
3865 ; layout (r64i, binding=0) coherent uniform iimage1DArray u_resultImage;
3866 ; layout (r64i, binding=1) writeonly uniform iimage1DArray u_intermValuesImage;
3867 ;
3868 ; void main (void)
3869 ; {
3870 ;    int gx = int(gl_GlobalInvocationID.x);
3871 ;    int gy = int(gl_GlobalInvocationID.y);
3872 ;    int gz = int(gl_GlobalInvocationID.z);
3873 ;    imageStore(u_intermValuesImage, ivec2(gx, gy), i64vec4(imageAtomicAdd(u_resultImage, ivec2(gx % 64, gy), int(gx*gx + gy*gy + gz*gz))));
3874 ; }
3875 ;
3876 ; SPIR-V
3877 ; Version: 1.3
3878 ; Generator: Khronos Glslang Reference Front End; 8
3879 ; Bound: 61
3880 ; Schema: 0
3881 OpCapability Shader
3882 OpCapability Int64
3883 OpCapability Int64Atomics
3884 OpCapability Image1D
3885 OpCapability Int64ImageEXT
3886 OpExtension "SPV_EXT_shader_image_int64"
3887 %1 = OpExtInstImport "GLSL.std.450"
3888 OpMemoryModel Logical GLSL450
3889 OpEntryPoint GLCompute %4 "main" %12
3890 OpExecutionMode %4 LocalSize 1 1 1
3891 OpDecorate %12 BuiltIn GlobalInvocationId
3892 OpDecorate %31 DescriptorSet 0
3893 OpDecorate %31 Binding 1
3894 OpDecorate %31 NonReadable
3895 OpDecorate %37 DescriptorSet 0
3896 OpDecorate %37 Binding 0
3897 OpDecorate %37 Coherent
3898 OpDecorate %60 BuiltIn WorkgroupSize
3899 %2 = OpTypeVoid
3900 %3 = OpTypeFunction %2
3901 %6 = OpTypeInt 32 1
3902 %7 = OpTypePointer Function %6
3903 %9 = OpTypeInt 32 0
3904 %10 = OpTypeVector %9 3
3905 %11 = OpTypePointer Input %10
3906 %12 = OpVariable %11 Input
3907 %13 = OpConstant %9 0
3908 %14 = OpTypePointer Input %9
3909 %19 = OpConstant %9 1
3910 %24 = OpConstant %9 2
3911 %28 = OpTypeInt 64 1
3912 %29 = OpTypeImage %28 1D 0 1 0 2 R64i
3913 %30 = OpTypePointer UniformConstant %29
3914 %31 = OpVariable %30 UniformConstant
3915 %35 = OpTypeVector %6 2
3916 %37 = OpVariable %30 UniformConstant
3917 %39 = OpConstant %6 64
3918 %55 = OpTypePointer Image %28
3919 %58 = OpTypeVector %28 4
3920 %60 = OpConstantComposite %10 %19 %19 %19
3921 %4 = OpFunction %2 None %3
3922 %5 = OpLabel
3923 %8 = OpVariable %7 Function
3924 %18 = OpVariable %7 Function
3925 %23 = OpVariable %7 Function
3926 %15 = OpAccessChain %14 %12 %13
3927 %16 = OpLoad %9 %15
3928 %17 = OpBitcast %6 %16
3929 OpStore %8 %17
3930 %20 = OpAccessChain %14 %12 %19
3931 %21 = OpLoad %9 %20
3932 %22 = OpBitcast %6 %21
3933 OpStore %18 %22
3934 %25 = OpAccessChain %14 %12 %24
3935 %26 = OpLoad %9 %25
3936 %27 = OpBitcast %6 %26
3937 OpStore %23 %27
3938 %32 = OpLoad %29 %31
3939 %33 = OpLoad %6 %8
3940 %34 = OpLoad %6 %18
3941 %36 = OpCompositeConstruct %35 %33 %34
3942 %38 = OpLoad %6 %8
3943 %40 = OpSMod %6 %38 %39
3944 %41 = OpLoad %6 %18
3945 %42 = OpCompositeConstruct %35 %40 %41
3946 %43 = OpLoad %6 %8
3947 %44 = OpLoad %6 %8
3948 %45 = OpIMul %6 %43 %44
3949 %46 = OpLoad %6 %18
3950 %47 = OpLoad %6 %18
3951 %48 = OpIMul %6 %46 %47
3952 %49 = OpIAdd %6 %45 %48
3953 %50 = OpLoad %6 %23
3954 %51 = OpLoad %6 %23
3955 %52 = OpIMul %6 %50 %51
3956 %53 = OpIAdd %6 %49 %52
3957 %54 = OpSConvert %28 %53
3958 %56 = OpImageTexelPointer %55 %37 %42 %13
3959 %57 = ${OPNAME} %28 %56 %19 %13 ${LASTARG:default=%54}
3960 %59 = OpCompositeConstruct %58 %57 %57 %57 %57
3961 OpImageWrite %32 %36 %59
3962 OpReturn
3963 OpFunctionEnd
3964 )";
3965
3966 const std::string kShader_2d_r64ui_end_result = R"(
3967 ; The SPIR-V shader below is based on the following GLSL shader, but OpAtomicIAdd has been
3968 ; replaced with a template parameter and the last argument for it has been made optional.
3969 ;
3970 ; #version 440
3971 ; precision highp uimage2D;
3972 ; #extension GL_EXT_shader_explicit_arithmetic_types_int64 : require
3973 ; #extension GL_EXT_shader_image_int64 : require
3974 ;
3975 ; layout (local_size_x = 1, local_size_y = 1, local_size_z = 1) in;
3976 ; layout (r64ui, binding=0) coherent uniform uimage2D u_resultImage;
3977 ;
3978 ; void main (void)
3979 ; {
3980 ;    int gx = int(gl_GlobalInvocationID.x);
3981 ;    int gy = int(gl_GlobalInvocationID.y);
3982 ;    int gz = int(gl_GlobalInvocationID.z);
3983 ;    imageAtomicAdd(u_resultImage, ivec2(gx % 64,gy), uint(gx*gx + gy*gy + gz*gz));
3984 ; }
3985 ;
3986 ; SPIR-V
3987 ; Version: 1.3
3988 ; Generator: Khronos Glslang Reference Front End; 8
3989 ; Bound: 56
3990 ; Schema: 0
3991 OpCapability Shader
3992 OpCapability Int64
3993 OpCapability Int64Atomics
3994 OpCapability Int64ImageEXT
3995 OpExtension "SPV_EXT_shader_image_int64"
3996 %1 = OpExtInstImport "GLSL.std.450"
3997 OpMemoryModel Logical GLSL450
3998 OpEntryPoint GLCompute %4 "main" %12
3999 OpExecutionMode %4 LocalSize 1 1 1
4000 OpDecorate %12 BuiltIn GlobalInvocationId
4001 OpDecorate %31 DescriptorSet 0
4002 OpDecorate %31 Binding 0
4003 OpDecorate %31 Coherent
4004 OpDecorate %55 BuiltIn WorkgroupSize
4005 %2 = OpTypeVoid
4006 %3 = OpTypeFunction %2
4007 %6 = OpTypeInt 32 1
4008 %7 = OpTypePointer Function %6
4009 %9 = OpTypeInt 32 0
4010 %10 = OpTypeVector %9 3
4011 %11 = OpTypePointer Input %10
4012 %12 = OpVariable %11 Input
4013 %13 = OpConstant %9 0
4014 %14 = OpTypePointer Input %9
4015 %19 = OpConstant %9 1
4016 %24 = OpConstant %9 2
4017 %28 = OpTypeInt 64 0
4018 %29 = OpTypeImage %28 2D 0 0 0 2 R64ui
4019 %30 = OpTypePointer UniformConstant %29
4020 %31 = OpVariable %30 UniformConstant
4021 %33 = OpConstant %6 64
4022 %36 = OpTypeVector %6 2
4023 %49 = OpTypeInt 64 1
4024 %52 = OpTypePointer Image %28
4025 %55 = OpConstantComposite %10 %19 %19 %19
4026 %4 = OpFunction %2 None %3
4027 %5 = OpLabel
4028 %8 = OpVariable %7 Function
4029 %18 = OpVariable %7 Function
4030 %23 = OpVariable %7 Function
4031 %15 = OpAccessChain %14 %12 %13
4032 %16 = OpLoad %9 %15
4033 %17 = OpBitcast %6 %16
4034 OpStore %8 %17
4035 %20 = OpAccessChain %14 %12 %19
4036 %21 = OpLoad %9 %20
4037 %22 = OpBitcast %6 %21
4038 OpStore %18 %22
4039 %25 = OpAccessChain %14 %12 %24
4040 %26 = OpLoad %9 %25
4041 %27 = OpBitcast %6 %26
4042 OpStore %23 %27
4043 %32 = OpLoad %6 %8
4044 %34 = OpSMod %6 %32 %33
4045 %35 = OpLoad %6 %18
4046 %37 = OpCompositeConstruct %36 %34 %35
4047 %38 = OpLoad %6 %8
4048 %39 = OpLoad %6 %8
4049 %40 = OpIMul %6 %38 %39
4050 %41 = OpLoad %6 %18
4051 %42 = OpLoad %6 %18
4052 %43 = OpIMul %6 %41 %42
4053 %44 = OpIAdd %6 %40 %43
4054 %45 = OpLoad %6 %23
4055 %46 = OpLoad %6 %23
4056 %47 = OpIMul %6 %45 %46
4057 %48 = OpIAdd %6 %44 %47
4058 %50 = OpSConvert %49 %48
4059 %51 = OpBitcast %28 %50
4060 %53 = OpImageTexelPointer %52 %31 %37 %13
4061 %54 = ${OPNAME} %28 %53 %19 %13 ${LASTARG:default=%51}
4062 OpReturn
4063 OpFunctionEnd
4064 )";
4065
4066 const std::string kShader_2d_r64ui_intermediate_values = R"(
4067 ; The SPIR-V shader below is based on the following GLSL shader, but OpAtomicIAdd has been
4068 ; replaced with a template parameter and the last argument for it has been made optional.
4069 ;
4070 ; #version 440
4071 ; precision highp uimage2D;
4072 ; #extension GL_EXT_shader_explicit_arithmetic_types_int64 : require
4073 ; #extension GL_EXT_shader_image_int64 : require
4074 ; layout (r64ui, binding=0) coherent uniform uimage2D u_resultImage;
4075 ; layout (r64ui, binding=1) writeonly uniform uimage2D u_intermValuesImage;
4076 ;
4077 ; layout (local_size_x = 1, local_size_y = 1, local_size_z = 1) in;
4078 ;
4079 ; void main (void)
4080 ; {
4081 ;    int gx = int(gl_GlobalInvocationID.x);
4082 ;    int gy = int(gl_GlobalInvocationID.y);
4083 ;    int gz = int(gl_GlobalInvocationID.z);
4084 ;    imageStore(u_intermValuesImage, ivec2(gx,gy), u64vec4(imageAtomicAdd(u_resultImage, ivec2(gx % 64,gy), uint(gx*gx + gy*gy + gz*gz))));
4085 ; }
4086 ;
4087 ; SPIR-V
4088 ; Version: 1.3
4089 ; Generator: Khronos Glslang Reference Front End; 8
4090 ; Bound: 63
4091 ; Schema: 0
4092 OpCapability Shader
4093 OpCapability Int64
4094 OpCapability Int64Atomics
4095 OpCapability Int64ImageEXT
4096 OpExtension "SPV_EXT_shader_image_int64"
4097 %1 = OpExtInstImport "GLSL.std.450"
4098 OpMemoryModel Logical GLSL450
4099 OpEntryPoint GLCompute %4 "main" %12
4100 OpExecutionMode %4 LocalSize 1 1 1
4101 OpDecorate %12 BuiltIn GlobalInvocationId
4102 OpDecorate %31 DescriptorSet 0
4103 OpDecorate %31 Binding 1
4104 OpDecorate %31 NonReadable
4105 OpDecorate %37 DescriptorSet 0
4106 OpDecorate %37 Binding 0
4107 OpDecorate %37 Coherent
4108 OpDecorate %62 BuiltIn WorkgroupSize
4109 %2 = OpTypeVoid
4110 %3 = OpTypeFunction %2
4111 %6 = OpTypeInt 32 1
4112 %7 = OpTypePointer Function %6
4113 %9 = OpTypeInt 32 0
4114 %10 = OpTypeVector %9 3
4115 %11 = OpTypePointer Input %10
4116 %12 = OpVariable %11 Input
4117 %13 = OpConstant %9 0
4118 %14 = OpTypePointer Input %9
4119 %19 = OpConstant %9 1
4120 %24 = OpConstant %9 2
4121 %28 = OpTypeInt 64 0
4122 %29 = OpTypeImage %28 2D 0 0 0 2 R64ui
4123 %30 = OpTypePointer UniformConstant %29
4124 %31 = OpVariable %30 UniformConstant
4125 %35 = OpTypeVector %6 2
4126 %37 = OpVariable %30 UniformConstant
4127 %39 = OpConstant %6 64
4128 %54 = OpTypeInt 64 1
4129 %57 = OpTypePointer Image %28
4130 %60 = OpTypeVector %28 4
4131 %62 = OpConstantComposite %10 %19 %19 %19
4132 %4 = OpFunction %2 None %3
4133 %5 = OpLabel
4134 %8 = OpVariable %7 Function
4135 %18 = OpVariable %7 Function
4136 %23 = OpVariable %7 Function
4137 %15 = OpAccessChain %14 %12 %13
4138 %16 = OpLoad %9 %15
4139 %17 = OpBitcast %6 %16
4140 OpStore %8 %17
4141 %20 = OpAccessChain %14 %12 %19
4142 %21 = OpLoad %9 %20
4143 %22 = OpBitcast %6 %21
4144 OpStore %18 %22
4145 %25 = OpAccessChain %14 %12 %24
4146 %26 = OpLoad %9 %25
4147 %27 = OpBitcast %6 %26
4148 OpStore %23 %27
4149 %32 = OpLoad %29 %31
4150 %33 = OpLoad %6 %8
4151 %34 = OpLoad %6 %18
4152 %36 = OpCompositeConstruct %35 %33 %34
4153 %38 = OpLoad %6 %8
4154 %40 = OpSMod %6 %38 %39
4155 %41 = OpLoad %6 %18
4156 %42 = OpCompositeConstruct %35 %40 %41
4157 %43 = OpLoad %6 %8
4158 %44 = OpLoad %6 %8
4159 %45 = OpIMul %6 %43 %44
4160 %46 = OpLoad %6 %18
4161 %47 = OpLoad %6 %18
4162 %48 = OpIMul %6 %46 %47
4163 %49 = OpIAdd %6 %45 %48
4164 %50 = OpLoad %6 %23
4165 %51 = OpLoad %6 %23
4166 %52 = OpIMul %6 %50 %51
4167 %53 = OpIAdd %6 %49 %52
4168 %55 = OpSConvert %54 %53
4169 %56 = OpBitcast %28 %55
4170 %58 = OpImageTexelPointer %57 %37 %42 %13
4171 %59 = ${OPNAME} %28 %58 %19 %13 ${LASTARG:default=%56}
4172 %61 = OpCompositeConstruct %60 %59 %59 %59 %59
4173 OpImageWrite %32 %36 %61
4174 OpReturn
4175 OpFunctionEnd
4176 )";
4177
4178 const std::string kShader_2d_r64i_end_result = R"(
4179 ; The SPIR-V shader below is based on the following GLSL shader, but OpAtomicIAdd has been
4180 ; replaced with a template parameter and the last argument for it has been made optional.
4181 ;
4182 ; #version 440
4183 ; precision highp iimage2D;
4184 ; #extension GL_EXT_shader_explicit_arithmetic_types_int64 : require
4185 ; #extension GL_EXT_shader_image_int64 : require
4186 ;
4187 ; layout (local_size_x = 1, local_size_y = 1, local_size_z = 1) in;
4188 ; layout (r64i, binding=0) coherent uniform iimage2D u_resultImage;
4189 ;
4190 ; void main (void)
4191 ; {
4192 ;    int gx = int(gl_GlobalInvocationID.x);
4193 ;    int gy = int(gl_GlobalInvocationID.y);
4194 ;    int gz = int(gl_GlobalInvocationID.z);
4195 ;    imageAtomicAdd(u_resultImage, ivec2(gx % 64,gy), int(gx*gx + gy*gy + gz*gz));
4196 ; }
4197 ;
4198 ; SPIR-V
4199 ; Version: 1.3
4200 ; Generator: Khronos Glslang Reference Front End; 8
4201 ; Bound: 54
4202 ; Schema: 0
4203 OpCapability Shader
4204 OpCapability Int64
4205 OpCapability Int64Atomics
4206 OpCapability Int64ImageEXT
4207 OpExtension "SPV_EXT_shader_image_int64"
4208 %1 = OpExtInstImport "GLSL.std.450"
4209 OpMemoryModel Logical GLSL450
4210 OpEntryPoint GLCompute %4 "main" %12
4211 OpExecutionMode %4 LocalSize 1 1 1
4212 OpDecorate %12 BuiltIn GlobalInvocationId
4213 OpDecorate %31 DescriptorSet 0
4214 OpDecorate %31 Binding 0
4215 OpDecorate %31 Coherent
4216 OpDecorate %53 BuiltIn WorkgroupSize
4217 %2 = OpTypeVoid
4218 %3 = OpTypeFunction %2
4219 %6 = OpTypeInt 32 1
4220 %7 = OpTypePointer Function %6
4221 %9 = OpTypeInt 32 0
4222 %10 = OpTypeVector %9 3
4223 %11 = OpTypePointer Input %10
4224 %12 = OpVariable %11 Input
4225 %13 = OpConstant %9 0
4226 %14 = OpTypePointer Input %9
4227 %19 = OpConstant %9 1
4228 %24 = OpConstant %9 2
4229 %28 = OpTypeInt 64 1
4230 %29 = OpTypeImage %28 2D 0 0 0 2 R64i
4231 %30 = OpTypePointer UniformConstant %29
4232 %31 = OpVariable %30 UniformConstant
4233 %33 = OpConstant %6 64
4234 %36 = OpTypeVector %6 2
4235 %50 = OpTypePointer Image %28
4236 %53 = OpConstantComposite %10 %19 %19 %19
4237 %4 = OpFunction %2 None %3
4238 %5 = OpLabel
4239 %8 = OpVariable %7 Function
4240 %18 = OpVariable %7 Function
4241 %23 = OpVariable %7 Function
4242 %15 = OpAccessChain %14 %12 %13
4243 %16 = OpLoad %9 %15
4244 %17 = OpBitcast %6 %16
4245 OpStore %8 %17
4246 %20 = OpAccessChain %14 %12 %19
4247 %21 = OpLoad %9 %20
4248 %22 = OpBitcast %6 %21
4249 OpStore %18 %22
4250 %25 = OpAccessChain %14 %12 %24
4251 %26 = OpLoad %9 %25
4252 %27 = OpBitcast %6 %26
4253 OpStore %23 %27
4254 %32 = OpLoad %6 %8
4255 %34 = OpSMod %6 %32 %33
4256 %35 = OpLoad %6 %18
4257 %37 = OpCompositeConstruct %36 %34 %35
4258 %38 = OpLoad %6 %8
4259 %39 = OpLoad %6 %8
4260 %40 = OpIMul %6 %38 %39
4261 %41 = OpLoad %6 %18
4262 %42 = OpLoad %6 %18
4263 %43 = OpIMul %6 %41 %42
4264 %44 = OpIAdd %6 %40 %43
4265 %45 = OpLoad %6 %23
4266 %46 = OpLoad %6 %23
4267 %47 = OpIMul %6 %45 %46
4268 %48 = OpIAdd %6 %44 %47
4269 %49 = OpSConvert %28 %48
4270 %51 = OpImageTexelPointer %50 %31 %37 %13
4271 %52 = ${OPNAME} %28 %51 %19 %13 ${LASTARG:default=%49}
4272 OpReturn
4273 OpFunctionEnd
4274 )";
4275
4276 const std::string kShader_2d_r64i_intermediate_values = R"(
4277 ; The SPIR-V shader below is based on the following GLSL shader, but OpAtomicIAdd has been
4278 ; replaced with a template parameter and the last argument for it has been made optional.
4279 ;
4280 ; #version 440
4281 ; precision highp iimage2D;
4282 ; #extension GL_EXT_shader_explicit_arithmetic_types_int64 : require
4283 ; #extension GL_EXT_shader_image_int64 : require
4284 ;
4285 ; layout (local_size_x = 1, local_size_y = 1, local_size_z = 1) in;
4286 ; layout (r64i, binding=0) coherent uniform iimage2D u_resultImage;
4287 ; layout (r64i, binding=1) writeonly uniform iimage2D u_intermValuesImage;
4288 ;
4289 ; void main (void)
4290 ; {
4291 ;    int gx = int(gl_GlobalInvocationID.x);
4292 ;    int gy = int(gl_GlobalInvocationID.y);
4293 ;    int gz = int(gl_GlobalInvocationID.z);
4294 ;    imageStore(u_intermValuesImage, ivec2(gx, gy), i64vec4(imageAtomicAdd(u_resultImage, ivec2(gx%64, gy), int(gx*gx + gy*gy + gz*gz))));
4295 ; }
4296 ;
4297 ; SPIR-V
4298 ; Version: 1.3
4299 ; Generator: Khronos Glslang Reference Front End; 8
4300 ; Bound: 61
4301 ; Schema: 0
4302 OpCapability Shader
4303 OpCapability Int64
4304 OpCapability Int64Atomics
4305 OpCapability Int64ImageEXT
4306 OpExtension "SPV_EXT_shader_image_int64"
4307 %1 = OpExtInstImport "GLSL.std.450"
4308 OpMemoryModel Logical GLSL450
4309 OpEntryPoint GLCompute %4 "main" %12
4310 OpExecutionMode %4 LocalSize 1 1 1
4311 OpDecorate %12 BuiltIn GlobalInvocationId
4312 OpDecorate %31 DescriptorSet 0
4313 OpDecorate %31 Binding 1
4314 OpDecorate %31 NonReadable
4315 OpDecorate %37 DescriptorSet 0
4316 OpDecorate %37 Binding 0
4317 OpDecorate %37 Coherent
4318 OpDecorate %60 BuiltIn WorkgroupSize
4319 %2 = OpTypeVoid
4320 %3 = OpTypeFunction %2
4321 %6 = OpTypeInt 32 1
4322 %7 = OpTypePointer Function %6
4323 %9 = OpTypeInt 32 0
4324 %10 = OpTypeVector %9 3
4325 %11 = OpTypePointer Input %10
4326 %12 = OpVariable %11 Input
4327 %13 = OpConstant %9 0
4328 %14 = OpTypePointer Input %9
4329 %19 = OpConstant %9 1
4330 %24 = OpConstant %9 2
4331 %28 = OpTypeInt 64 1
4332 %29 = OpTypeImage %28 2D 0 0 0 2 R64i
4333 %30 = OpTypePointer UniformConstant %29
4334 %31 = OpVariable %30 UniformConstant
4335 %35 = OpTypeVector %6 2
4336 %37 = OpVariable %30 UniformConstant
4337 %39 = OpConstant %6 64
4338 %55 = OpTypePointer Image %28
4339 %58 = OpTypeVector %28 4
4340 %60 = OpConstantComposite %10 %19 %19 %19
4341 %4 = OpFunction %2 None %3
4342 %5 = OpLabel
4343 %8 = OpVariable %7 Function
4344 %18 = OpVariable %7 Function
4345 %23 = OpVariable %7 Function
4346 %15 = OpAccessChain %14 %12 %13
4347 %16 = OpLoad %9 %15
4348 %17 = OpBitcast %6 %16
4349 OpStore %8 %17
4350 %20 = OpAccessChain %14 %12 %19
4351 %21 = OpLoad %9 %20
4352 %22 = OpBitcast %6 %21
4353 OpStore %18 %22
4354 %25 = OpAccessChain %14 %12 %24
4355 %26 = OpLoad %9 %25
4356 %27 = OpBitcast %6 %26
4357 OpStore %23 %27
4358 %32 = OpLoad %29 %31
4359 %33 = OpLoad %6 %8
4360 %34 = OpLoad %6 %18
4361 %36 = OpCompositeConstruct %35 %33 %34
4362 %38 = OpLoad %6 %8
4363 %40 = OpSMod %6 %38 %39
4364 %41 = OpLoad %6 %18
4365 %42 = OpCompositeConstruct %35 %40 %41
4366 %43 = OpLoad %6 %8
4367 %44 = OpLoad %6 %8
4368 %45 = OpIMul %6 %43 %44
4369 %46 = OpLoad %6 %18
4370 %47 = OpLoad %6 %18
4371 %48 = OpIMul %6 %46 %47
4372 %49 = OpIAdd %6 %45 %48
4373 %50 = OpLoad %6 %23
4374 %51 = OpLoad %6 %23
4375 %52 = OpIMul %6 %50 %51
4376 %53 = OpIAdd %6 %49 %52
4377 %54 = OpSConvert %28 %53
4378 %56 = OpImageTexelPointer %55 %37 %42 %13
4379 %57 = ${OPNAME} %28 %56 %19 %13 ${LASTARG:default=%54}
4380 %59 = OpCompositeConstruct %58 %57 %57 %57 %57
4381 OpImageWrite %32 %36 %59
4382 OpReturn
4383 OpFunctionEnd
4384 )";
4385
4386 const std::string kShader_2d_array_r64ui_end_result = R"(
4387 ; The SPIR-V shader below is based on the following GLSL shader, but OpAtomicIAdd has been
4388 ; replaced with a template parameter and the last argument for it has been made optional.
4389 ;
4390 ; #version 440
4391 ; precision highp uimage2DArray;
4392 ; #extension GL_EXT_shader_explicit_arithmetic_types_int64 : require
4393 ; #extension GL_EXT_shader_image_int64 : require
4394 ;
4395 ; layout (local_size_x = 1, local_size_y = 1, local_size_z = 1) in;
4396 ; layout (r64ui, binding=0) coherent uniform uimage2DArray u_resultImage;
4397 ;
4398 ; void main (void)
4399 ; {
4400 ;    int gx = int(gl_GlobalInvocationID.x);
4401 ;    int gy = int(gl_GlobalInvocationID.y);
4402 ;    int gz = int(gl_GlobalInvocationID.z);
4403 ;    imageAtomicAdd(u_resultImage, ivec3(gx%64, gy, gz), uint(gx*gx + gy*gy + gz*gz));
4404 ; }
4405 ;
4406 ; SPIR-V
4407 ; Version: 1.3
4408 ; Generator: Khronos Glslang Reference Front End; 8
4409 ; Bound: 57
4410 ; Schema: 0
4411 OpCapability Shader
4412 OpCapability Int64
4413 OpCapability Int64Atomics
4414 OpCapability Int64ImageEXT
4415 OpExtension "SPV_EXT_shader_image_int64"
4416 %1 = OpExtInstImport "GLSL.std.450"
4417 OpMemoryModel Logical GLSL450
4418 OpEntryPoint GLCompute %4 "main" %12
4419 OpExecutionMode %4 LocalSize 1 1 1
4420 OpDecorate %12 BuiltIn GlobalInvocationId
4421 OpDecorate %31 DescriptorSet 0
4422 OpDecorate %31 Binding 0
4423 OpDecorate %31 Coherent
4424 OpDecorate %56 BuiltIn WorkgroupSize
4425 %2 = OpTypeVoid
4426 %3 = OpTypeFunction %2
4427 %6 = OpTypeInt 32 1
4428 %7 = OpTypePointer Function %6
4429 %9 = OpTypeInt 32 0
4430 %10 = OpTypeVector %9 3
4431 %11 = OpTypePointer Input %10
4432 %12 = OpVariable %11 Input
4433 %13 = OpConstant %9 0
4434 %14 = OpTypePointer Input %9
4435 %19 = OpConstant %9 1
4436 %24 = OpConstant %9 2
4437 %28 = OpTypeInt 64 0
4438 %29 = OpTypeImage %28 2D 0 1 0 2 R64ui
4439 %30 = OpTypePointer UniformConstant %29
4440 %31 = OpVariable %30 UniformConstant
4441 %33 = OpConstant %6 64
4442 %37 = OpTypeVector %6 3
4443 %50 = OpTypeInt 64 1
4444 %53 = OpTypePointer Image %28
4445 %56 = OpConstantComposite %10 %19 %19 %19
4446 %4 = OpFunction %2 None %3
4447 %5 = OpLabel
4448 %8 = OpVariable %7 Function
4449 %18 = OpVariable %7 Function
4450 %23 = OpVariable %7 Function
4451 %15 = OpAccessChain %14 %12 %13
4452 %16 = OpLoad %9 %15
4453 %17 = OpBitcast %6 %16
4454 OpStore %8 %17
4455 %20 = OpAccessChain %14 %12 %19
4456 %21 = OpLoad %9 %20
4457 %22 = OpBitcast %6 %21
4458 OpStore %18 %22
4459 %25 = OpAccessChain %14 %12 %24
4460 %26 = OpLoad %9 %25
4461 %27 = OpBitcast %6 %26
4462 OpStore %23 %27
4463 %32 = OpLoad %6 %8
4464 %34 = OpSMod %6 %32 %33
4465 %35 = OpLoad %6 %18
4466 %36 = OpLoad %6 %23
4467 %38 = OpCompositeConstruct %37 %34 %35 %36
4468 %39 = OpLoad %6 %8
4469 %40 = OpLoad %6 %8
4470 %41 = OpIMul %6 %39 %40
4471 %42 = OpLoad %6 %18
4472 %43 = OpLoad %6 %18
4473 %44 = OpIMul %6 %42 %43
4474 %45 = OpIAdd %6 %41 %44
4475 %46 = OpLoad %6 %23
4476 %47 = OpLoad %6 %23
4477 %48 = OpIMul %6 %46 %47
4478 %49 = OpIAdd %6 %45 %48
4479 %51 = OpSConvert %50 %49
4480 %52 = OpBitcast %28 %51
4481 %54 = OpImageTexelPointer %53 %31 %38 %13
4482 %55 = ${OPNAME} %28 %54 %19 %13 ${LASTARG:default=%52}
4483 OpReturn
4484 OpFunctionEnd
4485 )";
4486
4487 const std::string kShader_2d_array_r64ui_intermediate_values = R"(
4488 ; The SPIR-V shader below is based on the following GLSL shader, but OpAtomicIAdd has been
4489 ; replaced with a template parameter and the last argument for it has been made optional.
4490 ;
4491 ; #version 440
4492 ; precision highp uimage2DArray;
4493 ; #extension GL_EXT_shader_explicit_arithmetic_types_int64 : require
4494 ; #extension GL_EXT_shader_image_int64 : require
4495 ;
4496 ; layout (local_size_x = 1, local_size_y = 1, local_size_z = 1) in;
4497 ; layout (r64ui, binding=0) coherent uniform uimage2DArray u_resultImage;
4498 ; layout (r64ui, binding=1) writeonly uniform uimage2DArray u_intermValuesImage;
4499 ;
4500 ; void main (void)
4501 ; {
4502 ;    int gx = int(gl_GlobalInvocationID.x);
4503 ;    int gy = int(gl_GlobalInvocationID.y);
4504 ;    int gz = int(gl_GlobalInvocationID.z);
4505 ;    imageStore(u_intermValuesImage, ivec3(gx, gy, gz), u64vec4(imageAtomicAdd(u_resultImage, ivec3(gx%64, gy, gz), uint(gx*gx + gy*gy + gz*gz))));
4506 ; }
4507 ;
4508 ; SPIR-V
4509 ; Version: 1.3
4510 ; Generator: Khronos Glslang Reference Front End; 8
4511 ; Bound: 65
4512 ; Schema: 0
4513 OpCapability Shader
4514 OpCapability Int64
4515 OpCapability Int64Atomics
4516 OpCapability Int64ImageEXT
4517 OpExtension "SPV_EXT_shader_image_int64"
4518 %1 = OpExtInstImport "GLSL.std.450"
4519 OpMemoryModel Logical GLSL450
4520 OpEntryPoint GLCompute %4 "main" %12
4521 OpExecutionMode %4 LocalSize 1 1 1
4522 OpDecorate %12 BuiltIn GlobalInvocationId
4523 OpDecorate %31 DescriptorSet 0
4524 OpDecorate %31 Binding 1
4525 OpDecorate %31 NonReadable
4526 OpDecorate %38 DescriptorSet 0
4527 OpDecorate %38 Binding 0
4528 OpDecorate %38 Coherent
4529 OpDecorate %64 BuiltIn WorkgroupSize
4530 %2 = OpTypeVoid
4531 %3 = OpTypeFunction %2
4532 %6 = OpTypeInt 32 1
4533 %7 = OpTypePointer Function %6
4534 %9 = OpTypeInt 32 0
4535 %10 = OpTypeVector %9 3
4536 %11 = OpTypePointer Input %10
4537 %12 = OpVariable %11 Input
4538 %13 = OpConstant %9 0
4539 %14 = OpTypePointer Input %9
4540 %19 = OpConstant %9 1
4541 %24 = OpConstant %9 2
4542 %28 = OpTypeInt 64 0
4543 %29 = OpTypeImage %28 2D 0 1 0 2 R64ui
4544 %30 = OpTypePointer UniformConstant %29
4545 %31 = OpVariable %30 UniformConstant
4546 %36 = OpTypeVector %6 3
4547 %38 = OpVariable %30 UniformConstant
4548 %40 = OpConstant %6 64
4549 %56 = OpTypeInt 64 1
4550 %59 = OpTypePointer Image %28
4551 %62 = OpTypeVector %28 4
4552 %64 = OpConstantComposite %10 %19 %19 %19
4553 %4 = OpFunction %2 None %3
4554 %5 = OpLabel
4555 %8 = OpVariable %7 Function
4556 %18 = OpVariable %7 Function
4557 %23 = OpVariable %7 Function
4558 %15 = OpAccessChain %14 %12 %13
4559 %16 = OpLoad %9 %15
4560 %17 = OpBitcast %6 %16
4561 OpStore %8 %17
4562 %20 = OpAccessChain %14 %12 %19
4563 %21 = OpLoad %9 %20
4564 %22 = OpBitcast %6 %21
4565 OpStore %18 %22
4566 %25 = OpAccessChain %14 %12 %24
4567 %26 = OpLoad %9 %25
4568 %27 = OpBitcast %6 %26
4569 OpStore %23 %27
4570 %32 = OpLoad %29 %31
4571 %33 = OpLoad %6 %8
4572 %34 = OpLoad %6 %18
4573 %35 = OpLoad %6 %23
4574 %37 = OpCompositeConstruct %36 %33 %34 %35
4575 %39 = OpLoad %6 %8
4576 %41 = OpSMod %6 %39 %40
4577 %42 = OpLoad %6 %18
4578 %43 = OpLoad %6 %23
4579 %44 = OpCompositeConstruct %36 %41 %42 %43
4580 %45 = OpLoad %6 %8
4581 %46 = OpLoad %6 %8
4582 %47 = OpIMul %6 %45 %46
4583 %48 = OpLoad %6 %18
4584 %49 = OpLoad %6 %18
4585 %50 = OpIMul %6 %48 %49
4586 %51 = OpIAdd %6 %47 %50
4587 %52 = OpLoad %6 %23
4588 %53 = OpLoad %6 %23
4589 %54 = OpIMul %6 %52 %53
4590 %55 = OpIAdd %6 %51 %54
4591 %57 = OpSConvert %56 %55
4592 %58 = OpBitcast %28 %57
4593 %60 = OpImageTexelPointer %59 %38 %44 %13
4594 %61 = ${OPNAME} %28 %60 %19 %13 ${LASTARG:default=%58}
4595 %63 = OpCompositeConstruct %62 %61 %61 %61 %61
4596 OpImageWrite %32 %37 %63
4597 OpReturn
4598 OpFunctionEnd
4599 )";
4600
4601 const std::string kShader_2d_array_r64i_end_result = R"(
4602 ; The SPIR-V shader below is based on the following GLSL shader, but OpAtomicIAdd has been
4603 ; replaced with a template parameter and the last argument for it has been made optional.
4604 ;
4605 ; #version 440
4606 ; precision highp iimage2DArray;
4607 ; #extension GL_EXT_shader_explicit_arithmetic_types_int64 : require
4608 ; #extension GL_EXT_shader_image_int64 : require
4609 ;
4610 ; layout (local_size_x = 1, local_size_y = 1, local_size_z = 1) in;
4611 ; layout (r64i, binding=0) coherent uniform iimage2DArray u_resultImage;
4612 ;
4613 ; void main (void)
4614 ; {
4615 ;    int gx = int(gl_GlobalInvocationID.x);
4616 ;    int gy = int(gl_GlobalInvocationID.y);
4617 ;    int gz = int(gl_GlobalInvocationID.z);
4618 ;    imageAtomicAdd(u_resultImage, ivec3(gx%64, gy, gz), int(gx*gx + gy*gy + gz*gz));
4619 ; }
4620 ;
4621 ; SPIR-V
4622 ; Version: 1.3
4623 ; Generator: Khronos Glslang Reference Front End; 8
4624 ; Bound: 55
4625 ; Schema: 0
4626 OpCapability Shader
4627 OpCapability Int64
4628 OpCapability Int64Atomics
4629 OpCapability Int64ImageEXT
4630 OpExtension "SPV_EXT_shader_image_int64"
4631 %1 = OpExtInstImport "GLSL.std.450"
4632 OpMemoryModel Logical GLSL450
4633 OpEntryPoint GLCompute %4 "main" %12
4634 OpExecutionMode %4 LocalSize 1 1 1
4635 OpDecorate %12 BuiltIn GlobalInvocationId
4636 OpDecorate %31 DescriptorSet 0
4637 OpDecorate %31 Binding 0
4638 OpDecorate %31 Coherent
4639 OpDecorate %54 BuiltIn WorkgroupSize
4640 %2 = OpTypeVoid
4641 %3 = OpTypeFunction %2
4642 %6 = OpTypeInt 32 1
4643 %7 = OpTypePointer Function %6
4644 %9 = OpTypeInt 32 0
4645 %10 = OpTypeVector %9 3
4646 %11 = OpTypePointer Input %10
4647 %12 = OpVariable %11 Input
4648 %13 = OpConstant %9 0
4649 %14 = OpTypePointer Input %9
4650 %19 = OpConstant %9 1
4651 %24 = OpConstant %9 2
4652 %28 = OpTypeInt 64 1
4653 %29 = OpTypeImage %28 2D 0 1 0 2 R64i
4654 %30 = OpTypePointer UniformConstant %29
4655 %31 = OpVariable %30 UniformConstant
4656 %33 = OpConstant %6 64
4657 %37 = OpTypeVector %6 3
4658 %51 = OpTypePointer Image %28
4659 %54 = OpConstantComposite %10 %19 %19 %19
4660 %4 = OpFunction %2 None %3
4661 %5 = OpLabel
4662 %8 = OpVariable %7 Function
4663 %18 = OpVariable %7 Function
4664 %23 = OpVariable %7 Function
4665 %15 = OpAccessChain %14 %12 %13
4666 %16 = OpLoad %9 %15
4667 %17 = OpBitcast %6 %16
4668 OpStore %8 %17
4669 %20 = OpAccessChain %14 %12 %19
4670 %21 = OpLoad %9 %20
4671 %22 = OpBitcast %6 %21
4672 OpStore %18 %22
4673 %25 = OpAccessChain %14 %12 %24
4674 %26 = OpLoad %9 %25
4675 %27 = OpBitcast %6 %26
4676 OpStore %23 %27
4677 %32 = OpLoad %6 %8
4678 %34 = OpSMod %6 %32 %33
4679 %35 = OpLoad %6 %18
4680 %36 = OpLoad %6 %23
4681 %38 = OpCompositeConstruct %37 %34 %35 %36
4682 %39 = OpLoad %6 %8
4683 %40 = OpLoad %6 %8
4684 %41 = OpIMul %6 %39 %40
4685 %42 = OpLoad %6 %18
4686 %43 = OpLoad %6 %18
4687 %44 = OpIMul %6 %42 %43
4688 %45 = OpIAdd %6 %41 %44
4689 %46 = OpLoad %6 %23
4690 %47 = OpLoad %6 %23
4691 %48 = OpIMul %6 %46 %47
4692 %49 = OpIAdd %6 %45 %48
4693 %50 = OpSConvert %28 %49
4694 %52 = OpImageTexelPointer %51 %31 %38 %13
4695 %53 = ${OPNAME} %28 %52 %19 %13 ${LASTARG:default=%50}
4696 OpReturn
4697 OpFunctionEnd
4698 )";
4699
4700 const std::string kShader_2d_array_r64i_intermediate_values = R"(
4701 ; The SPIR-V shader below is based on the following GLSL shader, but OpAtomicIAdd has been
4702 ; replaced with a template parameter and the last argument for it has been made optional.
4703 ;
4704 ; #version 440
4705 ; precision highp iimage2DArray;
4706 ; #extension GL_EXT_shader_explicit_arithmetic_types_int64 : require
4707 ; #extension GL_EXT_shader_image_int64 : require
4708 ;
4709 ; layout (local_size_x = 1, local_size_y = 1, local_size_z = 1) in;
4710 ; layout (r64i, binding=0) coherent uniform iimage2DArray u_resultImage;
4711 ; layout (r64i, binding=1) writeonly uniform iimage2DArray u_intermValuesImage;
4712 ;
4713 ; void main (void)
4714 ; {
4715 ;    int gx = int(gl_GlobalInvocationID.x);
4716 ;    int gy = int(gl_GlobalInvocationID.y);
4717 ;    int gz = int(gl_GlobalInvocationID.z);
4718 ;    imageStore(u_intermValuesImage, ivec3(gx, gy, gz), i64vec4(imageAtomicAdd(u_resultImage, ivec3(gx%64, gy, gz), int(gx*gx + gy*gy + gz*gz))));
4719 ; }
4720 ;
4721 ; SPIR-V
4722 ; Version: 1.3
4723 ; Generator: Khronos Glslang Reference Front End; 8
4724 ; Bound: 63
4725 ; Schema: 0
4726 OpCapability Shader
4727 OpCapability Int64
4728 OpCapability Int64Atomics
4729 OpCapability Int64ImageEXT
4730 OpExtension "SPV_EXT_shader_image_int64"
4731 %1 = OpExtInstImport "GLSL.std.450"
4732 OpMemoryModel Logical GLSL450
4733 OpEntryPoint GLCompute %4 "main" %12
4734 OpExecutionMode %4 LocalSize 1 1 1
4735 OpDecorate %12 BuiltIn GlobalInvocationId
4736 OpDecorate %31 DescriptorSet 0
4737 OpDecorate %31 Binding 1
4738 OpDecorate %31 NonReadable
4739 OpDecorate %38 DescriptorSet 0
4740 OpDecorate %38 Binding 0
4741 OpDecorate %38 Coherent
4742 OpDecorate %62 BuiltIn WorkgroupSize
4743 %2 = OpTypeVoid
4744 %3 = OpTypeFunction %2
4745 %6 = OpTypeInt 32 1
4746 %7 = OpTypePointer Function %6
4747 %9 = OpTypeInt 32 0
4748 %10 = OpTypeVector %9 3
4749 %11 = OpTypePointer Input %10
4750 %12 = OpVariable %11 Input
4751 %13 = OpConstant %9 0
4752 %14 = OpTypePointer Input %9
4753 %19 = OpConstant %9 1
4754 %24 = OpConstant %9 2
4755 %28 = OpTypeInt 64 1
4756 %29 = OpTypeImage %28 2D 0 1 0 2 R64i
4757 %30 = OpTypePointer UniformConstant %29
4758 %31 = OpVariable %30 UniformConstant
4759 %36 = OpTypeVector %6 3
4760 %38 = OpVariable %30 UniformConstant
4761 %40 = OpConstant %6 64
4762 %57 = OpTypePointer Image %28
4763 %60 = OpTypeVector %28 4
4764 %62 = OpConstantComposite %10 %19 %19 %19
4765 %4 = OpFunction %2 None %3
4766 %5 = OpLabel
4767 %8 = OpVariable %7 Function
4768 %18 = OpVariable %7 Function
4769 %23 = OpVariable %7 Function
4770 %15 = OpAccessChain %14 %12 %13
4771 %16 = OpLoad %9 %15
4772 %17 = OpBitcast %6 %16
4773 OpStore %8 %17
4774 %20 = OpAccessChain %14 %12 %19
4775 %21 = OpLoad %9 %20
4776 %22 = OpBitcast %6 %21
4777 OpStore %18 %22
4778 %25 = OpAccessChain %14 %12 %24
4779 %26 = OpLoad %9 %25
4780 %27 = OpBitcast %6 %26
4781 OpStore %23 %27
4782 %32 = OpLoad %29 %31
4783 %33 = OpLoad %6 %8
4784 %34 = OpLoad %6 %18
4785 %35 = OpLoad %6 %23
4786 %37 = OpCompositeConstruct %36 %33 %34 %35
4787 %39 = OpLoad %6 %8
4788 %41 = OpSMod %6 %39 %40
4789 %42 = OpLoad %6 %18
4790 %43 = OpLoad %6 %23
4791 %44 = OpCompositeConstruct %36 %41 %42 %43
4792 %45 = OpLoad %6 %8
4793 %46 = OpLoad %6 %8
4794 %47 = OpIMul %6 %45 %46
4795 %48 = OpLoad %6 %18
4796 %49 = OpLoad %6 %18
4797 %50 = OpIMul %6 %48 %49
4798 %51 = OpIAdd %6 %47 %50
4799 %52 = OpLoad %6 %23
4800 %53 = OpLoad %6 %23
4801 %54 = OpIMul %6 %52 %53
4802 %55 = OpIAdd %6 %51 %54
4803 %56 = OpSConvert %28 %55
4804 %58 = OpImageTexelPointer %57 %38 %44 %13
4805 %59 = ${OPNAME} %28 %58 %19 %13 ${LASTARG:default=%56}
4806 %61 = OpCompositeConstruct %60 %59 %59 %59 %59
4807 OpImageWrite %32 %37 %61
4808 OpReturn
4809 OpFunctionEnd
4810 )";
4811
4812 const std::string kShader_3d_r64ui_end_result = R"(
4813 ; The SPIR-V shader below is based on the following GLSL shader, but OpAtomicIAdd has been
4814 ; replaced with a template parameter and the last argument for it has been made optional.
4815 ;
4816 ; #version 440
4817 ; precision highp uimage3D;
4818 ; #extension GL_EXT_shader_explicit_arithmetic_types_int64 : require
4819 ; #extension GL_EXT_shader_image_int64 : require
4820 ;
4821 ; layout (local_size_x = 1, local_size_y = 1, local_size_z = 1) in;
4822 ; layout (r64ui, binding=0) coherent uniform uimage3D u_resultImage;
4823 ;
4824 ; void main (void)
4825 ; {
4826 ;    int gx = int(gl_GlobalInvocationID.x);
4827 ;    int gy = int(gl_GlobalInvocationID.y);
4828 ;    int gz = int(gl_GlobalInvocationID.z);
4829 ;    imageAtomicAdd(u_resultImage, ivec3(gx%48, gy, gz), uint(gx*gx + gy*gy + gz*gz));
4830 ; }
4831 ;
4832 ; SPIR-V
4833 ; Version: 1.3
4834 ; Generator: Khronos Glslang Reference Front End; 8
4835 ; Bound: 57
4836 ; Schema: 0
4837 OpCapability Shader
4838 OpCapability Int64
4839 OpCapability Int64Atomics
4840 OpCapability Int64ImageEXT
4841 OpExtension "SPV_EXT_shader_image_int64"
4842 %1 = OpExtInstImport "GLSL.std.450"
4843 OpMemoryModel Logical GLSL450
4844 OpEntryPoint GLCompute %4 "main" %12
4845 OpExecutionMode %4 LocalSize 1 1 1
4846 OpDecorate %12 BuiltIn GlobalInvocationId
4847 OpDecorate %31 DescriptorSet 0
4848 OpDecorate %31 Binding 0
4849 OpDecorate %31 Coherent
4850 OpDecorate %56 BuiltIn WorkgroupSize
4851 %2 = OpTypeVoid
4852 %3 = OpTypeFunction %2
4853 %6 = OpTypeInt 32 1
4854 %7 = OpTypePointer Function %6
4855 %9 = OpTypeInt 32 0
4856 %10 = OpTypeVector %9 3
4857 %11 = OpTypePointer Input %10
4858 %12 = OpVariable %11 Input
4859 %13 = OpConstant %9 0
4860 %14 = OpTypePointer Input %9
4861 %19 = OpConstant %9 1
4862 %24 = OpConstant %9 2
4863 %28 = OpTypeInt 64 0
4864 %29 = OpTypeImage %28 3D 0 0 0 2 R64ui
4865 %30 = OpTypePointer UniformConstant %29
4866 %31 = OpVariable %30 UniformConstant
4867 %33 = OpConstant %6 48
4868 %37 = OpTypeVector %6 3
4869 %50 = OpTypeInt 64 1
4870 %53 = OpTypePointer Image %28
4871 %56 = OpConstantComposite %10 %19 %19 %19
4872 %4 = OpFunction %2 None %3
4873 %5 = OpLabel
4874 %8 = OpVariable %7 Function
4875 %18 = OpVariable %7 Function
4876 %23 = OpVariable %7 Function
4877 %15 = OpAccessChain %14 %12 %13
4878 %16 = OpLoad %9 %15
4879 %17 = OpBitcast %6 %16
4880 OpStore %8 %17
4881 %20 = OpAccessChain %14 %12 %19
4882 %21 = OpLoad %9 %20
4883 %22 = OpBitcast %6 %21
4884 OpStore %18 %22
4885 %25 = OpAccessChain %14 %12 %24
4886 %26 = OpLoad %9 %25
4887 %27 = OpBitcast %6 %26
4888 OpStore %23 %27
4889 %32 = OpLoad %6 %8
4890 %34 = OpSMod %6 %32 %33
4891 %35 = OpLoad %6 %18
4892 %36 = OpLoad %6 %23
4893 %38 = OpCompositeConstruct %37 %34 %35 %36
4894 %39 = OpLoad %6 %8
4895 %40 = OpLoad %6 %8
4896 %41 = OpIMul %6 %39 %40
4897 %42 = OpLoad %6 %18
4898 %43 = OpLoad %6 %18
4899 %44 = OpIMul %6 %42 %43
4900 %45 = OpIAdd %6 %41 %44
4901 %46 = OpLoad %6 %23
4902 %47 = OpLoad %6 %23
4903 %48 = OpIMul %6 %46 %47
4904 %49 = OpIAdd %6 %45 %48
4905 %51 = OpSConvert %50 %49
4906 %52 = OpBitcast %28 %51
4907 %54 = OpImageTexelPointer %53 %31 %38 %13
4908 %55 = ${OPNAME} %28 %54 %19 %13 ${LASTARG:default=%52}
4909 OpReturn
4910 OpFunctionEnd
4911 )";
4912
4913 const std::string kShader_3d_r64ui_intermediate_values = R"(
4914 ; The SPIR-V shader below is based on the following GLSL shader, but OpAtomicIAdd has been
4915 ; replaced with a template parameter and the last argument for it has been made optional.
4916 ;
4917 ; #version 440
4918 ; precision highp uimage3D;
4919 ; #extension GL_EXT_shader_explicit_arithmetic_types_int64 : require
4920 ; #extension GL_EXT_shader_image_int64 : require
4921 ;
4922 ; layout (local_size_x = 1, local_size_y = 1, local_size_z = 1) in;
4923 ; layout (r64ui, binding=0) coherent uniform uimage3D u_resultImage;
4924 ; layout (r64ui, binding=1) writeonly uniform uimage3D u_intermValuesImage;
4925 ;
4926 ; void main (void)
4927 ; {
4928 ;    int gx = int(gl_GlobalInvocationID.x);
4929 ;    int gy = int(gl_GlobalInvocationID.y);
4930 ;    int gz = int(gl_GlobalInvocationID.z);
4931 ;    imageStore(u_intermValuesImage, ivec3(gx, gy, gz), u64vec4(imageAtomicAdd(u_resultImage, ivec3(gx%48, gy, gz), uint(gx*gx + gy*gy + gz*gz))));
4932 ; }
4933 ;
4934 ; SPIR-V
4935 ; Version: 1.3
4936 ; Generator: Khronos Glslang Reference Front End; 8
4937 ; Bound: 65
4938 ; Schema: 0
4939 OpCapability Shader
4940 OpCapability Int64
4941 OpCapability Int64Atomics
4942 OpCapability Int64ImageEXT
4943 OpExtension "SPV_EXT_shader_image_int64"
4944 %1 = OpExtInstImport "GLSL.std.450"
4945 OpMemoryModel Logical GLSL450
4946 OpEntryPoint GLCompute %4 "main" %12
4947 OpExecutionMode %4 LocalSize 1 1 1
4948 OpDecorate %12 BuiltIn GlobalInvocationId
4949 OpDecorate %31 DescriptorSet 0
4950 OpDecorate %31 Binding 1
4951 OpDecorate %31 NonReadable
4952 OpDecorate %38 DescriptorSet 0
4953 OpDecorate %38 Binding 0
4954 OpDecorate %38 Coherent
4955 OpDecorate %64 BuiltIn WorkgroupSize
4956 %2 = OpTypeVoid
4957 %3 = OpTypeFunction %2
4958 %6 = OpTypeInt 32 1
4959 %7 = OpTypePointer Function %6
4960 %9 = OpTypeInt 32 0
4961 %10 = OpTypeVector %9 3
4962 %11 = OpTypePointer Input %10
4963 %12 = OpVariable %11 Input
4964 %13 = OpConstant %9 0
4965 %14 = OpTypePointer Input %9
4966 %19 = OpConstant %9 1
4967 %24 = OpConstant %9 2
4968 %28 = OpTypeInt 64 0
4969 %29 = OpTypeImage %28 3D 0 0 0 2 R64ui
4970 %30 = OpTypePointer UniformConstant %29
4971 %31 = OpVariable %30 UniformConstant
4972 %36 = OpTypeVector %6 3
4973 %38 = OpVariable %30 UniformConstant
4974 %40 = OpConstant %6 48
4975 %56 = OpTypeInt 64 1
4976 %59 = OpTypePointer Image %28
4977 %62 = OpTypeVector %28 4
4978 %64 = OpConstantComposite %10 %19 %19 %19
4979 %4 = OpFunction %2 None %3
4980 %5 = OpLabel
4981 %8 = OpVariable %7 Function
4982 %18 = OpVariable %7 Function
4983 %23 = OpVariable %7 Function
4984 %15 = OpAccessChain %14 %12 %13
4985 %16 = OpLoad %9 %15
4986 %17 = OpBitcast %6 %16
4987 OpStore %8 %17
4988 %20 = OpAccessChain %14 %12 %19
4989 %21 = OpLoad %9 %20
4990 %22 = OpBitcast %6 %21
4991 OpStore %18 %22
4992 %25 = OpAccessChain %14 %12 %24
4993 %26 = OpLoad %9 %25
4994 %27 = OpBitcast %6 %26
4995 OpStore %23 %27
4996 %32 = OpLoad %29 %31
4997 %33 = OpLoad %6 %8
4998 %34 = OpLoad %6 %18
4999 %35 = OpLoad %6 %23
5000 %37 = OpCompositeConstruct %36 %33 %34 %35
5001 %39 = OpLoad %6 %8
5002 %41 = OpSMod %6 %39 %40
5003 %42 = OpLoad %6 %18
5004 %43 = OpLoad %6 %23
5005 %44 = OpCompositeConstruct %36 %41 %42 %43
5006 %45 = OpLoad %6 %8
5007 %46 = OpLoad %6 %8
5008 %47 = OpIMul %6 %45 %46
5009 %48 = OpLoad %6 %18
5010 %49 = OpLoad %6 %18
5011 %50 = OpIMul %6 %48 %49
5012 %51 = OpIAdd %6 %47 %50
5013 %52 = OpLoad %6 %23
5014 %53 = OpLoad %6 %23
5015 %54 = OpIMul %6 %52 %53
5016 %55 = OpIAdd %6 %51 %54
5017 %57 = OpSConvert %56 %55
5018 %58 = OpBitcast %28 %57
5019 %60 = OpImageTexelPointer %59 %38 %44 %13
5020 %61 = ${OPNAME} %28 %60 %19 %13 ${LASTARG:default=%58}
5021 %63 = OpCompositeConstruct %62 %61 %61 %61 %61
5022 OpImageWrite %32 %37 %63
5023 OpReturn
5024 OpFunctionEnd
5025 )";
5026
5027 const std::string kShader_3d_r64i_end_result = R"(
5028 ; The SPIR-V shader below is based on the following GLSL shader, but OpAtomicIAdd has been
5029 ; replaced with a template parameter and the last argument for it has been made optional.
5030 ;
5031 ; #version 440
5032 ; precision highp iimage3D;
5033 ; #extension GL_EXT_shader_explicit_arithmetic_types_int64 : require
5034 ; #extension GL_EXT_shader_image_int64 : require
5035 ;
5036 ; layout (local_size_x = 1, local_size_y = 1, local_size_z = 1) in;
5037 ; layout (r64i, binding=0) coherent uniform iimage3D u_resultImage;
5038 ;
5039 ; void main (void)
5040 ; {
5041 ;    int gx = int(gl_GlobalInvocationID.x);
5042 ;    int gy = int(gl_GlobalInvocationID.y);
5043 ;    int gz = int(gl_GlobalInvocationID.z);
5044 ;    imageAtomicAdd(u_resultImage, ivec3(gx%48, gy, gz), int(gx*gx + gy*gy + gz*gz));
5045 ; }
5046 ;
5047 ; SPIR-V
5048 ; Version: 1.3
5049 ; Generator: Khronos Glslang Reference Front End; 8
5050 ; Bound: 55
5051 ; Schema: 0
5052 OpCapability Shader
5053 OpCapability Int64
5054 OpCapability Int64Atomics
5055 OpCapability Int64ImageEXT
5056 OpExtension "SPV_EXT_shader_image_int64"
5057 %1 = OpExtInstImport "GLSL.std.450"
5058 OpMemoryModel Logical GLSL450
5059 OpEntryPoint GLCompute %4 "main" %12
5060 OpExecutionMode %4 LocalSize 1 1 1
5061 OpDecorate %12 BuiltIn GlobalInvocationId
5062 OpDecorate %31 DescriptorSet 0
5063 OpDecorate %31 Binding 0
5064 OpDecorate %31 Coherent
5065 OpDecorate %54 BuiltIn WorkgroupSize
5066 %2 = OpTypeVoid
5067 %3 = OpTypeFunction %2
5068 %6 = OpTypeInt 32 1
5069 %7 = OpTypePointer Function %6
5070 %9 = OpTypeInt 32 0
5071 %10 = OpTypeVector %9 3
5072 %11 = OpTypePointer Input %10
5073 %12 = OpVariable %11 Input
5074 %13 = OpConstant %9 0
5075 %14 = OpTypePointer Input %9
5076 %19 = OpConstant %9 1
5077 %24 = OpConstant %9 2
5078 %28 = OpTypeInt 64 1
5079 %29 = OpTypeImage %28 3D 0 0 0 2 R64i
5080 %30 = OpTypePointer UniformConstant %29
5081 %31 = OpVariable %30 UniformConstant
5082 %33 = OpConstant %6 48
5083 %37 = OpTypeVector %6 3
5084 %51 = OpTypePointer Image %28
5085 %54 = OpConstantComposite %10 %19 %19 %19
5086 %4 = OpFunction %2 None %3
5087 %5 = OpLabel
5088 %8 = OpVariable %7 Function
5089 %18 = OpVariable %7 Function
5090 %23 = OpVariable %7 Function
5091 %15 = OpAccessChain %14 %12 %13
5092 %16 = OpLoad %9 %15
5093 %17 = OpBitcast %6 %16
5094 OpStore %8 %17
5095 %20 = OpAccessChain %14 %12 %19
5096 %21 = OpLoad %9 %20
5097 %22 = OpBitcast %6 %21
5098 OpStore %18 %22
5099 %25 = OpAccessChain %14 %12 %24
5100 %26 = OpLoad %9 %25
5101 %27 = OpBitcast %6 %26
5102 OpStore %23 %27
5103 %32 = OpLoad %6 %8
5104 %34 = OpSMod %6 %32 %33
5105 %35 = OpLoad %6 %18
5106 %36 = OpLoad %6 %23
5107 %38 = OpCompositeConstruct %37 %34 %35 %36
5108 %39 = OpLoad %6 %8
5109 %40 = OpLoad %6 %8
5110 %41 = OpIMul %6 %39 %40
5111 %42 = OpLoad %6 %18
5112 %43 = OpLoad %6 %18
5113 %44 = OpIMul %6 %42 %43
5114 %45 = OpIAdd %6 %41 %44
5115 %46 = OpLoad %6 %23
5116 %47 = OpLoad %6 %23
5117 %48 = OpIMul %6 %46 %47
5118 %49 = OpIAdd %6 %45 %48
5119 %50 = OpSConvert %28 %49
5120 %52 = OpImageTexelPointer %51 %31 %38 %13
5121 %53 = ${OPNAME} %28 %52 %19 %13 ${LASTARG:default=%50}
5122 OpReturn
5123 OpFunctionEnd
5124 )";
5125
5126 const std::string kShader_3d_r64i_intermediate_values = R"(
5127 ; The SPIR-V shader below is based on the following GLSL shader, but OpAtomicIAdd has been
5128 ; replaced with a template parameter and the last argument for it has been made optional.
5129 ;
5130 ; #version 440
5131 ; precision highp iimage3D;
5132 ; #extension GL_EXT_shader_explicit_arithmetic_types_int64 : require
5133 ; #extension GL_EXT_shader_image_int64 : require
5134 ;
5135 ; layout (local_size_x = 1, local_size_y = 1, local_size_z = 1) in;
5136 ; layout (r64i, binding=0) coherent uniform iimage3D u_resultImage;
5137 ; layout (r64i, binding=1) writeonly uniform iimage3D u_intermValuesImage;
5138 ;
5139 ; void main (void)
5140 ; {
5141 ;    int gx = int(gl_GlobalInvocationID.x);
5142 ;    int gy = int(gl_GlobalInvocationID.y);
5143 ;    int gz = int(gl_GlobalInvocationID.z);
5144 ;    imageStore(u_intermValuesImage, ivec3(gx, gy, gz), i64vec4(imageAtomicAdd(u_resultImage, ivec3(gx%48, gy, gz), int(gx*gx + gy*gy + gz*gz))));
5145 ; }
5146 ;
5147 ; SPIR-V
5148 ; Version: 1.3
5149 ; Generator: Khronos Glslang Reference Front End; 8
5150 ; Bound: 63
5151 ; Schema: 0
5152 OpCapability Shader
5153 OpCapability Int64
5154 OpCapability Int64Atomics
5155 OpCapability Int64ImageEXT
5156 OpExtension "SPV_EXT_shader_image_int64"
5157 %1 = OpExtInstImport "GLSL.std.450"
5158 OpMemoryModel Logical GLSL450
5159 OpEntryPoint GLCompute %4 "main" %12
5160 OpExecutionMode %4 LocalSize 1 1 1
5161 OpDecorate %12 BuiltIn GlobalInvocationId
5162 OpDecorate %31 DescriptorSet 0
5163 OpDecorate %31 Binding 1
5164 OpDecorate %31 NonReadable
5165 OpDecorate %38 DescriptorSet 0
5166 OpDecorate %38 Binding 0
5167 OpDecorate %38 Coherent
5168 OpDecorate %62 BuiltIn WorkgroupSize
5169 %2 = OpTypeVoid
5170 %3 = OpTypeFunction %2
5171 %6 = OpTypeInt 32 1
5172 %7 = OpTypePointer Function %6
5173 %9 = OpTypeInt 32 0
5174 %10 = OpTypeVector %9 3
5175 %11 = OpTypePointer Input %10
5176 %12 = OpVariable %11 Input
5177 %13 = OpConstant %9 0
5178 %14 = OpTypePointer Input %9
5179 %19 = OpConstant %9 1
5180 %24 = OpConstant %9 2
5181 %28 = OpTypeInt 64 1
5182 %29 = OpTypeImage %28 3D 0 0 0 2 R64i
5183 %30 = OpTypePointer UniformConstant %29
5184 %31 = OpVariable %30 UniformConstant
5185 %36 = OpTypeVector %6 3
5186 %38 = OpVariable %30 UniformConstant
5187 %40 = OpConstant %6 48
5188 %57 = OpTypePointer Image %28
5189 %60 = OpTypeVector %28 4
5190 %62 = OpConstantComposite %10 %19 %19 %19
5191 %4 = OpFunction %2 None %3
5192 %5 = OpLabel
5193 %8 = OpVariable %7 Function
5194 %18 = OpVariable %7 Function
5195 %23 = OpVariable %7 Function
5196 %15 = OpAccessChain %14 %12 %13
5197 %16 = OpLoad %9 %15
5198 %17 = OpBitcast %6 %16
5199 OpStore %8 %17
5200 %20 = OpAccessChain %14 %12 %19
5201 %21 = OpLoad %9 %20
5202 %22 = OpBitcast %6 %21
5203 OpStore %18 %22
5204 %25 = OpAccessChain %14 %12 %24
5205 %26 = OpLoad %9 %25
5206 %27 = OpBitcast %6 %26
5207 OpStore %23 %27
5208 %32 = OpLoad %29 %31
5209 %33 = OpLoad %6 %8
5210 %34 = OpLoad %6 %18
5211 %35 = OpLoad %6 %23
5212 %37 = OpCompositeConstruct %36 %33 %34 %35
5213 %39 = OpLoad %6 %8
5214 %41 = OpSMod %6 %39 %40
5215 %42 = OpLoad %6 %18
5216 %43 = OpLoad %6 %23
5217 %44 = OpCompositeConstruct %36 %41 %42 %43
5218 %45 = OpLoad %6 %8
5219 %46 = OpLoad %6 %8
5220 %47 = OpIMul %6 %45 %46
5221 %48 = OpLoad %6 %18
5222 %49 = OpLoad %6 %18
5223 %50 = OpIMul %6 %48 %49
5224 %51 = OpIAdd %6 %47 %50
5225 %52 = OpLoad %6 %23
5226 %53 = OpLoad %6 %23
5227 %54 = OpIMul %6 %52 %53
5228 %55 = OpIAdd %6 %51 %54
5229 %56 = OpSConvert %28 %55
5230 %58 = OpImageTexelPointer %57 %38 %44 %13
5231 %59 = ${OPNAME} %28 %58 %19 %13 ${LASTARG:default=%56}
5232 %61 = OpCompositeConstruct %60 %59 %59 %59 %59
5233 OpImageWrite %32 %37 %61
5234 OpReturn
5235 OpFunctionEnd
5236 )";
5237
5238 const std::string kShader_cube_r64ui_end_result = R"(
5239 ; The SPIR-V shader below is based on the following GLSL shader, but OpAtomicIAdd has been
5240 ; replaced with a template parameter and the last argument for it has been made optional.
5241 ;
5242 ; #version 440
5243 ; precision highp uimageCube;
5244 ; #extension GL_EXT_shader_explicit_arithmetic_types_int64 : require
5245 ; #extension GL_EXT_shader_image_int64 : require
5246 ;
5247 ; layout (local_size_x = 1, local_size_y = 1, local_size_z = 1) in;
5248 ; layout (r64ui, binding=0) coherent uniform uimageCube u_resultImage;
5249 ;
5250 ; void main (void)
5251 ; {
5252 ;    int gx = int(gl_GlobalInvocationID.x);
5253 ;    int gy = int(gl_GlobalInvocationID.y);
5254 ;    int gz = int(gl_GlobalInvocationID.z);
5255 ;    imageAtomicAdd(u_resultImage, ivec3(gx%64, gy, gz), uint(gx*gx + gy*gy + gz*gz));
5256 ; }
5257 ;
5258 ; SPIR-V
5259 ; Version: 1.3
5260 ; Generator: Khronos Glslang Reference Front End; 8
5261 ; Bound: 57
5262 ; Schema: 0
5263 OpCapability Shader
5264 OpCapability Int64
5265 OpCapability Int64Atomics
5266 OpCapability Int64ImageEXT
5267 OpExtension "SPV_EXT_shader_image_int64"
5268 %1 = OpExtInstImport "GLSL.std.450"
5269 OpMemoryModel Logical GLSL450
5270 OpEntryPoint GLCompute %4 "main" %12
5271 OpExecutionMode %4 LocalSize 1 1 1
5272 OpDecorate %12 BuiltIn GlobalInvocationId
5273 OpDecorate %31 DescriptorSet 0
5274 OpDecorate %31 Binding 0
5275 OpDecorate %31 Coherent
5276 OpDecorate %56 BuiltIn WorkgroupSize
5277 %2 = OpTypeVoid
5278 %3 = OpTypeFunction %2
5279 %6 = OpTypeInt 32 1
5280 %7 = OpTypePointer Function %6
5281 %9 = OpTypeInt 32 0
5282 %10 = OpTypeVector %9 3
5283 %11 = OpTypePointer Input %10
5284 %12 = OpVariable %11 Input
5285 %13 = OpConstant %9 0
5286 %14 = OpTypePointer Input %9
5287 %19 = OpConstant %9 1
5288 %24 = OpConstant %9 2
5289 %28 = OpTypeInt 64 0
5290 %29 = OpTypeImage %28 Cube 0 0 0 2 R64ui
5291 %30 = OpTypePointer UniformConstant %29
5292 %31 = OpVariable %30 UniformConstant
5293 %33 = OpConstant %6 64
5294 %37 = OpTypeVector %6 3
5295 %50 = OpTypeInt 64 1
5296 %53 = OpTypePointer Image %28
5297 %56 = OpConstantComposite %10 %19 %19 %19
5298 %4 = OpFunction %2 None %3
5299 %5 = OpLabel
5300 %8 = OpVariable %7 Function
5301 %18 = OpVariable %7 Function
5302 %23 = OpVariable %7 Function
5303 %15 = OpAccessChain %14 %12 %13
5304 %16 = OpLoad %9 %15
5305 %17 = OpBitcast %6 %16
5306 OpStore %8 %17
5307 %20 = OpAccessChain %14 %12 %19
5308 %21 = OpLoad %9 %20
5309 %22 = OpBitcast %6 %21
5310 OpStore %18 %22
5311 %25 = OpAccessChain %14 %12 %24
5312 %26 = OpLoad %9 %25
5313 %27 = OpBitcast %6 %26
5314 OpStore %23 %27
5315 %32 = OpLoad %6 %8
5316 %34 = OpSMod %6 %32 %33
5317 %35 = OpLoad %6 %18
5318 %36 = OpLoad %6 %23
5319 %38 = OpCompositeConstruct %37 %34 %35 %36
5320 %39 = OpLoad %6 %8
5321 %40 = OpLoad %6 %8
5322 %41 = OpIMul %6 %39 %40
5323 %42 = OpLoad %6 %18
5324 %43 = OpLoad %6 %18
5325 %44 = OpIMul %6 %42 %43
5326 %45 = OpIAdd %6 %41 %44
5327 %46 = OpLoad %6 %23
5328 %47 = OpLoad %6 %23
5329 %48 = OpIMul %6 %46 %47
5330 %49 = OpIAdd %6 %45 %48
5331 %51 = OpSConvert %50 %49
5332 %52 = OpBitcast %28 %51
5333 %54 = OpImageTexelPointer %53 %31 %38 %13
5334 %55 = ${OPNAME} %28 %54 %19 %13 ${LASTARG:default=%52}
5335 OpReturn
5336 OpFunctionEnd
5337 )";
5338
5339 const std::string kShader_cube_r64ui_intermediate_values = R"(
5340 ; The SPIR-V shader below is based on the following GLSL shader, but OpAtomicIAdd has been
5341 ; replaced with a template parameter and the last argument for it has been made optional.
5342 ;
5343 ; #version 440
5344 ; precision highp uimageCube;
5345 ; #extension GL_EXT_shader_explicit_arithmetic_types_int64 : require
5346 ; #extension GL_EXT_shader_image_int64 : require
5347 ;
5348 ; layout (local_size_x = 1, local_size_y = 1, local_size_z = 1) in;
5349 ; layout (r64ui, binding=0) coherent uniform uimageCube u_resultImage;
5350 ; layout (r64ui, binding=1) writeonly uniform uimageCube u_intermValuesImage;
5351 ;
5352 ; void main (void)
5353 ; {
5354 ;    int gx = int(gl_GlobalInvocationID.x);
5355 ;    int gy = int(gl_GlobalInvocationID.y);
5356 ;    int gz = int(gl_GlobalInvocationID.z);
5357 ;    imageStore(u_intermValuesImage, ivec3(gx, gy, gz), u64vec4(imageAtomicAdd(u_resultImage, ivec3(gx%64, gy, gz), uint(gx*gx + gy*gy + gz*gz))));
5358 ; }
5359 ;
5360 ; SPIR-V
5361 ; Version: 1.3
5362 ; Generator: Khronos Glslang Reference Front End; 8
5363 ; Bound: 65
5364 ; Schema: 0
5365 OpCapability Shader
5366 OpCapability Int64
5367 OpCapability Int64Atomics
5368 OpCapability Int64ImageEXT
5369 OpExtension "SPV_EXT_shader_image_int64"
5370 %1 = OpExtInstImport "GLSL.std.450"
5371 OpMemoryModel Logical GLSL450
5372 OpEntryPoint GLCompute %4 "main" %12
5373 OpExecutionMode %4 LocalSize 1 1 1
5374 OpDecorate %12 BuiltIn GlobalInvocationId
5375 OpDecorate %31 DescriptorSet 0
5376 OpDecorate %31 Binding 1
5377 OpDecorate %31 NonReadable
5378 OpDecorate %38 DescriptorSet 0
5379 OpDecorate %38 Binding 0
5380 OpDecorate %38 Coherent
5381 OpDecorate %64 BuiltIn WorkgroupSize
5382 %2 = OpTypeVoid
5383 %3 = OpTypeFunction %2
5384 %6 = OpTypeInt 32 1
5385 %7 = OpTypePointer Function %6
5386 %9 = OpTypeInt 32 0
5387 %10 = OpTypeVector %9 3
5388 %11 = OpTypePointer Input %10
5389 %12 = OpVariable %11 Input
5390 %13 = OpConstant %9 0
5391 %14 = OpTypePointer Input %9
5392 %19 = OpConstant %9 1
5393 %24 = OpConstant %9 2
5394 %28 = OpTypeInt 64 0
5395 %29 = OpTypeImage %28 Cube 0 0 0 2 R64ui
5396 %30 = OpTypePointer UniformConstant %29
5397 %31 = OpVariable %30 UniformConstant
5398 %36 = OpTypeVector %6 3
5399 %38 = OpVariable %30 UniformConstant
5400 %40 = OpConstant %6 64
5401 %56 = OpTypeInt 64 1
5402 %59 = OpTypePointer Image %28
5403 %62 = OpTypeVector %28 4
5404 %64 = OpConstantComposite %10 %19 %19 %19
5405 %4 = OpFunction %2 None %3
5406 %5 = OpLabel
5407 %8 = OpVariable %7 Function
5408 %18 = OpVariable %7 Function
5409 %23 = OpVariable %7 Function
5410 %15 = OpAccessChain %14 %12 %13
5411 %16 = OpLoad %9 %15
5412 %17 = OpBitcast %6 %16
5413 OpStore %8 %17
5414 %20 = OpAccessChain %14 %12 %19
5415 %21 = OpLoad %9 %20
5416 %22 = OpBitcast %6 %21
5417 OpStore %18 %22
5418 %25 = OpAccessChain %14 %12 %24
5419 %26 = OpLoad %9 %25
5420 %27 = OpBitcast %6 %26
5421 OpStore %23 %27
5422 %32 = OpLoad %29 %31
5423 %33 = OpLoad %6 %8
5424 %34 = OpLoad %6 %18
5425 %35 = OpLoad %6 %23
5426 %37 = OpCompositeConstruct %36 %33 %34 %35
5427 %39 = OpLoad %6 %8
5428 %41 = OpSMod %6 %39 %40
5429 %42 = OpLoad %6 %18
5430 %43 = OpLoad %6 %23
5431 %44 = OpCompositeConstruct %36 %41 %42 %43
5432 %45 = OpLoad %6 %8
5433 %46 = OpLoad %6 %8
5434 %47 = OpIMul %6 %45 %46
5435 %48 = OpLoad %6 %18
5436 %49 = OpLoad %6 %18
5437 %50 = OpIMul %6 %48 %49
5438 %51 = OpIAdd %6 %47 %50
5439 %52 = OpLoad %6 %23
5440 %53 = OpLoad %6 %23
5441 %54 = OpIMul %6 %52 %53
5442 %55 = OpIAdd %6 %51 %54
5443 %57 = OpSConvert %56 %55
5444 %58 = OpBitcast %28 %57
5445 %60 = OpImageTexelPointer %59 %38 %44 %13
5446 %61 = ${OPNAME} %28 %60 %19 %13 ${LASTARG:default=%58}
5447 %63 = OpCompositeConstruct %62 %61 %61 %61 %61
5448 OpImageWrite %32 %37 %63
5449 OpReturn
5450 OpFunctionEnd
5451 )";
5452
5453 const std::string kShader_cube_r64i_end_result = R"(
5454 ; The SPIR-V shader below is based on the following GLSL shader, but OpAtomicIAdd has been
5455 ; replaced with a template parameter and the last argument for it has been made optional.
5456 ;
5457 ; #version 440
5458 ; precision highp iimageCube;
5459 ; #extension GL_EXT_shader_explicit_arithmetic_types_int64 : require
5460 ; #extension GL_EXT_shader_image_int64 : require
5461 ;
5462 ; layout (local_size_x = 1, local_size_y = 1, local_size_z = 1) in;
5463 ; layout (r64i, binding=0) coherent uniform iimageCube u_resultImage;
5464 ;
5465 ; void main (void)
5466 ; {
5467 ;    int gx = int(gl_GlobalInvocationID.x);
5468 ;    int gy = int(gl_GlobalInvocationID.y);
5469 ;    int gz = int(gl_GlobalInvocationID.z);
5470 ;    imageAtomicAdd(u_resultImage, ivec3(gx % 64, gy, gz), int(gx*gx + gy*gy + gz*gz));
5471 ; }
5472 ;
5473 ; SPIR-V
5474 ; Version: 1.3
5475 ; Generator: Khronos Glslang Reference Front End; 8
5476 ; Bound: 55
5477 ; Schema: 0
5478 OpCapability Shader
5479 OpCapability Int64
5480 OpCapability Int64Atomics
5481 OpCapability Int64ImageEXT
5482 OpExtension "SPV_EXT_shader_image_int64"
5483 %1 = OpExtInstImport "GLSL.std.450"
5484 OpMemoryModel Logical GLSL450
5485 OpEntryPoint GLCompute %4 "main" %12
5486 OpExecutionMode %4 LocalSize 1 1 1
5487 OpDecorate %12 BuiltIn GlobalInvocationId
5488 OpDecorate %31 DescriptorSet 0
5489 OpDecorate %31 Binding 0
5490 OpDecorate %31 Coherent
5491 OpDecorate %54 BuiltIn WorkgroupSize
5492 %2 = OpTypeVoid
5493 %3 = OpTypeFunction %2
5494 %6 = OpTypeInt 32 1
5495 %7 = OpTypePointer Function %6
5496 %9 = OpTypeInt 32 0
5497 %10 = OpTypeVector %9 3
5498 %11 = OpTypePointer Input %10
5499 %12 = OpVariable %11 Input
5500 %13 = OpConstant %9 0
5501 %14 = OpTypePointer Input %9
5502 %19 = OpConstant %9 1
5503 %24 = OpConstant %9 2
5504 %28 = OpTypeInt 64 1
5505 %29 = OpTypeImage %28 Cube 0 0 0 2 R64i
5506 %30 = OpTypePointer UniformConstant %29
5507 %31 = OpVariable %30 UniformConstant
5508 %33 = OpConstant %6 64
5509 %37 = OpTypeVector %6 3
5510 %51 = OpTypePointer Image %28
5511 %54 = OpConstantComposite %10 %19 %19 %19
5512 %4 = OpFunction %2 None %3
5513 %5 = OpLabel
5514 %8 = OpVariable %7 Function
5515 %18 = OpVariable %7 Function
5516 %23 = OpVariable %7 Function
5517 %15 = OpAccessChain %14 %12 %13
5518 %16 = OpLoad %9 %15
5519 %17 = OpBitcast %6 %16
5520 OpStore %8 %17
5521 %20 = OpAccessChain %14 %12 %19
5522 %21 = OpLoad %9 %20
5523 %22 = OpBitcast %6 %21
5524 OpStore %18 %22
5525 %25 = OpAccessChain %14 %12 %24
5526 %26 = OpLoad %9 %25
5527 %27 = OpBitcast %6 %26
5528 OpStore %23 %27
5529 %32 = OpLoad %6 %8
5530 %34 = OpSMod %6 %32 %33
5531 %35 = OpLoad %6 %18
5532 %36 = OpLoad %6 %23
5533 %38 = OpCompositeConstruct %37 %34 %35 %36
5534 %39 = OpLoad %6 %8
5535 %40 = OpLoad %6 %8
5536 %41 = OpIMul %6 %39 %40
5537 %42 = OpLoad %6 %18
5538 %43 = OpLoad %6 %18
5539 %44 = OpIMul %6 %42 %43
5540 %45 = OpIAdd %6 %41 %44
5541 %46 = OpLoad %6 %23
5542 %47 = OpLoad %6 %23
5543 %48 = OpIMul %6 %46 %47
5544 %49 = OpIAdd %6 %45 %48
5545 %50 = OpSConvert %28 %49
5546 %52 = OpImageTexelPointer %51 %31 %38 %13
5547 %53 = ${OPNAME} %28 %52 %19 %13 ${LASTARG:default=%50}
5548 OpReturn
5549 OpFunctionEnd
5550 )";
5551
5552 const std::string kShader_cube_r64i_intermediate_values = R"(
5553 ; The SPIR-V shader below is based on the following GLSL shader, but OpAtomicIAdd has been
5554 ; replaced with a template parameter and the last argument for it has been made optional.
5555 ;
5556 ; #version 440
5557 ; precision highp iimageCube;
5558 ; #extension GL_EXT_shader_explicit_arithmetic_types_int64 : require
5559 ; #extension GL_EXT_shader_image_int64 : require
5560 ;
5561 ; layout (local_size_x = 1, local_size_y = 1, local_size_z = 1) in;
5562 ; layout (r64i, binding=0) coherent uniform iimageCube u_resultImage;
5563 ; layout (r64i, binding=1) writeonly uniform iimageCube u_intermValuesImage;
5564 ;
5565 ; void main (void)
5566 ; {
5567 ;    int gx = int(gl_GlobalInvocationID.x);
5568 ;    int gy = int(gl_GlobalInvocationID.y);
5569 ;    int gz = int(gl_GlobalInvocationID.z);
5570 ;    imageStore(u_intermValuesImage, ivec3(gx, gy, gz), i64vec4(imageAtomicAdd(u_resultImage, ivec3(gx%64, gy, gz), int(gx*gx + gy*gy + gz*gz))));
5571 ; }
5572 ;
5573 ; SPIR-V
5574 ; Version: 1.3
5575 ; Generator: Khronos Glslang Reference Front End; 8
5576 ; Bound: 63
5577 ; Schema: 0
5578 OpCapability Shader
5579 OpCapability Int64
5580 OpCapability Int64Atomics
5581 OpCapability Int64ImageEXT
5582 OpExtension "SPV_EXT_shader_image_int64"
5583 %1 = OpExtInstImport "GLSL.std.450"
5584 OpMemoryModel Logical GLSL450
5585 OpEntryPoint GLCompute %4 "main" %12
5586 OpExecutionMode %4 LocalSize 1 1 1
5587 OpDecorate %12 BuiltIn GlobalInvocationId
5588 OpDecorate %31 DescriptorSet 0
5589 OpDecorate %31 Binding 1
5590 OpDecorate %31 NonReadable
5591 OpDecorate %38 DescriptorSet 0
5592 OpDecorate %38 Binding 0
5593 OpDecorate %38 Coherent
5594 OpDecorate %62 BuiltIn WorkgroupSize
5595 %2 = OpTypeVoid
5596 %3 = OpTypeFunction %2
5597 %6 = OpTypeInt 32 1
5598 %7 = OpTypePointer Function %6
5599 %9 = OpTypeInt 32 0
5600 %10 = OpTypeVector %9 3
5601 %11 = OpTypePointer Input %10
5602 %12 = OpVariable %11 Input
5603 %13 = OpConstant %9 0
5604 %14 = OpTypePointer Input %9
5605 %19 = OpConstant %9 1
5606 %24 = OpConstant %9 2
5607 %28 = OpTypeInt 64 1
5608 %29 = OpTypeImage %28 Cube 0 0 0 2 R64i
5609 %30 = OpTypePointer UniformConstant %29
5610 %31 = OpVariable %30 UniformConstant
5611 %36 = OpTypeVector %6 3
5612 %38 = OpVariable %30 UniformConstant
5613 %40 = OpConstant %6 64
5614 %57 = OpTypePointer Image %28
5615 %60 = OpTypeVector %28 4
5616 %62 = OpConstantComposite %10 %19 %19 %19
5617 %4 = OpFunction %2 None %3
5618 %5 = OpLabel
5619 %8 = OpVariable %7 Function
5620 %18 = OpVariable %7 Function
5621 %23 = OpVariable %7 Function
5622 %15 = OpAccessChain %14 %12 %13
5623 %16 = OpLoad %9 %15
5624 %17 = OpBitcast %6 %16
5625 OpStore %8 %17
5626 %20 = OpAccessChain %14 %12 %19
5627 %21 = OpLoad %9 %20
5628 %22 = OpBitcast %6 %21
5629 OpStore %18 %22
5630 %25 = OpAccessChain %14 %12 %24
5631 %26 = OpLoad %9 %25
5632 %27 = OpBitcast %6 %26
5633 OpStore %23 %27
5634 %32 = OpLoad %29 %31
5635 %33 = OpLoad %6 %8
5636 %34 = OpLoad %6 %18
5637 %35 = OpLoad %6 %23
5638 %37 = OpCompositeConstruct %36 %33 %34 %35
5639 %39 = OpLoad %6 %8
5640 %41 = OpSMod %6 %39 %40
5641 %42 = OpLoad %6 %18
5642 %43 = OpLoad %6 %23
5643 %44 = OpCompositeConstruct %36 %41 %42 %43
5644 %45 = OpLoad %6 %8
5645 %46 = OpLoad %6 %8
5646 %47 = OpIMul %6 %45 %46
5647 %48 = OpLoad %6 %18
5648 %49 = OpLoad %6 %18
5649 %50 = OpIMul %6 %48 %49
5650 %51 = OpIAdd %6 %47 %50
5651 %52 = OpLoad %6 %23
5652 %53 = OpLoad %6 %23
5653 %54 = OpIMul %6 %52 %53
5654 %55 = OpIAdd %6 %51 %54
5655 %56 = OpSConvert %28 %55
5656 %58 = OpImageTexelPointer %57 %38 %44 %13
5657 %59 = ${OPNAME} %28 %58 %19 %13 ${LASTARG:default=%56}
5658 %61 = OpCompositeConstruct %60 %59 %59 %59 %59
5659 OpImageWrite %32 %37 %61
5660 OpReturn
5661 OpFunctionEnd
5662 )";
5663
5664 const std::string kShader_cube_array_r64ui_end_result = R"(
5665 ; The SPIR-V shader below is based on the following GLSL shader, but OpAtomicIAdd has been
5666 ; replaced with a template parameter and the last argument for it has been made optional.
5667 ;
5668 ; #version 440
5669 ; precision highp uimageCubeArray;
5670 ; #extension GL_EXT_shader_explicit_arithmetic_types_int64 : require
5671 ; #extension GL_EXT_shader_image_int64 : require
5672 ;
5673 ; layout (local_size_x = 1, local_size_y = 1, local_size_z = 1) in;
5674 ; layout (r64ui, binding=0) coherent uniform uimageCubeArray u_resultImage;
5675 ;
5676 ; void main (void)
5677 ; {
5678 ;    int gx = int(gl_GlobalInvocationID.x);
5679 ;    int gy = int(gl_GlobalInvocationID.y);
5680 ;    int gz = int(gl_GlobalInvocationID.z);
5681 ;    imageAtomicAdd(u_resultImage, ivec3(gx%64, gy, gz), uint(gx*gx + gy*gy + gz*gz));
5682 ; }
5683 ;
5684 ; SPIR-V
5685 ; Version: 1.3
5686 ; Generator: Khronos Glslang Reference Front End; 8
5687 ; Bound: 57
5688 ; Schema: 0
5689 OpCapability Shader
5690 OpCapability Int64
5691 OpCapability Int64Atomics
5692 OpCapability ImageCubeArray
5693 OpCapability Int64ImageEXT
5694 OpExtension "SPV_EXT_shader_image_int64"
5695 %1 = OpExtInstImport "GLSL.std.450"
5696 OpMemoryModel Logical GLSL450
5697 OpEntryPoint GLCompute %4 "main" %12
5698 OpExecutionMode %4 LocalSize 1 1 1
5699 OpDecorate %12 BuiltIn GlobalInvocationId
5700 OpDecorate %31 DescriptorSet 0
5701 OpDecorate %31 Binding 0
5702 OpDecorate %31 Coherent
5703 OpDecorate %56 BuiltIn WorkgroupSize
5704 %2 = OpTypeVoid
5705 %3 = OpTypeFunction %2
5706 %6 = OpTypeInt 32 1
5707 %7 = OpTypePointer Function %6
5708 %9 = OpTypeInt 32 0
5709 %10 = OpTypeVector %9 3
5710 %11 = OpTypePointer Input %10
5711 %12 = OpVariable %11 Input
5712 %13 = OpConstant %9 0
5713 %14 = OpTypePointer Input %9
5714 %19 = OpConstant %9 1
5715 %24 = OpConstant %9 2
5716 %28 = OpTypeInt 64 0
5717 %29 = OpTypeImage %28 Cube 0 1 0 2 R64ui
5718 %30 = OpTypePointer UniformConstant %29
5719 %31 = OpVariable %30 UniformConstant
5720 %33 = OpConstant %6 64
5721 %37 = OpTypeVector %6 3
5722 %50 = OpTypeInt 64 1
5723 %53 = OpTypePointer Image %28
5724 %56 = OpConstantComposite %10 %19 %19 %19
5725 %4 = OpFunction %2 None %3
5726 %5 = OpLabel
5727 %8 = OpVariable %7 Function
5728 %18 = OpVariable %7 Function
5729 %23 = OpVariable %7 Function
5730 %15 = OpAccessChain %14 %12 %13
5731 %16 = OpLoad %9 %15
5732 %17 = OpBitcast %6 %16
5733 OpStore %8 %17
5734 %20 = OpAccessChain %14 %12 %19
5735 %21 = OpLoad %9 %20
5736 %22 = OpBitcast %6 %21
5737 OpStore %18 %22
5738 %25 = OpAccessChain %14 %12 %24
5739 %26 = OpLoad %9 %25
5740 %27 = OpBitcast %6 %26
5741 OpStore %23 %27
5742 %32 = OpLoad %6 %8
5743 %34 = OpSMod %6 %32 %33
5744 %35 = OpLoad %6 %18
5745 %36 = OpLoad %6 %23
5746 %38 = OpCompositeConstruct %37 %34 %35 %36
5747 %39 = OpLoad %6 %8
5748 %40 = OpLoad %6 %8
5749 %41 = OpIMul %6 %39 %40
5750 %42 = OpLoad %6 %18
5751 %43 = OpLoad %6 %18
5752 %44 = OpIMul %6 %42 %43
5753 %45 = OpIAdd %6 %41 %44
5754 %46 = OpLoad %6 %23
5755 %47 = OpLoad %6 %23
5756 %48 = OpIMul %6 %46 %47
5757 %49 = OpIAdd %6 %45 %48
5758 %51 = OpSConvert %50 %49
5759 %52 = OpBitcast %28 %51
5760 %54 = OpImageTexelPointer %53 %31 %38 %13
5761 %55 = ${OPNAME} %28 %54 %19 %13 ${LASTARG:default=%52}
5762 OpReturn
5763 OpFunctionEnd
5764 )";
5765
5766 const std::string kShader_cube_array_r64ui_intermediate_values = R"(
5767 ; The SPIR-V shader below is based on the following GLSL shader, but OpAtomicIAdd has been
5768 ; replaced with a template parameter and the last argument for it has been made optional.
5769 ;
5770 ; #version 440
5771 ; precision highp uimageCubeArray;
5772 ; #extension GL_EXT_shader_explicit_arithmetic_types_int64 : require
5773 ; #extension GL_EXT_shader_image_int64 : require
5774 ;
5775 ; layout (local_size_x = 1, local_size_y = 1, local_size_z = 1) in;
5776 ; layout (r64ui, binding=0) coherent uniform uimageCubeArray u_resultImage;
5777 ; layout (r64ui, binding=1) writeonly uniform uimageCubeArray u_intermValuesImage;
5778 ;
5779 ; void main (void)
5780 ; {
5781 ;    int gx = int(gl_GlobalInvocationID.x);
5782 ;    int gy = int(gl_GlobalInvocationID.y);
5783 ;    int gz = int(gl_GlobalInvocationID.z);
5784 ;    imageStore(u_intermValuesImage, ivec3(gx, gy, gz), u64vec4(imageAtomicAdd(u_resultImage, ivec3(gx%64, gy, gz), uint(gx*gx + gy*gy + gz*gz))));
5785 ; }
5786 ;
5787 ; SPIR-V
5788 ; Version: 1.3
5789 ; Generator: Khronos Glslang Reference Front End; 8
5790 ; Bound: 65
5791 ; Schema: 0
5792 OpCapability Shader
5793 OpCapability Int64
5794 OpCapability Int64Atomics
5795 OpCapability ImageCubeArray
5796 OpCapability Int64ImageEXT
5797 OpExtension "SPV_EXT_shader_image_int64"
5798 %1 = OpExtInstImport "GLSL.std.450"
5799 OpMemoryModel Logical GLSL450
5800 OpEntryPoint GLCompute %4 "main" %12
5801 OpExecutionMode %4 LocalSize 1 1 1
5802 OpDecorate %12 BuiltIn GlobalInvocationId
5803 OpDecorate %31 DescriptorSet 0
5804 OpDecorate %31 Binding 1
5805 OpDecorate %31 NonReadable
5806 OpDecorate %38 DescriptorSet 0
5807 OpDecorate %38 Binding 0
5808 OpDecorate %38 Coherent
5809 OpDecorate %64 BuiltIn WorkgroupSize
5810 %2 = OpTypeVoid
5811 %3 = OpTypeFunction %2
5812 %6 = OpTypeInt 32 1
5813 %7 = OpTypePointer Function %6
5814 %9 = OpTypeInt 32 0
5815 %10 = OpTypeVector %9 3
5816 %11 = OpTypePointer Input %10
5817 %12 = OpVariable %11 Input
5818 %13 = OpConstant %9 0
5819 %14 = OpTypePointer Input %9
5820 %19 = OpConstant %9 1
5821 %24 = OpConstant %9 2
5822 %28 = OpTypeInt 64 0
5823 %29 = OpTypeImage %28 Cube 0 1 0 2 R64ui
5824 %30 = OpTypePointer UniformConstant %29
5825 %31 = OpVariable %30 UniformConstant
5826 %36 = OpTypeVector %6 3
5827 %38 = OpVariable %30 UniformConstant
5828 %40 = OpConstant %6 64
5829 %56 = OpTypeInt 64 1
5830 %59 = OpTypePointer Image %28
5831 %62 = OpTypeVector %28 4
5832 %64 = OpConstantComposite %10 %19 %19 %19
5833 %4 = OpFunction %2 None %3
5834 %5 = OpLabel
5835 %8 = OpVariable %7 Function
5836 %18 = OpVariable %7 Function
5837 %23 = OpVariable %7 Function
5838 %15 = OpAccessChain %14 %12 %13
5839 %16 = OpLoad %9 %15
5840 %17 = OpBitcast %6 %16
5841 OpStore %8 %17
5842 %20 = OpAccessChain %14 %12 %19
5843 %21 = OpLoad %9 %20
5844 %22 = OpBitcast %6 %21
5845 OpStore %18 %22
5846 %25 = OpAccessChain %14 %12 %24
5847 %26 = OpLoad %9 %25
5848 %27 = OpBitcast %6 %26
5849 OpStore %23 %27
5850 %32 = OpLoad %29 %31
5851 %33 = OpLoad %6 %8
5852 %34 = OpLoad %6 %18
5853 %35 = OpLoad %6 %23
5854 %37 = OpCompositeConstruct %36 %33 %34 %35
5855 %39 = OpLoad %6 %8
5856 %41 = OpSMod %6 %39 %40
5857 %42 = OpLoad %6 %18
5858 %43 = OpLoad %6 %23
5859 %44 = OpCompositeConstruct %36 %41 %42 %43
5860 %45 = OpLoad %6 %8
5861 %46 = OpLoad %6 %8
5862 %47 = OpIMul %6 %45 %46
5863 %48 = OpLoad %6 %18
5864 %49 = OpLoad %6 %18
5865 %50 = OpIMul %6 %48 %49
5866 %51 = OpIAdd %6 %47 %50
5867 %52 = OpLoad %6 %23
5868 %53 = OpLoad %6 %23
5869 %54 = OpIMul %6 %52 %53
5870 %55 = OpIAdd %6 %51 %54
5871 %57 = OpSConvert %56 %55
5872 %58 = OpBitcast %28 %57
5873 %60 = OpImageTexelPointer %59 %38 %44 %13
5874 %61 = ${OPNAME} %28 %60 %19 %13 ${LASTARG:default=%58}
5875 %63 = OpCompositeConstruct %62 %61 %61 %61 %61
5876 OpImageWrite %32 %37 %63
5877 OpReturn
5878 OpFunctionEnd
5879 )";
5880
5881 const std::string kShader_cube_array_r64i_end_result = R"(
5882 ; The SPIR-V shader below is based on the following GLSL shader, but OpAtomicIAdd has been
5883 ; replaced with a template parameter and the last argument for it has been made optional.
5884 ;
5885 ; #version 440
5886 ; precision highp iimageCubeArray;
5887 ; #extension GL_EXT_shader_explicit_arithmetic_types_int64 : require
5888 ; #extension GL_EXT_shader_image_int64 : require
5889 ;
5890 ; layout (local_size_x = 1, local_size_y = 1, local_size_z = 1) in;
5891 ; layout (r64i, binding=0) coherent uniform iimageCubeArray u_resultImage;
5892 ;
5893 ; void main (void)
5894 ; {
5895 ;    int gx = int(gl_GlobalInvocationID.x);
5896 ;    int gy = int(gl_GlobalInvocationID.y);
5897 ;    int gz = int(gl_GlobalInvocationID.z);
5898 ;    imageAtomicAdd(u_resultImage, ivec3(gx % 64, gy, gz), int(gx*gx + gy*gy + gz*gz));
5899 ; }
5900 ;
5901 ; SPIR-V
5902 ; Version: 1.3
5903 ; Generator: Khronos Glslang Reference Front End; 8
5904 ; Bound: 55
5905 ; Schema: 0
5906 OpCapability Shader
5907 OpCapability Int64
5908 OpCapability Int64Atomics
5909 OpCapability ImageCubeArray
5910 OpCapability Int64ImageEXT
5911 OpExtension "SPV_EXT_shader_image_int64"
5912 %1 = OpExtInstImport "GLSL.std.450"
5913 OpMemoryModel Logical GLSL450
5914 OpEntryPoint GLCompute %4 "main" %12
5915 OpExecutionMode %4 LocalSize 1 1 1
5916 OpDecorate %12 BuiltIn GlobalInvocationId
5917 OpDecorate %31 DescriptorSet 0
5918 OpDecorate %31 Binding 0
5919 OpDecorate %31 Coherent
5920 OpDecorate %54 BuiltIn WorkgroupSize
5921 %2 = OpTypeVoid
5922 %3 = OpTypeFunction %2
5923 %6 = OpTypeInt 32 1
5924 %7 = OpTypePointer Function %6
5925 %9 = OpTypeInt 32 0
5926 %10 = OpTypeVector %9 3
5927 %11 = OpTypePointer Input %10
5928 %12 = OpVariable %11 Input
5929 %13 = OpConstant %9 0
5930 %14 = OpTypePointer Input %9
5931 %19 = OpConstant %9 1
5932 %24 = OpConstant %9 2
5933 %28 = OpTypeInt 64 1
5934 %29 = OpTypeImage %28 Cube 0 1 0 2 R64i
5935 %30 = OpTypePointer UniformConstant %29
5936 %31 = OpVariable %30 UniformConstant
5937 %33 = OpConstant %6 64
5938 %37 = OpTypeVector %6 3
5939 %51 = OpTypePointer Image %28
5940 %54 = OpConstantComposite %10 %19 %19 %19
5941 %4 = OpFunction %2 None %3
5942 %5 = OpLabel
5943 %8 = OpVariable %7 Function
5944 %18 = OpVariable %7 Function
5945 %23 = OpVariable %7 Function
5946 %15 = OpAccessChain %14 %12 %13
5947 %16 = OpLoad %9 %15
5948 %17 = OpBitcast %6 %16
5949 OpStore %8 %17
5950 %20 = OpAccessChain %14 %12 %19
5951 %21 = OpLoad %9 %20
5952 %22 = OpBitcast %6 %21
5953 OpStore %18 %22
5954 %25 = OpAccessChain %14 %12 %24
5955 %26 = OpLoad %9 %25
5956 %27 = OpBitcast %6 %26
5957 OpStore %23 %27
5958 %32 = OpLoad %6 %8
5959 %34 = OpSMod %6 %32 %33
5960 %35 = OpLoad %6 %18
5961 %36 = OpLoad %6 %23
5962 %38 = OpCompositeConstruct %37 %34 %35 %36
5963 %39 = OpLoad %6 %8
5964 %40 = OpLoad %6 %8
5965 %41 = OpIMul %6 %39 %40
5966 %42 = OpLoad %6 %18
5967 %43 = OpLoad %6 %18
5968 %44 = OpIMul %6 %42 %43
5969 %45 = OpIAdd %6 %41 %44
5970 %46 = OpLoad %6 %23
5971 %47 = OpLoad %6 %23
5972 %48 = OpIMul %6 %46 %47
5973 %49 = OpIAdd %6 %45 %48
5974 %50 = OpSConvert %28 %49
5975 %52 = OpImageTexelPointer %51 %31 %38 %13
5976 %53 = ${OPNAME} %28 %52 %19 %13 ${LASTARG:default=%50}
5977 OpReturn
5978 OpFunctionEnd
5979 )";
5980
5981 const std::string kShader_cube_array_r64i_intermediate_values = R"(
5982 ; The SPIR-V shader below is based on the following GLSL shader, but OpAtomicIAdd has been
5983 ; replaced with a template parameter and the last argument for it has been made optional.
5984 ;
5985 ; #version 440
5986 ; precision highp iimageCubeArray;
5987 ; #extension GL_EXT_shader_explicit_arithmetic_types_int64 : require
5988 ; #extension GL_EXT_shader_image_int64 : require
5989 ;
5990 ; layout (local_size_x = 1, local_size_y = 1, local_size_z = 1) in;
5991 ; layout (r64i, binding=0) coherent uniform iimageCubeArray u_resultImage;
5992 ; layout (r64i, binding=1) writeonly uniform iimageCubeArray u_intermValuesImage;
5993 ;
5994 ; void main (void)
5995 ; {
5996 ;    int gx = int(gl_GlobalInvocationID.x);
5997 ;    int gy = int(gl_GlobalInvocationID.y);
5998 ;    int gz = int(gl_GlobalInvocationID.z);
5999 ;    imageStore(u_intermValuesImage, ivec3(gx, gy, gz), i64vec4(imageAtomicAdd(u_resultImage, ivec3(gx%64, gy, gz), int(gx*gx + gy*gy + gz*gz))));
6000 ; }
6001 ;
6002 ; SPIR-V
6003 ; Version: 1.3
6004 ; Generator: Khronos Glslang Reference Front End; 8
6005 ; Bound: 63
6006 ; Schema: 0
6007 OpCapability Shader
6008 OpCapability Int64
6009 OpCapability Int64Atomics
6010 OpCapability ImageCubeArray
6011 OpCapability Int64ImageEXT
6012 OpExtension "SPV_EXT_shader_image_int64"
6013 %1 = OpExtInstImport "GLSL.std.450"
6014 OpMemoryModel Logical GLSL450
6015 OpEntryPoint GLCompute %4 "main" %12
6016 OpExecutionMode %4 LocalSize 1 1 1
6017 OpDecorate %12 BuiltIn GlobalInvocationId
6018 OpDecorate %31 DescriptorSet 0
6019 OpDecorate %31 Binding 1
6020 OpDecorate %31 NonReadable
6021 OpDecorate %38 DescriptorSet 0
6022 OpDecorate %38 Binding 0
6023 OpDecorate %38 Coherent
6024 OpDecorate %62 BuiltIn WorkgroupSize
6025 %2 = OpTypeVoid
6026 %3 = OpTypeFunction %2
6027 %6 = OpTypeInt 32 1
6028 %7 = OpTypePointer Function %6
6029 %9 = OpTypeInt 32 0
6030 %10 = OpTypeVector %9 3
6031 %11 = OpTypePointer Input %10
6032 %12 = OpVariable %11 Input
6033 %13 = OpConstant %9 0
6034 %14 = OpTypePointer Input %9
6035 %19 = OpConstant %9 1
6036 %24 = OpConstant %9 2
6037 %28 = OpTypeInt 64 1
6038 %29 = OpTypeImage %28 Cube 0 1 0 2 R64i
6039 %30 = OpTypePointer UniformConstant %29
6040 %31 = OpVariable %30 UniformConstant
6041 %36 = OpTypeVector %6 3
6042 %38 = OpVariable %30 UniformConstant
6043 %40 = OpConstant %6 64
6044 %57 = OpTypePointer Image %28
6045 %60 = OpTypeVector %28 4
6046 %62 = OpConstantComposite %10 %19 %19 %19
6047 %4 = OpFunction %2 None %3
6048 %5 = OpLabel
6049 %8 = OpVariable %7 Function
6050 %18 = OpVariable %7 Function
6051 %23 = OpVariable %7 Function
6052 %15 = OpAccessChain %14 %12 %13
6053 %16 = OpLoad %9 %15
6054 %17 = OpBitcast %6 %16
6055 OpStore %8 %17
6056 %20 = OpAccessChain %14 %12 %19
6057 %21 = OpLoad %9 %20
6058 %22 = OpBitcast %6 %21
6059 OpStore %18 %22
6060 %25 = OpAccessChain %14 %12 %24
6061 %26 = OpLoad %9 %25
6062 %27 = OpBitcast %6 %26
6063 OpStore %23 %27
6064 %32 = OpLoad %29 %31
6065 %33 = OpLoad %6 %8
6066 %34 = OpLoad %6 %18
6067 %35 = OpLoad %6 %23
6068 %37 = OpCompositeConstruct %36 %33 %34 %35
6069 %39 = OpLoad %6 %8
6070 %41 = OpSMod %6 %39 %40
6071 %42 = OpLoad %6 %18
6072 %43 = OpLoad %6 %23
6073 %44 = OpCompositeConstruct %36 %41 %42 %43
6074 %45 = OpLoad %6 %8
6075 %46 = OpLoad %6 %8
6076 %47 = OpIMul %6 %45 %46
6077 %48 = OpLoad %6 %18
6078 %49 = OpLoad %6 %18
6079 %50 = OpIMul %6 %48 %49
6080 %51 = OpIAdd %6 %47 %50
6081 %52 = OpLoad %6 %23
6082 %53 = OpLoad %6 %23
6083 %54 = OpIMul %6 %52 %53
6084 %55 = OpIAdd %6 %51 %54
6085 %56 = OpSConvert %28 %55
6086 %58 = OpImageTexelPointer %57 %38 %44 %13
6087 %59 = ${OPNAME} %28 %58 %19 %13 ${LASTARG:default=%56}
6088 %61 = OpCompositeConstruct %60 %59 %59 %59 %59
6089 OpImageWrite %32 %37 %61
6090 OpReturn
6091 OpFunctionEnd
6092 )";
6093
6094 const std::string kShader_image_buffer_r64ui_end_result = R"(
6095 ; The SPIR-V shader below is based on the following GLSL shader, but OpAtomicIAdd has been
6096 ; replaced with a template parameter and the last argument for it has been made optional.
6097 ;
6098 ;#version 440
6099 ;precision highp uimageBuffer;
6100 ;#extension GL_EXT_shader_explicit_arithmetic_types_int64 : require
6101 ;#extension GL_EXT_shader_image_int64 : require
6102 ;
6103 ;layout (local_size_x = 1, local_size_y = 1, local_size_z = 1) in;
6104 ;layout (r64ui, binding=0) coherent uniform uimageBuffer u_resultImage;
6105 ;
6106 ;void main (void)
6107 ;{
6108 ;    int gx = int(gl_GlobalInvocationID.x);
6109 ;    int gy = int(gl_GlobalInvocationID.y);
6110 ;    int gz = int(gl_GlobalInvocationID.z);
6111 ;    imageAtomicAdd(u_resultImage, gx % 64, uint(gx*gx + gy*gy + gz*gz));
6112 ;}
6113 ;
6114 ; SPIR-V
6115 ; Version: 1.3
6116 ; Generator: Khronos Glslang Reference Front End; 8
6117 ; Bound: 53
6118 ; Schema: 0
6119 OpCapability Shader
6120 OpCapability Int64
6121 OpCapability Int64Atomics
6122 OpCapability ImageBuffer
6123 OpCapability Int64ImageEXT
6124 OpExtension "SPV_EXT_shader_image_int64"
6125 %1 = OpExtInstImport "GLSL.std.450"
6126 OpMemoryModel Logical GLSL450
6127 OpEntryPoint GLCompute %4 "main" %12
6128 OpExecutionMode %4 LocalSize 1 1 1
6129 OpDecorate %12 BuiltIn GlobalInvocationId
6130 OpDecorate %31 DescriptorSet 0
6131 OpDecorate %31 Binding 0
6132 OpDecorate %31 Coherent
6133 OpDecorate %52 BuiltIn WorkgroupSize
6134 %2 = OpTypeVoid
6135 %3 = OpTypeFunction %2
6136 %6 = OpTypeInt 32 1
6137 %7 = OpTypePointer Function %6
6138 %9 = OpTypeInt 32 0
6139 %10 = OpTypeVector %9 3
6140 %11 = OpTypePointer Input %10
6141 %12 = OpVariable %11 Input
6142 %13 = OpConstant %9 0
6143 %14 = OpTypePointer Input %9
6144 %19 = OpConstant %9 1
6145 %24 = OpConstant %9 2
6146 %28 = OpTypeInt 64 0
6147 %29 = OpTypeImage %28 Buffer 0 0 0 2 R64ui
6148 %30 = OpTypePointer UniformConstant %29
6149 %31 = OpVariable %30 UniformConstant
6150 %33 = OpConstant %6 64
6151 %46 = OpTypeInt 64 1
6152 %49 = OpTypePointer Image %28
6153 %52 = OpConstantComposite %10 %19 %19 %19
6154 %4 = OpFunction %2 None %3
6155 %5 = OpLabel
6156 %8 = OpVariable %7 Function
6157 %18 = OpVariable %7 Function
6158 %23 = OpVariable %7 Function
6159 %15 = OpAccessChain %14 %12 %13
6160 %16 = OpLoad %9 %15
6161 %17 = OpBitcast %6 %16
6162 OpStore %8 %17
6163 %20 = OpAccessChain %14 %12 %19
6164 %21 = OpLoad %9 %20
6165 %22 = OpBitcast %6 %21
6166 OpStore %18 %22
6167 %25 = OpAccessChain %14 %12 %24
6168 %26 = OpLoad %9 %25
6169 %27 = OpBitcast %6 %26
6170 OpStore %23 %27
6171 %32 = OpLoad %6 %8
6172 %34 = OpSMod %6 %32 %33
6173 %35 = OpLoad %6 %8
6174 %36 = OpLoad %6 %8
6175 %37 = OpIMul %6 %35 %36
6176 %38 = OpLoad %6 %18
6177 %39 = OpLoad %6 %18
6178 %40 = OpIMul %6 %38 %39
6179 %41 = OpIAdd %6 %37 %40
6180 %42 = OpLoad %6 %23
6181 %43 = OpLoad %6 %23
6182 %44 = OpIMul %6 %42 %43
6183 %45 = OpIAdd %6 %41 %44
6184 %47 = OpSConvert %46 %45
6185 %48 = OpBitcast %28 %47
6186 %50 = OpImageTexelPointer %49 %31 %34 %13
6187 %51 = ${OPNAME} %28 %50 %19 %13 ${LASTARG:default=%48}
6188 OpReturn
6189 OpFunctionEnd
6190 )";
6191
6192 const std::string kShader_image_buffer_r64ui_intermediate_values = R"(
6193 ; The SPIR-V shader below is based on the following GLSL shader, but OpAtomicIAdd has been
6194 ; replaced with a template parameter and the last argument for it has been made optional.
6195 ;
6196 ;#version 440
6197 ;precision highp uimageBuffer;
6198 ;
6199 ;#extension GL_EXT_shader_explicit_arithmetic_types_int64 : require
6200 ;#extension GL_EXT_shader_image_int64 : require
6201 ;layout (local_size_x = 1, local_size_y = 1, local_size_z = 1) in;
6202 ;layout (r64ui, binding=0) coherent uniform uimageBuffer u_resultImage;
6203 ;layout (r64ui, binding=1) writeonly uniform uimageBuffer u_intermValuesImage;
6204 ;
6205 ;void main (void)
6206 ;{
6207 ;    int gx = int(gl_GlobalInvocationID.x);
6208 ;    int gy = int(gl_GlobalInvocationID.y);
6209 ;    int gz = int(gl_GlobalInvocationID.z);
6210 ;    imageStore(u_intermValuesImage, gx, u64vec4(imageAtomicAdd(u_resultImage, gx % 64, uint(gx*gx + gy*gy + gz*gz))));
6211 ;}
6212 ;
6213 ; SPIR-V
6214 ; Version: 1.0
6215 ; Generator: Khronos Glslang Reference Front End; 8
6216 ; Bound: 58
6217 ; Schema: 0
6218 OpCapability Shader
6219 OpCapability Int64
6220 OpCapability Int64Atomics
6221 OpCapability ImageBuffer
6222 OpCapability Int64ImageEXT
6223 OpExtension "SPV_EXT_shader_image_int64"
6224 %1 = OpExtInstImport "GLSL.std.450"
6225 OpMemoryModel Logical GLSL450
6226 OpEntryPoint GLCompute %4 "main" %12
6227 OpExecutionMode %4 LocalSize 1 1 1
6228 OpDecorate %12 BuiltIn GlobalInvocationId
6229 OpDecorate %31 DescriptorSet 0
6230 OpDecorate %31 Binding 1
6231 OpDecorate %31 NonReadable
6232 OpDecorate %34 DescriptorSet 0
6233 OpDecorate %34 Binding 0
6234 OpDecorate %34 Coherent
6235 OpDecorate %57 BuiltIn WorkgroupSize
6236 %2 = OpTypeVoid
6237 %3 = OpTypeFunction %2
6238 %6 = OpTypeInt 32 1
6239 %7 = OpTypePointer Function %6
6240 %9 = OpTypeInt 32 0
6241 %10 = OpTypeVector %9 3
6242 %11 = OpTypePointer Input %10
6243 %12 = OpVariable %11 Input
6244 %13 = OpConstant %9 0
6245 %14 = OpTypePointer Input %9
6246 %19 = OpConstant %9 1
6247 %24 = OpConstant %9 2
6248 %28 = OpTypeInt 64 0
6249 %29 = OpTypeImage %28 Buffer 0 0 0 2 R64ui
6250 %30 = OpTypePointer UniformConstant %29
6251 %31 = OpVariable %30 UniformConstant
6252 %34 = OpVariable %30 UniformConstant
6253 %36 = OpConstant %6 64
6254 %49 = OpTypeInt 64 1
6255 %52 = OpTypePointer Image %28
6256 %55 = OpTypeVector %28 4
6257 %57 = OpConstantComposite %10 %19 %19 %19
6258 %4 = OpFunction %2 None %3
6259 %5 = OpLabel
6260 %8 = OpVariable %7 Function
6261 %18 = OpVariable %7 Function
6262 %23 = OpVariable %7 Function
6263 %15 = OpAccessChain %14 %12 %13
6264 %16 = OpLoad %9 %15
6265 %17 = OpBitcast %6 %16
6266 OpStore %8 %17
6267 %20 = OpAccessChain %14 %12 %19
6268 %21 = OpLoad %9 %20
6269 %22 = OpBitcast %6 %21
6270 OpStore %18 %22
6271 %25 = OpAccessChain %14 %12 %24
6272 %26 = OpLoad %9 %25
6273 %27 = OpBitcast %6 %26
6274 OpStore %23 %27
6275 %32 = OpLoad %29 %31
6276 %33 = OpLoad %6 %8
6277 %35 = OpLoad %6 %8
6278 %37 = OpSMod %6 %35 %36
6279 %38 = OpLoad %6 %8
6280 %39 = OpLoad %6 %8
6281 %40 = OpIMul %6 %38 %39
6282 %41 = OpLoad %6 %18
6283 %42 = OpLoad %6 %18
6284 %43 = OpIMul %6 %41 %42
6285 %44 = OpIAdd %6 %40 %43
6286 %45 = OpLoad %6 %23
6287 %46 = OpLoad %6 %23
6288 %47 = OpIMul %6 %45 %46
6289 %48 = OpIAdd %6 %44 %47
6290 %50 = OpSConvert %49 %48
6291 %51 = OpBitcast %28 %50
6292 %53 = OpImageTexelPointer %52 %34 %37 %13
6293 %54 = ${OPNAME} %28 %53 %19 %13 ${LASTARG:default=%51}
6294 %56 = OpCompositeConstruct %55 %54 %54 %54 %54
6295 OpImageWrite %32 %33 %56
6296 OpReturn
6297 OpFunctionEnd
6298 )";
6299
6300 const std::string kShader_image_buffer_r64i_end_result = R"(
6301 ; The SPIR-V shader below is based on the following GLSL shader, but OpAtomicIAdd has been
6302 ; replaced with a template parameter and the last argument for it has been made optional.
6303 ;
6304 ;#version 440
6305 ;precision highp iimageBuffer;
6306 ;#extension GL_EXT_shader_explicit_arithmetic_types_int64 : require
6307 ;#extension GL_EXT_shader_image_int64 : require
6308 ;
6309 ;layout (local_size_x = 1, local_size_y = 1, local_size_z = 1) in;
6310 ;layout (r64i, binding=0) coherent uniform iimageBuffer u_resultImage;
6311 ;
6312 ;void main (void)
6313 ;{
6314 ;    int gx = int(gl_GlobalInvocationID.x);
6315 ;    int gy = int(gl_GlobalInvocationID.y);
6316 ;    int gz = int(gl_GlobalInvocationID.z);
6317 ;    imageAtomicAdd(u_resultImage, gx % 64, int(gx*gx + gy*gy + gz*gz));
6318 ;}
6319 ;
6320 ; SPIR-V
6321 ; Version: 1.0
6322 ; Generator: Khronos Glslang Reference Front End; 8
6323 ; Bound: 51
6324 ; Schema: 0
6325 OpCapability Shader
6326 OpCapability Int64
6327 OpCapability Int64Atomics
6328 OpCapability ImageBuffer
6329 OpCapability Int64ImageEXT
6330 OpExtension "SPV_EXT_shader_image_int64"
6331 %1 = OpExtInstImport "GLSL.std.450"
6332 OpMemoryModel Logical GLSL450
6333 OpEntryPoint GLCompute %4 "main" %12
6334 OpExecutionMode %4 LocalSize 1 1 1
6335 OpDecorate %12 BuiltIn GlobalInvocationId
6336 OpDecorate %31 DescriptorSet 0
6337 OpDecorate %31 Binding 0
6338 OpDecorate %31 Coherent
6339 OpDecorate %50 BuiltIn WorkgroupSize
6340 %2 = OpTypeVoid
6341 %3 = OpTypeFunction %2
6342 %6 = OpTypeInt 32 1
6343 %7 = OpTypePointer Function %6
6344 %9 = OpTypeInt 32 0
6345 %10 = OpTypeVector %9 3
6346 %11 = OpTypePointer Input %10
6347 %12 = OpVariable %11 Input
6348 %13 = OpConstant %9 0
6349 %14 = OpTypePointer Input %9
6350 %19 = OpConstant %9 1
6351 %24 = OpConstant %9 2
6352 %28 = OpTypeInt 64 1
6353 %29 = OpTypeImage %28 Buffer 0 0 0 2 R64i
6354 %30 = OpTypePointer UniformConstant %29
6355 %31 = OpVariable %30 UniformConstant
6356 %33 = OpConstant %6 64
6357 %47 = OpTypePointer Image %28
6358 %50 = OpConstantComposite %10 %19 %19 %19
6359 %4 = OpFunction %2 None %3
6360 %5 = OpLabel
6361 %8 = OpVariable %7 Function
6362 %18 = OpVariable %7 Function
6363 %23 = OpVariable %7 Function
6364 %15 = OpAccessChain %14 %12 %13
6365 %16 = OpLoad %9 %15
6366 %17 = OpBitcast %6 %16
6367 OpStore %8 %17
6368 %20 = OpAccessChain %14 %12 %19
6369 %21 = OpLoad %9 %20
6370 %22 = OpBitcast %6 %21
6371 OpStore %18 %22
6372 %25 = OpAccessChain %14 %12 %24
6373 %26 = OpLoad %9 %25
6374 %27 = OpBitcast %6 %26
6375 OpStore %23 %27
6376 %32 = OpLoad %6 %8
6377 %34 = OpSMod %6 %32 %33
6378 %35 = OpLoad %6 %8
6379 %36 = OpLoad %6 %8
6380 %37 = OpIMul %6 %35 %36
6381 %38 = OpLoad %6 %18
6382 %39 = OpLoad %6 %18
6383 %40 = OpIMul %6 %38 %39
6384 %41 = OpIAdd %6 %37 %40
6385 %42 = OpLoad %6 %23
6386 %43 = OpLoad %6 %23
6387 %44 = OpIMul %6 %42 %43
6388 %45 = OpIAdd %6 %41 %44
6389 %46 = OpSConvert %28 %45
6390 %48 = OpImageTexelPointer %47 %31 %34 %13
6391 %49 = ${OPNAME} %28 %48 %19 %13 ${LASTARG:default=%46}
6392 OpReturn
6393 OpFunctionEnd
6394 )";
6395
6396 const std::string kShader_image_buffer_r64i_intermediate_values = R"(
6397 ; The SPIR-V shader below is based on the following GLSL shader, but OpAtomicIAdd has been
6398 ; replaced with a template parameter and the last argument for it has been made optional.
6399 ;
6400 ;#version 440
6401 ;precision highp iimageBuffer;
6402 ;
6403 ;#extension GL_EXT_shader_explicit_arithmetic_types_int64 : require
6404 ;#extension GL_EXT_shader_image_int64 : require
6405 ;layout (local_size_x = 1, local_size_y = 1, local_size_z = 1) in;
6406 ;layout (r64i, binding=0) coherent uniform iimageBuffer u_resultImage;
6407 ;layout (r64i, binding=1) writeonly uniform iimageBuffer u_intermValuesImage;
6408 ;
6409 ;void main (void)
6410 ;{
6411 ;    int gx = int(gl_GlobalInvocationID.x);
6412 ;    int gy = int(gl_GlobalInvocationID.y);
6413 ;    int gz = int(gl_GlobalInvocationID.z);
6414 ;    imageStore(u_intermValuesImage, gx, i64vec4(imageAtomicAdd(u_resultImage, gx % 64, int(gx*gx + gy*gy + gz*gz))));
6415 ;}
6416 ; SPIR-V
6417 ; Version: 1.0
6418 ; Generator: Khronos Glslang Reference Front End; 8
6419 ; Bound: 56
6420 ; Schema: 0
6421 OpCapability Shader
6422 OpCapability Int64
6423 OpCapability Int64Atomics
6424 OpCapability ImageBuffer
6425 OpCapability Int64ImageEXT
6426 OpExtension "SPV_EXT_shader_image_int64"
6427 %1 = OpExtInstImport "GLSL.std.450"
6428 OpMemoryModel Logical GLSL450
6429 OpEntryPoint GLCompute %4 "main" %12
6430 OpExecutionMode %4 LocalSize 1 1 1
6431 OpDecorate %12 BuiltIn GlobalInvocationId
6432 OpDecorate %31 DescriptorSet 0
6433 OpDecorate %31 Binding 1
6434 OpDecorate %31 NonReadable
6435 OpDecorate %34 DescriptorSet 0
6436 OpDecorate %34 Binding 0
6437 OpDecorate %34 Coherent
6438 OpDecorate %55 BuiltIn WorkgroupSize
6439 %2 = OpTypeVoid
6440 %3 = OpTypeFunction %2
6441 %6 = OpTypeInt 32 1
6442 %7 = OpTypePointer Function %6
6443 %9 = OpTypeInt 32 0
6444 %10 = OpTypeVector %9 3
6445 %11 = OpTypePointer Input %10
6446 %12 = OpVariable %11 Input
6447 %13 = OpConstant %9 0
6448 %14 = OpTypePointer Input %9
6449 %19 = OpConstant %9 1
6450 %24 = OpConstant %9 2
6451 %28 = OpTypeInt 64 1
6452 %29 = OpTypeImage %28 Buffer 0 0 0 2 R64i
6453 %30 = OpTypePointer UniformConstant %29
6454 %31 = OpVariable %30 UniformConstant
6455 %34 = OpVariable %30 UniformConstant
6456 %36 = OpConstant %6 64
6457 %50 = OpTypePointer Image %28
6458 %53 = OpTypeVector %28 4
6459 %55 = OpConstantComposite %10 %19 %19 %19
6460 %4 = OpFunction %2 None %3
6461 %5 = OpLabel
6462 %8 = OpVariable %7 Function
6463 %18 = OpVariable %7 Function
6464 %23 = OpVariable %7 Function
6465 %15 = OpAccessChain %14 %12 %13
6466 %16 = OpLoad %9 %15
6467 %17 = OpBitcast %6 %16
6468 OpStore %8 %17
6469 %20 = OpAccessChain %14 %12 %19
6470 %21 = OpLoad %9 %20
6471 %22 = OpBitcast %6 %21
6472 OpStore %18 %22
6473 %25 = OpAccessChain %14 %12 %24
6474 %26 = OpLoad %9 %25
6475 %27 = OpBitcast %6 %26
6476 OpStore %23 %27
6477 %32 = OpLoad %29 %31
6478 %33 = OpLoad %6 %8
6479 %35 = OpLoad %6 %8
6480 %37 = OpSMod %6 %35 %36
6481 %38 = OpLoad %6 %8
6482 %39 = OpLoad %6 %8
6483 %40 = OpIMul %6 %38 %39
6484 %41 = OpLoad %6 %18
6485 %42 = OpLoad %6 %18
6486 %43 = OpIMul %6 %41 %42
6487 %44 = OpIAdd %6 %40 %43
6488 %45 = OpLoad %6 %23
6489 %46 = OpLoad %6 %23
6490 %47 = OpIMul %6 %45 %46
6491 %48 = OpIAdd %6 %44 %47
6492 %49 = OpSConvert %28 %48
6493 %51 = OpImageTexelPointer %50 %34 %37 %13
6494 %52 = ${OPNAME} %28 %51 %19 %13 ${LASTARG:default=%49}
6495 %54 = OpCompositeConstruct %53 %52 %52 %52 %52
6496 OpImageWrite %32 %33 %54
6497 OpReturn
6498 OpFunctionEnd
6499 )";
6500
6501 } // anonymous namespace
6502
6503 bool CaseVariant::operator< (const CaseVariant& other) const
6504 {
6505         // Simple lexicographical comparison using the struct members.
6506         const std::array<int, 4> thisMembers =
6507         {{
6508                 static_cast<int>(imageType),
6509                 static_cast<int>(textureFormat.order),
6510                 static_cast<int>(textureFormat.type),
6511                 static_cast<int>(checkType),
6512         }};
6513
6514         const std::array<int, 4> otherMembers =
6515         {{
6516                 static_cast<int>(other.imageType),
6517                 static_cast<int>(other.textureFormat.order),
6518                 static_cast<int>(other.textureFormat.type),
6519                 static_cast<int>(other.checkType),
6520         }};
6521
6522         return thisMembers < otherMembers;
6523 }
6524
6525 CaseVariant::CaseVariant (ImageType imgtype, tcu::TextureFormat::ChannelOrder order, tcu::TextureFormat::ChannelType chtype, CheckType cktype)
6526         : imageType{imgtype}, textureFormat{order, chtype}, checkType{cktype}
6527 {}
6528
6529 std::string getSpirvAtomicOpShader (const CaseVariant& caseVariant)
6530 {
6531         using ShadersMapT       = std::map<CaseVariant, const std::string*>;
6532         using ValueType         = ShadersMapT::value_type;
6533
6534         static const ShadersMapT kShadersMap =
6535         {
6536                 ValueType{CaseVariant{IMAGE_TYPE_1D,                    tcu::TextureFormat::R,  tcu::TextureFormat::UNSIGNED_INT32,     CaseVariant::CHECK_TYPE_END_RESULTS},                   &kShader_1d_r32ui_end_result},
6537                 ValueType{CaseVariant{IMAGE_TYPE_1D,                    tcu::TextureFormat::R,  tcu::TextureFormat::UNSIGNED_INT32,     CaseVariant::CHECK_TYPE_INTERMEDIATE_RESULTS},  &kShader_1d_r32ui_intermediate_values},
6538                 ValueType{CaseVariant{IMAGE_TYPE_1D,                    tcu::TextureFormat::R,  tcu::TextureFormat::SIGNED_INT32,       CaseVariant::CHECK_TYPE_END_RESULTS},                   &kShader_1d_r32i_end_result},
6539                 ValueType{CaseVariant{IMAGE_TYPE_1D,                    tcu::TextureFormat::R,  tcu::TextureFormat::SIGNED_INT32,       CaseVariant::CHECK_TYPE_INTERMEDIATE_RESULTS},  &kShader_1d_r32i_intermediate_values},
6540                 ValueType{CaseVariant{IMAGE_TYPE_1D_ARRAY,              tcu::TextureFormat::R,  tcu::TextureFormat::UNSIGNED_INT32,     CaseVariant::CHECK_TYPE_END_RESULTS},                   &kShader_1d_array_r32ui_end_result},
6541                 ValueType{CaseVariant{IMAGE_TYPE_1D_ARRAY,              tcu::TextureFormat::R,  tcu::TextureFormat::UNSIGNED_INT32,     CaseVariant::CHECK_TYPE_INTERMEDIATE_RESULTS},  &kShader_1d_array_r32ui_intermediate_values},
6542                 ValueType{CaseVariant{IMAGE_TYPE_1D_ARRAY,              tcu::TextureFormat::R,  tcu::TextureFormat::SIGNED_INT32,       CaseVariant::CHECK_TYPE_END_RESULTS},                   &kShader_1d_array_r32i_end_result},
6543                 ValueType{CaseVariant{IMAGE_TYPE_1D_ARRAY,              tcu::TextureFormat::R,  tcu::TextureFormat::SIGNED_INT32,       CaseVariant::CHECK_TYPE_INTERMEDIATE_RESULTS},  &kShader_1d_array_r32i_intermediate_values},
6544                 ValueType{CaseVariant{IMAGE_TYPE_2D,                    tcu::TextureFormat::R,  tcu::TextureFormat::UNSIGNED_INT32,     CaseVariant::CHECK_TYPE_END_RESULTS},                   &kShader_2d_r32ui_end_result},
6545                 ValueType{CaseVariant{IMAGE_TYPE_2D,                    tcu::TextureFormat::R,  tcu::TextureFormat::UNSIGNED_INT32,     CaseVariant::CHECK_TYPE_INTERMEDIATE_RESULTS},  &kShader_2d_r32ui_intermediate_values},
6546                 ValueType{CaseVariant{IMAGE_TYPE_2D,                    tcu::TextureFormat::R,  tcu::TextureFormat::SIGNED_INT32,       CaseVariant::CHECK_TYPE_END_RESULTS},                   &kShader_2d_r32i_end_result},
6547                 ValueType{CaseVariant{IMAGE_TYPE_2D,                    tcu::TextureFormat::R,  tcu::TextureFormat::SIGNED_INT32,       CaseVariant::CHECK_TYPE_INTERMEDIATE_RESULTS},  &kShader_2d_r32i_intermediate_values},
6548                 ValueType{CaseVariant{IMAGE_TYPE_2D_ARRAY,              tcu::TextureFormat::R,  tcu::TextureFormat::UNSIGNED_INT32,     CaseVariant::CHECK_TYPE_END_RESULTS},                   &kShader_2d_array_r32ui_end_result},
6549                 ValueType{CaseVariant{IMAGE_TYPE_2D_ARRAY,              tcu::TextureFormat::R,  tcu::TextureFormat::UNSIGNED_INT32,     CaseVariant::CHECK_TYPE_INTERMEDIATE_RESULTS},  &kShader_2d_array_r32ui_intermediate_values},
6550                 ValueType{CaseVariant{IMAGE_TYPE_2D_ARRAY,              tcu::TextureFormat::R,  tcu::TextureFormat::SIGNED_INT32,       CaseVariant::CHECK_TYPE_END_RESULTS},                   &kShader_2d_array_r32i_end_result},
6551                 ValueType{CaseVariant{IMAGE_TYPE_2D_ARRAY,              tcu::TextureFormat::R,  tcu::TextureFormat::SIGNED_INT32,       CaseVariant::CHECK_TYPE_INTERMEDIATE_RESULTS},  &kShader_2d_array_r32i_intermediate_values},
6552                 ValueType{CaseVariant{IMAGE_TYPE_3D,                    tcu::TextureFormat::R,  tcu::TextureFormat::UNSIGNED_INT32,     CaseVariant::CHECK_TYPE_END_RESULTS},                   &kShader_3d_r32ui_end_result},
6553                 ValueType{CaseVariant{IMAGE_TYPE_3D,                    tcu::TextureFormat::R,  tcu::TextureFormat::UNSIGNED_INT32,     CaseVariant::CHECK_TYPE_INTERMEDIATE_RESULTS},  &kShader_3d_r32ui_intermediate_values},
6554                 ValueType{CaseVariant{IMAGE_TYPE_3D,                    tcu::TextureFormat::R,  tcu::TextureFormat::SIGNED_INT32,       CaseVariant::CHECK_TYPE_END_RESULTS},                   &kShader_3d_r32i_end_result},
6555                 ValueType{CaseVariant{IMAGE_TYPE_3D,                    tcu::TextureFormat::R,  tcu::TextureFormat::SIGNED_INT32,       CaseVariant::CHECK_TYPE_INTERMEDIATE_RESULTS},  &kShader_3d_r32i_intermediate_values},
6556                 ValueType{CaseVariant{IMAGE_TYPE_CUBE,                  tcu::TextureFormat::R,  tcu::TextureFormat::UNSIGNED_INT32,     CaseVariant::CHECK_TYPE_END_RESULTS},                   &kShader_cube_r32ui_end_result},
6557                 ValueType{CaseVariant{IMAGE_TYPE_CUBE,                  tcu::TextureFormat::R,  tcu::TextureFormat::UNSIGNED_INT32,     CaseVariant::CHECK_TYPE_INTERMEDIATE_RESULTS},  &kShader_cube_r32ui_intermediate_values},
6558                 ValueType{CaseVariant{IMAGE_TYPE_CUBE,                  tcu::TextureFormat::R,  tcu::TextureFormat::SIGNED_INT32,       CaseVariant::CHECK_TYPE_END_RESULTS},                   &kShader_cube_r32i_end_result},
6559                 ValueType{CaseVariant{IMAGE_TYPE_CUBE,                  tcu::TextureFormat::R,  tcu::TextureFormat::SIGNED_INT32,       CaseVariant::CHECK_TYPE_INTERMEDIATE_RESULTS},  &kShader_cube_r32i_intermediate_values},
6560                 ValueType{CaseVariant{IMAGE_TYPE_CUBE_ARRAY,    tcu::TextureFormat::R,  tcu::TextureFormat::UNSIGNED_INT32,     CaseVariant::CHECK_TYPE_END_RESULTS},                   &kShader_cube_array_r32ui_end_result},
6561                 ValueType{CaseVariant{IMAGE_TYPE_CUBE_ARRAY,    tcu::TextureFormat::R,  tcu::TextureFormat::UNSIGNED_INT32,     CaseVariant::CHECK_TYPE_INTERMEDIATE_RESULTS},  &kShader_cube_array_r32ui_intermediate_values},
6562                 ValueType{CaseVariant{IMAGE_TYPE_CUBE_ARRAY,    tcu::TextureFormat::R,  tcu::TextureFormat::SIGNED_INT32,       CaseVariant::CHECK_TYPE_END_RESULTS},                   &kShader_cube_array_r32i_end_result},
6563                 ValueType{CaseVariant{IMAGE_TYPE_CUBE_ARRAY,    tcu::TextureFormat::R,  tcu::TextureFormat::SIGNED_INT32,       CaseVariant::CHECK_TYPE_INTERMEDIATE_RESULTS},  &kShader_cube_array_r32i_intermediate_values},
6564                 ValueType{CaseVariant{IMAGE_TYPE_BUFFER,                tcu::TextureFormat::R,  tcu::TextureFormat::UNSIGNED_INT32,     CaseVariant::CHECK_TYPE_END_RESULTS},                   &kShader_image_buffer_r32ui_end_result},
6565                 ValueType{CaseVariant{IMAGE_TYPE_BUFFER,                tcu::TextureFormat::R,  tcu::TextureFormat::UNSIGNED_INT32,     CaseVariant::CHECK_TYPE_INTERMEDIATE_RESULTS},  &kShader_image_buffer_r32ui_intermediate_values},
6566                 ValueType{CaseVariant{IMAGE_TYPE_BUFFER,                tcu::TextureFormat::R,  tcu::TextureFormat::SIGNED_INT32,       CaseVariant::CHECK_TYPE_END_RESULTS},                   &kShader_image_buffer_r32i_end_result},
6567                 ValueType{CaseVariant{IMAGE_TYPE_BUFFER,                tcu::TextureFormat::R,  tcu::TextureFormat::SIGNED_INT32,       CaseVariant::CHECK_TYPE_INTERMEDIATE_RESULTS},  &kShader_image_buffer_r32i_intermediate_values},
6568
6569                 ValueType{CaseVariant{IMAGE_TYPE_1D,                    tcu::TextureFormat::R,  tcu::TextureFormat::UNSIGNED_INT64,     CaseVariant::CHECK_TYPE_END_RESULTS},                   &kShader_1d_r64ui_end_result},
6570                 ValueType{CaseVariant{IMAGE_TYPE_1D,                    tcu::TextureFormat::R,  tcu::TextureFormat::UNSIGNED_INT64,     CaseVariant::CHECK_TYPE_INTERMEDIATE_RESULTS},  &kShader_1d_r64ui_intermediate_values},
6571                 ValueType{CaseVariant{IMAGE_TYPE_1D,                    tcu::TextureFormat::R,  tcu::TextureFormat::SIGNED_INT64,       CaseVariant::CHECK_TYPE_END_RESULTS},                   &kShader_1d_r64i_end_result},
6572                 ValueType{CaseVariant{IMAGE_TYPE_1D,                    tcu::TextureFormat::R,  tcu::TextureFormat::SIGNED_INT64,       CaseVariant::CHECK_TYPE_INTERMEDIATE_RESULTS},  &kShader_1d_r64i_intermediate_values},
6573                 ValueType{CaseVariant{IMAGE_TYPE_1D_ARRAY,              tcu::TextureFormat::R,  tcu::TextureFormat::UNSIGNED_INT64,     CaseVariant::CHECK_TYPE_END_RESULTS},                   &kShader_1d_array_r64ui_end_result},
6574                 ValueType{CaseVariant{IMAGE_TYPE_1D_ARRAY,              tcu::TextureFormat::R,  tcu::TextureFormat::UNSIGNED_INT64,     CaseVariant::CHECK_TYPE_INTERMEDIATE_RESULTS},  &kShader_1d_array_r64ui_intermediate_values},
6575                 ValueType{CaseVariant{IMAGE_TYPE_1D_ARRAY,              tcu::TextureFormat::R,  tcu::TextureFormat::SIGNED_INT64,       CaseVariant::CHECK_TYPE_END_RESULTS},                   &kShader_1d_array_r64i_end_result},
6576                 ValueType{CaseVariant{IMAGE_TYPE_1D_ARRAY,              tcu::TextureFormat::R,  tcu::TextureFormat::SIGNED_INT64,       CaseVariant::CHECK_TYPE_INTERMEDIATE_RESULTS},  &kShader_1d_array_r64i_intermediate_values},
6577                 ValueType{CaseVariant{IMAGE_TYPE_2D,                    tcu::TextureFormat::R,  tcu::TextureFormat::UNSIGNED_INT64,     CaseVariant::CHECK_TYPE_END_RESULTS},                   &kShader_2d_r64ui_end_result},
6578                 ValueType{CaseVariant{IMAGE_TYPE_2D,                    tcu::TextureFormat::R,  tcu::TextureFormat::UNSIGNED_INT64,     CaseVariant::CHECK_TYPE_INTERMEDIATE_RESULTS},  &kShader_2d_r64ui_intermediate_values},
6579                 ValueType{CaseVariant{IMAGE_TYPE_2D,                    tcu::TextureFormat::R,  tcu::TextureFormat::SIGNED_INT64,       CaseVariant::CHECK_TYPE_END_RESULTS},                   &kShader_2d_r64i_end_result},
6580                 ValueType{CaseVariant{IMAGE_TYPE_2D,                    tcu::TextureFormat::R,  tcu::TextureFormat::SIGNED_INT64,       CaseVariant::CHECK_TYPE_INTERMEDIATE_RESULTS},  &kShader_2d_r64i_intermediate_values},
6581                 ValueType{CaseVariant{IMAGE_TYPE_2D_ARRAY,              tcu::TextureFormat::R,  tcu::TextureFormat::UNSIGNED_INT64,     CaseVariant::CHECK_TYPE_END_RESULTS},                   &kShader_2d_array_r64ui_end_result},
6582                 ValueType{CaseVariant{IMAGE_TYPE_2D_ARRAY,              tcu::TextureFormat::R,  tcu::TextureFormat::UNSIGNED_INT64,     CaseVariant::CHECK_TYPE_INTERMEDIATE_RESULTS},  &kShader_2d_array_r64ui_intermediate_values},
6583                 ValueType{CaseVariant{IMAGE_TYPE_2D_ARRAY,              tcu::TextureFormat::R,  tcu::TextureFormat::SIGNED_INT64,       CaseVariant::CHECK_TYPE_END_RESULTS},                   &kShader_2d_array_r64i_end_result},
6584                 ValueType{CaseVariant{IMAGE_TYPE_2D_ARRAY,              tcu::TextureFormat::R,  tcu::TextureFormat::SIGNED_INT64,       CaseVariant::CHECK_TYPE_INTERMEDIATE_RESULTS},  &kShader_2d_array_r64i_intermediate_values},
6585                 ValueType{CaseVariant{IMAGE_TYPE_3D,                    tcu::TextureFormat::R,  tcu::TextureFormat::UNSIGNED_INT64,     CaseVariant::CHECK_TYPE_END_RESULTS},                   &kShader_3d_r64ui_end_result},
6586                 ValueType{CaseVariant{IMAGE_TYPE_3D,                    tcu::TextureFormat::R,  tcu::TextureFormat::UNSIGNED_INT64,     CaseVariant::CHECK_TYPE_INTERMEDIATE_RESULTS},  &kShader_3d_r64ui_intermediate_values},
6587                 ValueType{CaseVariant{IMAGE_TYPE_3D,                    tcu::TextureFormat::R,  tcu::TextureFormat::SIGNED_INT64,       CaseVariant::CHECK_TYPE_END_RESULTS},                   &kShader_3d_r64i_end_result},
6588                 ValueType{CaseVariant{IMAGE_TYPE_3D,                    tcu::TextureFormat::R,  tcu::TextureFormat::SIGNED_INT64,       CaseVariant::CHECK_TYPE_INTERMEDIATE_RESULTS},  &kShader_3d_r64i_intermediate_values},
6589                 ValueType{CaseVariant{IMAGE_TYPE_CUBE,                  tcu::TextureFormat::R,  tcu::TextureFormat::UNSIGNED_INT64,     CaseVariant::CHECK_TYPE_END_RESULTS},                   &kShader_cube_r64ui_end_result},
6590                 ValueType{CaseVariant{IMAGE_TYPE_CUBE,                  tcu::TextureFormat::R,  tcu::TextureFormat::UNSIGNED_INT64,     CaseVariant::CHECK_TYPE_INTERMEDIATE_RESULTS},  &kShader_cube_r64ui_intermediate_values},
6591                 ValueType{CaseVariant{IMAGE_TYPE_CUBE,                  tcu::TextureFormat::R,  tcu::TextureFormat::SIGNED_INT64,       CaseVariant::CHECK_TYPE_END_RESULTS},                   &kShader_cube_r64i_end_result},
6592                 ValueType{CaseVariant{IMAGE_TYPE_CUBE,                  tcu::TextureFormat::R,  tcu::TextureFormat::SIGNED_INT64,       CaseVariant::CHECK_TYPE_INTERMEDIATE_RESULTS},  &kShader_cube_r64i_intermediate_values},
6593                 ValueType{CaseVariant{IMAGE_TYPE_CUBE_ARRAY,    tcu::TextureFormat::R,  tcu::TextureFormat::UNSIGNED_INT64,     CaseVariant::CHECK_TYPE_END_RESULTS},                   &kShader_cube_array_r64ui_end_result},
6594                 ValueType{CaseVariant{IMAGE_TYPE_CUBE_ARRAY,    tcu::TextureFormat::R,  tcu::TextureFormat::UNSIGNED_INT64,     CaseVariant::CHECK_TYPE_INTERMEDIATE_RESULTS},  &kShader_cube_array_r64ui_intermediate_values},
6595                 ValueType{CaseVariant{IMAGE_TYPE_CUBE_ARRAY,    tcu::TextureFormat::R,  tcu::TextureFormat::SIGNED_INT64,       CaseVariant::CHECK_TYPE_END_RESULTS},                   &kShader_cube_array_r64i_end_result},
6596                 ValueType{CaseVariant{IMAGE_TYPE_CUBE_ARRAY,    tcu::TextureFormat::R,  tcu::TextureFormat::SIGNED_INT64,       CaseVariant::CHECK_TYPE_INTERMEDIATE_RESULTS},  &kShader_cube_array_r64i_intermediate_values},
6597                 ValueType{CaseVariant{IMAGE_TYPE_BUFFER,                tcu::TextureFormat::R,  tcu::TextureFormat::UNSIGNED_INT64,     CaseVariant::CHECK_TYPE_END_RESULTS},                   &kShader_image_buffer_r64ui_end_result},
6598                 ValueType{CaseVariant{IMAGE_TYPE_BUFFER,                tcu::TextureFormat::R,  tcu::TextureFormat::UNSIGNED_INT64,     CaseVariant::CHECK_TYPE_INTERMEDIATE_RESULTS},  &kShader_image_buffer_r64ui_intermediate_values},
6599                 ValueType{CaseVariant{IMAGE_TYPE_BUFFER,                tcu::TextureFormat::R,  tcu::TextureFormat::SIGNED_INT64,       CaseVariant::CHECK_TYPE_END_RESULTS},                   &kShader_image_buffer_r64i_end_result},
6600                 ValueType{CaseVariant{IMAGE_TYPE_BUFFER,                tcu::TextureFormat::R,  tcu::TextureFormat::SIGNED_INT64,       CaseVariant::CHECK_TYPE_INTERMEDIATE_RESULTS},  &kShader_image_buffer_r64i_intermediate_values},
6601         };
6602
6603         const auto iter = kShadersMap.find(caseVariant);
6604         DE_ASSERT(iter != kShadersMap.end());
6605         return *(iter->second);
6606 }
6607
6608 } // namespace image
6609 } // namespace vkt
6610
6611 // Note: the SPIR-V shaders above were created using the atomic addition shaders as a base, replacing OpAtomicIAdd with a string
6612 // template and making the last operation argument optional. Because the atomic addition shaders are generated, the final version of
6613 // each shader was obtained from TestResults.qpa after running the whole atomic addition group, using the Python script documented
6614 // below.
6615 #if 0
6616 import html
6617 import re
6618 import sys
6619
6620 STATE_OUT = 0
6621 STATE_GLSL = 1
6622 STATE_SPIRV = 2
6623
6624 state = STATE_OUT
6625 test_name = None
6626 glsl_lines = []
6627 spirv_lines = []
6628 header_printed = False
6629
6630 for line in sys.stdin:
6631         if line.startswith("#beginTestCaseResult"):
6632                 test_name = line.strip().split()[1]
6633                 test_name = "_".join(test_name.split(".")[-2:])
6634
6635         if "<ShaderSource>" in line:
6636                 line = re.sub(r".*<ShaderSource>", "", line)
6637                 state = STATE_GLSL
6638
6639         if "</ShaderSource>" in line:
6640                 state = STATE_OUT
6641
6642         if "<SpirVAssemblySource>" in line:
6643                 line = re.sub(r".*<SpirVAssemblySource>", "", line)
6644                 state = STATE_SPIRV
6645
6646         if "</SpirVAssemblySource>" in line:
6647                 state = STATE_OUT
6648                 if not header_printed:
6649                         print("#include <string>")
6650                         print()
6651                         header_printed = True
6652                 print("const std::string kShader_%s = R\"(" % (test_name,))
6653                 print("; The SPIR-V shader below is based on the following GLSL shader, but OpAtomicIAdd has been")
6654                 print("; replaced with a template parameter and the last argument for it has been made optional.")
6655                 print(";")
6656                 for glsl_line in glsl_lines:
6657                         glsl_line = html.unescape(glsl_line)
6658                         print("; %s" % (glsl_line,), end="")
6659                 print(";")
6660                 for spirv_line in spirv_lines:
6661                         spirv_line = html.unescape(spirv_line)
6662                         if "OpAtomicIAdd" in spirv_line:
6663                                 words = spirv_line.strip().split()
6664                                 for i in range(len(words)):
6665                                         if words[i] == "OpAtomicIAdd":
6666                                                 words[i] = r"${OPNAME}"
6667                                 words[-1] = r"${LASTARG:default=%s}" % (words[-1], )
6668                                 spirv_line = " ".join(words) + "\n"
6669                         print("%s" % (spirv_line, ), end="")
6670                 print(")\";")
6671                 print()
6672
6673                 test_name = None
6674                 glsl_lines = []
6675                 spirv_lines = []
6676
6677         if state == STATE_GLSL:
6678                 glsl_lines.append(line)
6679         elif state == STATE_SPIRV:
6680                 spirv_lines.append(line)
6681 #endif