1#!amber
2SHADER compute compute_shader SPIRV-ASM
3; SPIR-V
4; Version: 1.3
5; Generator: Google Tint Compiler; 0
6; Bound: 36
7; Schema: 0
8               OpCapability Shader
9               OpExtension "SPV_KHR_storage_buffer_storage_class"
10               OpMemoryModel Logical GLSL450
11               OpEntryPoint GLCompute %main "main"
12               OpExecutionMode %main LocalSize 1 1 1
13               OpName %flow_block "flow_block"
14               OpMemberName %flow_block 0 "inner"
15               OpName %flow "flow"
16               OpName %main "main"
17               OpName %LOOP_COUNTER "LOOP_COUNTER"
18               OpDecorate %flow_block Block
19               OpMemberDecorate %flow_block 0 Offset 0
20               OpDecorate %_arr_uint_uint_2 ArrayStride 4
21               OpDecorate %flow DescriptorSet 0
22               OpDecorate %flow Binding 0
23       %uint = OpTypeInt 32 0
24     %uint_2 = OpConstant %uint 2
25%_arr_uint_uint_2 = OpTypeArray %uint %uint_2
26 %flow_block = OpTypeStruct %_arr_uint_uint_2
27%_ptr_StorageBuffer_flow_block = OpTypePointer StorageBuffer %flow_block
28       %flow = OpVariable %_ptr_StorageBuffer_flow_block StorageBuffer
29       %void = OpTypeVoid
30          %7 = OpTypeFunction %void
31         %11 = OpConstantNull %uint
32%_ptr_Function_uint = OpTypePointer Function %uint
33     %uint_0 = OpConstant %uint 0
34%_ptr_StorageBuffer_uint = OpTypePointer StorageBuffer %uint
35     %uint_1 = OpConstant %uint 1
36       %bool = OpTypeBool
37       %main = OpFunction %void None %7
38         %10 = OpLabel
39%LOOP_COUNTER = OpVariable %_ptr_Function_uint Function %11
40               OpStore %LOOP_COUNTER %11
41               OpBranch %14
42         %14 = OpLabel
43               OpLoopMerge %15 %16 None
44               OpBranch %17
45         %17 = OpLabel
46         %20 = OpAccessChain %_ptr_StorageBuffer_uint %flow %uint_0 %11
47         %21 = OpAccessChain %_ptr_StorageBuffer_uint %flow %uint_0 %11
48         %22 = OpLoad %uint %21
49         %24 = OpIAdd %uint %22 %uint_1
50               OpStore %20 %24
51         %25 = OpLoad %uint %LOOP_COUNTER
52         %26 = OpUGreaterThanEqual %bool %25 %uint_1
53               OpSelectionMerge %28 None
54               OpBranchConditional %26 %29 %28
55         %29 = OpLabel
56         %30 = OpAccessChain %_ptr_StorageBuffer_uint %flow %uint_0 %uint_1
57         %31 = OpAccessChain %_ptr_StorageBuffer_uint %flow %uint_0 %uint_1
58         %32 = OpLoad %uint %31
59         %33 = OpIAdd %uint %32 %uint_1
60               OpStore %30 %33
61               OpBranch %15
62         %28 = OpLabel
63         %34 = OpLoad %uint %LOOP_COUNTER
64         %35 = OpIAdd %uint %34 %uint_1
65               OpStore %LOOP_COUNTER %35
66               OpBranch %16
67         %16 = OpLabel
68               OpBranch %14
69         %15 = OpLabel
70               OpReturn
71               OpFunctionEnd
72END
73
74BUFFER buf0 DATA_TYPE uint32 DATA 0 0 END
75
76BUFFER expected0 DATA_TYPE uint32 DATA 2 1 END
77
78PIPELINE compute pipeline
79  ATTACH compute_shader
80
81  BIND BUFFER buf0 AS storage DESCRIPTOR_SET 0 BINDING 0
82END
83
84RUN pipeline 1 1 1
85
86#EXPECT buf0 IDX 0 EQ 2
87#EXPECT buf0 IDX 4 EQ 1
88
89EXPECT buf0 EQ_BUFFER expected0
90