Fix missing dependency on sparse binds
[platform/upstream/VK-GL-CTS.git] / external / vulkancts / data / vulkan / amber / graphicsfuzz / stable-mergesort-reversed-for-loop.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 GraphicsFuzz.
19
20 # Short description: A fragment shader with once iterated reversed for loop
21
22 # The test passes because both shaders render the same image.
23
24 SHADER vertex reference_vertex_shader PASSTHROUGH
25
26 # reference_fragment_shader is derived from the following GLSL:
27 # #version 320 es
28 # precision highp float;
29 #
30 # precision highp int;
31 #
32 # layout(location = 0) out vec4 _GLF_color;
33 #
34 # layout(set = 0, binding = 0) uniform buf0
35 # {
36 #     vec2 injectionSwitch;
37 # };
38 # const int N = 10;
39 #
40 # int data[10], temp[10];
41 #
42 # void merge(int from, int mid, int to)
43 # {
44 #     int k = from, i = from, j = mid + 1;
45 #     while (i <= mid && j <= to)
46 #     {
47 #         if (data[i] < data[j])
48 #         {
49 #             temp[k++] = data[i++];
50 #         }
51 #         else
52 #         {
53 #             temp[k++] = data[j++];
54 #         }
55 #     }
56 #     while (i < N && i <= mid)
57 #     {
58 #         temp[k++] = data[i++];
59 #     }
60 #     for (int i = from; i <= to; i++)
61 #     {
62 #         data[i] = temp[i];
63 #     }
64 # }
65 # void mergeSort()
66 # {
67 #     int low = 0;
68 #     int high = N - 1;
69 #     for (int m = 1; m <= high; m = 2 * m)
70 #     {
71 #         for (int i = low; i < high; i += 2 * m)
72 #         {
73 #             int from = i;
74 #             int mid = i + m - 1;
75 #             int to = min(i + 2 * m - 1, high);
76 #             merge(from, mid, to);
77 #         }
78 #     }
79 # }
80 # void main()
81 # {
82 #     int i = int(injectionSwitch.x);
83 #     do
84 #     {
85 #         switch (i)
86 #         {
87 #         case 0:
88 #             data[i] = 4;
89 #             break;
90 #         case 1:
91 #             data[i] = 3;
92 #             break;
93 #         case 2:
94 #             data[i] = 2;
95 #             break;
96 #         case 3:
97 #             data[i] = 1;
98 #             break;
99 #         case 4:
100 #             data[i] = 0;
101 #             break;
102 #         case 5:
103 #             data[i] = -1;
104 #             break;
105 #         case 6:
106 #             data[i] = -2;
107 #             break;
108 #         case 7:
109 #             data[i] = -3;
110 #             break;
111 #         case 8:
112 #             data[i] = -4;
113 #             break;
114 #         case 9:
115 #             data[i] = -5;
116 #             break;
117 #         }
118 #         i++;
119 #     } while (i < 10);
120 #     for (int j = 0; j < 10; j++)
121 #     {
122 #         temp[j] = data[j];
123 #     }
124 #     mergeSort();
125 #     float grey;
126 #     if (int(gl_FragCoord[1]) < 30)
127 #     {
128 #         grey = 0.5 + float(data[0]) / 10.0;
129 #     }
130 #     else
131 #     {
132 #         if (int(gl_FragCoord[1]) < 60)
133 #         {
134 #             grey = 0.5 + float(data[1]) / 10.0;
135 #         }
136 #         else
137 #         {
138 #             if (int(gl_FragCoord[1]) < 90)
139 #             {
140 #                 grey = 0.5 + float(data[2]) / 10.0;
141 #             }
142 #             else
143 #             {
144 #                 if (int(gl_FragCoord[1]) < 120)
145 #                 {
146 #                     grey = 0.5 + float(data[3]) / 10.0;
147 #                 }
148 #                 else
149 #                 {
150 #                     if (int(gl_FragCoord[1]) < 150)
151 #                     {
152 #                         discard;
153 #                     }
154 #                     else
155 #                     {
156 #                         if (int(gl_FragCoord[1]) < 180)
157 #                         {
158 #                             grey = 0.5 + float(data[5]) / 10.0;
159 #                         }
160 #                         else
161 #                         {
162 #                             if (int(gl_FragCoord[1]) < 210)
163 #                             {
164 #                                 grey = 0.5 + float(data[6]) / 10.0;
165 #                             }
166 #                             else
167 #                             {
168 #                                 if (int(gl_FragCoord[1]) < 240)
169 #                                 {
170 #                                     grey = 0.5 + float(data[7]) / 10.0;
171 #                                 }
172 #                                 else
173 #                                 {
174 #                                     if (int(gl_FragCoord[1]) < 270)
175 #                                     {
176 #                                         grey = 0.5 + float(data[8]) / 10.0;
177 #                                     }
178 #                                     else
179 #                                     {
180 #                                         discard;
181 #                                     }
182 #                                 }
183 #                             }
184 #                         }
185 #                     }
186 #                 }
187 #             }
188 #         }
189 #     }
190 #     _GLF_color = vec4(vec3(grey), 1.0);
191 # }
192 SHADER fragment reference_fragment_shader SPIRV-ASM TARGET_ENV spv1.0
193 ; SPIR-V
194 ; Version: 1.0
195 ; Generator: Khronos Glslang Reference Front End; 10
196 ; Bound: 378
197 ; Schema: 0
198                OpCapability Shader
199           %1 = OpExtInstImport "GLSL.std.450"
200                OpMemoryModel Logical GLSL450
201                OpEntryPoint Fragment %4 "main" %243 %369
202                OpExecutionMode %4 OriginUpperLeft
203                OpSource ESSL 320
204                OpName %4 "main"
205                OpName %12 "merge(i1;i1;i1;"
206                OpName %9 "from"
207                OpName %10 "mid"
208                OpName %11 "to"
209                OpName %14 "mergeSort("
210                OpName %16 "k"
211                OpName %18 "i"
212                OpName %20 "j"
213                OpName %41 "data"
214                OpName %52 "temp"
215                OpName %87 "i"
216                OpName %104 "low"
217                OpName %106 "high"
218                OpName %108 "m"
219                OpName %117 "i"
220                OpName %127 "from"
221                OpName %129 "mid"
222                OpName %134 "to"
223                OpName %143 "param"
224                OpName %145 "param"
225                OpName %147 "param"
226                OpName %156 "i"
227                OpName %159 "buf0"
228                OpMemberName %159 0 "injectionSwitch"
229                OpName %161 ""
230                OpName %225 "j"
231                OpName %243 "gl_FragCoord"
232                OpName %254 "grey"
233                OpName %369 "_GLF_color"
234                OpMemberDecorate %159 0 Offset 0
235                OpDecorate %159 Block
236                OpDecorate %161 DescriptorSet 0
237                OpDecorate %161 Binding 0
238                OpDecorate %243 BuiltIn FragCoord
239                OpDecorate %369 Location 0
240           %2 = OpTypeVoid
241           %3 = OpTypeFunction %2
242           %6 = OpTypeInt 32 1
243           %7 = OpTypePointer Function %6
244           %8 = OpTypeFunction %2 %7 %7 %7
245          %22 = OpConstant %6 1
246          %31 = OpTypeBool
247          %37 = OpTypeInt 32 0
248          %38 = OpConstant %37 10
249          %39 = OpTypeArray %6 %38
250          %40 = OpTypePointer Private %39
251          %41 = OpVariable %40 Private
252          %43 = OpTypePointer Private %6
253          %52 = OpVariable %40 Private
254          %74 = OpConstant %6 10
255         %105 = OpConstant %6 0
256         %107 = OpConstant %6 9
257         %136 = OpConstant %6 2
258         %157 = OpTypeFloat 32
259         %158 = OpTypeVector %157 2
260         %159 = OpTypeStruct %158
261         %160 = OpTypePointer Uniform %159
262         %161 = OpVariable %160 Uniform
263         %162 = OpConstant %37 0
264         %163 = OpTypePointer Uniform %157
265         %184 = OpConstant %6 4
266         %188 = OpConstant %6 3
267         %201 = OpConstant %6 -1
268         %205 = OpConstant %6 -2
269         %209 = OpConstant %6 -3
270         %213 = OpConstant %6 -4
271         %217 = OpConstant %6 -5
272         %241 = OpTypeVector %157 4
273         %242 = OpTypePointer Input %241
274         %243 = OpVariable %242 Input
275         %244 = OpConstant %37 1
276         %245 = OpTypePointer Input %157
277         %249 = OpConstant %6 30
278         %253 = OpTypePointer Function %157
279         %255 = OpConstant %157 0.5
280         %259 = OpConstant %157 10
281         %266 = OpConstant %6 60
282         %279 = OpConstant %6 90
283         %292 = OpConstant %6 120
284         %305 = OpConstant %6 150
285         %314 = OpConstant %6 180
286         %318 = OpConstant %6 5
287         %328 = OpConstant %6 210
288         %332 = OpConstant %6 6
289         %342 = OpConstant %6 240
290         %346 = OpConstant %6 7
291         %356 = OpConstant %6 270
292         %360 = OpConstant %6 8
293         %368 = OpTypePointer Output %241
294         %369 = OpVariable %368 Output
295         %371 = OpTypeVector %157 3
296         %373 = OpConstant %157 1
297           %4 = OpFunction %2 None %3
298           %5 = OpLabel
299         %156 = OpVariable %7 Function
300         %225 = OpVariable %7 Function
301         %254 = OpVariable %253 Function
302         %164 = OpAccessChain %163 %161 %105 %162
303         %165 = OpLoad %157 %164
304         %166 = OpConvertFToS %6 %165
305                OpStore %156 %166
306                OpBranch %167
307         %167 = OpLabel
308                OpLoopMerge %169 %170 None
309                OpBranch %168
310         %168 = OpLabel
311         %171 = OpLoad %6 %156
312                OpSelectionMerge %182 None
313                OpSwitch %171 %182 0 %172 1 %173 2 %174 3 %175 4 %176 5 %177 6 %178 7 %179 8 %180 9 %181
314         %172 = OpLabel
315         %183 = OpLoad %6 %156
316         %185 = OpAccessChain %43 %41 %183
317                OpStore %185 %184
318                OpBranch %182
319         %173 = OpLabel
320         %187 = OpLoad %6 %156
321         %189 = OpAccessChain %43 %41 %187
322                OpStore %189 %188
323                OpBranch %182
324         %174 = OpLabel
325         %191 = OpLoad %6 %156
326         %192 = OpAccessChain %43 %41 %191
327                OpStore %192 %136
328                OpBranch %182
329         %175 = OpLabel
330         %194 = OpLoad %6 %156
331         %195 = OpAccessChain %43 %41 %194
332                OpStore %195 %22
333                OpBranch %182
334         %176 = OpLabel
335         %197 = OpLoad %6 %156
336         %198 = OpAccessChain %43 %41 %197
337                OpStore %198 %105
338                OpBranch %182
339         %177 = OpLabel
340         %200 = OpLoad %6 %156
341         %202 = OpAccessChain %43 %41 %200
342                OpStore %202 %201
343                OpBranch %182
344         %178 = OpLabel
345         %204 = OpLoad %6 %156
346         %206 = OpAccessChain %43 %41 %204
347                OpStore %206 %205
348                OpBranch %182
349         %179 = OpLabel
350         %208 = OpLoad %6 %156
351         %210 = OpAccessChain %43 %41 %208
352                OpStore %210 %209
353                OpBranch %182
354         %180 = OpLabel
355         %212 = OpLoad %6 %156
356         %214 = OpAccessChain %43 %41 %212
357                OpStore %214 %213
358                OpBranch %182
359         %181 = OpLabel
360         %216 = OpLoad %6 %156
361         %218 = OpAccessChain %43 %41 %216
362                OpStore %218 %217
363                OpBranch %182
364         %182 = OpLabel
365         %221 = OpLoad %6 %156
366         %222 = OpIAdd %6 %221 %22
367                OpStore %156 %222
368                OpBranch %170
369         %170 = OpLabel
370         %223 = OpLoad %6 %156
371         %224 = OpSLessThan %31 %223 %74
372                OpBranchConditional %224 %167 %169
373         %169 = OpLabel
374                OpStore %225 %105
375                OpBranch %226
376         %226 = OpLabel
377                OpLoopMerge %228 %229 None
378                OpBranch %230
379         %230 = OpLabel
380         %231 = OpLoad %6 %225
381         %232 = OpSLessThan %31 %231 %74
382                OpBranchConditional %232 %227 %228
383         %227 = OpLabel
384         %233 = OpLoad %6 %225
385         %234 = OpLoad %6 %225
386         %235 = OpAccessChain %43 %41 %234
387         %236 = OpLoad %6 %235
388         %237 = OpAccessChain %43 %52 %233
389                OpStore %237 %236
390                OpBranch %229
391         %229 = OpLabel
392         %238 = OpLoad %6 %225
393         %239 = OpIAdd %6 %238 %22
394                OpStore %225 %239
395                OpBranch %226
396         %228 = OpLabel
397         %240 = OpFunctionCall %2 %14
398         %246 = OpAccessChain %245 %243 %244
399         %247 = OpLoad %157 %246
400         %248 = OpConvertFToS %6 %247
401         %250 = OpSLessThan %31 %248 %249
402                OpSelectionMerge %252 None
403                OpBranchConditional %250 %251 %262
404         %251 = OpLabel
405         %256 = OpAccessChain %43 %41 %105
406         %257 = OpLoad %6 %256
407         %258 = OpConvertSToF %157 %257
408         %260 = OpFDiv %157 %258 %259
409         %261 = OpFAdd %157 %255 %260
410                OpStore %254 %261
411                OpBranch %252
412         %262 = OpLabel
413         %263 = OpAccessChain %245 %243 %244
414         %264 = OpLoad %157 %263
415         %265 = OpConvertFToS %6 %264
416         %267 = OpSLessThan %31 %265 %266
417                OpSelectionMerge %269 None
418                OpBranchConditional %267 %268 %275
419         %268 = OpLabel
420         %270 = OpAccessChain %43 %41 %22
421         %271 = OpLoad %6 %270
422         %272 = OpConvertSToF %157 %271
423         %273 = OpFDiv %157 %272 %259
424         %274 = OpFAdd %157 %255 %273
425                OpStore %254 %274
426                OpBranch %269
427         %275 = OpLabel
428         %276 = OpAccessChain %245 %243 %244
429         %277 = OpLoad %157 %276
430         %278 = OpConvertFToS %6 %277
431         %280 = OpSLessThan %31 %278 %279
432                OpSelectionMerge %282 None
433                OpBranchConditional %280 %281 %288
434         %281 = OpLabel
435         %283 = OpAccessChain %43 %41 %136
436         %284 = OpLoad %6 %283
437         %285 = OpConvertSToF %157 %284
438         %286 = OpFDiv %157 %285 %259
439         %287 = OpFAdd %157 %255 %286
440                OpStore %254 %287
441                OpBranch %282
442         %288 = OpLabel
443         %289 = OpAccessChain %245 %243 %244
444         %290 = OpLoad %157 %289
445         %291 = OpConvertFToS %6 %290
446         %293 = OpSLessThan %31 %291 %292
447                OpSelectionMerge %295 None
448                OpBranchConditional %293 %294 %301
449         %294 = OpLabel
450         %296 = OpAccessChain %43 %41 %188
451         %297 = OpLoad %6 %296
452         %298 = OpConvertSToF %157 %297
453         %299 = OpFDiv %157 %298 %259
454         %300 = OpFAdd %157 %255 %299
455                OpStore %254 %300
456                OpBranch %295
457         %301 = OpLabel
458         %302 = OpAccessChain %245 %243 %244
459         %303 = OpLoad %157 %302
460         %304 = OpConvertFToS %6 %303
461         %306 = OpSLessThan %31 %304 %305
462                OpSelectionMerge %308 None
463                OpBranchConditional %306 %307 %310
464         %307 = OpLabel
465                OpKill
466         %310 = OpLabel
467         %311 = OpAccessChain %245 %243 %244
468         %312 = OpLoad %157 %311
469         %313 = OpConvertFToS %6 %312
470         %315 = OpSLessThan %31 %313 %314
471                OpSelectionMerge %317 None
472                OpBranchConditional %315 %316 %324
473         %316 = OpLabel
474         %319 = OpAccessChain %43 %41 %318
475         %320 = OpLoad %6 %319
476         %321 = OpConvertSToF %157 %320
477         %322 = OpFDiv %157 %321 %259
478         %323 = OpFAdd %157 %255 %322
479                OpStore %254 %323
480                OpBranch %317
481         %324 = OpLabel
482         %325 = OpAccessChain %245 %243 %244
483         %326 = OpLoad %157 %325
484         %327 = OpConvertFToS %6 %326
485         %329 = OpSLessThan %31 %327 %328
486                OpSelectionMerge %331 None
487                OpBranchConditional %329 %330 %338
488         %330 = OpLabel
489         %333 = OpAccessChain %43 %41 %332
490         %334 = OpLoad %6 %333
491         %335 = OpConvertSToF %157 %334
492         %336 = OpFDiv %157 %335 %259
493         %337 = OpFAdd %157 %255 %336
494                OpStore %254 %337
495                OpBranch %331
496         %338 = OpLabel
497         %339 = OpAccessChain %245 %243 %244
498         %340 = OpLoad %157 %339
499         %341 = OpConvertFToS %6 %340
500         %343 = OpSLessThan %31 %341 %342
501                OpSelectionMerge %345 None
502                OpBranchConditional %343 %344 %352
503         %344 = OpLabel
504         %347 = OpAccessChain %43 %41 %346
505         %348 = OpLoad %6 %347
506         %349 = OpConvertSToF %157 %348
507         %350 = OpFDiv %157 %349 %259
508         %351 = OpFAdd %157 %255 %350
509                OpStore %254 %351
510                OpBranch %345
511         %352 = OpLabel
512         %353 = OpAccessChain %245 %243 %244
513         %354 = OpLoad %157 %353
514         %355 = OpConvertFToS %6 %354
515         %357 = OpSLessThan %31 %355 %356
516                OpSelectionMerge %359 None
517                OpBranchConditional %357 %358 %366
518         %358 = OpLabel
519         %361 = OpAccessChain %43 %41 %360
520         %362 = OpLoad %6 %361
521         %363 = OpConvertSToF %157 %362
522         %364 = OpFDiv %157 %363 %259
523         %365 = OpFAdd %157 %255 %364
524                OpStore %254 %365
525                OpBranch %359
526         %366 = OpLabel
527                OpKill
528         %359 = OpLabel
529                OpBranch %345
530         %345 = OpLabel
531                OpBranch %331
532         %331 = OpLabel
533                OpBranch %317
534         %317 = OpLabel
535                OpBranch %308
536         %308 = OpLabel
537                OpBranch %295
538         %295 = OpLabel
539                OpBranch %282
540         %282 = OpLabel
541                OpBranch %269
542         %269 = OpLabel
543                OpBranch %252
544         %252 = OpLabel
545         %370 = OpLoad %157 %254
546         %372 = OpCompositeConstruct %371 %370 %370 %370
547         %374 = OpCompositeExtract %157 %372 0
548         %375 = OpCompositeExtract %157 %372 1
549         %376 = OpCompositeExtract %157 %372 2
550         %377 = OpCompositeConstruct %241 %374 %375 %376 %373
551                OpStore %369 %377
552                OpReturn
553                OpFunctionEnd
554          %12 = OpFunction %2 None %8
555           %9 = OpFunctionParameter %7
556          %10 = OpFunctionParameter %7
557          %11 = OpFunctionParameter %7
558          %13 = OpLabel
559          %16 = OpVariable %7 Function
560          %18 = OpVariable %7 Function
561          %20 = OpVariable %7 Function
562          %87 = OpVariable %7 Function
563          %17 = OpLoad %6 %9
564                OpStore %16 %17
565          %19 = OpLoad %6 %9
566                OpStore %18 %19
567          %21 = OpLoad %6 %10
568          %23 = OpIAdd %6 %21 %22
569                OpStore %20 %23
570                OpBranch %24
571          %24 = OpLabel
572                OpLoopMerge %26 %27 None
573                OpBranch %28
574          %28 = OpLabel
575          %29 = OpLoad %6 %18
576          %30 = OpLoad %6 %10
577          %32 = OpSLessThanEqual %31 %29 %30
578          %33 = OpLoad %6 %20
579          %34 = OpLoad %6 %11
580          %35 = OpSLessThanEqual %31 %33 %34
581          %36 = OpLogicalAnd %31 %32 %35
582                OpBranchConditional %36 %25 %26
583          %25 = OpLabel
584          %42 = OpLoad %6 %18
585          %44 = OpAccessChain %43 %41 %42
586          %45 = OpLoad %6 %44
587          %46 = OpLoad %6 %20
588          %47 = OpAccessChain %43 %41 %46
589          %48 = OpLoad %6 %47
590          %49 = OpSLessThan %31 %45 %48
591                OpSelectionMerge %51 None
592                OpBranchConditional %49 %50 %60
593          %50 = OpLabel
594          %53 = OpLoad %6 %16
595          %54 = OpIAdd %6 %53 %22
596                OpStore %16 %54
597          %55 = OpLoad %6 %18
598          %56 = OpIAdd %6 %55 %22
599                OpStore %18 %56
600          %57 = OpAccessChain %43 %41 %55
601          %58 = OpLoad %6 %57
602          %59 = OpAccessChain %43 %52 %53
603                OpStore %59 %58
604                OpBranch %51
605          %60 = OpLabel
606          %61 = OpLoad %6 %16
607          %62 = OpIAdd %6 %61 %22
608                OpStore %16 %62
609          %63 = OpLoad %6 %20
610          %64 = OpIAdd %6 %63 %22
611                OpStore %20 %64
612          %65 = OpAccessChain %43 %41 %63
613          %66 = OpLoad %6 %65
614          %67 = OpAccessChain %43 %52 %61
615                OpStore %67 %66
616                OpBranch %51
617          %51 = OpLabel
618                OpBranch %27
619          %27 = OpLabel
620                OpBranch %24
621          %26 = OpLabel
622                OpBranch %68
623          %68 = OpLabel
624                OpLoopMerge %70 %71 None
625                OpBranch %72
626          %72 = OpLabel
627          %73 = OpLoad %6 %18
628          %75 = OpSLessThan %31 %73 %74
629          %76 = OpLoad %6 %18
630          %77 = OpLoad %6 %10
631          %78 = OpSLessThanEqual %31 %76 %77
632          %79 = OpLogicalAnd %31 %75 %78
633                OpBranchConditional %79 %69 %70
634          %69 = OpLabel
635          %80 = OpLoad %6 %16
636          %81 = OpIAdd %6 %80 %22
637                OpStore %16 %81
638          %82 = OpLoad %6 %18
639          %83 = OpIAdd %6 %82 %22
640                OpStore %18 %83
641          %84 = OpAccessChain %43 %41 %82
642          %85 = OpLoad %6 %84
643          %86 = OpAccessChain %43 %52 %80
644                OpStore %86 %85
645                OpBranch %71
646          %71 = OpLabel
647                OpBranch %68
648          %70 = OpLabel
649          %88 = OpLoad %6 %9
650                OpStore %87 %88
651                OpBranch %89
652          %89 = OpLabel
653                OpLoopMerge %91 %92 None
654                OpBranch %93
655          %93 = OpLabel
656          %94 = OpLoad %6 %87
657          %95 = OpLoad %6 %11
658          %96 = OpSLessThanEqual %31 %94 %95
659                OpBranchConditional %96 %90 %91
660          %90 = OpLabel
661          %97 = OpLoad %6 %87
662          %98 = OpLoad %6 %87
663          %99 = OpAccessChain %43 %52 %98
664         %100 = OpLoad %6 %99
665         %101 = OpAccessChain %43 %41 %97
666                OpStore %101 %100
667                OpBranch %92
668          %92 = OpLabel
669         %102 = OpLoad %6 %87
670         %103 = OpIAdd %6 %102 %22
671                OpStore %87 %103
672                OpBranch %89
673          %91 = OpLabel
674                OpReturn
675                OpFunctionEnd
676          %14 = OpFunction %2 None %3
677          %15 = OpLabel
678         %104 = OpVariable %7 Function
679         %106 = OpVariable %7 Function
680         %108 = OpVariable %7 Function
681         %117 = OpVariable %7 Function
682         %127 = OpVariable %7 Function
683         %129 = OpVariable %7 Function
684         %134 = OpVariable %7 Function
685         %143 = OpVariable %7 Function
686         %145 = OpVariable %7 Function
687         %147 = OpVariable %7 Function
688                OpStore %104 %105
689                OpStore %106 %107
690                OpStore %108 %22
691                OpBranch %109
692         %109 = OpLabel
693                OpLoopMerge %111 %112 None
694                OpBranch %113
695         %113 = OpLabel
696         %114 = OpLoad %6 %108
697         %115 = OpLoad %6 %106
698         %116 = OpSLessThanEqual %31 %114 %115
699                OpBranchConditional %116 %110 %111
700         %110 = OpLabel
701         %118 = OpLoad %6 %104
702                OpStore %117 %118
703                OpBranch %119
704         %119 = OpLabel
705                OpLoopMerge %121 %122 None
706                OpBranch %123
707         %123 = OpLabel
708         %124 = OpLoad %6 %117
709         %125 = OpLoad %6 %106
710         %126 = OpSLessThan %31 %124 %125
711                OpBranchConditional %126 %120 %121
712         %120 = OpLabel
713         %128 = OpLoad %6 %117
714                OpStore %127 %128
715         %130 = OpLoad %6 %117
716         %131 = OpLoad %6 %108
717         %132 = OpIAdd %6 %130 %131
718         %133 = OpISub %6 %132 %22
719                OpStore %129 %133
720         %135 = OpLoad %6 %117
721         %137 = OpLoad %6 %108
722         %138 = OpIMul %6 %136 %137
723         %139 = OpIAdd %6 %135 %138
724         %140 = OpISub %6 %139 %22
725         %141 = OpLoad %6 %106
726         %142 = OpExtInst %6 %1 SMin %140 %141
727                OpStore %134 %142
728         %144 = OpLoad %6 %127
729                OpStore %143 %144
730         %146 = OpLoad %6 %129
731                OpStore %145 %146
732         %148 = OpLoad %6 %134
733                OpStore %147 %148
734         %149 = OpFunctionCall %2 %12 %143 %145 %147
735                OpBranch %122
736         %122 = OpLabel
737         %150 = OpLoad %6 %108
738         %151 = OpIMul %6 %136 %150
739         %152 = OpLoad %6 %117
740         %153 = OpIAdd %6 %152 %151
741                OpStore %117 %153
742                OpBranch %119
743         %121 = OpLabel
744                OpBranch %112
745         %112 = OpLabel
746         %154 = OpLoad %6 %108
747         %155 = OpIMul %6 %136 %154
748                OpStore %108 %155
749                OpBranch %109
750         %111 = OpLabel
751                OpReturn
752                OpFunctionEnd
753 END
754
755 # uniforms for reference
756
757 # injectionSwitch
758 BUFFER reference_injectionSwitch DATA_TYPE vec2<float> DATA
759  0.0 1.0
760 END
761
762 BUFFER reference_framebuffer FORMAT B8G8R8A8_UNORM
763
764 PIPELINE graphics reference_pipeline
765   ATTACH reference_vertex_shader
766   ATTACH reference_fragment_shader
767   FRAMEBUFFER_SIZE 256 256
768   BIND BUFFER reference_framebuffer AS color LOCATION 0
769   BIND BUFFER reference_injectionSwitch AS uniform DESCRIPTOR_SET 0 BINDING 0
770 END
771 CLEAR_COLOR reference_pipeline 0 0 0 255
772
773 CLEAR reference_pipeline
774 RUN reference_pipeline DRAW_RECT POS 0 0 SIZE 256 256
775
776
777 SHADER vertex variant_vertex_shader PASSTHROUGH
778
779 # variant_fragment_shader is derived from the following GLSL:
780 # #version 320 es
781 # precision highp float;
782 #
783 # precision highp int;
784 #
785 # layout(location = 0) out vec4 _GLF_color;
786 #
787 # layout(set = 0, binding = 0) uniform buf0
788 # {
789 #     vec2 injectionSwitch;
790 # };
791 # const int N = 10;
792 #
793 # int data[10], temp[10];
794 #
795 # void merge(int from, int mid, int to)
796 # {
797 #     int k = from, i = from, j = mid + 1;
798 #     while (i <= mid && j <= to)
799 #     {
800 #         if (data[i] < data[j])
801 #         {
802 #             temp[k++] = data[i++];
803 #         }
804 #         else
805 #         {
806 #             temp[k++] = data[j++];
807 #         }
808 #     }
809 #     while (i < N && i <= mid)
810 #     {
811 #         temp[k++] = data[i++];
812 #     }
813 #     for (int i = from; i <= to; i++)
814 #     {
815 #         data[i] = temp[i];
816 #     }
817 # }
818 # void mergeSort()
819 # {
820 #     int low = 0;
821 #     int high = N - 1;
822 #     for (int m = 1; m <= high; m = 2 * m)
823 #     {
824 #         for (int i = low; i < high; i += 2 * m)
825 #         {
826 #             int from = i;
827 #             int mid = i + m - 1;
828 #             int to = min(i + 2 * m - 1, high);
829 #             merge(from, mid, to);
830 #         }
831 #     }
832 # }
833 # void main()
834 # {
835 #     int i = int(injectionSwitch.x);
836 #     do
837 #     {
838 #         switch (i)
839 #         {
840 #         case 0:
841 #             data[i] = 4;
842 #             break;
843 #         case 1:
844 #             data[i] = 3;
845 #             break;
846 #         case 2:
847 #             data[i] = 2;
848 #             break;
849 #         case 3:
850 #             data[i] = 1;
851 #             break;
852 #         case 4:
853 #             data[i] = 0;
854 #             break;
855 #         case 5:
856 #             data[i] = -1;
857 #             break;
858 #         case 6:
859 #             data[i] = -2;
860 #             break;
861 #         case 7:
862 #             data[i] = -3;
863 #             break;
864 #         case 8:
865 #             data[i] = -4;
866 #             break;
867 #         case 9:
868 #             data[i] = -5;
869 #             break;
870 #         }
871 #         i++;
872 #     } while (i < 10);
873 #     for (int j = 0; j < 10; j++)
874 #     {
875 #         temp[j] = data[j];
876 #     }
877 #     mergeSort();
878 #     float grey;
879 #     if (int(gl_FragCoord[1]) < 30)
880 #     {
881 #         grey = 0.5 + float(data[0]) / 10.0;
882 #     }
883 #     else
884 #     {
885 #         if (int(gl_FragCoord[1]) < 60)
886 #         {
887 #             grey = 0.5 + float(data[1]) / 10.0;
888 #         }
889 #         else
890 #         {
891 #             if (int(gl_FragCoord[1]) < 90)
892 #             {
893 #                 grey = 0.5 + float(data[2]) / 10.0;
894 #             }
895 #             else
896 #             {
897 #                 if (int(gl_FragCoord[1]) < 120)
898 #                 {
899 #                     grey = 0.5 + float(data[3]) / 10.0;
900 #                 }
901 #                 else
902 #                 {
903 #                     if (int(gl_FragCoord[1]) < 150)
904 #                     {
905 #                         // Iterates once.
906 #                         for (int int_i = 1; int_i > int((injectionSwitch.x)); int_i--)
907 #                         {
908 #                             discard;
909 #                         }
910 #                     }
911 #                     else
912 #                     {
913 #                         if (int(gl_FragCoord[1]) < 180)
914 #                         {
915 #                             grey = 0.5 + float(data[5]) / 10.0;
916 #                         }
917 #                         else
918 #                         {
919 #                             if (int(gl_FragCoord[1]) < 210)
920 #                             {
921 #                                 grey = 0.5 + float(data[6]) / 10.0;
922 #                             }
923 #                             else
924 #                             {
925 #                                 if (int(gl_FragCoord[1]) < 240)
926 #                                 {
927 #                                     grey = 0.5 + float(data[7]) / 10.0;
928 #                                 }
929 #                                 else
930 #                                 {
931 #                                     if (int(gl_FragCoord[1]) < 270)
932 #                                     {
933 #                                         grey = 0.5 + float(data[8]) / 10.0;
934 #                                     }
935 #                                     else
936 #                                     {
937 #                                         discard;
938 #                                     }
939 #                                 }
940 #                             }
941 #                         }
942 #                     }
943 #                 }
944 #             }
945 #         }
946 #     }
947 #     _GLF_color = vec4(vec3(grey), 1.0);
948 # }
949 SHADER fragment variant_fragment_shader SPIRV-ASM TARGET_ENV spv1.0
950 ; SPIR-V
951 ; Version: 1.0
952 ; Generator: Khronos Glslang Reference Front End; 10
953 ; Bound: 391
954 ; Schema: 0
955                OpCapability Shader
956           %1 = OpExtInstImport "GLSL.std.450"
957                OpMemoryModel Logical GLSL450
958                OpEntryPoint Fragment %4 "main" %243 %382
959                OpExecutionMode %4 OriginUpperLeft
960                OpSource ESSL 320
961                OpName %4 "main"
962                OpName %12 "merge(i1;i1;i1;"
963                OpName %9 "from"
964                OpName %10 "mid"
965                OpName %11 "to"
966                OpName %14 "mergeSort("
967                OpName %16 "k"
968                OpName %18 "i"
969                OpName %20 "j"
970                OpName %41 "data"
971                OpName %52 "temp"
972                OpName %87 "i"
973                OpName %104 "low"
974                OpName %106 "high"
975                OpName %108 "m"
976                OpName %117 "i"
977                OpName %127 "from"
978                OpName %129 "mid"
979                OpName %134 "to"
980                OpName %143 "param"
981                OpName %145 "param"
982                OpName %147 "param"
983                OpName %156 "i"
984                OpName %159 "buf0"
985                OpMemberName %159 0 "injectionSwitch"
986                OpName %161 ""
987                OpName %225 "j"
988                OpName %243 "gl_FragCoord"
989                OpName %254 "grey"
990                OpName %309 "int_i"
991                OpName %382 "_GLF_color"
992                OpMemberDecorate %159 0 Offset 0
993                OpDecorate %159 Block
994                OpDecorate %161 DescriptorSet 0
995                OpDecorate %161 Binding 0
996                OpDecorate %243 BuiltIn FragCoord
997                OpDecorate %382 Location 0
998           %2 = OpTypeVoid
999           %3 = OpTypeFunction %2
1000           %6 = OpTypeInt 32 1
1001           %7 = OpTypePointer Function %6
1002           %8 = OpTypeFunction %2 %7 %7 %7
1003          %22 = OpConstant %6 1
1004          %31 = OpTypeBool
1005          %37 = OpTypeInt 32 0
1006          %38 = OpConstant %37 10
1007          %39 = OpTypeArray %6 %38
1008          %40 = OpTypePointer Private %39
1009          %41 = OpVariable %40 Private
1010          %43 = OpTypePointer Private %6
1011          %52 = OpVariable %40 Private
1012          %74 = OpConstant %6 10
1013         %105 = OpConstant %6 0
1014         %107 = OpConstant %6 9
1015         %136 = OpConstant %6 2
1016         %157 = OpTypeFloat 32
1017         %158 = OpTypeVector %157 2
1018         %159 = OpTypeStruct %158
1019         %160 = OpTypePointer Uniform %159
1020         %161 = OpVariable %160 Uniform
1021         %162 = OpConstant %37 0
1022         %163 = OpTypePointer Uniform %157
1023         %184 = OpConstant %6 4
1024         %188 = OpConstant %6 3
1025         %201 = OpConstant %6 -1
1026         %205 = OpConstant %6 -2
1027         %209 = OpConstant %6 -3
1028         %213 = OpConstant %6 -4
1029         %217 = OpConstant %6 -5
1030         %241 = OpTypeVector %157 4
1031         %242 = OpTypePointer Input %241
1032         %243 = OpVariable %242 Input
1033         %244 = OpConstant %37 1
1034         %245 = OpTypePointer Input %157
1035         %249 = OpConstant %6 30
1036         %253 = OpTypePointer Function %157
1037         %255 = OpConstant %157 0.5
1038         %259 = OpConstant %157 10
1039         %266 = OpConstant %6 60
1040         %279 = OpConstant %6 90
1041         %292 = OpConstant %6 120
1042         %305 = OpConstant %6 150
1043         %327 = OpConstant %6 180
1044         %331 = OpConstant %6 5
1045         %341 = OpConstant %6 210
1046         %345 = OpConstant %6 6
1047         %355 = OpConstant %6 240
1048         %359 = OpConstant %6 7
1049         %369 = OpConstant %6 270
1050         %373 = OpConstant %6 8
1051         %381 = OpTypePointer Output %241
1052         %382 = OpVariable %381 Output
1053         %384 = OpTypeVector %157 3
1054         %386 = OpConstant %157 1
1055           %4 = OpFunction %2 None %3
1056           %5 = OpLabel
1057         %156 = OpVariable %7 Function
1058         %225 = OpVariable %7 Function
1059         %254 = OpVariable %253 Function
1060         %309 = OpVariable %7 Function
1061         %164 = OpAccessChain %163 %161 %105 %162
1062         %165 = OpLoad %157 %164
1063         %166 = OpConvertFToS %6 %165
1064                OpStore %156 %166
1065                OpBranch %167
1066         %167 = OpLabel
1067                OpLoopMerge %169 %170 None
1068                OpBranch %168
1069         %168 = OpLabel
1070         %171 = OpLoad %6 %156
1071                OpSelectionMerge %182 None
1072                OpSwitch %171 %182 0 %172 1 %173 2 %174 3 %175 4 %176 5 %177 6 %178 7 %179 8 %180 9 %181
1073         %172 = OpLabel
1074         %183 = OpLoad %6 %156
1075         %185 = OpAccessChain %43 %41 %183
1076                OpStore %185 %184
1077                OpBranch %182
1078         %173 = OpLabel
1079         %187 = OpLoad %6 %156
1080         %189 = OpAccessChain %43 %41 %187
1081                OpStore %189 %188
1082                OpBranch %182
1083         %174 = OpLabel
1084         %191 = OpLoad %6 %156
1085         %192 = OpAccessChain %43 %41 %191
1086                OpStore %192 %136
1087                OpBranch %182
1088         %175 = OpLabel
1089         %194 = OpLoad %6 %156
1090         %195 = OpAccessChain %43 %41 %194
1091                OpStore %195 %22
1092                OpBranch %182
1093         %176 = OpLabel
1094         %197 = OpLoad %6 %156
1095         %198 = OpAccessChain %43 %41 %197
1096                OpStore %198 %105
1097                OpBranch %182
1098         %177 = OpLabel
1099         %200 = OpLoad %6 %156
1100         %202 = OpAccessChain %43 %41 %200
1101                OpStore %202 %201
1102                OpBranch %182
1103         %178 = OpLabel
1104         %204 = OpLoad %6 %156
1105         %206 = OpAccessChain %43 %41 %204
1106                OpStore %206 %205
1107                OpBranch %182
1108         %179 = OpLabel
1109         %208 = OpLoad %6 %156
1110         %210 = OpAccessChain %43 %41 %208
1111                OpStore %210 %209
1112                OpBranch %182
1113         %180 = OpLabel
1114         %212 = OpLoad %6 %156
1115         %214 = OpAccessChain %43 %41 %212
1116                OpStore %214 %213
1117                OpBranch %182
1118         %181 = OpLabel
1119         %216 = OpLoad %6 %156
1120         %218 = OpAccessChain %43 %41 %216
1121                OpStore %218 %217
1122                OpBranch %182
1123         %182 = OpLabel
1124         %221 = OpLoad %6 %156
1125         %222 = OpIAdd %6 %221 %22
1126                OpStore %156 %222
1127                OpBranch %170
1128         %170 = OpLabel
1129         %223 = OpLoad %6 %156
1130         %224 = OpSLessThan %31 %223 %74
1131                OpBranchConditional %224 %167 %169
1132         %169 = OpLabel
1133                OpStore %225 %105
1134                OpBranch %226
1135         %226 = OpLabel
1136                OpLoopMerge %228 %229 None
1137                OpBranch %230
1138         %230 = OpLabel
1139         %231 = OpLoad %6 %225
1140         %232 = OpSLessThan %31 %231 %74
1141                OpBranchConditional %232 %227 %228
1142         %227 = OpLabel
1143         %233 = OpLoad %6 %225
1144         %234 = OpLoad %6 %225
1145         %235 = OpAccessChain %43 %41 %234
1146         %236 = OpLoad %6 %235
1147         %237 = OpAccessChain %43 %52 %233
1148                OpStore %237 %236
1149                OpBranch %229
1150         %229 = OpLabel
1151         %238 = OpLoad %6 %225
1152         %239 = OpIAdd %6 %238 %22
1153                OpStore %225 %239
1154                OpBranch %226
1155         %228 = OpLabel
1156         %240 = OpFunctionCall %2 %14
1157         %246 = OpAccessChain %245 %243 %244
1158         %247 = OpLoad %157 %246
1159         %248 = OpConvertFToS %6 %247
1160         %250 = OpSLessThan %31 %248 %249
1161                OpSelectionMerge %252 None
1162                OpBranchConditional %250 %251 %262
1163         %251 = OpLabel
1164         %256 = OpAccessChain %43 %41 %105
1165         %257 = OpLoad %6 %256
1166         %258 = OpConvertSToF %157 %257
1167         %260 = OpFDiv %157 %258 %259
1168         %261 = OpFAdd %157 %255 %260
1169                OpStore %254 %261
1170                OpBranch %252
1171         %262 = OpLabel
1172         %263 = OpAccessChain %245 %243 %244
1173         %264 = OpLoad %157 %263
1174         %265 = OpConvertFToS %6 %264
1175         %267 = OpSLessThan %31 %265 %266
1176                OpSelectionMerge %269 None
1177                OpBranchConditional %267 %268 %275
1178         %268 = OpLabel
1179         %270 = OpAccessChain %43 %41 %22
1180         %271 = OpLoad %6 %270
1181         %272 = OpConvertSToF %157 %271
1182         %273 = OpFDiv %157 %272 %259
1183         %274 = OpFAdd %157 %255 %273
1184                OpStore %254 %274
1185                OpBranch %269
1186         %275 = OpLabel
1187         %276 = OpAccessChain %245 %243 %244
1188         %277 = OpLoad %157 %276
1189         %278 = OpConvertFToS %6 %277
1190         %280 = OpSLessThan %31 %278 %279
1191                OpSelectionMerge %282 None
1192                OpBranchConditional %280 %281 %288
1193         %281 = OpLabel
1194         %283 = OpAccessChain %43 %41 %136
1195         %284 = OpLoad %6 %283
1196         %285 = OpConvertSToF %157 %284
1197         %286 = OpFDiv %157 %285 %259
1198         %287 = OpFAdd %157 %255 %286
1199                OpStore %254 %287
1200                OpBranch %282
1201         %288 = OpLabel
1202         %289 = OpAccessChain %245 %243 %244
1203         %290 = OpLoad %157 %289
1204         %291 = OpConvertFToS %6 %290
1205         %293 = OpSLessThan %31 %291 %292
1206                OpSelectionMerge %295 None
1207                OpBranchConditional %293 %294 %301
1208         %294 = OpLabel
1209         %296 = OpAccessChain %43 %41 %188
1210         %297 = OpLoad %6 %296
1211         %298 = OpConvertSToF %157 %297
1212         %299 = OpFDiv %157 %298 %259
1213         %300 = OpFAdd %157 %255 %299
1214                OpStore %254 %300
1215                OpBranch %295
1216         %301 = OpLabel
1217         %302 = OpAccessChain %245 %243 %244
1218         %303 = OpLoad %157 %302
1219         %304 = OpConvertFToS %6 %303
1220         %306 = OpSLessThan %31 %304 %305
1221                OpSelectionMerge %308 None
1222                OpBranchConditional %306 %307 %323
1223         %307 = OpLabel
1224                OpStore %309 %22
1225                OpBranch %310
1226         %310 = OpLabel
1227                OpLoopMerge %312 %313 None
1228                OpBranch %314
1229         %314 = OpLabel
1230         %315 = OpLoad %6 %309
1231         %316 = OpAccessChain %163 %161 %105 %162
1232         %317 = OpLoad %157 %316
1233         %318 = OpConvertFToS %6 %317
1234         %319 = OpSGreaterThan %31 %315 %318
1235                OpBranchConditional %319 %311 %312
1236         %311 = OpLabel
1237                OpKill
1238         %313 = OpLabel
1239                OpBranch %310
1240         %312 = OpLabel
1241                OpBranch %308
1242         %323 = OpLabel
1243         %324 = OpAccessChain %245 %243 %244
1244         %325 = OpLoad %157 %324
1245         %326 = OpConvertFToS %6 %325
1246         %328 = OpSLessThan %31 %326 %327
1247                OpSelectionMerge %330 None
1248                OpBranchConditional %328 %329 %337
1249         %329 = OpLabel
1250         %332 = OpAccessChain %43 %41 %331
1251         %333 = OpLoad %6 %332
1252         %334 = OpConvertSToF %157 %333
1253         %335 = OpFDiv %157 %334 %259
1254         %336 = OpFAdd %157 %255 %335
1255                OpStore %254 %336
1256                OpBranch %330
1257         %337 = OpLabel
1258         %338 = OpAccessChain %245 %243 %244
1259         %339 = OpLoad %157 %338
1260         %340 = OpConvertFToS %6 %339
1261         %342 = OpSLessThan %31 %340 %341
1262                OpSelectionMerge %344 None
1263                OpBranchConditional %342 %343 %351
1264         %343 = OpLabel
1265         %346 = OpAccessChain %43 %41 %345
1266         %347 = OpLoad %6 %346
1267         %348 = OpConvertSToF %157 %347
1268         %349 = OpFDiv %157 %348 %259
1269         %350 = OpFAdd %157 %255 %349
1270                OpStore %254 %350
1271                OpBranch %344
1272         %351 = OpLabel
1273         %352 = OpAccessChain %245 %243 %244
1274         %353 = OpLoad %157 %352
1275         %354 = OpConvertFToS %6 %353
1276         %356 = OpSLessThan %31 %354 %355
1277                OpSelectionMerge %358 None
1278                OpBranchConditional %356 %357 %365
1279         %357 = OpLabel
1280         %360 = OpAccessChain %43 %41 %359
1281         %361 = OpLoad %6 %360
1282         %362 = OpConvertSToF %157 %361
1283         %363 = OpFDiv %157 %362 %259
1284         %364 = OpFAdd %157 %255 %363
1285                OpStore %254 %364
1286                OpBranch %358
1287         %365 = OpLabel
1288         %366 = OpAccessChain %245 %243 %244
1289         %367 = OpLoad %157 %366
1290         %368 = OpConvertFToS %6 %367
1291         %370 = OpSLessThan %31 %368 %369
1292                OpSelectionMerge %372 None
1293                OpBranchConditional %370 %371 %379
1294         %371 = OpLabel
1295         %374 = OpAccessChain %43 %41 %373
1296         %375 = OpLoad %6 %374
1297         %376 = OpConvertSToF %157 %375
1298         %377 = OpFDiv %157 %376 %259
1299         %378 = OpFAdd %157 %255 %377
1300                OpStore %254 %378
1301                OpBranch %372
1302         %379 = OpLabel
1303                OpKill
1304         %372 = OpLabel
1305                OpBranch %358
1306         %358 = OpLabel
1307                OpBranch %344
1308         %344 = OpLabel
1309                OpBranch %330
1310         %330 = OpLabel
1311                OpBranch %308
1312         %308 = OpLabel
1313                OpBranch %295
1314         %295 = OpLabel
1315                OpBranch %282
1316         %282 = OpLabel
1317                OpBranch %269
1318         %269 = OpLabel
1319                OpBranch %252
1320         %252 = OpLabel
1321         %383 = OpLoad %157 %254
1322         %385 = OpCompositeConstruct %384 %383 %383 %383
1323         %387 = OpCompositeExtract %157 %385 0
1324         %388 = OpCompositeExtract %157 %385 1
1325         %389 = OpCompositeExtract %157 %385 2
1326         %390 = OpCompositeConstruct %241 %387 %388 %389 %386
1327                OpStore %382 %390
1328                OpReturn
1329                OpFunctionEnd
1330          %12 = OpFunction %2 None %8
1331           %9 = OpFunctionParameter %7
1332          %10 = OpFunctionParameter %7
1333          %11 = OpFunctionParameter %7
1334          %13 = OpLabel
1335          %16 = OpVariable %7 Function
1336          %18 = OpVariable %7 Function
1337          %20 = OpVariable %7 Function
1338          %87 = OpVariable %7 Function
1339          %17 = OpLoad %6 %9
1340                OpStore %16 %17
1341          %19 = OpLoad %6 %9
1342                OpStore %18 %19
1343          %21 = OpLoad %6 %10
1344          %23 = OpIAdd %6 %21 %22
1345                OpStore %20 %23
1346                OpBranch %24
1347          %24 = OpLabel
1348                OpLoopMerge %26 %27 None
1349                OpBranch %28
1350          %28 = OpLabel
1351          %29 = OpLoad %6 %18
1352          %30 = OpLoad %6 %10
1353          %32 = OpSLessThanEqual %31 %29 %30
1354          %33 = OpLoad %6 %20
1355          %34 = OpLoad %6 %11
1356          %35 = OpSLessThanEqual %31 %33 %34
1357          %36 = OpLogicalAnd %31 %32 %35
1358                OpBranchConditional %36 %25 %26
1359          %25 = OpLabel
1360          %42 = OpLoad %6 %18
1361          %44 = OpAccessChain %43 %41 %42
1362          %45 = OpLoad %6 %44
1363          %46 = OpLoad %6 %20
1364          %47 = OpAccessChain %43 %41 %46
1365          %48 = OpLoad %6 %47
1366          %49 = OpSLessThan %31 %45 %48
1367                OpSelectionMerge %51 None
1368                OpBranchConditional %49 %50 %60
1369          %50 = OpLabel
1370          %53 = OpLoad %6 %16
1371          %54 = OpIAdd %6 %53 %22
1372                OpStore %16 %54
1373          %55 = OpLoad %6 %18
1374          %56 = OpIAdd %6 %55 %22
1375                OpStore %18 %56
1376          %57 = OpAccessChain %43 %41 %55
1377          %58 = OpLoad %6 %57
1378          %59 = OpAccessChain %43 %52 %53
1379                OpStore %59 %58
1380                OpBranch %51
1381          %60 = OpLabel
1382          %61 = OpLoad %6 %16
1383          %62 = OpIAdd %6 %61 %22
1384                OpStore %16 %62
1385          %63 = OpLoad %6 %20
1386          %64 = OpIAdd %6 %63 %22
1387                OpStore %20 %64
1388          %65 = OpAccessChain %43 %41 %63
1389          %66 = OpLoad %6 %65
1390          %67 = OpAccessChain %43 %52 %61
1391                OpStore %67 %66
1392                OpBranch %51
1393          %51 = OpLabel
1394                OpBranch %27
1395          %27 = OpLabel
1396                OpBranch %24
1397          %26 = OpLabel
1398                OpBranch %68
1399          %68 = OpLabel
1400                OpLoopMerge %70 %71 None
1401                OpBranch %72
1402          %72 = OpLabel
1403          %73 = OpLoad %6 %18
1404          %75 = OpSLessThan %31 %73 %74
1405          %76 = OpLoad %6 %18
1406          %77 = OpLoad %6 %10
1407          %78 = OpSLessThanEqual %31 %76 %77
1408          %79 = OpLogicalAnd %31 %75 %78
1409                OpBranchConditional %79 %69 %70
1410          %69 = OpLabel
1411          %80 = OpLoad %6 %16
1412          %81 = OpIAdd %6 %80 %22
1413                OpStore %16 %81
1414          %82 = OpLoad %6 %18
1415          %83 = OpIAdd %6 %82 %22
1416                OpStore %18 %83
1417          %84 = OpAccessChain %43 %41 %82
1418          %85 = OpLoad %6 %84
1419          %86 = OpAccessChain %43 %52 %80
1420                OpStore %86 %85
1421                OpBranch %71
1422          %71 = OpLabel
1423                OpBranch %68
1424          %70 = OpLabel
1425          %88 = OpLoad %6 %9
1426                OpStore %87 %88
1427                OpBranch %89
1428          %89 = OpLabel
1429                OpLoopMerge %91 %92 None
1430                OpBranch %93
1431          %93 = OpLabel
1432          %94 = OpLoad %6 %87
1433          %95 = OpLoad %6 %11
1434          %96 = OpSLessThanEqual %31 %94 %95
1435                OpBranchConditional %96 %90 %91
1436          %90 = OpLabel
1437          %97 = OpLoad %6 %87
1438          %98 = OpLoad %6 %87
1439          %99 = OpAccessChain %43 %52 %98
1440         %100 = OpLoad %6 %99
1441         %101 = OpAccessChain %43 %41 %97
1442                OpStore %101 %100
1443                OpBranch %92
1444          %92 = OpLabel
1445         %102 = OpLoad %6 %87
1446         %103 = OpIAdd %6 %102 %22
1447                OpStore %87 %103
1448                OpBranch %89
1449          %91 = OpLabel
1450                OpReturn
1451                OpFunctionEnd
1452          %14 = OpFunction %2 None %3
1453          %15 = OpLabel
1454         %104 = OpVariable %7 Function
1455         %106 = OpVariable %7 Function
1456         %108 = OpVariable %7 Function
1457         %117 = OpVariable %7 Function
1458         %127 = OpVariable %7 Function
1459         %129 = OpVariable %7 Function
1460         %134 = OpVariable %7 Function
1461         %143 = OpVariable %7 Function
1462         %145 = OpVariable %7 Function
1463         %147 = OpVariable %7 Function
1464                OpStore %104 %105
1465                OpStore %106 %107
1466                OpStore %108 %22
1467                OpBranch %109
1468         %109 = OpLabel
1469                OpLoopMerge %111 %112 None
1470                OpBranch %113
1471         %113 = OpLabel
1472         %114 = OpLoad %6 %108
1473         %115 = OpLoad %6 %106
1474         %116 = OpSLessThanEqual %31 %114 %115
1475                OpBranchConditional %116 %110 %111
1476         %110 = OpLabel
1477         %118 = OpLoad %6 %104
1478                OpStore %117 %118
1479                OpBranch %119
1480         %119 = OpLabel
1481                OpLoopMerge %121 %122 None
1482                OpBranch %123
1483         %123 = OpLabel
1484         %124 = OpLoad %6 %117
1485         %125 = OpLoad %6 %106
1486         %126 = OpSLessThan %31 %124 %125
1487                OpBranchConditional %126 %120 %121
1488         %120 = OpLabel
1489         %128 = OpLoad %6 %117
1490                OpStore %127 %128
1491         %130 = OpLoad %6 %117
1492         %131 = OpLoad %6 %108
1493         %132 = OpIAdd %6 %130 %131
1494         %133 = OpISub %6 %132 %22
1495                OpStore %129 %133
1496         %135 = OpLoad %6 %117
1497         %137 = OpLoad %6 %108
1498         %138 = OpIMul %6 %136 %137
1499         %139 = OpIAdd %6 %135 %138
1500         %140 = OpISub %6 %139 %22
1501         %141 = OpLoad %6 %106
1502         %142 = OpExtInst %6 %1 SMin %140 %141
1503                OpStore %134 %142
1504         %144 = OpLoad %6 %127
1505                OpStore %143 %144
1506         %146 = OpLoad %6 %129
1507                OpStore %145 %146
1508         %148 = OpLoad %6 %134
1509                OpStore %147 %148
1510         %149 = OpFunctionCall %2 %12 %143 %145 %147
1511                OpBranch %122
1512         %122 = OpLabel
1513         %150 = OpLoad %6 %108
1514         %151 = OpIMul %6 %136 %150
1515         %152 = OpLoad %6 %117
1516         %153 = OpIAdd %6 %152 %151
1517                OpStore %117 %153
1518                OpBranch %119
1519         %121 = OpLabel
1520                OpBranch %112
1521         %112 = OpLabel
1522         %154 = OpLoad %6 %108
1523         %155 = OpIMul %6 %136 %154
1524                OpStore %108 %155
1525                OpBranch %109
1526         %111 = OpLabel
1527                OpReturn
1528                OpFunctionEnd
1529 END
1530
1531 # uniforms for variant
1532
1533 # injectionSwitch
1534 BUFFER variant_injectionSwitch DATA_TYPE vec2<float> DATA
1535  0.0 1.0
1536 END
1537
1538 BUFFER variant_framebuffer FORMAT B8G8R8A8_UNORM
1539
1540 PIPELINE graphics variant_pipeline
1541   ATTACH variant_vertex_shader
1542   ATTACH variant_fragment_shader
1543   FRAMEBUFFER_SIZE 256 256
1544   BIND BUFFER variant_framebuffer AS color LOCATION 0
1545   BIND BUFFER variant_injectionSwitch AS uniform DESCRIPTOR_SET 0 BINDING 0
1546 END
1547 CLEAR_COLOR variant_pipeline 0 0 0 255
1548
1549 CLEAR variant_pipeline
1550 RUN variant_pipeline DRAW_RECT POS 0 0 SIZE 256 256
1551
1552 EXPECT reference_framebuffer EQ_HISTOGRAM_EMD_BUFFER variant_framebuffer TOLERANCE 0.005