Fix missing dependency on sparse binds
[platform/upstream/VK-GL-CTS.git] / external / vulkancts / data / vulkan / amber / graphicsfuzz / spv-double-branch-to-same-block2.amber
1 #!amber
2
3 # Copyright 2020 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 the GraphicsFuzz project.
19
20 # Short description: Equivalent shaders, one with more complex branching
21
22 # The test passes because both shaders render the same image.
23
24 SHADER vertex reference_vertex_shader PASSTHROUGH
25
26 SHADER fragment reference_fragment_shader SPIRV-ASM TARGET_ENV spv1.0
27 ; SPIR-V
28 ; Version: 1.0
29 ; Generator: Khronos Glslang Reference Front End; 7
30 ; Bound: 197
31 ; Schema: 0
32                OpCapability Shader
33           %1 = OpExtInstImport "GLSL.std.450"
34                OpMemoryModel Logical GLSL450
35                OpEntryPoint Fragment %4 "main" %16 %139
36                OpExecutionMode %4 OriginUpperLeft
37                OpSource ESSL 320
38                OpName %4 "main"
39                OpName %16 "gl_FragCoord"
40                OpName %23 "buf1"
41                OpMemberName %23 0 "resolution"
42                OpName %25 ""
43                OpName %61 "data"
44                OpName %66 "buf0"
45                OpMemberName %66 0 "injectionSwitch"
46                OpName %68 ""
47                OpName %139 "_GLF_color"
48                OpDecorate %16 BuiltIn FragCoord
49                OpMemberDecorate %23 0 Offset 0
50                OpDecorate %23 Block
51                OpDecorate %25 DescriptorSet 0
52                OpDecorate %25 Binding 1
53                OpMemberDecorate %66 0 Offset 0
54                OpDecorate %66 Block
55                OpDecorate %68 DescriptorSet 0
56                OpDecorate %68 Binding 0
57                OpDecorate %139 Location 0
58           %2 = OpTypeVoid
59           %3 = OpTypeFunction %2
60           %6 = OpTypeFloat 32
61           %7 = OpTypePointer Function %6
62           %8 = OpTypeBool
63          %14 = OpTypeVector %6 4
64          %15 = OpTypePointer Input %14
65          %16 = OpVariable %15 Input
66          %17 = OpTypeInt 32 0
67          %18 = OpConstant %17 1
68          %19 = OpTypePointer Input %6
69          %22 = OpTypeVector %6 2
70          %23 = OpTypeStruct %22
71          %24 = OpTypePointer Uniform %23
72          %25 = OpVariable %24 Uniform
73          %26 = OpTypeInt 32 1
74          %27 = OpConstant %26 0
75          %28 = OpTypePointer Uniform %6
76          %56 = OpConstant %26 10
77          %58 = OpConstant %17 10
78          %59 = OpTypeArray %6 %58
79          %60 = OpTypePointer Function %59
80          %66 = OpTypeStruct %22
81          %67 = OpTypePointer Uniform %66
82          %68 = OpVariable %67 Uniform
83          %74 = OpConstant %26 1
84          %83 = OpConstant %26 9
85         %129 = OpConstant %17 0
86         %138 = OpTypePointer Output %14
87         %139 = OpVariable %138 Output
88         %144 = OpConstant %26 5
89         %151 = OpConstant %6 1
90         %195 = OpConstant %6 0.5
91         %196 = OpConstant %6 0.100000001
92           %4 = OpFunction %2 None %3
93           %5 = OpLabel
94          %61 = OpVariable %60 Function
95                OpBranch %50
96          %50 = OpLabel
97         %183 = OpPhi %26 %27 %5 %75 %51
98          %57 = OpSLessThan %8 %183 %56
99                OpLoopMerge %52 %51 None
100                OpBranchConditional %57 %51 %52
101          %51 = OpLabel
102          %64 = OpISub %26 %56 %183
103          %65 = OpConvertSToF %6 %64
104          %69 = OpAccessChain %28 %68 %27 %18
105          %70 = OpLoad %6 %69
106          %71 = OpFMul %6 %65 %70
107          %72 = OpAccessChain %7 %61 %183
108                OpStore %72 %71
109          %75 = OpIAdd %26 %183 %74
110                OpBranch %50
111          %52 = OpLabel
112                OpBranch %77
113          %77 = OpLabel
114         %184 = OpPhi %26 %27 %52 %128 %80
115          %84 = OpSLessThan %8 %184 %83
116                OpLoopMerge %79 %80 None
117                OpBranchConditional %84 %78 %79
118          %78 = OpLabel
119                OpBranch %86
120          %86 = OpLabel
121         %185 = OpPhi %26 %27 %78 %126 %89
122          %92 = OpSLessThan %8 %185 %56
123                OpLoopMerge %88 %89 None
124                OpBranchConditional %92 %87 %88
125          %87 = OpLabel
126          %95 = OpIAdd %26 %184 %74
127          %96 = OpSLessThan %8 %185 %95
128                OpSelectionMerge %98 None
129                OpBranchConditional %96 %97 %98
130          %97 = OpLabel
131                OpBranch %89
132          %98 = OpLabel
133         %104 = OpAccessChain %7 %61 %184
134         %105 = OpLoad %6 %104
135         %107 = OpAccessChain %7 %61 %185
136         %108 = OpLoad %6 %107
137         %167 = OpAccessChain %19 %16 %18
138         %168 = OpLoad %6 %167
139         %169 = OpAccessChain %28 %25 %27 %18
140         %170 = OpLoad %6 %169
141         %171 = OpFMul %6 %170 %195
142         %172 = OpFOrdLessThan %8 %168 %171
143                OpSelectionMerge %181 None
144                OpBranchConditional %172 %173 %177
145         %173 = OpLabel
146         %176 = OpFOrdGreaterThan %8 %105 %108
147                OpBranch %181
148         %177 = OpLabel
149         %180 = OpFOrdLessThan %8 %105 %108
150                OpBranch %181
151         %181 = OpLabel
152         %187 = OpPhi %8 %176 %173 %180 %177
153                OpSelectionMerge %112 None
154                OpBranchConditional %187 %111 %112
155         %111 = OpLabel
156         %116 = OpLoad %6 %104
157         %120 = OpLoad %6 %107
158                OpStore %104 %120
159                OpStore %107 %116
160                OpBranch %112
161         %112 = OpLabel
162                OpBranch %89
163          %89 = OpLabel
164         %126 = OpIAdd %26 %185 %74
165                OpBranch %86
166          %88 = OpLabel
167                OpBranch %80
168          %80 = OpLabel
169         %128 = OpIAdd %26 %184 %74
170                OpBranch %77
171          %79 = OpLabel
172         %130 = OpAccessChain %19 %16 %129
173         %131 = OpLoad %6 %130
174         %132 = OpAccessChain %28 %25 %27 %129
175         %133 = OpLoad %6 %132
176         %134 = OpFMul %6 %133 %195
177         %135 = OpFOrdLessThan %8 %131 %134
178                OpSelectionMerge %137 None
179                OpBranchConditional %135 %136 %153
180         %136 = OpLabel
181         %140 = OpAccessChain %7 %61 %27
182         %141 = OpLoad %6 %140
183         %143 = OpFMul %6 %141 %196
184         %145 = OpAccessChain %7 %61 %144
185         %146 = OpLoad %6 %145
186         %147 = OpFMul %6 %146 %196
187         %148 = OpAccessChain %7 %61 %83
188         %149 = OpLoad %6 %148
189         %150 = OpFMul %6 %149 %196
190         %152 = OpCompositeConstruct %14 %143 %147 %150 %151
191                OpStore %139 %152
192                OpBranch %137
193         %153 = OpLabel
194         %154 = OpAccessChain %7 %61 %144
195         %155 = OpLoad %6 %154
196         %156 = OpFMul %6 %155 %196
197         %157 = OpAccessChain %7 %61 %83
198         %158 = OpLoad %6 %157
199         %159 = OpFMul %6 %158 %196
200         %160 = OpAccessChain %7 %61 %27
201         %161 = OpLoad %6 %160
202         %162 = OpFMul %6 %161 %196
203         %163 = OpCompositeConstruct %14 %156 %159 %162 %151
204                OpStore %139 %163
205                OpBranch %137
206         %137 = OpLabel
207                OpReturn
208                OpFunctionEnd
209 END
210
211 # uniforms for reference
212
213 # injectionSwitch
214 BUFFER reference_injectionSwitch DATA_TYPE vec2<float> DATA
215  0.0 1.0
216 END
217 # resolution
218 BUFFER reference_resolution DATA_TYPE vec2<float> DATA
219  256.0 256.0
220 END
221
222 BUFFER reference_framebuffer FORMAT B8G8R8A8_UNORM
223
224 PIPELINE graphics reference_pipeline
225   ATTACH reference_vertex_shader
226   ATTACH reference_fragment_shader
227   FRAMEBUFFER_SIZE 256 256
228   BIND BUFFER reference_framebuffer AS color LOCATION 0
229   BIND BUFFER reference_injectionSwitch AS uniform DESCRIPTOR_SET 0 BINDING 0
230   BIND BUFFER reference_resolution AS uniform DESCRIPTOR_SET 0 BINDING 1
231 END
232 CLEAR_COLOR reference_pipeline 0 0 0 255
233
234 CLEAR reference_pipeline
235 RUN reference_pipeline DRAW_RECT POS 0 0 SIZE 256 256
236
237
238 SHADER vertex variant_vertex_shader PASSTHROUGH
239
240 SHADER fragment variant_fragment_shader SPIRV-ASM TARGET_ENV spv1.0
241 ; SPIR-V
242 ; Version: 1.0
243 ; Generator: Khronos Glslang Reference Front End; 7
244 ; Bound: 304
245 ; Schema: 0
246                OpCapability Shader
247           %1 = OpExtInstImport "GLSL.std.450"
248                OpMemoryModel Logical GLSL450
249                OpEntryPoint Fragment %4 "main" %16 %139
250                OpExecutionMode %4 OriginUpperLeft
251                OpSource ESSL 320
252                OpName %4 "main"
253                OpName %16 "gl_FragCoord"
254                OpName %23 "buf1"
255                OpMemberName %23 0 "resolution"
256                OpName %25 ""
257                OpName %61 "data"
258                OpName %66 "buf0"
259                OpMemberName %66 0 "injectionSwitch"
260                OpName %68 ""
261                OpName %139 "_GLF_color"
262                OpDecorate %16 BuiltIn FragCoord
263                OpMemberDecorate %23 0 Offset 0
264                OpDecorate %23 Block
265                OpDecorate %25 DescriptorSet 0
266                OpDecorate %25 Binding 1
267                OpMemberDecorate %66 0 Offset 0
268                OpDecorate %66 Block
269                OpDecorate %68 DescriptorSet 0
270                OpDecorate %68 Binding 0
271                OpDecorate %139 Location 0
272           %2 = OpTypeVoid
273           %3 = OpTypeFunction %2
274           %6 = OpTypeFloat 32
275           %7 = OpTypePointer Function %6
276           %8 = OpTypeBool
277          %14 = OpTypeVector %6 4
278          %15 = OpTypePointer Input %14
279          %16 = OpVariable %15 Input
280          %17 = OpTypeInt 32 0
281          %18 = OpConstant %17 1
282          %19 = OpTypePointer Input %6
283          %22 = OpTypeVector %6 2
284          %23 = OpTypeStruct %22
285          %24 = OpTypePointer Uniform %23
286          %25 = OpVariable %24 Uniform
287          %26 = OpTypeInt 32 1
288          %27 = OpConstant %26 0
289          %28 = OpTypePointer Uniform %6
290          %56 = OpConstant %26 10
291          %58 = OpConstant %17 10
292          %59 = OpTypeArray %6 %58
293          %60 = OpTypePointer Function %59
294          %66 = OpTypeStruct %22
295          %67 = OpTypePointer Uniform %66
296          %68 = OpVariable %67 Uniform
297          %74 = OpConstant %26 1
298          %83 = OpConstant %26 9
299         %129 = OpConstant %17 0
300         %138 = OpTypePointer Output %14
301         %139 = OpVariable %138 Output
302         %144 = OpConstant %26 5
303         %151 = OpConstant %6 1
304         %195 = OpConstant %6 0.5
305         %196 = OpConstant %6 0.100000001
306         %303 = OpConstantTrue %8
307           %4 = OpFunction %2 None %3
308           %5 = OpLabel
309          %61 = OpVariable %60 Function
310                OpBranch %50
311          %50 = OpLabel
312         %183 = OpPhi %26 %27 %5 %75 %51
313          %57 = OpSLessThan %8 %183 %56
314                OpLoopMerge %52 %51 None
315                OpBranchConditional %57 %51 %52
316          %51 = OpLabel
317          %64 = OpISub %26 %56 %183
318          %65 = OpConvertSToF %6 %64
319          %69 = OpAccessChain %28 %68 %27 %18
320          %70 = OpLoad %6 %69
321          %71 = OpFMul %6 %65 %70
322          %72 = OpAccessChain %7 %61 %183
323                OpStore %72 %71
324          %75 = OpIAdd %26 %183 %74
325                OpBranch %50
326          %52 = OpLabel
327                OpBranch %77
328          %77 = OpLabel
329         %184 = OpPhi %26 %27 %52 %128 %80
330          %84 = OpSLessThan %8 %184 %83
331                OpLoopMerge %79 %80 None
332                OpBranchConditional %84 %78 %79
333          %78 = OpLabel
334                OpBranch %86
335          %86 = OpLabel
336         %185 = OpPhi %26 %27 %78 %126 %89
337          %92 = OpSLessThan %8 %185 %56
338                OpLoopMerge %88 %89 None
339                OpBranchConditional %92 %87 %88
340          %87 = OpLabel
341          %95 = OpIAdd %26 %184 %74
342          %96 = OpSLessThan %8 %185 %95
343                OpSelectionMerge %98 None
344                OpBranchConditional %96 %97 %98
345          %97 = OpLabel
346                OpBranch %89
347          %98 = OpLabel
348         %104 = OpAccessChain %7 %61 %184
349         %105 = OpLoad %6 %104
350         %107 = OpAccessChain %7 %61 %185
351         %108 = OpLoad %6 %107
352         %167 = OpAccessChain %19 %16 %18
353         %168 = OpLoad %6 %167
354         %169 = OpAccessChain %28 %25 %27 %18
355         %170 = OpLoad %6 %169
356         %171 = OpFMul %6 %170 %195
357         %172 = OpFOrdLessThan %8 %168 %171
358                OpSelectionMerge %181 None
359                OpBranchConditional %172 %173 %177
360         %173 = OpLabel
361         %176 = OpFOrdGreaterThan %8 %105 %108
362                OpBranch %181
363         %177 = OpLabel
364         %180 = OpFOrdLessThan %8 %105 %108
365                OpBranch %181
366         %181 = OpLabel
367         %187 = OpPhi %8 %176 %173 %180 %177
368                OpSelectionMerge %112 None
369                OpBranchConditional %187 %111 %112
370         %111 = OpLabel
371         %116 = OpLoad %6 %104
372         %120 = OpLoad %6 %107
373                OpStore %104 %120
374                OpStore %107 %116
375                OpBranch %112
376         %112 = OpLabel
377                OpBranch %89
378          %89 = OpLabel
379         %126 = OpIAdd %26 %185 %74
380                OpBranch %86
381          %88 = OpLabel
382                OpBranch %80
383          %80 = OpLabel
384         %128 = OpIAdd %26 %184 %74
385                OpBranch %77
386          %79 = OpLabel
387         %130 = OpAccessChain %19 %16 %129
388         %131 = OpLoad %6 %130
389         %132 = OpAccessChain %28 %25 %27 %129
390         %133 = OpLoad %6 %132
391         %134 = OpFMul %6 %133 %195
392         %135 = OpFOrdLessThan %8 %131 %134
393                OpSelectionMerge %137 None
394                OpBranchConditional %135 %136 %153
395         %136 = OpLabel
396         %140 = OpAccessChain %7 %61 %27
397         %141 = OpLoad %6 %140
398         %143 = OpFMul %6 %141 %196
399         %145 = OpAccessChain %7 %61 %144
400         %146 = OpLoad %6 %145
401         %147 = OpFMul %6 %146 %196
402         %148 = OpAccessChain %7 %61 %83
403         %149 = OpLoad %6 %148
404         %150 = OpFMul %6 %149 %196
405         %152 = OpCompositeConstruct %14 %143 %147 %150 %151
406                OpStore %139 %152
407                OpBranch %137
408         %153 = OpLabel
409         %154 = OpAccessChain %7 %61 %144
410         %155 = OpLoad %6 %154
411         %156 = OpFMul %6 %155 %196
412         %157 = OpAccessChain %7 %61 %83
413         %158 = OpLoad %6 %157
414         %159 = OpFMul %6 %158 %196
415         %160 = OpAccessChain %7 %61 %27
416         %161 = OpLoad %6 %160
417         %162 = OpFMul %6 %161 %196
418         %163 = OpCompositeConstruct %14 %156 %159 %162 %151
419                OpStore %139 %163
420                OpBranchConditional %303 %137 %137
421         %137 = OpLabel
422                OpReturn
423                OpFunctionEnd
424 END
425
426 # uniforms for variant
427
428 # injectionSwitch
429 BUFFER variant_injectionSwitch DATA_TYPE vec2<float> DATA
430  0.0 1.0
431 END
432 # resolution
433 BUFFER variant_resolution DATA_TYPE vec2<float> DATA
434  256.0 256.0
435 END
436
437 BUFFER variant_framebuffer FORMAT B8G8R8A8_UNORM
438
439 PIPELINE graphics variant_pipeline
440   ATTACH variant_vertex_shader
441   ATTACH variant_fragment_shader
442   FRAMEBUFFER_SIZE 256 256
443   BIND BUFFER variant_framebuffer AS color LOCATION 0
444   BIND BUFFER variant_injectionSwitch AS uniform DESCRIPTOR_SET 0 BINDING 0
445   BIND BUFFER variant_resolution AS uniform DESCRIPTOR_SET 0 BINDING 1
446 END
447 CLEAR_COLOR variant_pipeline 0 0 0 255
448
449 CLEAR variant_pipeline
450 RUN variant_pipeline DRAW_RECT POS 0 0 SIZE 256 256
451
452 EXPECT reference_framebuffer EQ_HISTOGRAM_EMD_BUFFER variant_framebuffer TOLERANCE 0.005