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