Fix missing dependency on sparse binds
[platform/upstream/VK-GL-CTS.git] / external / vulkancts / data / vulkan / amber / graphicsfuzz / stable-colorgrid-modulo-true-conditional-simple-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 conditional and simple 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 resolution;
37 # };
38 # float compute_value(float limit, float thirty_two)
39 # {
40 #   float result = -0.5;
41 #   for (int i = 1; i < 800; i++)
42 #   {
43 #     if ((i % 32) == 0)
44 #     {
45 #       result += 0.4;
46 #     }
47 #     else
48 #     {
49 #       if (mod(float(i), round(thirty_two)) <= 0.01)
50 #       {
51 #         result += 100.0;
52 #       }
53 #     }
54 #     if (float(i) >= limit)
55 #     {
56 #       return result;
57 #     }
58 #   }
59 #   return result;
60 # }
61 # void main()
62 # {
63 #   vec3 c = vec3(7.0, 8.0, 9.0);
64 #   float thirty_two = round(resolution.x / 8.0);
65 #   c.x = compute_value(gl_FragCoord.x, thirty_two);
66 #   c.y = compute_value(gl_FragCoord.y, thirty_two);
67 #   c.z = c.x + c.y;
68 #   for (int i = 0; i < 3; i++)
69 #   {
70 #     if (c[i] >= 1.0)
71 #     {
72 #       c[i] = c[i] * c[i];
73 #     }
74 #   }
75 #   _GLF_color = vec4(normalize(abs(c)), 1.0);
76 # }
77 SHADER fragment reference_fragment_shader SPIRV-ASM TARGET_ENV spv1.0
78 ; SPIR-V
79 ; Version: 1.0
80 ; Generator: Khronos Glslang Reference Front End; 10
81 ; Bound: 145
82 ; Schema: 0
83                OpCapability Shader
84           %1 = OpExtInstImport "GLSL.std.450"
85                OpMemoryModel Logical GLSL450
86                OpEntryPoint Fragment %4 "main" %85 %137
87                OpExecutionMode %4 OriginUpperLeft
88                OpSource ESSL 320
89                OpName %4 "main"
90                OpName %11 "compute_value(f1;f1;"
91                OpName %9 "limit"
92                OpName %10 "thirty_two"
93                OpName %13 "result"
94                OpName %17 "i"
95                OpName %66 "c"
96                OpName %71 "thirty_two"
97                OpName %73 "buf0"
98                OpMemberName %73 0 "resolution"
99                OpName %75 ""
100                OpName %85 "gl_FragCoord"
101                OpName %86 "param"
102                OpName %90 "param"
103                OpName %94 "param"
104                OpName %98 "param"
105                OpName %109 "i"
106                OpName %137 "_GLF_color"
107                OpMemberDecorate %73 0 Offset 0
108                OpDecorate %73 Block
109                OpDecorate %75 DescriptorSet 0
110                OpDecorate %75 Binding 0
111                OpDecorate %85 BuiltIn FragCoord
112                OpDecorate %137 Location 0
113           %2 = OpTypeVoid
114           %3 = OpTypeFunction %2
115           %6 = OpTypeFloat 32
116           %7 = OpTypePointer Function %6
117           %8 = OpTypeFunction %6 %7 %7
118          %14 = OpConstant %6 -0.5
119          %15 = OpTypeInt 32 1
120          %16 = OpTypePointer Function %15
121          %18 = OpConstant %15 1
122          %25 = OpConstant %15 800
123          %26 = OpTypeBool
124          %29 = OpConstant %15 32
125          %31 = OpConstant %15 0
126          %35 = OpConstant %6 0.400000006
127          %44 = OpConstant %6 0.00999999978
128          %48 = OpConstant %6 100
129          %64 = OpTypeVector %6 3
130          %65 = OpTypePointer Function %64
131          %67 = OpConstant %6 7
132          %68 = OpConstant %6 8
133          %69 = OpConstant %6 9
134          %70 = OpConstantComposite %64 %67 %68 %69
135          %72 = OpTypeVector %6 2
136          %73 = OpTypeStruct %72
137          %74 = OpTypePointer Uniform %73
138          %75 = OpVariable %74 Uniform
139          %76 = OpTypeInt 32 0
140          %77 = OpConstant %76 0
141          %78 = OpTypePointer Uniform %6
142          %83 = OpTypeVector %6 4
143          %84 = OpTypePointer Input %83
144          %85 = OpVariable %84 Input
145          %87 = OpTypePointer Input %6
146          %95 = OpConstant %76 1
147         %107 = OpConstant %76 2
148         %116 = OpConstant %15 3
149         %121 = OpConstant %6 1
150         %136 = OpTypePointer Output %83
151         %137 = OpVariable %136 Output
152           %4 = OpFunction %2 None %3
153           %5 = OpLabel
154          %66 = OpVariable %65 Function
155          %71 = OpVariable %7 Function
156          %86 = OpVariable %7 Function
157          %90 = OpVariable %7 Function
158          %94 = OpVariable %7 Function
159          %98 = OpVariable %7 Function
160         %109 = OpVariable %16 Function
161                OpStore %66 %70
162          %79 = OpAccessChain %78 %75 %31 %77
163          %80 = OpLoad %6 %79
164          %81 = OpFDiv %6 %80 %68
165          %82 = OpExtInst %6 %1 Round %81
166                OpStore %71 %82
167          %88 = OpAccessChain %87 %85 %77
168          %89 = OpLoad %6 %88
169                OpStore %86 %89
170          %91 = OpLoad %6 %71
171                OpStore %90 %91
172          %92 = OpFunctionCall %6 %11 %86 %90
173          %93 = OpAccessChain %7 %66 %77
174                OpStore %93 %92
175          %96 = OpAccessChain %87 %85 %95
176          %97 = OpLoad %6 %96
177                OpStore %94 %97
178          %99 = OpLoad %6 %71
179                OpStore %98 %99
180         %100 = OpFunctionCall %6 %11 %94 %98
181         %101 = OpAccessChain %7 %66 %95
182                OpStore %101 %100
183         %102 = OpAccessChain %7 %66 %77
184         %103 = OpLoad %6 %102
185         %104 = OpAccessChain %7 %66 %95
186         %105 = OpLoad %6 %104
187         %106 = OpFAdd %6 %103 %105
188         %108 = OpAccessChain %7 %66 %107
189                OpStore %108 %106
190                OpStore %109 %31
191                OpBranch %110
192         %110 = OpLabel
193                OpLoopMerge %112 %113 None
194                OpBranch %114
195         %114 = OpLabel
196         %115 = OpLoad %15 %109
197         %117 = OpSLessThan %26 %115 %116
198                OpBranchConditional %117 %111 %112
199         %111 = OpLabel
200         %118 = OpLoad %15 %109
201         %119 = OpAccessChain %7 %66 %118
202         %120 = OpLoad %6 %119
203         %122 = OpFOrdGreaterThanEqual %26 %120 %121
204                OpSelectionMerge %124 None
205                OpBranchConditional %122 %123 %124
206         %123 = OpLabel
207         %125 = OpLoad %15 %109
208         %126 = OpLoad %15 %109
209         %127 = OpAccessChain %7 %66 %126
210         %128 = OpLoad %6 %127
211         %129 = OpLoad %15 %109
212         %130 = OpAccessChain %7 %66 %129
213         %131 = OpLoad %6 %130
214         %132 = OpFMul %6 %128 %131
215         %133 = OpAccessChain %7 %66 %125
216                OpStore %133 %132
217                OpBranch %124
218         %124 = OpLabel
219                OpBranch %113
220         %113 = OpLabel
221         %134 = OpLoad %15 %109
222         %135 = OpIAdd %15 %134 %18
223                OpStore %109 %135
224                OpBranch %110
225         %112 = OpLabel
226         %138 = OpLoad %64 %66
227         %139 = OpExtInst %64 %1 FAbs %138
228         %140 = OpExtInst %64 %1 Normalize %139
229         %141 = OpCompositeExtract %6 %140 0
230         %142 = OpCompositeExtract %6 %140 1
231         %143 = OpCompositeExtract %6 %140 2
232         %144 = OpCompositeConstruct %83 %141 %142 %143 %121
233                OpStore %137 %144
234                OpReturn
235                OpFunctionEnd
236          %11 = OpFunction %6 None %8
237           %9 = OpFunctionParameter %7
238          %10 = OpFunctionParameter %7
239          %12 = OpLabel
240          %13 = OpVariable %7 Function
241          %17 = OpVariable %16 Function
242                OpStore %13 %14
243                OpStore %17 %18
244                OpBranch %19
245          %19 = OpLabel
246                OpLoopMerge %21 %22 None
247                OpBranch %23
248          %23 = OpLabel
249          %24 = OpLoad %15 %17
250          %27 = OpSLessThan %26 %24 %25
251                OpBranchConditional %27 %20 %21
252          %20 = OpLabel
253          %28 = OpLoad %15 %17
254          %30 = OpSMod %15 %28 %29
255          %32 = OpIEqual %26 %30 %31
256                OpSelectionMerge %34 None
257                OpBranchConditional %32 %33 %38
258          %33 = OpLabel
259          %36 = OpLoad %6 %13
260          %37 = OpFAdd %6 %36 %35
261                OpStore %13 %37
262                OpBranch %34
263          %38 = OpLabel
264          %39 = OpLoad %15 %17
265          %40 = OpConvertSToF %6 %39
266          %41 = OpLoad %6 %10
267          %42 = OpExtInst %6 %1 Round %41
268          %43 = OpFMod %6 %40 %42
269          %45 = OpFOrdLessThanEqual %26 %43 %44
270                OpSelectionMerge %47 None
271                OpBranchConditional %45 %46 %47
272          %46 = OpLabel
273          %49 = OpLoad %6 %13
274          %50 = OpFAdd %6 %49 %48
275                OpStore %13 %50
276                OpBranch %47
277          %47 = OpLabel
278                OpBranch %34
279          %34 = OpLabel
280          %51 = OpLoad %15 %17
281          %52 = OpConvertSToF %6 %51
282          %53 = OpLoad %6 %9
283          %54 = OpFOrdGreaterThanEqual %26 %52 %53
284                OpSelectionMerge %56 None
285                OpBranchConditional %54 %55 %56
286          %55 = OpLabel
287          %57 = OpLoad %6 %13
288                OpReturnValue %57
289          %56 = OpLabel
290                OpBranch %22
291          %22 = OpLabel
292          %59 = OpLoad %15 %17
293          %60 = OpIAdd %15 %59 %18
294                OpStore %17 %60
295                OpBranch %19
296          %21 = OpLabel
297          %61 = OpLoad %6 %13
298                OpReturnValue %61
299                OpFunctionEnd
300 END
301
302 # uniforms for reference
303
304 # resolution
305 BUFFER reference_resolution DATA_TYPE vec2<float> DATA
306  256.0 256.0
307 END
308
309 BUFFER reference_framebuffer FORMAT B8G8R8A8_UNORM
310
311 PIPELINE graphics reference_pipeline
312   ATTACH reference_vertex_shader
313   ATTACH reference_fragment_shader
314   FRAMEBUFFER_SIZE 256 256
315   BIND BUFFER reference_framebuffer AS color LOCATION 0
316   BIND BUFFER reference_resolution AS uniform DESCRIPTOR_SET 0 BINDING 0
317 END
318 CLEAR_COLOR reference_pipeline 0 0 0 255
319
320 CLEAR reference_pipeline
321 RUN reference_pipeline DRAW_RECT POS 0 0 SIZE 256 256
322
323
324 SHADER vertex variant_vertex_shader PASSTHROUGH
325
326 # variant_fragment_shader is derived from the following GLSL:
327 # #version 320 es
328 # precision highp float;
329 #
330 # precision highp int;
331 #
332 # layout(location = 0) out vec4 _GLF_color;
333 #
334 # layout(set = 0, binding = 0) uniform buf0
335 # {
336 #   vec2 resolution;
337 # };
338 #
339 # layout(set = 0, binding = 1) uniform buf1
340 # {
341 #   vec2 injectionSwitch; //x == 1.0, y == 0.0
342 # };
343 # float compute_value(float limit, float thirty_two)
344 # {
345 #   float result = -0.5;
346 #   for (int i = 1; i < 800; i++)
347 #   {
348 #     if ((i % 32) == 0)
349 #     {
350 #       result += 0.4;
351 #     }
352 #     else
353 #     {
354 #       if (mod(float(i), round(thirty_two)) <= 0.01)
355 #       {
356 #         result += 100.0;
357 #       }
358 #     }
359 #     if (float(i) >= limit)
360 #     {
361 #       return result;
362 #     }
363 #   }
364 #   return result;
365 # }
366 # void main()
367 # {
368 #   vec3 c = vec3(7.0, 8.0, 9.0);
369 #   float thirty_two = round(resolution.x / 8.0);
370 #   c.x = compute_value(gl_FragCoord.x, thirty_two);
371 #   c.y = compute_value(gl_FragCoord.y, thirty_two);
372 #   // Always true and result should be the same as in reference shader.
373 #   c.z = c.x + (true ? c : c * injectionSwitch.x).y;
374 #   for (int i = 0; i < 3; i++)
375 #   {
376 #     if (c[i] >= 1.0)
377 #     {
378 #       c[i] = c[i] * c[i];
379 #     }
380 #     float j = 0.0;
381 #     // Always true, iterates once before break.
382 #     while (injectionSwitch.x > injectionSwitch.y)
383 #     {
384 #       if (j >= injectionSwitch.x)
385 #       {
386 #         break;
387 #       }
388 #       j++;
389 #     }
390 #   }
391 #   _GLF_color = vec4(normalize(abs(c)), 1.0);
392 # }
393 SHADER fragment variant_fragment_shader SPIRV-ASM TARGET_ENV spv1.0
394 ; SPIR-V
395 ; Version: 1.0
396 ; Generator: Khronos Glslang Reference Front End; 10
397 ; Bound: 179
398 ; Schema: 0
399                OpCapability Shader
400           %1 = OpExtInstImport "GLSL.std.450"
401                OpMemoryModel Logical GLSL450
402                OpEntryPoint Fragment %4 "main" %85 %171
403                OpExecutionMode %4 OriginUpperLeft
404                OpSource ESSL 320
405                OpName %4 "main"
406                OpName %11 "compute_value(f1;f1;"
407                OpName %9 "limit"
408                OpName %10 "thirty_two"
409                OpName %13 "result"
410                OpName %17 "i"
411                OpName %66 "c"
412                OpName %71 "thirty_two"
413                OpName %73 "buf0"
414                OpMemberName %73 0 "resolution"
415                OpName %75 ""
416                OpName %85 "gl_FragCoord"
417                OpName %86 "param"
418                OpName %90 "param"
419                OpName %94 "param"
420                OpName %98 "param"
421                OpName %111 "buf1"
422                OpMemberName %111 0 "injectionSwitch"
423                OpName %113 ""
424                OpName %122 "i"
425                OpName %147 "j"
426                OpName %171 "_GLF_color"
427                OpMemberDecorate %73 0 Offset 0
428                OpDecorate %73 Block
429                OpDecorate %75 DescriptorSet 0
430                OpDecorate %75 Binding 0
431                OpDecorate %85 BuiltIn FragCoord
432                OpMemberDecorate %111 0 Offset 0
433                OpDecorate %111 Block
434                OpDecorate %113 DescriptorSet 0
435                OpDecorate %113 Binding 1
436                OpDecorate %171 Location 0
437           %2 = OpTypeVoid
438           %3 = OpTypeFunction %2
439           %6 = OpTypeFloat 32
440           %7 = OpTypePointer Function %6
441           %8 = OpTypeFunction %6 %7 %7
442          %14 = OpConstant %6 -0.5
443          %15 = OpTypeInt 32 1
444          %16 = OpTypePointer Function %15
445          %18 = OpConstant %15 1
446          %25 = OpConstant %15 800
447          %26 = OpTypeBool
448          %29 = OpConstant %15 32
449          %31 = OpConstant %15 0
450          %35 = OpConstant %6 0.400000006
451          %44 = OpConstant %6 0.00999999978
452          %48 = OpConstant %6 100
453          %64 = OpTypeVector %6 3
454          %65 = OpTypePointer Function %64
455          %67 = OpConstant %6 7
456          %68 = OpConstant %6 8
457          %69 = OpConstant %6 9
458          %70 = OpConstantComposite %64 %67 %68 %69
459          %72 = OpTypeVector %6 2
460          %73 = OpTypeStruct %72
461          %74 = OpTypePointer Uniform %73
462          %75 = OpVariable %74 Uniform
463          %76 = OpTypeInt 32 0
464          %77 = OpConstant %76 0
465          %78 = OpTypePointer Uniform %6
466          %83 = OpTypeVector %6 4
467          %84 = OpTypePointer Input %83
468          %85 = OpVariable %84 Input
469          %87 = OpTypePointer Input %6
470          %95 = OpConstant %76 1
471         %104 = OpConstantTrue %26
472         %111 = OpTypeStruct %72
473         %112 = OpTypePointer Uniform %111
474         %113 = OpVariable %112 Uniform
475         %120 = OpConstant %76 2
476         %129 = OpConstant %15 3
477         %134 = OpConstant %6 1
478         %148 = OpConstant %6 0
479         %170 = OpTypePointer Output %83
480         %171 = OpVariable %170 Output
481           %4 = OpFunction %2 None %3
482           %5 = OpLabel
483          %66 = OpVariable %65 Function
484          %71 = OpVariable %7 Function
485          %86 = OpVariable %7 Function
486          %90 = OpVariable %7 Function
487          %94 = OpVariable %7 Function
488          %98 = OpVariable %7 Function
489         %105 = OpVariable %65 Function
490         %122 = OpVariable %16 Function
491         %147 = OpVariable %7 Function
492                OpStore %66 %70
493          %79 = OpAccessChain %78 %75 %31 %77
494          %80 = OpLoad %6 %79
495          %81 = OpFDiv %6 %80 %68
496          %82 = OpExtInst %6 %1 Round %81
497                OpStore %71 %82
498          %88 = OpAccessChain %87 %85 %77
499          %89 = OpLoad %6 %88
500                OpStore %86 %89
501          %91 = OpLoad %6 %71
502                OpStore %90 %91
503          %92 = OpFunctionCall %6 %11 %86 %90
504          %93 = OpAccessChain %7 %66 %77
505                OpStore %93 %92
506          %96 = OpAccessChain %87 %85 %95
507          %97 = OpLoad %6 %96
508                OpStore %94 %97
509          %99 = OpLoad %6 %71
510                OpStore %98 %99
511         %100 = OpFunctionCall %6 %11 %94 %98
512         %101 = OpAccessChain %7 %66 %95
513                OpStore %101 %100
514         %102 = OpAccessChain %7 %66 %77
515         %103 = OpLoad %6 %102
516                OpSelectionMerge %107 None
517                OpBranchConditional %104 %106 %109
518         %106 = OpLabel
519         %108 = OpLoad %64 %66
520                OpStore %105 %108
521                OpBranch %107
522         %109 = OpLabel
523         %110 = OpLoad %64 %66
524         %114 = OpAccessChain %78 %113 %31 %77
525         %115 = OpLoad %6 %114
526         %116 = OpVectorTimesScalar %64 %110 %115
527                OpStore %105 %116
528                OpBranch %107
529         %107 = OpLabel
530         %117 = OpAccessChain %7 %105 %95
531         %118 = OpLoad %6 %117
532         %119 = OpFAdd %6 %103 %118
533         %121 = OpAccessChain %7 %66 %120
534                OpStore %121 %119
535                OpStore %122 %31
536                OpBranch %123
537         %123 = OpLabel
538                OpLoopMerge %125 %126 None
539                OpBranch %127
540         %127 = OpLabel
541         %128 = OpLoad %15 %122
542         %130 = OpSLessThan %26 %128 %129
543                OpBranchConditional %130 %124 %125
544         %124 = OpLabel
545         %131 = OpLoad %15 %122
546         %132 = OpAccessChain %7 %66 %131
547         %133 = OpLoad %6 %132
548         %135 = OpFOrdGreaterThanEqual %26 %133 %134
549                OpSelectionMerge %137 None
550                OpBranchConditional %135 %136 %137
551         %136 = OpLabel
552         %138 = OpLoad %15 %122
553         %139 = OpLoad %15 %122
554         %140 = OpAccessChain %7 %66 %139
555         %141 = OpLoad %6 %140
556         %142 = OpLoad %15 %122
557         %143 = OpAccessChain %7 %66 %142
558         %144 = OpLoad %6 %143
559         %145 = OpFMul %6 %141 %144
560         %146 = OpAccessChain %7 %66 %138
561                OpStore %146 %145
562                OpBranch %137
563         %137 = OpLabel
564                OpStore %147 %148
565                OpBranch %149
566         %149 = OpLabel
567                OpLoopMerge %151 %152 None
568                OpBranch %153
569         %153 = OpLabel
570         %154 = OpAccessChain %78 %113 %31 %77
571         %155 = OpLoad %6 %154
572         %156 = OpAccessChain %78 %113 %31 %95
573         %157 = OpLoad %6 %156
574         %158 = OpFOrdGreaterThan %26 %155 %157
575                OpBranchConditional %158 %150 %151
576         %150 = OpLabel
577         %159 = OpLoad %6 %147
578         %160 = OpAccessChain %78 %113 %31 %77
579         %161 = OpLoad %6 %160
580         %162 = OpFOrdGreaterThanEqual %26 %159 %161
581                OpSelectionMerge %164 None
582                OpBranchConditional %162 %163 %164
583         %163 = OpLabel
584                OpBranch %151
585         %164 = OpLabel
586         %166 = OpLoad %6 %147
587         %167 = OpFAdd %6 %166 %134
588                OpStore %147 %167
589                OpBranch %152
590         %152 = OpLabel
591                OpBranch %149
592         %151 = OpLabel
593                OpBranch %126
594         %126 = OpLabel
595         %168 = OpLoad %15 %122
596         %169 = OpIAdd %15 %168 %18
597                OpStore %122 %169
598                OpBranch %123
599         %125 = OpLabel
600         %172 = OpLoad %64 %66
601         %173 = OpExtInst %64 %1 FAbs %172
602         %174 = OpExtInst %64 %1 Normalize %173
603         %175 = OpCompositeExtract %6 %174 0
604         %176 = OpCompositeExtract %6 %174 1
605         %177 = OpCompositeExtract %6 %174 2
606         %178 = OpCompositeConstruct %83 %175 %176 %177 %134
607                OpStore %171 %178
608                OpReturn
609                OpFunctionEnd
610          %11 = OpFunction %6 None %8
611           %9 = OpFunctionParameter %7
612          %10 = OpFunctionParameter %7
613          %12 = OpLabel
614          %13 = OpVariable %7 Function
615          %17 = OpVariable %16 Function
616                OpStore %13 %14
617                OpStore %17 %18
618                OpBranch %19
619          %19 = OpLabel
620                OpLoopMerge %21 %22 None
621                OpBranch %23
622          %23 = OpLabel
623          %24 = OpLoad %15 %17
624          %27 = OpSLessThan %26 %24 %25
625                OpBranchConditional %27 %20 %21
626          %20 = OpLabel
627          %28 = OpLoad %15 %17
628          %30 = OpSMod %15 %28 %29
629          %32 = OpIEqual %26 %30 %31
630                OpSelectionMerge %34 None
631                OpBranchConditional %32 %33 %38
632          %33 = OpLabel
633          %36 = OpLoad %6 %13
634          %37 = OpFAdd %6 %36 %35
635                OpStore %13 %37
636                OpBranch %34
637          %38 = OpLabel
638          %39 = OpLoad %15 %17
639          %40 = OpConvertSToF %6 %39
640          %41 = OpLoad %6 %10
641          %42 = OpExtInst %6 %1 Round %41
642          %43 = OpFMod %6 %40 %42
643          %45 = OpFOrdLessThanEqual %26 %43 %44
644                OpSelectionMerge %47 None
645                OpBranchConditional %45 %46 %47
646          %46 = OpLabel
647          %49 = OpLoad %6 %13
648          %50 = OpFAdd %6 %49 %48
649                OpStore %13 %50
650                OpBranch %47
651          %47 = OpLabel
652                OpBranch %34
653          %34 = OpLabel
654          %51 = OpLoad %15 %17
655          %52 = OpConvertSToF %6 %51
656          %53 = OpLoad %6 %9
657          %54 = OpFOrdGreaterThanEqual %26 %52 %53
658                OpSelectionMerge %56 None
659                OpBranchConditional %54 %55 %56
660          %55 = OpLabel
661          %57 = OpLoad %6 %13
662                OpReturnValue %57
663          %56 = OpLabel
664                OpBranch %22
665          %22 = OpLabel
666          %59 = OpLoad %15 %17
667          %60 = OpIAdd %15 %59 %18
668                OpStore %17 %60
669                OpBranch %19
670          %21 = OpLabel
671          %61 = OpLoad %6 %13
672                OpReturnValue %61
673                OpFunctionEnd
674 END
675
676 # uniforms for variant
677
678 # resolution
679 BUFFER variant_resolution DATA_TYPE vec2<float> DATA
680  256.0 256.0
681 END
682 # injectionSwitch
683 BUFFER variant_injectionSwitch DATA_TYPE vec2<float> DATA
684  1.0 0.0
685 END
686
687 BUFFER variant_framebuffer FORMAT B8G8R8A8_UNORM
688
689 PIPELINE graphics variant_pipeline
690   ATTACH variant_vertex_shader
691   ATTACH variant_fragment_shader
692   FRAMEBUFFER_SIZE 256 256
693   BIND BUFFER variant_framebuffer AS color LOCATION 0
694   BIND BUFFER variant_resolution AS uniform DESCRIPTOR_SET 0 BINDING 0
695   BIND BUFFER variant_injectionSwitch AS uniform DESCRIPTOR_SET 0 BINDING 1
696 END
697 CLEAR_COLOR variant_pipeline 0 0 0 255
698
699 CLEAR variant_pipeline
700 RUN variant_pipeline DRAW_RECT POS 0 0 SIZE 256 256
701
702 EXPECT reference_framebuffer EQ_HISTOGRAM_EMD_BUFFER variant_framebuffer TOLERANCE 0.005