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