Fix missing dependency on sparse binds
[platform/upstream/VK-GL-CTS.git] / external / vulkancts / data / vulkan / amber / graphicsfuzz / two-for-loops-with-barrier-function.amber
1 #!amber
2
3 # Copyright 2019 Google LLC
4 #
5 # Licensed under the Apache License, Version 2.0 (the "License");
6 # you may not use this file except in compliance with the License.
7 # You may obtain a copy of the License at
8 #
9 #     http://www.apache.org/licenses/LICENSE-2.0
10 #
11 # Unless required by applicable law or agreed to in writing, software
12 # distributed under the License is distributed on an "AS IS" BASIS,
13 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 # See the License for the specific language governing permissions and
15 # limitations under the License.
16
17
18 # A test for a bug found by GraphicsFuzz.
19
20 # Short description: A compute shader with two barrier functions
21
22 # The test passes because main always outputs 42.
23
24 # variant_compute_shader is derived from the following GLSL:
25 # #version 310 es
26 # precision highp float;
27 #
28 # layout(std430, binding = 0) buffer doesNotMatter
29 # {
30 #     uint _compute_data[];
31 # };
32 # layout(local_size_x = 1, local_size_y = 18, local_size_z = 6) in;
33 # mediump vec4 GLF_live2gl_FragCoord;
34 # layout(set = 0, binding = 1) uniform buf0 {
35 #  vec2 injectionSwitch;
36 # };
37 #
38 # void main()
39 # {
40 #     int GLF_live2_looplimiter1 = 0;
41 #     for (
42 #         int i = 0;
43 #         i < 1;
44 #         ++i)
45 #     {
46 #         if (GLF_live2_looplimiter1 >= 3) //always false
47 #         {
48 #             for (
49 #                 int j = 0;
50 #                 j < 1;
51 #                 ++j)
52 #             {
53 #                 if (int(GLF_live2gl_FragCoord.x) < 120)
54 #                 {
55 #                 }
56 #                 else
57 #                 {
58 #                     barrier();
59 #                 }
60 #             }
61 #             break;
62 #         }
63 #     }
64 #     float GLF_dead3x = (injectionSwitch.x > injectionSwitch.y ? GLF_live2gl_FragCoord.x : 0.0); // always 0.0
65 #     for (
66 #         int GLF_dead3k = 0;
67 #         GLF_dead3k < 2;
68 #         ++GLF_dead3k)
69 #     {
70 #         if (GLF_dead3x > 4.0) //always false
71 #         {
72 #             break;
73 #         }
74 #         GLF_dead3x = GLF_live2gl_FragCoord.x;
75 #         barrier();
76 #     }
77 #
78 #     _compute_data[0] = 42u;
79 # }
80 SHADER compute variant_compute_shader SPIRV-ASM TARGET_ENV spv1.0
81 ; SPIR-V
82 ; Version: 1.0
83 ; Generator: Khronos Glslang Reference Front End; 7
84 ; Bound: 106
85 ; Schema: 0
86                OpCapability Shader
87           %1 = OpExtInstImport "GLSL.std.450"
88                OpMemoryModel Logical GLSL450
89                OpEntryPoint GLCompute %4 "main"
90                OpExecutionMode %4 LocalSize 1 18 6
91                OpSource ESSL 310
92                OpName %4 "main"
93                OpName %8 "GLF_live2_looplimiter1"
94                OpName %10 "i"
95                OpName %25 "j"
96                OpName %36 "GLF_live2gl_FragCoord"
97                OpName %56 "GLF_dead3x"
98                OpName %58 "buf0"
99                OpMemberName %58 0 "injectionSwitch"
100                OpName %60 ""
101                OpName %76 "GLF_dead3k"
102                OpName %96 "doesNotMatter"
103                OpMemberName %96 0 "_compute_data"
104                OpName %98 ""
105                OpDecorate %36 RelaxedPrecision
106                OpDecorate %41 RelaxedPrecision
107                OpMemberDecorate %58 0 Offset 0
108                OpDecorate %58 Block
109                OpDecorate %60 DescriptorSet 0
110                OpDecorate %60 Binding 1
111                OpDecorate %72 RelaxedPrecision
112                OpDecorate %75 RelaxedPrecision
113                OpDecorate %92 RelaxedPrecision
114                OpDecorate %95 ArrayStride 4
115                OpMemberDecorate %96 0 Offset 0
116                OpDecorate %96 BufferBlock
117                OpDecorate %98 DescriptorSet 0
118                OpDecorate %98 Binding 0
119                OpDecorate %105 BuiltIn WorkgroupSize
120           %2 = OpTypeVoid
121           %3 = OpTypeFunction %2
122           %6 = OpTypeInt 32 1
123           %7 = OpTypePointer Function %6
124           %9 = OpConstant %6 0
125          %17 = OpConstant %6 1
126          %18 = OpTypeBool
127          %21 = OpConstant %6 3
128          %33 = OpTypeFloat 32
129          %34 = OpTypeVector %33 4
130          %35 = OpTypePointer Private %34
131          %36 = OpVariable %35 Private
132          %37 = OpTypeInt 32 0
133          %38 = OpConstant %37 0
134          %39 = OpTypePointer Private %33
135          %43 = OpConstant %6 120
136          %48 = OpConstant %37 2
137          %49 = OpConstant %37 264
138          %55 = OpTypePointer Function %33
139          %57 = OpTypeVector %33 2
140          %58 = OpTypeStruct %57
141          %59 = OpTypePointer Uniform %58
142          %60 = OpVariable %59 Uniform
143          %61 = OpTypePointer Uniform %33
144          %64 = OpConstant %37 1
145          %74 = OpConstant %33 0
146          %83 = OpConstant %6 2
147          %86 = OpConstant %33 4
148          %95 = OpTypeRuntimeArray %37
149          %96 = OpTypeStruct %95
150          %97 = OpTypePointer Uniform %96
151          %98 = OpVariable %97 Uniform
152          %99 = OpConstant %37 42
153         %100 = OpTypePointer Uniform %37
154         %102 = OpTypeVector %37 3
155         %103 = OpConstant %37 18
156         %104 = OpConstant %37 6
157         %105 = OpConstantComposite %102 %64 %103 %104
158           %4 = OpFunction %2 None %3
159           %5 = OpLabel
160           %8 = OpVariable %7 Function
161          %10 = OpVariable %7 Function
162          %25 = OpVariable %7 Function
163          %56 = OpVariable %55 Function
164          %68 = OpVariable %55 Function
165          %76 = OpVariable %7 Function
166                OpStore %8 %9
167                OpStore %10 %9
168                OpBranch %11
169          %11 = OpLabel
170                OpLoopMerge %13 %14 None
171                OpBranch %15
172          %15 = OpLabel
173          %16 = OpLoad %6 %10
174          %19 = OpSLessThan %18 %16 %17
175                OpBranchConditional %19 %12 %13
176          %12 = OpLabel
177          %20 = OpLoad %6 %8
178          %22 = OpSGreaterThanEqual %18 %20 %21
179                OpSelectionMerge %24 None
180                OpBranchConditional %22 %23 %24
181          %23 = OpLabel
182                OpStore %25 %9
183                OpBranch %26
184          %26 = OpLabel
185                OpLoopMerge %28 %29 None
186                OpBranch %30
187          %30 = OpLabel
188          %31 = OpLoad %6 %25
189          %32 = OpSLessThan %18 %31 %17
190                OpBranchConditional %32 %27 %28
191          %27 = OpLabel
192          %40 = OpAccessChain %39 %36 %38
193          %41 = OpLoad %33 %40
194          %42 = OpConvertFToS %6 %41
195          %44 = OpSLessThan %18 %42 %43
196                OpSelectionMerge %46 None
197                OpBranchConditional %44 %45 %47
198          %45 = OpLabel
199                OpBranch %46
200          %47 = OpLabel
201                OpControlBarrier %48 %48 %49
202                OpBranch %46
203          %46 = OpLabel
204                OpBranch %29
205          %29 = OpLabel
206          %50 = OpLoad %6 %25
207          %51 = OpIAdd %6 %50 %17
208                OpStore %25 %51
209                OpBranch %26
210          %28 = OpLabel
211                OpBranch %13
212          %24 = OpLabel
213                OpBranch %14
214          %14 = OpLabel
215          %53 = OpLoad %6 %10
216          %54 = OpIAdd %6 %53 %17
217                OpStore %10 %54
218                OpBranch %11
219          %13 = OpLabel
220          %62 = OpAccessChain %61 %60 %9 %38
221          %63 = OpLoad %33 %62
222          %65 = OpAccessChain %61 %60 %9 %64
223          %66 = OpLoad %33 %65
224          %67 = OpFOrdGreaterThan %18 %63 %66
225                OpSelectionMerge %70 None
226                OpBranchConditional %67 %69 %73
227          %69 = OpLabel
228          %71 = OpAccessChain %39 %36 %38
229          %72 = OpLoad %33 %71
230                OpStore %68 %72
231                OpBranch %70
232          %73 = OpLabel
233                OpStore %68 %74
234                OpBranch %70
235          %70 = OpLabel
236          %75 = OpLoad %33 %68
237                OpStore %56 %75
238                OpStore %76 %9
239                OpBranch %77
240          %77 = OpLabel
241                OpLoopMerge %79 %80 None
242                OpBranch %81
243          %81 = OpLabel
244          %82 = OpLoad %6 %76
245          %84 = OpSLessThan %18 %82 %83
246                OpBranchConditional %84 %78 %79
247          %78 = OpLabel
248          %85 = OpLoad %33 %56
249          %87 = OpFOrdGreaterThan %18 %85 %86
250                OpSelectionMerge %89 None
251                OpBranchConditional %87 %88 %89
252          %88 = OpLabel
253                OpBranch %79
254          %89 = OpLabel
255          %91 = OpAccessChain %39 %36 %38
256          %92 = OpLoad %33 %91
257                OpStore %56 %92
258                OpControlBarrier %48 %48 %49
259                OpBranch %80
260          %80 = OpLabel
261          %93 = OpLoad %6 %76
262          %94 = OpIAdd %6 %93 %17
263                OpStore %76 %94
264                OpBranch %77
265          %79 = OpLabel
266         %101 = OpAccessChain %100 %98 %9 %9
267                OpStore %101 %99
268                OpReturn
269                OpFunctionEnd
270 END
271
272 # uniforms for variant
273
274 # injectionSwitch
275 BUFFER variant_injectionSwitch DATA_TYPE vec2<float> DATA
276  0.0 1.0
277 END
278
279 BUFFER variant_ssbo DATA_TYPE uint32 DATA
280  0 0 0 0 0 0 0 0 0 0
281 END
282
283 PIPELINE compute variant_pipeline
284   ATTACH variant_compute_shader
285   BIND BUFFER variant_ssbo AS storage DESCRIPTOR_SET 0 BINDING 0
286   BIND BUFFER variant_injectionSwitch AS uniform DESCRIPTOR_SET 0 BINDING 1
287 END
288
289 RUN variant_pipeline 1 6 2
290
291 EXPECT variant_ssbo IDX 0 EQ 42