1 # Copyright 2018 Google LLC
3 # Licensed under the Apache License, Version 2.0 (the "License");
4 # you may not use this file except in compliance with the License.
5 # You may obtain a copy of the License at
7 # http://www.apache.org/licenses/LICENSE-2.0
9 # Unless required by applicable law or agreed to in writing, software
10 # distributed under the License is distributed on an "AS IS" BASIS,
11 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 # See the License for the specific language governing permissions and
13 # limitations under the License.
15 # A test for a bug found by GraphicsFuzz.
17 # Short description: A compute shader with a barrier in a loop with a break
19 # Derived from the following GLSL.
21 # Compute shader GLSL:
24 # layout(set = 0, binding = 1) uniform buf1 {
25 # vec2 injectionSwitch;
27 # layout(std430, binding = 0) buffer doesNotMatter {
31 # layout(local_size_x = 16, local_size_y = 1) in;
34 # int lid = int(gl_LocalInvocationID.x);
35 # int val = global_seed;
44 # val += data[lid - 1];
45 # if(injectionSwitch.x > 100.0)
57 [compute shader spirv]
60 ; Generator: Khronos Glslang Reference Front End; 7
64 %1 = OpExtInstImport "GLSL.std.450"
65 OpMemoryModel Logical GLSL450
66 OpEntryPoint GLCompute %4 "main" %12
67 OpExecutionMode %4 LocalSize 16 1 1
71 OpName %12 "gl_LocalInvocationID"
73 OpName %20 "doesNotMatter"
74 OpMemberName %20 0 "global_seed"
75 OpMemberName %20 1 "data"
79 OpMemberName %50 0 "injectionSwitch"
81 OpDecorate %12 BuiltIn LocalInvocationId
82 OpDecorate %19 ArrayStride 4
83 OpMemberDecorate %20 0 Offset 0
84 OpMemberDecorate %20 1 Offset 4
85 OpDecorate %20 BufferBlock
86 OpDecorate %22 DescriptorSet 0
87 OpDecorate %22 Binding 0
88 OpMemberDecorate %50 0 Offset 0
90 OpDecorate %52 DescriptorSet 0
91 OpDecorate %52 Binding 1
92 OpDecorate %73 BuiltIn WorkgroupSize
94 %3 = OpTypeFunction %2
96 %7 = OpTypePointer Function %6
98 %10 = OpTypeVector %9 3
99 %11 = OpTypePointer Input %10
100 %12 = OpVariable %11 Input
101 %13 = OpConstant %9 0
102 %14 = OpTypePointer Input %9
103 %19 = OpTypeRuntimeArray %6
104 %20 = OpTypeStruct %6 %19
105 %21 = OpTypePointer Uniform %20
106 %22 = OpVariable %21 Uniform
107 %23 = OpConstant %6 0
108 %24 = OpTypePointer Uniform %6
109 %34 = OpConstant %6 2
111 %41 = OpConstant %6 1
113 %49 = OpTypeVector %48 2
114 %50 = OpTypeStruct %49
115 %51 = OpTypePointer Uniform %50
116 %52 = OpVariable %51 Uniform
117 %53 = OpTypePointer Uniform %48
118 %56 = OpConstant %48 100
119 %61 = OpConstant %9 2
120 %62 = OpConstant %9 264
121 %69 = OpConstant %6 42
122 %71 = OpConstant %9 16
123 %72 = OpConstant %9 1
124 %73 = OpConstantComposite %10 %71 %72 %72
125 %4 = OpFunction %2 None %3
127 %8 = OpVariable %7 Function
128 %18 = OpVariable %7 Function
129 %27 = OpVariable %7 Function
130 %15 = OpAccessChain %14 %12 %13
132 %17 = OpBitcast %6 %16
134 %25 = OpAccessChain %24 %22 %23
140 OpLoopMerge %30 %31 None
144 %36 = OpSLessThan %35 %33 %34
145 OpBranchConditional %36 %29 %30
148 %38 = OpSGreaterThan %35 %37 %23
149 OpSelectionMerge %40 None
150 OpBranchConditional %38 %39 %40
153 %43 = OpISub %6 %42 %41
154 %44 = OpAccessChain %24 %22 %41 %43
157 %47 = OpIAdd %6 %46 %45
159 %54 = OpAccessChain %53 %52 %23 %13
161 %57 = OpFOrdGreaterThan %35 %55 %56
162 OpSelectionMerge %59 None
163 OpBranchConditional %57 %58 %59
169 OpControlBarrier %61 %61 %62
173 %64 = OpIAdd %6 %63 %41
178 %66 = OpIEqual %35 %65 %23
179 OpSelectionMerge %68 None
180 OpBranchConditional %66 %67 %68
182 %70 = OpAccessChain %24 %22 %41 %23
193 uniform ubo 0:1 vec2 0 0.0 1.0
195 ssbo 0 subdata int 0 12345
196 ssbo 0 subdata int 4 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
199 probe ssbo int 0 4 == 42