Fix missing dependency on sparse binds
[platform/upstream/VK-GL-CTS.git] / external / vulkancts / data / vulkan / amber / graphicsfuzz / stable-mergesort-for-always-false-if-discard.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: A fragment shader with for loop and always false if
21
22 # The test passes because both shaders render the same image.
23
24 # Optimized using spirv-opt with the following arguments:
25 # '-O'
26 # spirv-opt commit hash: 717e7877cac15d393fd3bb1bd872679de8b59add
27
28
29
30 SHADER vertex reference_vertex_shader PASSTHROUGH
31
32 # reference_fragment_shader is derived from the following GLSL:
33 # #version 320 es
34 # precision highp float;
35 #
36 # precision highp int;
37 #
38 # layout(location = 0) out vec4 _GLF_color;
39 #
40 # layout(set = 0, binding = 0) uniform buf0
41 # {
42 #   vec2 injectionSwitch;
43 # };
44 # const int N = 10;
45 #
46 # int data[10], temp[10];
47 #
48 # void merge(int from, int mid, int to)
49 # {
50 #   int k = from, i = from, j = mid + 1;
51 #   while (i <= mid && j <= to)
52 #   {
53 #     if (data[i] < data[j])
54 #     {
55 #       temp[k++] = data[i++];
56 #     }
57 #     else
58 #     {
59 #       temp[k++] = data[j++];
60 #     }
61 #   }
62 #   while (i < N && i <= mid)
63 #   {
64 #     temp[k++] = data[i++];
65 #   }
66 #   for (int i = from; i <= to; i++)
67 #   {
68 #     data[i] = temp[i];
69 #   }
70 # }
71 # void mergeSort()
72 # {
73 #   int low = 0;
74 #   int high = N - 1;
75 #   for (int m = 1; m <= high; m = 2 * m)
76 #   {
77 #     for (int i = low; i < high; i += 2 * m)
78 #     {
79 #       int from = i;
80 #       int mid = i + m - 1;
81 #       int to = min(i + 2 * m - 1, high);
82 #       merge(from, mid, to);
83 #     }
84 #   }
85 # }
86 # void main()
87 # {
88 #   int i = int(injectionSwitch.x);
89 #   do
90 #   {
91 #     switch (i)
92 #     {
93 #     case 0:
94 #       data[i] = 4;
95 #       break;
96 #     case 1:
97 #       data[i] = 3;
98 #       break;
99 #     case 2:
100 #       data[i] = 2;
101 #       break;
102 #     case 3:
103 #       data[i] = 1;
104 #       break;
105 #     case 4:
106 #       data[i] = 0;
107 #       break;
108 #     case 5:
109 #       data[i] = -1;
110 #       break;
111 #     case 6:
112 #       data[i] = -2;
113 #       break;
114 #     case 7:
115 #       data[i] = -3;
116 #       break;
117 #     case 8:
118 #       data[i] = -4;
119 #       break;
120 #     case 9:
121 #       data[i] = -5;
122 #       break;
123 #     }
124 #     i++;
125 #   } while (i < 10);
126 #   for (int j = 0; j < 10; j++)
127 #   {
128 #     temp[j] = data[j];
129 #   }
130 #   mergeSort();
131 #   float grey;
132 #   if (int(gl_FragCoord[1]) < 30)
133 #   {
134 #     grey = 0.5 + float(data[0]) / 10.0;
135 #   }
136 #   else
137 #   {
138 #     if (int(gl_FragCoord[1]) < 60)
139 #     {
140 #       grey = 0.5 + float(data[1]) / 10.0;
141 #     }
142 #     else
143 #     {
144 #       if (int(gl_FragCoord[1]) < 90)
145 #       {
146 #         grey = 0.5 + float(data[2]) / 10.0;
147 #       }
148 #       else
149 #       {
150 #         if (int(gl_FragCoord[1]) < 120)
151 #         {
152 #           grey = 0.5 + float(data[3]) / 10.0;
153 #         }
154 #         else
155 #         {
156 #           if (int(gl_FragCoord[1]) < 150)
157 #           {
158 #             discard;
159 #           }
160 #           else
161 #           {
162 #             if (int(gl_FragCoord[1]) < 180)
163 #             {
164 #               grey = 0.5 + float(data[5]) / 10.0;
165 #             }
166 #             else
167 #             {
168 #               if (int(gl_FragCoord[1]) < 210)
169 #               {
170 #                 grey = 0.5 + float(data[6]) / 10.0;
171 #               }
172 #               else
173 #               {
174 #                 if (int(gl_FragCoord[1]) < 240)
175 #                 {
176 #                   grey = 0.5 + float(data[7]) / 10.0;
177 #                 }
178 #                 else
179 #                 {
180 #                   if (int(gl_FragCoord[1]) < 270)
181 #                   {
182 #                     grey = 0.5 + float(data[8]) / 10.0;
183 #                   }
184 #                   else
185 #                   {
186 #                     discard;
187 #                   }
188 #                 }
189 #               }
190 #             }
191 #           }
192 #         }
193 #       }
194 #     }
195 #   }
196 #   _GLF_color = vec4(vec3(grey), 1.0);
197 # }
198 SHADER fragment reference_fragment_shader SPIRV-ASM TARGET_ENV spv1.0
199 ; SPIR-V
200 ; Version: 1.0
201 ; Generator: Khronos Glslang Reference Front End; 10
202 ; Bound: 540
203 ; Schema: 0
204                OpCapability Shader
205           %1 = OpExtInstImport "GLSL.std.450"
206                OpMemoryModel Logical GLSL450
207                OpEntryPoint Fragment %4 "main" %243 %369
208                OpExecutionMode %4 OriginUpperLeft
209                OpSource ESSL 320
210                OpName %4 "main"
211                OpName %41 "data"
212                OpName %52 "temp"
213                OpName %159 "buf0"
214                OpMemberName %159 0 "injectionSwitch"
215                OpName %161 ""
216                OpName %243 "gl_FragCoord"
217                OpName %369 "_GLF_color"
218                OpMemberDecorate %159 0 Offset 0
219                OpDecorate %159 Block
220                OpDecorate %161 DescriptorSet 0
221                OpDecorate %161 Binding 0
222                OpDecorate %243 BuiltIn FragCoord
223                OpDecorate %369 Location 0
224           %2 = OpTypeVoid
225           %3 = OpTypeFunction %2
226           %6 = OpTypeInt 32 1
227           %7 = OpTypePointer Function %6
228          %22 = OpConstant %6 1
229          %31 = OpTypeBool
230          %37 = OpTypeInt 32 0
231          %38 = OpConstant %37 10
232          %39 = OpTypeArray %6 %38
233          %74 = OpConstant %6 10
234         %105 = OpConstant %6 0
235         %107 = OpConstant %6 9
236         %136 = OpConstant %6 2
237         %157 = OpTypeFloat 32
238         %158 = OpTypeVector %157 2
239         %159 = OpTypeStruct %158
240         %160 = OpTypePointer Uniform %159
241         %161 = OpVariable %160 Uniform
242         %162 = OpConstant %37 0
243         %163 = OpTypePointer Uniform %157
244         %184 = OpConstant %6 4
245         %188 = OpConstant %6 3
246         %201 = OpConstant %6 -1
247         %205 = OpConstant %6 -2
248         %209 = OpConstant %6 -3
249         %213 = OpConstant %6 -4
250         %217 = OpConstant %6 -5
251         %241 = OpTypeVector %157 4
252         %242 = OpTypePointer Input %241
253         %243 = OpVariable %242 Input
254         %244 = OpConstant %37 1
255         %245 = OpTypePointer Input %157
256         %249 = OpConstant %6 30
257         %255 = OpConstant %157 0.5
258         %266 = OpConstant %6 60
259         %279 = OpConstant %6 90
260         %292 = OpConstant %6 120
261         %305 = OpConstant %6 150
262         %314 = OpConstant %6 180
263         %318 = OpConstant %6 5
264         %328 = OpConstant %6 210
265         %332 = OpConstant %6 6
266         %342 = OpConstant %6 240
267         %346 = OpConstant %6 7
268         %356 = OpConstant %6 270
269         %360 = OpConstant %6 8
270         %368 = OpTypePointer Output %241
271         %369 = OpVariable %368 Output
272         %373 = OpConstant %157 1
273         %507 = OpTypePointer Function %39
274         %539 = OpConstant %157 0.100000001
275           %4 = OpFunction %2 None %3
276           %5 = OpLabel
277          %52 = OpVariable %507 Function
278          %41 = OpVariable %507 Function
279         %164 = OpAccessChain %163 %161 %105 %162
280         %165 = OpLoad %157 %164
281         %166 = OpConvertFToS %6 %165
282                OpBranch %167
283         %167 = OpLabel
284         %508 = OpPhi %6 %166 %5 %222 %170
285                OpLoopMerge %169 %170 None
286                OpBranch %168
287         %168 = OpLabel
288                OpSelectionMerge %182 None
289                OpSwitch %508 %182 0 %172 1 %173 2 %174 3 %175 4 %176 5 %177 6 %178 7 %179 8 %180 9 %181
290         %172 = OpLabel
291         %185 = OpAccessChain %7 %41 %508
292                OpStore %185 %184
293                OpBranch %182
294         %173 = OpLabel
295         %189 = OpAccessChain %7 %41 %508
296                OpStore %189 %188
297                OpBranch %182
298         %174 = OpLabel
299         %192 = OpAccessChain %7 %41 %508
300                OpStore %192 %136
301                OpBranch %182
302         %175 = OpLabel
303         %195 = OpAccessChain %7 %41 %508
304                OpStore %195 %22
305                OpBranch %182
306         %176 = OpLabel
307         %198 = OpAccessChain %7 %41 %508
308                OpStore %198 %105
309                OpBranch %182
310         %177 = OpLabel
311         %202 = OpAccessChain %7 %41 %508
312                OpStore %202 %201
313                OpBranch %182
314         %178 = OpLabel
315         %206 = OpAccessChain %7 %41 %508
316                OpStore %206 %205
317                OpBranch %182
318         %179 = OpLabel
319         %210 = OpAccessChain %7 %41 %508
320                OpStore %210 %209
321                OpBranch %182
322         %180 = OpLabel
323         %214 = OpAccessChain %7 %41 %508
324                OpStore %214 %213
325                OpBranch %182
326         %181 = OpLabel
327         %218 = OpAccessChain %7 %41 %508
328                OpStore %218 %217
329                OpBranch %182
330         %182 = OpLabel
331         %222 = OpIAdd %6 %508 %22
332                OpBranch %170
333         %170 = OpLabel
334         %224 = OpSLessThan %31 %222 %74
335                OpBranchConditional %224 %167 %169
336         %169 = OpLabel
337                OpBranch %226
338         %226 = OpLabel
339         %510 = OpPhi %6 %105 %169 %239 %227
340         %232 = OpSLessThan %31 %510 %74
341                OpLoopMerge %228 %227 None
342                OpBranchConditional %232 %227 %228
343         %227 = OpLabel
344         %235 = OpAccessChain %7 %41 %510
345         %236 = OpLoad %6 %235
346         %237 = OpAccessChain %7 %52 %510
347                OpStore %237 %236
348         %239 = OpIAdd %6 %510 %22
349                OpBranch %226
350         %228 = OpLabel
351                OpBranch %389
352         %389 = OpLabel
353         %511 = OpPhi %6 %22 %228 %426 %424
354         %393 = OpSLessThanEqual %31 %511 %107
355                OpLoopMerge %427 %424 None
356                OpBranchConditional %393 %394 %427
357         %394 = OpLabel
358                OpBranch %396
359         %396 = OpLabel
360         %519 = OpPhi %6 %105 %394 %410 %418
361         %400 = OpSLessThan %31 %519 %107
362                OpLoopMerge %423 %418 None
363                OpBranchConditional %400 %401 %423
364         %401 = OpLabel
365         %405 = OpIAdd %6 %519 %511
366         %406 = OpISub %6 %405 %22
367         %409 = OpIMul %6 %136 %511
368         %410 = OpIAdd %6 %519 %409
369         %411 = OpISub %6 %410 %22
370         %413 = OpExtInst %6 %1 SMin %411 %107
371                OpBranch %437
372         %437 = OpLabel
373         %532 = OpPhi %6 %519 %401 %456 %471
374         %522 = OpPhi %6 %405 %401 %534 %471
375         %521 = OpPhi %6 %519 %401 %533 %471
376         %441 = OpSLessThanEqual %31 %521 %406
377         %444 = OpSLessThanEqual %31 %522 %413
378         %445 = OpLogicalAnd %31 %441 %444
379                OpLoopMerge %472 %471 None
380                OpBranchConditional %445 %446 %472
381         %446 = OpLabel
382         %448 = OpAccessChain %7 %41 %521
383         %449 = OpLoad %6 %448
384         %451 = OpAccessChain %7 %41 %522
385         %452 = OpLoad %6 %451
386         %453 = OpSLessThan %31 %449 %452
387         %456 = OpIAdd %6 %532 %22
388                OpSelectionMerge %470 None
389                OpBranchConditional %453 %454 %462
390         %454 = OpLabel
391         %458 = OpIAdd %6 %521 %22
392         %460 = OpLoad %6 %448
393         %461 = OpAccessChain %7 %52 %532
394                OpStore %461 %460
395                OpBranch %470
396         %462 = OpLabel
397         %466 = OpIAdd %6 %522 %22
398         %468 = OpLoad %6 %451
399         %469 = OpAccessChain %7 %52 %532
400                OpStore %469 %468
401                OpBranch %470
402         %470 = OpLabel
403         %534 = OpPhi %6 %522 %454 %466 %462
404         %533 = OpPhi %6 %458 %454 %521 %462
405                OpBranch %471
406         %471 = OpLabel
407                OpBranch %437
408         %472 = OpLabel
409                OpBranch %473
410         %473 = OpLabel
411         %531 = OpPhi %6 %532 %472 %483 %481
412         %523 = OpPhi %6 %521 %472 %485 %481
413         %476 = OpSLessThan %31 %523 %74
414         %479 = OpSLessThanEqual %31 %523 %406
415         %480 = OpLogicalAnd %31 %476 %479
416                OpLoopMerge %490 %481 None
417                OpBranchConditional %480 %481 %490
418         %481 = OpLabel
419         %483 = OpIAdd %6 %531 %22
420         %485 = OpIAdd %6 %523 %22
421         %486 = OpAccessChain %7 %41 %523
422         %487 = OpLoad %6 %486
423         %488 = OpAccessChain %7 %52 %531
424                OpStore %488 %487
425                OpBranch %473
426         %490 = OpLabel
427                OpBranch %492
428         %492 = OpLabel
429         %524 = OpPhi %6 %519 %490 %505 %497
430         %496 = OpSLessThanEqual %31 %524 %413
431                OpLoopMerge %506 %497 None
432                OpBranchConditional %496 %497 %506
433         %497 = OpLabel
434         %500 = OpAccessChain %7 %52 %524
435         %501 = OpLoad %6 %500
436         %502 = OpAccessChain %7 %41 %524
437                OpStore %502 %501
438         %505 = OpIAdd %6 %524 %22
439                OpBranch %492
440         %506 = OpLabel
441                OpBranch %418
442         %418 = OpLabel
443                OpBranch %396
444         %423 = OpLabel
445                OpBranch %424
446         %424 = OpLabel
447         %426 = OpIMul %6 %136 %511
448                OpBranch %389
449         %427 = OpLabel
450         %246 = OpAccessChain %245 %243 %244
451         %247 = OpLoad %157 %246
452         %248 = OpConvertFToS %6 %247
453         %250 = OpSLessThan %31 %248 %249
454                OpSelectionMerge %252 None
455                OpBranchConditional %250 %251 %262
456         %251 = OpLabel
457         %256 = OpAccessChain %7 %41 %105
458         %257 = OpLoad %6 %256
459         %258 = OpConvertSToF %157 %257
460         %260 = OpFMul %157 %258 %539
461         %261 = OpFAdd %157 %255 %260
462                OpBranch %252
463         %262 = OpLabel
464         %267 = OpSLessThan %31 %248 %266
465                OpSelectionMerge %269 None
466                OpBranchConditional %267 %268 %275
467         %268 = OpLabel
468         %270 = OpAccessChain %7 %41 %22
469         %271 = OpLoad %6 %270
470         %272 = OpConvertSToF %157 %271
471         %273 = OpFMul %157 %272 %539
472         %274 = OpFAdd %157 %255 %273
473                OpBranch %269
474         %275 = OpLabel
475         %280 = OpSLessThan %31 %248 %279
476                OpSelectionMerge %282 None
477                OpBranchConditional %280 %281 %288
478         %281 = OpLabel
479         %283 = OpAccessChain %7 %41 %136
480         %284 = OpLoad %6 %283
481         %285 = OpConvertSToF %157 %284
482         %286 = OpFMul %157 %285 %539
483         %287 = OpFAdd %157 %255 %286
484                OpBranch %282
485         %288 = OpLabel
486         %293 = OpSLessThan %31 %248 %292
487                OpSelectionMerge %295 None
488                OpBranchConditional %293 %294 %301
489         %294 = OpLabel
490         %296 = OpAccessChain %7 %41 %188
491         %297 = OpLoad %6 %296
492         %298 = OpConvertSToF %157 %297
493         %299 = OpFMul %157 %298 %539
494         %300 = OpFAdd %157 %255 %299
495                OpBranch %295
496         %301 = OpLabel
497         %306 = OpSLessThan %31 %248 %305
498                OpSelectionMerge %308 None
499                OpBranchConditional %306 %307 %310
500         %307 = OpLabel
501                OpKill
502         %310 = OpLabel
503         %315 = OpSLessThan %31 %248 %314
504                OpSelectionMerge %317 None
505                OpBranchConditional %315 %316 %324
506         %316 = OpLabel
507         %319 = OpAccessChain %7 %41 %318
508         %320 = OpLoad %6 %319
509         %321 = OpConvertSToF %157 %320
510         %322 = OpFMul %157 %321 %539
511         %323 = OpFAdd %157 %255 %322
512                OpBranch %317
513         %324 = OpLabel
514         %329 = OpSLessThan %31 %248 %328
515                OpSelectionMerge %331 None
516                OpBranchConditional %329 %330 %338
517         %330 = OpLabel
518         %333 = OpAccessChain %7 %41 %332
519         %334 = OpLoad %6 %333
520         %335 = OpConvertSToF %157 %334
521         %336 = OpFMul %157 %335 %539
522         %337 = OpFAdd %157 %255 %336
523                OpBranch %331
524         %338 = OpLabel
525         %343 = OpSLessThan %31 %248 %342
526                OpSelectionMerge %345 None
527                OpBranchConditional %343 %344 %352
528         %344 = OpLabel
529         %347 = OpAccessChain %7 %41 %346
530         %348 = OpLoad %6 %347
531         %349 = OpConvertSToF %157 %348
532         %350 = OpFMul %157 %349 %539
533         %351 = OpFAdd %157 %255 %350
534                OpBranch %345
535         %352 = OpLabel
536         %357 = OpSLessThan %31 %248 %356
537                OpSelectionMerge %358 None
538                OpBranchConditional %357 %358 %366
539         %358 = OpLabel
540         %361 = OpAccessChain %7 %41 %360
541         %362 = OpLoad %6 %361
542         %363 = OpConvertSToF %157 %362
543         %364 = OpFMul %157 %363 %539
544         %365 = OpFAdd %157 %255 %364
545                OpBranch %345
546         %366 = OpLabel
547                OpKill
548         %345 = OpLabel
549         %518 = OpPhi %157 %351 %344 %365 %358
550                OpBranch %331
551         %331 = OpLabel
552         %517 = OpPhi %157 %337 %330 %518 %345
553                OpBranch %317
554         %317 = OpLabel
555         %516 = OpPhi %157 %323 %316 %517 %331
556                OpBranch %308
557         %308 = OpLabel
558                OpBranch %295
559         %295 = OpLabel
560         %515 = OpPhi %157 %300 %294 %516 %308
561                OpBranch %282
562         %282 = OpLabel
563         %514 = OpPhi %157 %287 %281 %515 %295
564                OpBranch %269
565         %269 = OpLabel
566         %513 = OpPhi %157 %274 %268 %514 %282
567                OpBranch %252
568         %252 = OpLabel
569         %512 = OpPhi %157 %261 %251 %513 %269
570         %377 = OpCompositeConstruct %241 %512 %512 %512 %373
571                OpStore %369 %377
572                OpReturn
573                OpFunctionEnd
574 END
575
576 # uniforms for reference
577
578 # injectionSwitch
579 BUFFER reference_injectionSwitch DATA_TYPE vec2<float> STD140 DATA
580  0.0 1.0
581 END
582
583 BUFFER reference_framebuffer FORMAT B8G8R8A8_UNORM
584
585 PIPELINE graphics reference_pipeline
586   ATTACH reference_vertex_shader
587   ATTACH reference_fragment_shader
588   FRAMEBUFFER_SIZE 256 256
589   BIND BUFFER reference_framebuffer AS color LOCATION 0
590   BIND BUFFER reference_injectionSwitch AS uniform DESCRIPTOR_SET 0 BINDING 0
591 END
592 CLEAR_COLOR reference_pipeline 0 0 0 255
593
594 CLEAR reference_pipeline
595 RUN reference_pipeline DRAW_RECT POS 0 0 SIZE 256 256
596
597
598 SHADER vertex variant_vertex_shader PASSTHROUGH
599
600 # variant_fragment_shader is derived from the following GLSL:
601 # #version 320 es
602 # precision highp float;
603 #
604 # precision highp int;
605 #
606 # layout(location = 0) out vec4 _GLF_color;
607 #
608 # layout(set = 0, binding = 0) uniform buf0
609 # {
610 #   vec2 injectionSwitch; // x == 0.0, y == 1.0
611 # };
612 # const int N = 10;
613 #
614 # int data[10], temp[10];
615 #
616 # void merge(int from, int mid, int to)
617 # {
618 #   int k = from, i = from, j = mid + 1;
619 #   while (i <= mid && j <= to)
620 #   {
621 #     if (data[i] < data[j])
622 #     {
623 #       temp[k++] = data[i++];
624 #     }
625 #     else
626 #     {
627 #       temp[k++] = data[j++];
628 #     }
629 #   }
630 #   while (i < N && i <= mid)
631 #   {
632 #     temp[k++] = data[i++];
633 #   }
634 #   for (int i = from; i <= to; i++)
635 #   {
636 #     data[i] = temp[i];
637 #   }
638 # }
639 # void mergeSort()
640 # {
641 #   int low = 0;
642 #   int high = N - 1;
643 #   for (int m = 1; m <= high; m = 2 * m)
644 #   {
645 #     for (int i = low; i < high; i += 2 * m)
646 #     {
647 #       int from = i;
648 #       int mid = i + m - 1;
649 #       int to = min(i + 2 * m - 1, high);
650 #       merge(from, mid, to);
651 #     }
652 #   }
653 # }
654 # void main()
655 # {
656 #   int i = int(injectionSwitch.x);
657 #   do
658 #   {
659 #     switch (i)
660 #     {
661 #     case 0:
662 #       data[i] = 4;
663 #       break;
664 #     case 1:
665 #       data[i] = 3;
666 #       break;
667 #     case 2:
668 #       data[i] = 2;
669 #       break;
670 #     case 3:
671 #       data[i] = 1;
672 #       break;
673 #     case 4:
674 #       data[i] = 0;
675 #       break;
676 #     case 5:
677 #       data[i] = -1;
678 #       break;
679 #     case 6:
680 #       data[i] = -2;
681 #       break;
682 #     case 7:
683 #       data[i] = -3;
684 #       break;
685 #     case 8:
686 #       data[i] = -4;
687 #       break;
688 #     case 9:
689 #       data[i] = -5;
690 #       break;
691 #     }
692 #     i++;
693 #   } while (i < 10);
694 #   for (int j = 0; j < 10; j++)
695 #   {
696 #     temp[j] = data[j];
697 #   }
698 #   mergeSort();
699 #   float grey;
700 #   if (int(gl_FragCoord[1]) < 30)
701 #   {
702 #     grey = 0.5 + float(data[0]) / 10.0;
703 #   }
704 #   else
705 #   {
706 #     if (int(gl_FragCoord[1]) < 60)
707 #     {
708 #       grey = 0.5 + float(data[1]) / 10.0;
709 #     }
710 #     else
711 #     {
712 #       if (int(gl_FragCoord[1]) < 90)
713 #       {
714 #         grey = 0.5 + float(data[2]) / 10.0;
715 #       }
716 #       else
717 #       {
718 #         if (int(gl_FragCoord[1]) < 120)
719 #         {
720 #           grey = 0.5 + float(data[3]) / 10.0;
721 #         }
722 #         else
723 #         {
724 #           if (int(gl_FragCoord[1]) < 150)
725 #           {
726 #             discard;
727 #           }
728 #           else
729 #           {
730 #             if (int(gl_FragCoord[1]) < 180)
731 #             {
732 #               grey = 0.5 + float(data[5]) / 10.0;
733 #             }
734 #             else
735 #             {
736 #               if (int(gl_FragCoord[1]) < 210)
737 #               {
738 #                 grey = 0.5 + float(data[6]) / 10.0;
739 #               }
740 #               else
741 #               {
742 #                 if (int(gl_FragCoord[1]) < 240)
743 #                 {
744 #                   grey = 0.5 + float(data[7]) / 10.0;
745 #                 }
746 #                 else
747 #                 {
748 #                   if (int(gl_FragCoord[1]) < 270)
749 #                   {
750 #                     grey = 0.5 + float(data[8]) / 10.0;
751 #                   }
752 #                   else
753 #                   {
754 #                     discard;
755 #                   }
756 #                 }
757 #               }
758 #             }
759 #             // Code block bellow should not affect output image.
760 #             // Always false.
761 #             if (injectionSwitch.x > injectionSwitch.y)
762 #             {
763 #               _GLF_color = vec4(1.0);
764 #             }
765 #             vec2 a = vec2(1.0, 1.0);
766 #             for (int i = 0; i <= 32; i++)
767 #             {
768 #               // Always false.
769 #               if (a.x < 0.0)
770 #               {
771 #                 // Always false.
772 #                 if (injectionSwitch.x > injectionSwitch.y)
773 #                 {
774 #                   discard;
775 #                 }
776 #                 a.y++;
777 #               }
778 #               a.x += a.y;
779 #             }
780 #             // End of block.
781 #           }
782 #         }
783 #       }
784 #     }
785 #   }
786 #   _GLF_color = vec4(vec3(grey), 1.0);
787 # }
788 SHADER fragment variant_fragment_shader SPIRV-ASM TARGET_ENV spv1.0
789 ; SPIR-V
790 ; Version: 1.0
791 ; Generator: Khronos Glslang Reference Front End; 10
792 ; Bound: 602
793 ; Schema: 0
794                OpCapability Shader
795           %1 = OpExtInstImport "GLSL.std.450"
796                OpMemoryModel Logical GLSL450
797                OpEntryPoint Fragment %4 "main" %243 %376
798                OpExecutionMode %4 OriginUpperLeft
799                OpSource ESSL 320
800                OpName %4 "main"
801                OpName %41 "data"
802                OpName %52 "temp"
803                OpName %159 "buf0"
804                OpMemberName %159 0 "injectionSwitch"
805                OpName %161 ""
806                OpName %243 "gl_FragCoord"
807                OpName %376 "_GLF_color"
808                OpMemberDecorate %159 0 Offset 0
809                OpDecorate %159 Block
810                OpDecorate %161 DescriptorSet 0
811                OpDecorate %161 Binding 0
812                OpDecorate %243 BuiltIn FragCoord
813                OpDecorate %376 Location 0
814           %2 = OpTypeVoid
815           %3 = OpTypeFunction %2
816           %6 = OpTypeInt 32 1
817           %7 = OpTypePointer Function %6
818          %22 = OpConstant %6 1
819          %31 = OpTypeBool
820          %37 = OpTypeInt 32 0
821          %38 = OpConstant %37 10
822          %39 = OpTypeArray %6 %38
823          %74 = OpConstant %6 10
824         %105 = OpConstant %6 0
825         %107 = OpConstant %6 9
826         %136 = OpConstant %6 2
827         %157 = OpTypeFloat 32
828         %158 = OpTypeVector %157 2
829         %159 = OpTypeStruct %158
830         %160 = OpTypePointer Uniform %159
831         %161 = OpVariable %160 Uniform
832         %162 = OpConstant %37 0
833         %163 = OpTypePointer Uniform %157
834         %184 = OpConstant %6 4
835         %188 = OpConstant %6 3
836         %201 = OpConstant %6 -1
837         %205 = OpConstant %6 -2
838         %209 = OpConstant %6 -3
839         %213 = OpConstant %6 -4
840         %217 = OpConstant %6 -5
841         %241 = OpTypeVector %157 4
842         %242 = OpTypePointer Input %241
843         %243 = OpVariable %242 Input
844         %244 = OpConstant %37 1
845         %245 = OpTypePointer Input %157
846         %249 = OpConstant %6 30
847         %255 = OpConstant %157 0.5
848         %266 = OpConstant %6 60
849         %279 = OpConstant %6 90
850         %292 = OpConstant %6 120
851         %305 = OpConstant %6 150
852         %314 = OpConstant %6 180
853         %318 = OpConstant %6 5
854         %328 = OpConstant %6 210
855         %332 = OpConstant %6 6
856         %342 = OpConstant %6 240
857         %346 = OpConstant %6 7
858         %356 = OpConstant %6 270
859         %360 = OpConstant %6 8
860         %375 = OpTypePointer Output %241
861         %376 = OpVariable %375 Output
862         %377 = OpConstant %157 1
863         %378 = OpConstantComposite %241 %377 %377 %377 %377
864         %381 = OpConstantComposite %158 %377 %377
865         %389 = OpConstant %6 32
866         %393 = OpConstant %157 0
867         %552 = OpTypePointer Function %39
868         %601 = OpConstant %157 0.100000001
869           %4 = OpFunction %2 None %3
870           %5 = OpLabel
871          %52 = OpVariable %552 Function
872          %41 = OpVariable %552 Function
873         %164 = OpAccessChain %163 %161 %105 %162
874         %165 = OpLoad %157 %164
875         %166 = OpConvertFToS %6 %165
876                OpBranch %167
877         %167 = OpLabel
878         %561 = OpPhi %6 %166 %5 %222 %170
879                OpLoopMerge %169 %170 None
880                OpBranch %168
881         %168 = OpLabel
882                OpSelectionMerge %182 None
883                OpSwitch %561 %182 0 %172 1 %173 2 %174 3 %175 4 %176 5 %177 6 %178 7 %179 8 %180 9 %181
884         %172 = OpLabel
885         %185 = OpAccessChain %7 %41 %561
886                OpStore %185 %184
887                OpBranch %182
888         %173 = OpLabel
889         %189 = OpAccessChain %7 %41 %561
890                OpStore %189 %188
891                OpBranch %182
892         %174 = OpLabel
893         %192 = OpAccessChain %7 %41 %561
894                OpStore %192 %136
895                OpBranch %182
896         %175 = OpLabel
897         %195 = OpAccessChain %7 %41 %561
898                OpStore %195 %22
899                OpBranch %182
900         %176 = OpLabel
901         %198 = OpAccessChain %7 %41 %561
902                OpStore %198 %105
903                OpBranch %182
904         %177 = OpLabel
905         %202 = OpAccessChain %7 %41 %561
906                OpStore %202 %201
907                OpBranch %182
908         %178 = OpLabel
909         %206 = OpAccessChain %7 %41 %561
910                OpStore %206 %205
911                OpBranch %182
912         %179 = OpLabel
913         %210 = OpAccessChain %7 %41 %561
914                OpStore %210 %209
915                OpBranch %182
916         %180 = OpLabel
917         %214 = OpAccessChain %7 %41 %561
918                OpStore %214 %213
919                OpBranch %182
920         %181 = OpLabel
921         %218 = OpAccessChain %7 %41 %561
922                OpStore %218 %217
923                OpBranch %182
924         %182 = OpLabel
925         %222 = OpIAdd %6 %561 %22
926                OpBranch %170
927         %170 = OpLabel
928         %224 = OpSLessThan %31 %222 %74
929                OpBranchConditional %224 %167 %169
930         %169 = OpLabel
931                OpBranch %226
932         %226 = OpLabel
933         %563 = OpPhi %6 %105 %169 %239 %227
934         %232 = OpSLessThan %31 %563 %74
935                OpLoopMerge %228 %227 None
936                OpBranchConditional %232 %227 %228
937         %227 = OpLabel
938         %235 = OpAccessChain %7 %41 %563
939         %236 = OpLoad %6 %235
940         %237 = OpAccessChain %7 %52 %563
941                OpStore %237 %236
942         %239 = OpIAdd %6 %563 %22
943                OpBranch %226
944         %228 = OpLabel
945                OpBranch %434
946         %434 = OpLabel
947         %564 = OpPhi %6 %22 %228 %471 %469
948         %438 = OpSLessThanEqual %31 %564 %107
949                OpLoopMerge %472 %469 None
950                OpBranchConditional %438 %439 %472
951         %439 = OpLabel
952                OpBranch %441
953         %441 = OpLabel
954         %579 = OpPhi %6 %105 %439 %455 %463
955         %445 = OpSLessThan %31 %579 %107
956                OpLoopMerge %468 %463 None
957                OpBranchConditional %445 %446 %468
958         %446 = OpLabel
959         %450 = OpIAdd %6 %579 %564
960         %451 = OpISub %6 %450 %22
961         %454 = OpIMul %6 %136 %564
962         %455 = OpIAdd %6 %579 %454
963         %456 = OpISub %6 %455 %22
964         %458 = OpExtInst %6 %1 SMin %456 %107
965                OpBranch %482
966         %482 = OpLabel
967         %592 = OpPhi %6 %579 %446 %501 %516
968         %582 = OpPhi %6 %450 %446 %594 %516
969         %581 = OpPhi %6 %579 %446 %593 %516
970         %486 = OpSLessThanEqual %31 %581 %451
971         %489 = OpSLessThanEqual %31 %582 %458
972         %490 = OpLogicalAnd %31 %486 %489
973                OpLoopMerge %517 %516 None
974                OpBranchConditional %490 %491 %517
975         %491 = OpLabel
976         %493 = OpAccessChain %7 %41 %581
977         %494 = OpLoad %6 %493
978         %496 = OpAccessChain %7 %41 %582
979         %497 = OpLoad %6 %496
980         %498 = OpSLessThan %31 %494 %497
981         %501 = OpIAdd %6 %592 %22
982                OpSelectionMerge %515 None
983                OpBranchConditional %498 %499 %507
984         %499 = OpLabel
985         %503 = OpIAdd %6 %581 %22
986         %505 = OpLoad %6 %493
987         %506 = OpAccessChain %7 %52 %592
988                OpStore %506 %505
989                OpBranch %515
990         %507 = OpLabel
991         %511 = OpIAdd %6 %582 %22
992         %513 = OpLoad %6 %496
993         %514 = OpAccessChain %7 %52 %592
994                OpStore %514 %513
995                OpBranch %515
996         %515 = OpLabel
997         %594 = OpPhi %6 %582 %499 %511 %507
998         %593 = OpPhi %6 %503 %499 %581 %507
999                OpBranch %516
1000         %516 = OpLabel
1001                OpBranch %482
1002         %517 = OpLabel
1003                OpBranch %518
1004         %518 = OpLabel
1005         %591 = OpPhi %6 %592 %517 %528 %526
1006         %583 = OpPhi %6 %581 %517 %530 %526
1007         %521 = OpSLessThan %31 %583 %74
1008         %524 = OpSLessThanEqual %31 %583 %451
1009         %525 = OpLogicalAnd %31 %521 %524
1010                OpLoopMerge %535 %526 None
1011                OpBranchConditional %525 %526 %535
1012         %526 = OpLabel
1013         %528 = OpIAdd %6 %591 %22
1014         %530 = OpIAdd %6 %583 %22
1015         %531 = OpAccessChain %7 %41 %583
1016         %532 = OpLoad %6 %531
1017         %533 = OpAccessChain %7 %52 %591
1018                OpStore %533 %532
1019                OpBranch %518
1020         %535 = OpLabel
1021                OpBranch %537
1022         %537 = OpLabel
1023         %584 = OpPhi %6 %579 %535 %550 %542
1024         %541 = OpSLessThanEqual %31 %584 %458
1025                OpLoopMerge %551 %542 None
1026                OpBranchConditional %541 %542 %551
1027         %542 = OpLabel
1028         %545 = OpAccessChain %7 %52 %584
1029         %546 = OpLoad %6 %545
1030         %547 = OpAccessChain %7 %41 %584
1031                OpStore %547 %546
1032         %550 = OpIAdd %6 %584 %22
1033                OpBranch %537
1034         %551 = OpLabel
1035                OpBranch %463
1036         %463 = OpLabel
1037                OpBranch %441
1038         %468 = OpLabel
1039                OpBranch %469
1040         %469 = OpLabel
1041         %471 = OpIMul %6 %136 %564
1042                OpBranch %434
1043         %472 = OpLabel
1044         %246 = OpAccessChain %245 %243 %244
1045         %247 = OpLoad %157 %246
1046         %248 = OpConvertFToS %6 %247
1047         %250 = OpSLessThan %31 %248 %249
1048                OpSelectionMerge %252 None
1049                OpBranchConditional %250 %251 %262
1050         %251 = OpLabel
1051         %256 = OpAccessChain %7 %41 %105
1052         %257 = OpLoad %6 %256
1053         %258 = OpConvertSToF %157 %257
1054         %260 = OpFMul %157 %258 %601
1055         %261 = OpFAdd %157 %255 %260
1056                OpBranch %252
1057         %262 = OpLabel
1058         %267 = OpSLessThan %31 %248 %266
1059                OpSelectionMerge %269 None
1060                OpBranchConditional %267 %268 %275
1061         %268 = OpLabel
1062         %270 = OpAccessChain %7 %41 %22
1063         %271 = OpLoad %6 %270
1064         %272 = OpConvertSToF %157 %271
1065         %273 = OpFMul %157 %272 %601
1066         %274 = OpFAdd %157 %255 %273
1067                OpBranch %269
1068         %275 = OpLabel
1069         %280 = OpSLessThan %31 %248 %279
1070                OpSelectionMerge %282 None
1071                OpBranchConditional %280 %281 %288
1072         %281 = OpLabel
1073         %283 = OpAccessChain %7 %41 %136
1074         %284 = OpLoad %6 %283
1075         %285 = OpConvertSToF %157 %284
1076         %286 = OpFMul %157 %285 %601
1077         %287 = OpFAdd %157 %255 %286
1078                OpBranch %282
1079         %288 = OpLabel
1080         %293 = OpSLessThan %31 %248 %292
1081                OpSelectionMerge %295 None
1082                OpBranchConditional %293 %294 %301
1083         %294 = OpLabel
1084         %296 = OpAccessChain %7 %41 %188
1085         %297 = OpLoad %6 %296
1086         %298 = OpConvertSToF %157 %297
1087         %299 = OpFMul %157 %298 %601
1088         %300 = OpFAdd %157 %255 %299
1089                OpBranch %295
1090         %301 = OpLabel
1091         %306 = OpSLessThan %31 %248 %305
1092                OpSelectionMerge %308 None
1093                OpBranchConditional %306 %307 %310
1094         %307 = OpLabel
1095                OpKill
1096         %310 = OpLabel
1097         %315 = OpSLessThan %31 %248 %314
1098                OpSelectionMerge %317 None
1099                OpBranchConditional %315 %316 %324
1100         %316 = OpLabel
1101         %319 = OpAccessChain %7 %41 %318
1102         %320 = OpLoad %6 %319
1103         %321 = OpConvertSToF %157 %320
1104         %322 = OpFMul %157 %321 %601
1105         %323 = OpFAdd %157 %255 %322
1106                OpBranch %317
1107         %324 = OpLabel
1108         %329 = OpSLessThan %31 %248 %328
1109                OpSelectionMerge %331 None
1110                OpBranchConditional %329 %330 %338
1111         %330 = OpLabel
1112         %333 = OpAccessChain %7 %41 %332
1113         %334 = OpLoad %6 %333
1114         %335 = OpConvertSToF %157 %334
1115         %336 = OpFMul %157 %335 %601
1116         %337 = OpFAdd %157 %255 %336
1117                OpBranch %331
1118         %338 = OpLabel
1119         %343 = OpSLessThan %31 %248 %342
1120                OpSelectionMerge %345 None
1121                OpBranchConditional %343 %344 %352
1122         %344 = OpLabel
1123         %347 = OpAccessChain %7 %41 %346
1124         %348 = OpLoad %6 %347
1125         %349 = OpConvertSToF %157 %348
1126         %350 = OpFMul %157 %349 %601
1127         %351 = OpFAdd %157 %255 %350
1128                OpBranch %345
1129         %352 = OpLabel
1130         %357 = OpSLessThan %31 %248 %356
1131                OpSelectionMerge %358 None
1132                OpBranchConditional %357 %358 %366
1133         %358 = OpLabel
1134         %361 = OpAccessChain %7 %41 %360
1135         %362 = OpLoad %6 %361
1136         %363 = OpConvertSToF %157 %362
1137         %364 = OpFMul %157 %363 %601
1138         %365 = OpFAdd %157 %255 %364
1139                OpBranch %345
1140         %366 = OpLabel
1141                OpKill
1142         %345 = OpLabel
1143         %577 = OpPhi %157 %351 %344 %365 %358
1144                OpBranch %331
1145         %331 = OpLabel
1146         %576 = OpPhi %157 %337 %330 %577 %345
1147                OpBranch %317
1148         %317 = OpLabel
1149         %575 = OpPhi %157 %323 %316 %576 %331
1150         %370 = OpAccessChain %163 %161 %105 %244
1151         %371 = OpLoad %157 %370
1152         %372 = OpFOrdGreaterThan %31 %165 %371
1153                OpSelectionMerge %374 None
1154                OpBranchConditional %372 %373 %374
1155         %373 = OpLabel
1156                OpStore %376 %378
1157                OpBranch %374
1158         %374 = OpLabel
1159                OpBranch %383
1160         %383 = OpLabel
1161         %566 = OpPhi %158 %381 %374 %560 %386
1162         %565 = OpPhi %6 %105 %374 %415 %386
1163         %390 = OpSLessThanEqual %31 %565 %389
1164                OpLoopMerge %385 %386 None
1165                OpBranchConditional %390 %384 %385
1166         %384 = OpLabel
1167         %392 = OpCompositeExtract %157 %566 0
1168         %394 = OpFOrdLessThan %31 %392 %393
1169                OpSelectionMerge %396 None
1170                OpBranchConditional %394 %395 %396
1171         %395 = OpLabel
1172                OpSelectionMerge %403 None
1173                OpBranchConditional %372 %402 %403
1174         %402 = OpLabel
1175                OpKill
1176         %403 = OpLabel
1177         %406 = OpCompositeExtract %157 %566 1
1178         %407 = OpFAdd %157 %406 %377
1179         %556 = OpCompositeInsert %158 %407 %566 1
1180                OpBranch %396
1181         %396 = OpLabel
1182         %567 = OpPhi %158 %566 %384 %556 %403
1183         %409 = OpCompositeExtract %157 %567 1
1184         %411 = OpCompositeExtract %157 %567 0
1185         %412 = OpFAdd %157 %411 %409
1186         %560 = OpCompositeInsert %158 %412 %567 0
1187                OpBranch %386
1188         %386 = OpLabel
1189         %415 = OpIAdd %6 %565 %22
1190                OpBranch %383
1191         %385 = OpLabel
1192                OpBranch %308
1193         %308 = OpLabel
1194                OpBranch %295
1195         %295 = OpLabel
1196         %572 = OpPhi %157 %300 %294 %575 %308
1197                OpBranch %282
1198         %282 = OpLabel
1199         %571 = OpPhi %157 %287 %281 %572 %295
1200                OpBranch %269
1201         %269 = OpLabel
1202         %570 = OpPhi %157 %274 %268 %571 %282
1203                OpBranch %252
1204         %252 = OpLabel
1205         %569 = OpPhi %157 %261 %251 %570 %269
1206         %422 = OpCompositeConstruct %241 %569 %569 %569 %377
1207                OpStore %376 %422
1208                OpReturn
1209                OpFunctionEnd
1210 END
1211
1212 # uniforms for variant
1213
1214 # injectionSwitch
1215 BUFFER variant_injectionSwitch DATA_TYPE vec2<float> STD140 DATA
1216  0.0 1.0
1217 END
1218
1219 BUFFER variant_framebuffer FORMAT B8G8R8A8_UNORM
1220
1221 PIPELINE graphics variant_pipeline
1222   ATTACH variant_vertex_shader
1223   ATTACH variant_fragment_shader
1224   FRAMEBUFFER_SIZE 256 256
1225   BIND BUFFER variant_framebuffer AS color LOCATION 0
1226   BIND BUFFER variant_injectionSwitch AS uniform DESCRIPTOR_SET 0 BINDING 0
1227 END
1228 CLEAR_COLOR variant_pipeline 0 0 0 255
1229
1230 CLEAR variant_pipeline
1231 RUN variant_pipeline DRAW_RECT POS 0 0 SIZE 256 256
1232
1233 EXPECT reference_framebuffer EQ_HISTOGRAM_EMD_BUFFER variant_framebuffer TOLERANCE 0.005