Fix missing dependency on sparse binds
[platform/upstream/VK-GL-CTS.git] / external / vulkancts / data / vulkan / amber / graphicsfuzz / cov-integer-minus-one-increased-before-indexing-array.amber
1 #!amber
2
3 # Copyright 2021 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_8 _GLF_uniform_int_values[0]
30 # #define _int_9 _GLF_uniform_int_values[1]
31 # #define _int_1 _GLF_uniform_int_values[2]
32 # #define _int_2 _GLF_uniform_int_values[3]
33 # #define _int_3 _GLF_uniform_int_values[4]
34 # #define _int_4 _GLF_uniform_int_values[5]
35 # #define _int_5 _GLF_uniform_int_values[6]
36 # #define _int_6 _GLF_uniform_int_values[7]
37 # #define _int_7 _GLF_uniform_int_values[8]
38 # #define _int_0 _GLF_uniform_int_values[9]
39 # #define _int_10 _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 # // Contents of _GLF_uniform_int_values: [8, 9, 1, 2, 3, 4, 5, 6, 7, 0, 10]
51 # layout(set = 0, binding = 1) uniform buf1
52 # {
53 #     int _GLF_uniform_int_values[11];
54 # };
55 #
56 # const int _GLF_global_loop_bound = 10;
57 # int _GLF_global_loop_count = 0;
58 #
59 # // Contents of zero: 0.0
60 # layout(push_constant) uniform buf_push
61 # {
62 #     float zero;
63 # };
64 #
65 # layout(location = 0) out vec4 _GLF_color;
66 #
67 # // This function is called once with x = 0.
68 # int func(int x)
69 # {
70 #     int i = _int_1;
71 #
72 #     while(_GLF_global_loop_count < _GLF_global_loop_bound)
73 #     {
74 #         _GLF_global_loop_count ++;
75 #
76 #         // Always true.
77 #         if(x <= _int_1)
78 #         {
79 #             // Iterated once.
80 #             for(int k = int(zero); k != _int_1; k ++)
81 #             {
82 #                 // Always true.
83 #                 if(gl_FragCoord.y >= 0.0)
84 #                 {
85 #                     i++;
86 #                 }
87 #             }
88 #
89 #             // Sets global loop count to global loop bound.
90 #             for(int k = int(zero); k < _int_1 && _GLF_global_loop_count < _GLF_global_loop_bound; )
91 #             {
92 #                 _GLF_global_loop_count++;
93 #             }
94 #         }
95 #     }
96 #
97 #     // Returns 2.
98 #     return i;
99 # }
100 #
101 # void main()
102 # {
103 #     int a = _int_1, b = _int_1, c = -_int_1;
104 #     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);
105 #
106 #     // Always true.
107 #     if(gl_FragCoord.y >= 0.0)
108 #     {
109 #         // c becomes zero.
110 #         arr[++c] = _int_1;
111 #     }
112 #
113 #     // Iterated once.
114 #     while(c >= _int_0 && _GLF_global_loop_count < _GLF_global_loop_bound)
115 #     {
116 #         _GLF_global_loop_count ++;
117 #
118 #         // Always true.
119 #         if(gl_FragCoord.y > _float_0_0)
120 #         {
121 #             // a becomes 0
122 #             a = arr[c];
123 #         }
124 #
125 #         // Always true.
126 #         if(zero == _float_0_0)
127 #         {
128 #             b = arr[c];
129 #         }
130 #
131 #         if(a < _int_1)
132 #         {
133 #             // arr[0] becomes one and c becomes one.
134 #             arr[++c] = _int_1;
135 #         }
136 #
137 #         // Calling the function makes global loop count to reach the global loop bound. The function returns 2 making the condition false.
138 #         if(func(a) < _int_1)
139 #         {
140 #             arr[++c] = b;
141 #         }
142 #     }
143 #
144 #     // Check the array against reference values, and set output color to black if the check fails.
145 #     int ref[10] = int[10](_int_1, _int_1, _int_2, _int_3, _int_4, _int_5, _int_6, _int_7, _int_8, _int_9);
146 #     _GLF_color = vec4(_int_1, _int_0, _int_0, _int_1);
147 #
148 #     for(int i = _int_0; i < _int_10; i ++)
149 #     {
150 #         if(arr[i] != ref[i])
151 #         {
152 #             _GLF_color = vec4(_int_0);
153 #         }
154 #     }
155 # }
156 SHADER fragment variant_fragment_shader SPIRV-ASM TARGET_ENV spv1.0
157 ; SPIR-V
158 ; Version: 1.0
159 ; Generator: Khronos Glslang Reference Front End; 10
160 ; Bound: 276
161 ; Schema: 0
162                OpCapability Shader
163           %1 = OpExtInstImport "GLSL.std.450"
164                OpMemoryModel Logical GLSL450
165                OpEntryPoint Fragment %4 "main" %64 %235
166                OpExecutionMode %4 OriginUpperLeft
167                OpSource ESSL 320
168                OpName %4 "main"
169                OpName %10 "func(i1;"
170                OpName %9 "x"
171                OpName %13 "_GLF_global_loop_count"
172                OpName %15 "i"
173                OpName %19 "buf1"
174                OpMemberName %19 0 "_GLF_uniform_int_values"
175                OpName %21 ""
176                OpName %44 "k"
177                OpName %46 "buf_push"
178                OpMemberName %46 0 "zero"
179                OpName %48 ""
180                OpName %64 "gl_FragCoord"
181                OpName %77 "k"
182                OpName %98 "a"
183                OpName %101 "b"
184                OpName %104 "c"
185                OpName %111 "arr"
186                OpName %167 "buf0"
187                OpMemberName %167 0 "_GLF_uniform_float_values"
188                OpName %169 ""
189                OpName %200 "param"
190                OpName %212 "ref"
191                OpName %235 "_GLF_color"
192                OpName %249 "i"
193                OpDecorate %18 ArrayStride 16
194                OpMemberDecorate %19 0 Offset 0
195                OpDecorate %19 Block
196                OpDecorate %21 DescriptorSet 0
197                OpDecorate %21 Binding 1
198                OpMemberDecorate %46 0 Offset 0
199                OpDecorate %46 Block
200                OpDecorate %64 BuiltIn FragCoord
201                OpDecorate %166 ArrayStride 16
202                OpMemberDecorate %167 0 Offset 0
203                OpDecorate %167 Block
204                OpDecorate %169 DescriptorSet 0
205                OpDecorate %169 Binding 0
206                OpDecorate %235 Location 0
207           %2 = OpTypeVoid
208           %3 = OpTypeFunction %2
209           %6 = OpTypeInt 32 1
210           %7 = OpTypePointer Function %6
211           %8 = OpTypeFunction %6 %7
212          %12 = OpTypePointer Private %6
213          %13 = OpVariable %12 Private
214          %14 = OpConstant %6 0
215          %16 = OpTypeInt 32 0
216          %17 = OpConstant %16 11
217          %18 = OpTypeArray %6 %17
218          %19 = OpTypeStruct %18
219          %20 = OpTypePointer Uniform %19
220          %21 = OpVariable %20 Uniform
221          %22 = OpConstant %6 2
222          %23 = OpTypePointer Uniform %6
223          %32 = OpConstant %6 10
224          %33 = OpTypeBool
225          %36 = OpConstant %6 1
226          %45 = OpTypeFloat 32
227          %46 = OpTypeStruct %45
228          %47 = OpTypePointer PushConstant %46
229          %48 = OpVariable %47 PushConstant
230          %49 = OpTypePointer PushConstant %45
231          %62 = OpTypeVector %45 4
232          %63 = OpTypePointer Input %62
233          %64 = OpVariable %63 Input
234          %65 = OpConstant %16 1
235          %66 = OpTypePointer Input %45
236          %69 = OpConstant %45 0
237         %108 = OpConstant %16 10
238         %109 = OpTypeArray %6 %108
239         %110 = OpTypePointer Function %109
240         %112 = OpConstant %6 9
241         %117 = OpConstant %6 3
242         %120 = OpConstant %6 4
243         %123 = OpConstant %6 5
244         %126 = OpConstant %6 6
245         %129 = OpConstant %6 7
246         %132 = OpConstant %6 8
247         %166 = OpTypeArray %45 %65
248         %167 = OpTypeStruct %166
249         %168 = OpTypePointer Uniform %167
250         %169 = OpVariable %168 Uniform
251         %170 = OpTypePointer Uniform %45
252         %234 = OpTypePointer Output %62
253         %235 = OpVariable %234 Output
254           %4 = OpFunction %2 None %3
255           %5 = OpLabel
256          %98 = OpVariable %7 Function
257         %101 = OpVariable %7 Function
258         %104 = OpVariable %7 Function
259         %111 = OpVariable %110 Function
260         %200 = OpVariable %7 Function
261         %212 = OpVariable %110 Function
262         %249 = OpVariable %7 Function
263                OpStore %13 %14
264          %99 = OpAccessChain %23 %21 %14 %22
265         %100 = OpLoad %6 %99
266                OpStore %98 %100
267         %102 = OpAccessChain %23 %21 %14 %22
268         %103 = OpLoad %6 %102
269                OpStore %101 %103
270         %105 = OpAccessChain %23 %21 %14 %22
271         %106 = OpLoad %6 %105
272         %107 = OpSNegate %6 %106
273                OpStore %104 %107
274         %113 = OpAccessChain %23 %21 %14 %112
275         %114 = OpLoad %6 %113
276         %115 = OpAccessChain %23 %21 %14 %22
277         %116 = OpLoad %6 %115
278         %118 = OpAccessChain %23 %21 %14 %117
279         %119 = OpLoad %6 %118
280         %121 = OpAccessChain %23 %21 %14 %120
281         %122 = OpLoad %6 %121
282         %124 = OpAccessChain %23 %21 %14 %123
283         %125 = OpLoad %6 %124
284         %127 = OpAccessChain %23 %21 %14 %126
285         %128 = OpLoad %6 %127
286         %130 = OpAccessChain %23 %21 %14 %129
287         %131 = OpLoad %6 %130
288         %133 = OpAccessChain %23 %21 %14 %132
289         %134 = OpLoad %6 %133
290         %135 = OpAccessChain %23 %21 %14 %14
291         %136 = OpLoad %6 %135
292         %137 = OpAccessChain %23 %21 %14 %36
293         %138 = OpLoad %6 %137
294         %139 = OpCompositeConstruct %109 %114 %116 %119 %122 %125 %128 %131 %134 %136 %138
295                OpStore %111 %139
296         %140 = OpAccessChain %66 %64 %65
297         %141 = OpLoad %45 %140
298         %142 = OpFOrdGreaterThanEqual %33 %141 %69
299                OpSelectionMerge %144 None
300                OpBranchConditional %142 %143 %144
301         %143 = OpLabel
302         %145 = OpLoad %6 %104
303         %146 = OpIAdd %6 %145 %36
304                OpStore %104 %146
305         %147 = OpAccessChain %23 %21 %14 %22
306         %148 = OpLoad %6 %147
307         %149 = OpAccessChain %7 %111 %146
308                OpStore %149 %148
309                OpBranch %144
310         %144 = OpLabel
311                OpBranch %150
312         %150 = OpLabel
313                OpLoopMerge %152 %153 None
314                OpBranch %154
315         %154 = OpLabel
316         %155 = OpLoad %6 %104
317         %156 = OpAccessChain %23 %21 %14 %112
318         %157 = OpLoad %6 %156
319         %158 = OpSGreaterThanEqual %33 %155 %157
320         %159 = OpLoad %6 %13
321         %160 = OpSLessThan %33 %159 %32
322         %161 = OpLogicalAnd %33 %158 %160
323                OpBranchConditional %161 %151 %152
324         %151 = OpLabel
325         %162 = OpLoad %6 %13
326         %163 = OpIAdd %6 %162 %36
327                OpStore %13 %163
328         %164 = OpAccessChain %66 %64 %65
329         %165 = OpLoad %45 %164
330         %171 = OpAccessChain %170 %169 %14 %14
331         %172 = OpLoad %45 %171
332         %173 = OpFOrdGreaterThan %33 %165 %172
333                OpSelectionMerge %175 None
334                OpBranchConditional %173 %174 %175
335         %174 = OpLabel
336         %176 = OpLoad %6 %104
337         %177 = OpAccessChain %7 %111 %176
338         %178 = OpLoad %6 %177
339                OpStore %98 %178
340                OpBranch %175
341         %175 = OpLabel
342         %179 = OpAccessChain %49 %48 %14
343         %180 = OpLoad %45 %179
344         %181 = OpAccessChain %170 %169 %14 %14
345         %182 = OpLoad %45 %181
346         %183 = OpFOrdEqual %33 %180 %182
347                OpSelectionMerge %185 None
348                OpBranchConditional %183 %184 %185
349         %184 = OpLabel
350         %186 = OpLoad %6 %104
351         %187 = OpAccessChain %7 %111 %186
352         %188 = OpLoad %6 %187
353                OpStore %101 %188
354                OpBranch %185
355         %185 = OpLabel
356         %189 = OpLoad %6 %98
357         %190 = OpAccessChain %23 %21 %14 %22
358         %191 = OpLoad %6 %190
359         %192 = OpSLessThan %33 %189 %191
360                OpSelectionMerge %194 None
361                OpBranchConditional %192 %193 %194
362         %193 = OpLabel
363         %195 = OpLoad %6 %104
364         %196 = OpIAdd %6 %195 %36
365                OpStore %104 %196
366         %197 = OpAccessChain %23 %21 %14 %22
367         %198 = OpLoad %6 %197
368         %199 = OpAccessChain %7 %111 %196
369                OpStore %199 %198
370                OpBranch %194
371         %194 = OpLabel
372         %201 = OpLoad %6 %98
373                OpStore %200 %201
374         %202 = OpFunctionCall %6 %10 %200
375         %203 = OpAccessChain %23 %21 %14 %22
376         %204 = OpLoad %6 %203
377         %205 = OpSLessThan %33 %202 %204
378                OpSelectionMerge %207 None
379                OpBranchConditional %205 %206 %207
380         %206 = OpLabel
381         %208 = OpLoad %6 %104
382         %209 = OpIAdd %6 %208 %36
383                OpStore %104 %209
384         %210 = OpLoad %6 %101
385         %211 = OpAccessChain %7 %111 %209
386                OpStore %211 %210
387                OpBranch %207
388         %207 = OpLabel
389                OpBranch %153
390         %153 = OpLabel
391                OpBranch %150
392         %152 = OpLabel
393         %213 = OpAccessChain %23 %21 %14 %22
394         %214 = OpLoad %6 %213
395         %215 = OpAccessChain %23 %21 %14 %22
396         %216 = OpLoad %6 %215
397         %217 = OpAccessChain %23 %21 %14 %117
398         %218 = OpLoad %6 %217
399         %219 = OpAccessChain %23 %21 %14 %120
400         %220 = OpLoad %6 %219
401         %221 = OpAccessChain %23 %21 %14 %123
402         %222 = OpLoad %6 %221
403         %223 = OpAccessChain %23 %21 %14 %126
404         %224 = OpLoad %6 %223
405         %225 = OpAccessChain %23 %21 %14 %129
406         %226 = OpLoad %6 %225
407         %227 = OpAccessChain %23 %21 %14 %132
408         %228 = OpLoad %6 %227
409         %229 = OpAccessChain %23 %21 %14 %14
410         %230 = OpLoad %6 %229
411         %231 = OpAccessChain %23 %21 %14 %36
412         %232 = OpLoad %6 %231
413         %233 = OpCompositeConstruct %109 %214 %216 %218 %220 %222 %224 %226 %228 %230 %232
414                OpStore %212 %233
415         %236 = OpAccessChain %23 %21 %14 %22
416         %237 = OpLoad %6 %236
417         %238 = OpConvertSToF %45 %237
418         %239 = OpAccessChain %23 %21 %14 %112
419         %240 = OpLoad %6 %239
420         %241 = OpConvertSToF %45 %240
421         %242 = OpAccessChain %23 %21 %14 %112
422         %243 = OpLoad %6 %242
423         %244 = OpConvertSToF %45 %243
424         %245 = OpAccessChain %23 %21 %14 %22
425         %246 = OpLoad %6 %245
426         %247 = OpConvertSToF %45 %246
427         %248 = OpCompositeConstruct %62 %238 %241 %244 %247
428                OpStore %235 %248
429         %250 = OpAccessChain %23 %21 %14 %112
430         %251 = OpLoad %6 %250
431                OpStore %249 %251
432                OpBranch %252
433         %252 = OpLabel
434                OpLoopMerge %254 %255 None
435                OpBranch %256
436         %256 = OpLabel
437         %257 = OpLoad %6 %249
438         %258 = OpAccessChain %23 %21 %14 %32
439         %259 = OpLoad %6 %258
440         %260 = OpSLessThan %33 %257 %259
441                OpBranchConditional %260 %253 %254
442         %253 = OpLabel
443         %261 = OpLoad %6 %249
444         %262 = OpAccessChain %7 %111 %261
445         %263 = OpLoad %6 %262
446         %264 = OpLoad %6 %249
447         %265 = OpAccessChain %7 %212 %264
448         %266 = OpLoad %6 %265
449         %267 = OpINotEqual %33 %263 %266
450                OpSelectionMerge %269 None
451                OpBranchConditional %267 %268 %269
452         %268 = OpLabel
453         %270 = OpAccessChain %23 %21 %14 %112
454         %271 = OpLoad %6 %270
455         %272 = OpConvertSToF %45 %271
456         %273 = OpCompositeConstruct %62 %272 %272 %272 %272
457                OpStore %235 %273
458                OpBranch %269
459         %269 = OpLabel
460                OpBranch %255
461         %255 = OpLabel
462         %274 = OpLoad %6 %249
463         %275 = OpIAdd %6 %274 %36
464                OpStore %249 %275
465                OpBranch %252
466         %254 = OpLabel
467                OpReturn
468                OpFunctionEnd
469          %10 = OpFunction %6 None %8
470           %9 = OpFunctionParameter %7
471          %11 = OpLabel
472          %15 = OpVariable %7 Function
473          %44 = OpVariable %7 Function
474          %77 = OpVariable %7 Function
475          %24 = OpAccessChain %23 %21 %14 %22
476          %25 = OpLoad %6 %24
477                OpStore %15 %25
478                OpBranch %26
479          %26 = OpLabel
480                OpLoopMerge %28 %29 None
481                OpBranch %30
482          %30 = OpLabel
483          %31 = OpLoad %6 %13
484          %34 = OpSLessThan %33 %31 %32
485                OpBranchConditional %34 %27 %28
486          %27 = OpLabel
487          %35 = OpLoad %6 %13
488          %37 = OpIAdd %6 %35 %36
489                OpStore %13 %37
490          %38 = OpLoad %6 %9
491          %39 = OpAccessChain %23 %21 %14 %22
492          %40 = OpLoad %6 %39
493          %41 = OpSLessThanEqual %33 %38 %40
494                OpSelectionMerge %43 None
495                OpBranchConditional %41 %42 %43
496          %42 = OpLabel
497          %50 = OpAccessChain %49 %48 %14
498          %51 = OpLoad %45 %50
499          %52 = OpConvertFToS %6 %51
500                OpStore %44 %52
501                OpBranch %53
502          %53 = OpLabel
503                OpLoopMerge %55 %56 None
504                OpBranch %57
505          %57 = OpLabel
506          %58 = OpLoad %6 %44
507          %59 = OpAccessChain %23 %21 %14 %22
508          %60 = OpLoad %6 %59
509          %61 = OpINotEqual %33 %58 %60
510                OpBranchConditional %61 %54 %55
511          %54 = OpLabel
512          %67 = OpAccessChain %66 %64 %65
513          %68 = OpLoad %45 %67
514          %70 = OpFOrdGreaterThanEqual %33 %68 %69
515                OpSelectionMerge %72 None
516                OpBranchConditional %70 %71 %72
517          %71 = OpLabel
518          %73 = OpLoad %6 %15
519          %74 = OpIAdd %6 %73 %36
520                OpStore %15 %74
521                OpBranch %72
522          %72 = OpLabel
523                OpBranch %56
524          %56 = OpLabel
525          %75 = OpLoad %6 %44
526          %76 = OpIAdd %6 %75 %36
527                OpStore %44 %76
528                OpBranch %53
529          %55 = OpLabel
530          %78 = OpAccessChain %49 %48 %14
531          %79 = OpLoad %45 %78
532          %80 = OpConvertFToS %6 %79
533                OpStore %77 %80
534                OpBranch %81
535          %81 = OpLabel
536                OpLoopMerge %83 %84 None
537                OpBranch %85
538          %85 = OpLabel
539          %86 = OpLoad %6 %77
540          %87 = OpAccessChain %23 %21 %14 %22
541          %88 = OpLoad %6 %87
542          %89 = OpSLessThan %33 %86 %88
543          %90 = OpLoad %6 %13
544          %91 = OpSLessThan %33 %90 %32
545          %92 = OpLogicalAnd %33 %89 %91
546                OpBranchConditional %92 %82 %83
547          %82 = OpLabel
548          %93 = OpLoad %6 %13
549          %94 = OpIAdd %6 %93 %36
550                OpStore %13 %94
551                OpBranch %84
552          %84 = OpLabel
553                OpBranch %81
554          %83 = OpLabel
555                OpBranch %43
556          %43 = OpLabel
557                OpBranch %29
558          %29 = OpLabel
559                OpBranch %26
560          %28 = OpLabel
561          %95 = OpLoad %6 %15
562                OpReturnValue %95
563                OpFunctionEnd
564 END
565
566 # uniforms for variant
567
568 # zero
569 BUFFER variant_zero DATA_TYPE float STD140 DATA
570  0.0
571 END
572 # _GLF_uniform_int_values
573 BUFFER variant__GLF_uniform_int_values DATA_TYPE int32[] STD140 DATA
574  8 9 1 2 3 4 5 6 7 0 10
575 END
576 # _GLF_uniform_float_values
577 BUFFER variant__GLF_uniform_float_values DATA_TYPE float[] STD140 DATA
578  0.0
579 END
580
581 BUFFER variant_framebuffer FORMAT B8G8R8A8_UNORM
582
583 PIPELINE graphics variant_pipeline
584   ATTACH variant_vertex_shader
585   ATTACH variant_fragment_shader
586   FRAMEBUFFER_SIZE 16 16
587   BIND BUFFER variant_framebuffer AS color LOCATION 0
588   BIND BUFFER variant_zero AS push_constant
589   BIND BUFFER variant__GLF_uniform_int_values AS uniform DESCRIPTOR_SET 0 BINDING 1
590   BIND BUFFER variant__GLF_uniform_float_values AS uniform DESCRIPTOR_SET 0 BINDING 0
591 END
592 CLEAR_COLOR variant_pipeline 0 0 0 255
593
594 CLEAR variant_pipeline
595 RUN variant_pipeline DRAW_RECT POS 0 0 SIZE 16 16
596
597 EXPECT variant_framebuffer IDX 0 0 SIZE 16 16 EQ_RGBA 255 0 0 255