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