dEQP-VK.graphicsfuzz.spv-stable-quicksort-mat-func-param
dEQP-VK.graphicsfuzz.spv-stable-rects-Os-mutate-var-push-through-var
dEQP-VK.graphicsfuzz.stable-binarysearch-tree-false-if-discard-loop
+dEQP-VK.graphicsfuzz.stable-binarysearch-tree-fragcoord-less-than-zero
dEQP-VK.graphicsfuzz.stable-binarysearch-tree-nested-if-and-conditional
dEQP-VK.graphicsfuzz.stable-binarysearch-tree-with-loop-read-write-global
dEQP-VK.graphicsfuzz.stable-collatz-push-constant-with-nested-min-max
+dEQP-VK.graphicsfuzz.stable-colorgrid-modulo-double-always-false-discard
dEQP-VK.graphicsfuzz.stable-colorgrid-modulo-injected-conditional-true
dEQP-VK.graphicsfuzz.stable-colorgrid-modulo-true-conditional-simple-loop
dEQP-VK.graphicsfuzz.stable-colorgrid-modulo-vec3-values-from-matrix
+dEQP-VK.graphicsfuzz.stable-mergesort-for-always-false-if-discard
dEQP-VK.graphicsfuzz.stable-mergesort-reversed-for-loop
dEQP-VK.graphicsfuzz.stable-quicksort-for-loop-with-injection
dEQP-VK.graphicsfuzz.stable-quicksort-if-false-else-return
dEQP-VK.graphicsfuzz.spv-stable-quicksort-mat-func-param
dEQP-VK.graphicsfuzz.spv-stable-rects-Os-mutate-var-push-through-var
dEQP-VK.graphicsfuzz.stable-binarysearch-tree-false-if-discard-loop
+dEQP-VK.graphicsfuzz.stable-binarysearch-tree-fragcoord-less-than-zero
dEQP-VK.graphicsfuzz.stable-binarysearch-tree-nested-if-and-conditional
dEQP-VK.graphicsfuzz.stable-binarysearch-tree-with-loop-read-write-global
dEQP-VK.graphicsfuzz.stable-collatz-push-constant-with-nested-min-max
+dEQP-VK.graphicsfuzz.stable-colorgrid-modulo-double-always-false-discard
dEQP-VK.graphicsfuzz.stable-colorgrid-modulo-injected-conditional-true
dEQP-VK.graphicsfuzz.stable-colorgrid-modulo-true-conditional-simple-loop
dEQP-VK.graphicsfuzz.stable-colorgrid-modulo-vec3-values-from-matrix
+dEQP-VK.graphicsfuzz.stable-mergesort-for-always-false-if-discard
dEQP-VK.graphicsfuzz.stable-mergesort-reversed-for-loop
dEQP-VK.graphicsfuzz.stable-quicksort-for-loop-with-injection
dEQP-VK.graphicsfuzz.stable-quicksort-if-false-else-return
{ "spv-stable-quicksort-mat-func-param.amber", "spv-stable-quicksort-mat-func-param", "Two shaders with diff: added mat3x3 func param" },
{ "spv-stable-rects-Os-mutate-var-push-through-var.amber", "spv-stable-rects-Os-mutate-var-push-through-var", "Three shaders diff: new variable used and mutated" },
{ "stable-binarysearch-tree-false-if-discard-loop.amber", "stable-binarysearch-tree-false-if-discard-loop", "A fragment shader with always false if with discard loop" },
+{ "stable-binarysearch-tree-fragcoord-less-than-zero.amber", "stable-binarysearch-tree-fragcoord-less-than-zero", "A fragment shader with gl_FragCoord.x less than zero" },
{ "stable-binarysearch-tree-nested-if-and-conditional.amber", "stable-binarysearch-tree-nested-if-and-conditional", "A fragment shader with nested if and conditional statement" },
{ "stable-binarysearch-tree-with-loop-read-write-global.amber", "stable-binarysearch-tree-with-loop-read-write-global", "A pair of fragment shaders that both render red" },
{ "stable-collatz-push-constant-with-nested-min-max.amber", "stable-collatz-push-constant-with-nested-min-max", "A fragment shader with push constant and nested min max" },
+{ "stable-colorgrid-modulo-double-always-false-discard.amber", "stable-colorgrid-modulo-double-always-false-discard", "A fragment shader with two always false discards" },
{ "stable-colorgrid-modulo-injected-conditional-true.amber", "stable-colorgrid-modulo-injected-conditional-true", "A fragment shader with an always true conditional" },
{ "stable-colorgrid-modulo-true-conditional-simple-loop.amber", "stable-colorgrid-modulo-true-conditional-simple-loop", "A fragment shader with conditional and simple loop" },
{ "stable-colorgrid-modulo-vec3-values-from-matrix.amber", "stable-colorgrid-modulo-vec3-values-from-matrix", "A fragment shader with vec3 values set from matrix4x2" },
+{ "stable-mergesort-for-always-false-if-discard.amber", "stable-mergesort-for-always-false-if-discard", "A fragment shader with for loop and always false if" },
{ "stable-mergesort-reversed-for-loop.amber", "stable-mergesort-reversed-for-loop", "A fragment shader with once iterated reversed for loop" },
{ "stable-quicksort-for-loop-with-injection.amber", "stable-quicksort-for-loop-with-injection", "A fragment shader with a for loop containing injection" },
{ "stable-quicksort-if-false-else-return.amber", "stable-quicksort-if-false-else-return", "A fragment shader with an always false if statement" },
--- /dev/null
+#!amber
+
+# Copyright 2020 Google LLC
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+
+# A test for a bug found by GraphicsFuzz.
+
+# Short description: A fragment shader with gl_FragCoord.x less than zero
+
+# The test passes because both shaders render the same image.
+
+SHADER vertex reference_vertex_shader PASSTHROUGH
+
+# reference_fragment_shader is derived from the following GLSL:
+# #version 320 es
+# precision highp float;
+#
+# precision highp int;
+#
+# layout(location = 0) out vec4 _GLF_color;
+#
+# struct BST {
+# int data;
+# int leftIndex;
+# int rightIndex;
+# } ;
+#
+# BST tree[10];
+#
+# void makeTreeNode(inout BST tree, int data)
+# {
+# tree.data = data;
+# tree.leftIndex = - 1;
+# tree.rightIndex = - 1;
+# }
+# void insert(int treeIndex, int data)
+# {
+# int baseIndex = 0;
+# while(baseIndex <= treeIndex)
+# {
+# if(data <= tree[baseIndex].data)
+# {
+# if(tree[baseIndex].leftIndex == - 1)
+# {
+# tree[baseIndex].leftIndex = treeIndex;
+# makeTreeNode(tree[treeIndex], data);
+# return;
+# }
+# else
+# {
+# baseIndex = tree[baseIndex].leftIndex;
+# continue;
+# }
+# }
+# else
+# {
+# if(tree[baseIndex].rightIndex == - 1)
+# {
+# tree[baseIndex].rightIndex = treeIndex;
+# makeTreeNode(tree[treeIndex], data);
+# return;
+# }
+# else
+# {
+# baseIndex = tree[baseIndex].rightIndex;
+# continue;
+# }
+# }
+# }
+# }
+# int search(int target)
+# {
+# BST currentNode;
+# int index = 0;
+# while(index != - 1)
+# {
+# currentNode = tree[index];
+# if(currentNode.data == target)
+# {
+# return target;
+# }
+# index = target > currentNode.data ? currentNode.rightIndex : currentNode.leftIndex;
+# }
+# return - 1;
+# }
+# void main()
+# {
+# int treeIndex = 0;
+# makeTreeNode(tree[0], 9);
+# treeIndex ++;
+# insert(treeIndex, 5);
+# treeIndex ++;
+# insert(treeIndex, 12);
+# treeIndex ++;
+# insert(treeIndex, 15);
+# treeIndex ++;
+# insert(treeIndex, 7);
+# treeIndex ++;
+# insert(treeIndex, 8);
+# treeIndex ++;
+# insert(treeIndex, 2);
+# treeIndex ++;
+# insert(treeIndex, 6);
+# treeIndex ++;
+# insert(treeIndex, 17);
+# treeIndex ++;
+# insert(treeIndex, 13);
+# int count = 0;
+# for(int i = 0; i < 20; i ++)
+# {
+# int result = search(i);
+# switch(i)
+# {
+# case 9:
+# case 5:
+# case 12:
+# case 15:
+# case 7:
+# case 8:
+# case 2:
+# case 6:
+# case 17:
+# case 13:
+# if(result == i)
+# {
+# count ++;
+# }
+# break;
+# default:
+# if(result == - 1)
+# {
+# count ++;
+# }
+# break;
+# }
+# }
+# if(count == 20)
+# {
+# _GLF_color = vec4(1.0, 0.0, 0.0, 1.0);
+# }
+# else
+# {
+# _GLF_color = vec4(0.0, 0.0, 1.0, 1.0);
+# }
+# }
+SHADER fragment reference_fragment_shader SPIRV-ASM
+; SPIR-V
+; Version: 1.0
+; Generator: Khronos Glslang Reference Front End; 10
+; Bound: 260
+; Schema: 0
+ OpCapability Shader
+ %1 = OpExtInstImport "GLSL.std.450"
+ OpMemoryModel Logical GLSL450
+ OpEntryPoint Fragment %4 "main" %254
+ OpExecutionMode %4 OriginUpperLeft
+ OpSource ESSL 320
+ OpName %4 "main"
+ OpName %7 "BST"
+ OpMemberName %7 0 "data"
+ OpMemberName %7 1 "leftIndex"
+ OpMemberName %7 2 "rightIndex"
+ OpName %13 "makeTreeNode(struct-BST-i1-i1-i11;i1;"
+ OpName %11 "tree"
+ OpName %12 "data"
+ OpName %18 "insert(i1;i1;"
+ OpName %16 "treeIndex"
+ OpName %17 "data"
+ OpName %22 "search(i1;"
+ OpName %21 "target"
+ OpName %32 "baseIndex"
+ OpName %47 "tree"
+ OpName %65 "param"
+ OpName %69 "param"
+ OpName %91 "param"
+ OpName %94 "param"
+ OpName %105 "index"
+ OpName %113 "currentNode"
+ OpName %140 "treeIndex"
+ OpName %142 "param"
+ OpName %145 "param"
+ OpName %152 "param"
+ OpName %154 "param"
+ OpName %159 "param"
+ OpName %161 "param"
+ OpName %166 "param"
+ OpName %168 "param"
+ OpName %173 "param"
+ OpName %175 "param"
+ OpName %180 "param"
+ OpName %182 "param"
+ OpName %186 "param"
+ OpName %188 "param"
+ OpName %193 "param"
+ OpName %195 "param"
+ OpName %200 "param"
+ OpName %202 "param"
+ OpName %207 "param"
+ OpName %209 "param"
+ OpName %211 "count"
+ OpName %212 "i"
+ OpName %221 "result"
+ OpName %222 "param"
+ OpName %254 "_GLF_color"
+ OpDecorate %254 Location 0
+ %2 = OpTypeVoid
+ %3 = OpTypeFunction %2
+ %6 = OpTypeInt 32 1
+ %7 = OpTypeStruct %6 %6 %6
+ %8 = OpTypePointer Function %7
+ %9 = OpTypePointer Function %6
+ %10 = OpTypeFunction %2 %8 %9
+ %15 = OpTypeFunction %2 %9 %9
+ %20 = OpTypeFunction %6 %9
+ %24 = OpConstant %6 0
+ %27 = OpConstant %6 1
+ %28 = OpConstant %6 -1
+ %30 = OpConstant %6 2
+ %40 = OpTypeBool
+ %43 = OpTypeInt 32 0
+ %44 = OpConstant %43 10
+ %45 = OpTypeArray %7 %44
+ %46 = OpTypePointer Private %45
+ %47 = OpVariable %46 Private
+ %49 = OpTypePointer Private %6
+ %66 = OpTypePointer Private %7
+ %141 = OpConstant %6 9
+ %151 = OpConstant %6 5
+ %158 = OpConstant %6 12
+ %165 = OpConstant %6 15
+ %172 = OpConstant %6 7
+ %179 = OpConstant %6 8
+ %192 = OpConstant %6 6
+ %199 = OpConstant %6 17
+ %206 = OpConstant %6 13
+ %219 = OpConstant %6 20
+ %251 = OpTypeFloat 32
+ %252 = OpTypeVector %251 4
+ %253 = OpTypePointer Output %252
+ %254 = OpVariable %253 Output
+ %255 = OpConstant %251 1
+ %256 = OpConstant %251 0
+ %257 = OpConstantComposite %252 %255 %256 %256 %255
+ %259 = OpConstantComposite %252 %256 %256 %255 %255
+ %4 = OpFunction %2 None %3
+ %5 = OpLabel
+ %140 = OpVariable %9 Function
+ %142 = OpVariable %8 Function
+ %145 = OpVariable %9 Function
+ %152 = OpVariable %9 Function
+ %154 = OpVariable %9 Function
+ %159 = OpVariable %9 Function
+ %161 = OpVariable %9 Function
+ %166 = OpVariable %9 Function
+ %168 = OpVariable %9 Function
+ %173 = OpVariable %9 Function
+ %175 = OpVariable %9 Function
+ %180 = OpVariable %9 Function
+ %182 = OpVariable %9 Function
+ %186 = OpVariable %9 Function
+ %188 = OpVariable %9 Function
+ %193 = OpVariable %9 Function
+ %195 = OpVariable %9 Function
+ %200 = OpVariable %9 Function
+ %202 = OpVariable %9 Function
+ %207 = OpVariable %9 Function
+ %209 = OpVariable %9 Function
+ %211 = OpVariable %9 Function
+ %212 = OpVariable %9 Function
+ %221 = OpVariable %9 Function
+ %222 = OpVariable %9 Function
+ OpStore %140 %24
+ %143 = OpAccessChain %66 %47 %24
+ %144 = OpLoad %7 %143
+ OpStore %142 %144
+ OpStore %145 %141
+ %146 = OpFunctionCall %2 %13 %142 %145
+ %147 = OpLoad %7 %142
+ %148 = OpAccessChain %66 %47 %24
+ OpStore %148 %147
+ %149 = OpLoad %6 %140
+ %150 = OpIAdd %6 %149 %27
+ OpStore %140 %150
+ %153 = OpLoad %6 %140
+ OpStore %152 %153
+ OpStore %154 %151
+ %155 = OpFunctionCall %2 %18 %152 %154
+ %156 = OpLoad %6 %140
+ %157 = OpIAdd %6 %156 %27
+ OpStore %140 %157
+ %160 = OpLoad %6 %140
+ OpStore %159 %160
+ OpStore %161 %158
+ %162 = OpFunctionCall %2 %18 %159 %161
+ %163 = OpLoad %6 %140
+ %164 = OpIAdd %6 %163 %27
+ OpStore %140 %164
+ %167 = OpLoad %6 %140
+ OpStore %166 %167
+ OpStore %168 %165
+ %169 = OpFunctionCall %2 %18 %166 %168
+ %170 = OpLoad %6 %140
+ %171 = OpIAdd %6 %170 %27
+ OpStore %140 %171
+ %174 = OpLoad %6 %140
+ OpStore %173 %174
+ OpStore %175 %172
+ %176 = OpFunctionCall %2 %18 %173 %175
+ %177 = OpLoad %6 %140
+ %178 = OpIAdd %6 %177 %27
+ OpStore %140 %178
+ %181 = OpLoad %6 %140
+ OpStore %180 %181
+ OpStore %182 %179
+ %183 = OpFunctionCall %2 %18 %180 %182
+ %184 = OpLoad %6 %140
+ %185 = OpIAdd %6 %184 %27
+ OpStore %140 %185
+ %187 = OpLoad %6 %140
+ OpStore %186 %187
+ OpStore %188 %30
+ %189 = OpFunctionCall %2 %18 %186 %188
+ %190 = OpLoad %6 %140
+ %191 = OpIAdd %6 %190 %27
+ OpStore %140 %191
+ %194 = OpLoad %6 %140
+ OpStore %193 %194
+ OpStore %195 %192
+ %196 = OpFunctionCall %2 %18 %193 %195
+ %197 = OpLoad %6 %140
+ %198 = OpIAdd %6 %197 %27
+ OpStore %140 %198
+ %201 = OpLoad %6 %140
+ OpStore %200 %201
+ OpStore %202 %199
+ %203 = OpFunctionCall %2 %18 %200 %202
+ %204 = OpLoad %6 %140
+ %205 = OpIAdd %6 %204 %27
+ OpStore %140 %205
+ %208 = OpLoad %6 %140
+ OpStore %207 %208
+ OpStore %209 %206
+ %210 = OpFunctionCall %2 %18 %207 %209
+ OpStore %211 %24
+ OpStore %212 %24
+ OpBranch %213
+ %213 = OpLabel
+ OpLoopMerge %215 %216 None
+ OpBranch %217
+ %217 = OpLabel
+ %218 = OpLoad %6 %212
+ %220 = OpSLessThan %40 %218 %219
+ OpBranchConditional %220 %214 %215
+ %214 = OpLabel
+ %223 = OpLoad %6 %212
+ OpStore %222 %223
+ %224 = OpFunctionCall %6 %22 %222
+ OpStore %221 %224
+ %225 = OpLoad %6 %212
+ OpSelectionMerge %228 None
+ OpSwitch %225 %227 9 %226 5 %226 12 %226 15 %226 7 %226 8 %226 2 %226 6 %226 17 %226 13 %226
+ %227 = OpLabel
+ %237 = OpLoad %6 %221
+ %238 = OpIEqual %40 %237 %28
+ OpSelectionMerge %240 None
+ OpBranchConditional %238 %239 %240
+ %239 = OpLabel
+ %241 = OpLoad %6 %211
+ %242 = OpIAdd %6 %241 %27
+ OpStore %211 %242
+ OpBranch %240
+ %240 = OpLabel
+ OpBranch %228
+ %226 = OpLabel
+ %229 = OpLoad %6 %221
+ %230 = OpLoad %6 %212
+ %231 = OpIEqual %40 %229 %230
+ OpSelectionMerge %233 None
+ OpBranchConditional %231 %232 %233
+ %232 = OpLabel
+ %234 = OpLoad %6 %211
+ %235 = OpIAdd %6 %234 %27
+ OpStore %211 %235
+ OpBranch %233
+ %233 = OpLabel
+ OpBranch %228
+ %228 = OpLabel
+ OpBranch %216
+ %216 = OpLabel
+ %245 = OpLoad %6 %212
+ %246 = OpIAdd %6 %245 %27
+ OpStore %212 %246
+ OpBranch %213
+ %215 = OpLabel
+ %247 = OpLoad %6 %211
+ %248 = OpIEqual %40 %247 %219
+ OpSelectionMerge %250 None
+ OpBranchConditional %248 %249 %258
+ %249 = OpLabel
+ OpStore %254 %257
+ OpBranch %250
+ %258 = OpLabel
+ OpStore %254 %259
+ OpBranch %250
+ %250 = OpLabel
+ OpReturn
+ OpFunctionEnd
+ %13 = OpFunction %2 None %10
+ %11 = OpFunctionParameter %8
+ %12 = OpFunctionParameter %9
+ %14 = OpLabel
+ %25 = OpLoad %6 %12
+ %26 = OpAccessChain %9 %11 %24
+ OpStore %26 %25
+ %29 = OpAccessChain %9 %11 %27
+ OpStore %29 %28
+ %31 = OpAccessChain %9 %11 %30
+ OpStore %31 %28
+ OpReturn
+ OpFunctionEnd
+ %18 = OpFunction %2 None %15
+ %16 = OpFunctionParameter %9
+ %17 = OpFunctionParameter %9
+ %19 = OpLabel
+ %32 = OpVariable %9 Function
+ %65 = OpVariable %8 Function
+ %69 = OpVariable %9 Function
+ %91 = OpVariable %8 Function
+ %94 = OpVariable %9 Function
+ OpStore %32 %24
+ OpBranch %33
+ %33 = OpLabel
+ OpLoopMerge %35 %36 None
+ OpBranch %37
+ %37 = OpLabel
+ %38 = OpLoad %6 %32
+ %39 = OpLoad %6 %16
+ %41 = OpSLessThanEqual %40 %38 %39
+ OpBranchConditional %41 %34 %35
+ %34 = OpLabel
+ %42 = OpLoad %6 %17
+ %48 = OpLoad %6 %32
+ %50 = OpAccessChain %49 %47 %48 %24
+ %51 = OpLoad %6 %50
+ %52 = OpSLessThanEqual %40 %42 %51
+ OpSelectionMerge %54 None
+ OpBranchConditional %52 %53 %80
+ %53 = OpLabel
+ %55 = OpLoad %6 %32
+ %56 = OpAccessChain %49 %47 %55 %27
+ %57 = OpLoad %6 %56
+ %58 = OpIEqual %40 %57 %28
+ OpSelectionMerge %60 None
+ OpBranchConditional %58 %59 %75
+ %59 = OpLabel
+ %61 = OpLoad %6 %32
+ %62 = OpLoad %6 %16
+ %63 = OpAccessChain %49 %47 %61 %27
+ OpStore %63 %62
+ %64 = OpLoad %6 %16
+ %67 = OpAccessChain %66 %47 %64
+ %68 = OpLoad %7 %67
+ OpStore %65 %68
+ %70 = OpLoad %6 %17
+ OpStore %69 %70
+ %71 = OpFunctionCall %2 %13 %65 %69
+ %72 = OpLoad %7 %65
+ %73 = OpAccessChain %66 %47 %64
+ OpStore %73 %72
+ OpReturn
+ %75 = OpLabel
+ %76 = OpLoad %6 %32
+ %77 = OpAccessChain %49 %47 %76 %27
+ %78 = OpLoad %6 %77
+ OpStore %32 %78
+ OpBranch %36
+ %60 = OpLabel
+ OpUnreachable
+ %80 = OpLabel
+ %81 = OpLoad %6 %32
+ %82 = OpAccessChain %49 %47 %81 %30
+ %83 = OpLoad %6 %82
+ %84 = OpIEqual %40 %83 %28
+ OpSelectionMerge %86 None
+ OpBranchConditional %84 %85 %100
+ %85 = OpLabel
+ %87 = OpLoad %6 %32
+ %88 = OpLoad %6 %16
+ %89 = OpAccessChain %49 %47 %87 %30
+ OpStore %89 %88
+ %90 = OpLoad %6 %16
+ %92 = OpAccessChain %66 %47 %90
+ %93 = OpLoad %7 %92
+ OpStore %91 %93
+ %95 = OpLoad %6 %17
+ OpStore %94 %95
+ %96 = OpFunctionCall %2 %13 %91 %94
+ %97 = OpLoad %7 %91
+ %98 = OpAccessChain %66 %47 %90
+ OpStore %98 %97
+ OpReturn
+ %100 = OpLabel
+ %101 = OpLoad %6 %32
+ %102 = OpAccessChain %49 %47 %101 %30
+ %103 = OpLoad %6 %102
+ OpStore %32 %103
+ OpBranch %36
+ %86 = OpLabel
+ OpUnreachable
+ %54 = OpLabel
+ OpUnreachable
+ %36 = OpLabel
+ OpBranch %33
+ %35 = OpLabel
+ OpReturn
+ OpFunctionEnd
+ %22 = OpFunction %6 None %20
+ %21 = OpFunctionParameter %9
+ %23 = OpLabel
+ %105 = OpVariable %9 Function
+ %113 = OpVariable %8 Function
+ %129 = OpVariable %9 Function
+ OpStore %105 %24
+ OpBranch %106
+ %106 = OpLabel
+ OpLoopMerge %108 %109 None
+ OpBranch %110
+ %110 = OpLabel
+ %111 = OpLoad %6 %105
+ %112 = OpINotEqual %40 %111 %28
+ OpBranchConditional %112 %107 %108
+ %107 = OpLabel
+ %114 = OpLoad %6 %105
+ %115 = OpAccessChain %66 %47 %114
+ %116 = OpLoad %7 %115
+ OpStore %113 %116
+ %117 = OpAccessChain %9 %113 %24
+ %118 = OpLoad %6 %117
+ %119 = OpLoad %6 %21
+ %120 = OpIEqual %40 %118 %119
+ OpSelectionMerge %122 None
+ OpBranchConditional %120 %121 %122
+ %121 = OpLabel
+ %123 = OpLoad %6 %21
+ OpReturnValue %123
+ %122 = OpLabel
+ %125 = OpLoad %6 %21
+ %126 = OpAccessChain %9 %113 %24
+ %127 = OpLoad %6 %126
+ %128 = OpSGreaterThan %40 %125 %127
+ OpSelectionMerge %131 None
+ OpBranchConditional %128 %130 %134
+ %130 = OpLabel
+ %132 = OpAccessChain %9 %113 %30
+ %133 = OpLoad %6 %132
+ OpStore %129 %133
+ OpBranch %131
+ %134 = OpLabel
+ %135 = OpAccessChain %9 %113 %27
+ %136 = OpLoad %6 %135
+ OpStore %129 %136
+ OpBranch %131
+ %131 = OpLabel
+ %137 = OpLoad %6 %129
+ OpStore %105 %137
+ OpBranch %109
+ %109 = OpLabel
+ OpBranch %106
+ %108 = OpLabel
+ OpReturnValue %28
+ OpFunctionEnd
+END
+
+
+BUFFER reference_framebuffer FORMAT B8G8R8A8_UNORM
+
+PIPELINE graphics reference_pipeline
+ ATTACH reference_vertex_shader
+ ATTACH reference_fragment_shader
+ FRAMEBUFFER_SIZE 256 256
+ BIND BUFFER reference_framebuffer AS color LOCATION 0
+END
+CLEAR_COLOR reference_pipeline 0 0 0 255
+
+CLEAR reference_pipeline
+RUN reference_pipeline DRAW_RECT POS 0 0 SIZE 256 256
+
+
+SHADER vertex variant_vertex_shader PASSTHROUGH
+
+# variant_fragment_shader is derived from the following GLSL:
+# #version 320 es
+# precision highp float;
+#
+# precision highp int;
+#
+# layout(location = 0) out vec4 _GLF_color;
+#
+# struct BST {
+# int data;
+# int leftIndex;
+# int rightIndex;
+# } ;
+#
+# BST tree[10];
+#
+# void makeTreeNode(inout BST tree, int data)
+# {
+# tree.data = data;
+# tree.leftIndex = - 1;
+# tree.rightIndex = - 1;
+# }
+# void insert(int treeIndex, int data)
+# {
+# int baseIndex = 0;
+# while(baseIndex <= treeIndex)
+# {
+# if(data <= tree[baseIndex].data)
+# {
+# if(tree[baseIndex].leftIndex == - 1)
+# {
+# tree[baseIndex].leftIndex = treeIndex;
+# makeTreeNode(tree[treeIndex], data);
+# return;
+# }
+# else
+# {
+# baseIndex = tree[baseIndex].leftIndex;
+# continue;
+# }
+# }
+# else
+# {
+# if(tree[baseIndex].rightIndex == - 1)
+# {
+# tree[baseIndex].rightIndex = treeIndex;
+# makeTreeNode(tree[treeIndex], data);
+# return;
+# }
+# else
+# {
+# baseIndex = tree[baseIndex].rightIndex;
+# continue;
+# }
+# }
+# }
+# }
+# int search(int target)
+# {
+# BST currentNode;
+# int index = 0;
+# while(index != - 1)
+# {
+# currentNode = tree[index];
+# if(currentNode.data == target)
+# {
+# return target;
+# }
+# index = target > currentNode.data ? currentNode.rightIndex : currentNode.leftIndex;
+# }
+# return - 1;
+# }
+# void main()
+# {
+# int treeIndex = 0;
+# makeTreeNode(tree[0], 9);
+# treeIndex ++;
+# insert(treeIndex, 5);
+# treeIndex ++;
+# insert(treeIndex, 12);
+# treeIndex ++;
+# insert(treeIndex, 15);
+# treeIndex ++;
+# insert(treeIndex, 7);
+# treeIndex ++;
+# insert(treeIndex, 8);
+# treeIndex ++;
+# insert(treeIndex, 2);
+# treeIndex ++;
+# insert(treeIndex, 6);
+# treeIndex ++;
+# insert(treeIndex, 17);
+# treeIndex ++;
+# insert(treeIndex, 13);
+# int count = 0;
+# for(int i = 0; i < 20; i ++)
+# {
+# int result = search(i);
+# switch(i)
+# {
+# case 9:
+# case 5:
+# case 12:
+# case 15:
+# case 7:
+# case 8:
+# case 2:
+# case 6:
+# case 17:
+# case 13:
+# // Always false: gl_Frag_Coord.x < 0.0
+# // Thus, the end result is the same as in the reference shader.
+# if((result == i) || (gl_FragCoord.x < 0.0))
+# {
+# count ++;
+# }
+# break;
+# default:
+# if(result == - 1)
+# {
+# count ++;
+# }
+# break;
+# }
+# }
+# if(count == 20)
+# {
+# _GLF_color = vec4(1.0, 0.0, 0.0, 1.0);
+# }
+# else
+# {
+# _GLF_color = vec4(0.0, 0.0, 1.0, 1.0);
+# }
+# }
+SHADER fragment variant_fragment_shader SPIRV-ASM
+; SPIR-V
+; Version: 1.0
+; Generator: Khronos Glslang Reference Front End; 10
+; Bound: 271
+; Schema: 0
+ OpCapability Shader
+ %1 = OpExtInstImport "GLSL.std.450"
+ OpMemoryModel Logical GLSL450
+ OpEntryPoint Fragment %4 "main" %238 %266
+ OpExecutionMode %4 OriginUpperLeft
+ OpSource ESSL 320
+ OpName %4 "main"
+ OpName %7 "BST"
+ OpMemberName %7 0 "data"
+ OpMemberName %7 1 "leftIndex"
+ OpMemberName %7 2 "rightIndex"
+ OpName %13 "makeTreeNode(struct-BST-i1-i1-i11;i1;"
+ OpName %11 "tree"
+ OpName %12 "data"
+ OpName %18 "insert(i1;i1;"
+ OpName %16 "treeIndex"
+ OpName %17 "data"
+ OpName %22 "search(i1;"
+ OpName %21 "target"
+ OpName %32 "baseIndex"
+ OpName %47 "tree"
+ OpName %65 "param"
+ OpName %69 "param"
+ OpName %91 "param"
+ OpName %94 "param"
+ OpName %105 "index"
+ OpName %113 "currentNode"
+ OpName %140 "treeIndex"
+ OpName %142 "param"
+ OpName %145 "param"
+ OpName %152 "param"
+ OpName %154 "param"
+ OpName %159 "param"
+ OpName %161 "param"
+ OpName %166 "param"
+ OpName %168 "param"
+ OpName %173 "param"
+ OpName %175 "param"
+ OpName %180 "param"
+ OpName %182 "param"
+ OpName %186 "param"
+ OpName %188 "param"
+ OpName %193 "param"
+ OpName %195 "param"
+ OpName %200 "param"
+ OpName %202 "param"
+ OpName %207 "param"
+ OpName %209 "param"
+ OpName %211 "count"
+ OpName %212 "i"
+ OpName %221 "result"
+ OpName %222 "param"
+ OpName %238 "gl_FragCoord"
+ OpName %266 "_GLF_color"
+ OpDecorate %238 BuiltIn FragCoord
+ OpDecorate %266 Location 0
+ %2 = OpTypeVoid
+ %3 = OpTypeFunction %2
+ %6 = OpTypeInt 32 1
+ %7 = OpTypeStruct %6 %6 %6
+ %8 = OpTypePointer Function %7
+ %9 = OpTypePointer Function %6
+ %10 = OpTypeFunction %2 %8 %9
+ %15 = OpTypeFunction %2 %9 %9
+ %20 = OpTypeFunction %6 %9
+ %24 = OpConstant %6 0
+ %27 = OpConstant %6 1
+ %28 = OpConstant %6 -1
+ %30 = OpConstant %6 2
+ %40 = OpTypeBool
+ %43 = OpTypeInt 32 0
+ %44 = OpConstant %43 10
+ %45 = OpTypeArray %7 %44
+ %46 = OpTypePointer Private %45
+ %47 = OpVariable %46 Private
+ %49 = OpTypePointer Private %6
+ %66 = OpTypePointer Private %7
+ %141 = OpConstant %6 9
+ %151 = OpConstant %6 5
+ %158 = OpConstant %6 12
+ %165 = OpConstant %6 15
+ %172 = OpConstant %6 7
+ %179 = OpConstant %6 8
+ %192 = OpConstant %6 6
+ %199 = OpConstant %6 17
+ %206 = OpConstant %6 13
+ %219 = OpConstant %6 20
+ %235 = OpTypeFloat 32
+ %236 = OpTypeVector %235 4
+ %237 = OpTypePointer Input %236
+ %238 = OpVariable %237 Input
+ %239 = OpConstant %43 0
+ %240 = OpTypePointer Input %235
+ %243 = OpConstant %235 0
+ %265 = OpTypePointer Output %236
+ %266 = OpVariable %265 Output
+ %267 = OpConstant %235 1
+ %268 = OpConstantComposite %236 %267 %243 %243 %267
+ %270 = OpConstantComposite %236 %243 %243 %267 %267
+ %4 = OpFunction %2 None %3
+ %5 = OpLabel
+ %140 = OpVariable %9 Function
+ %142 = OpVariable %8 Function
+ %145 = OpVariable %9 Function
+ %152 = OpVariable %9 Function
+ %154 = OpVariable %9 Function
+ %159 = OpVariable %9 Function
+ %161 = OpVariable %9 Function
+ %166 = OpVariable %9 Function
+ %168 = OpVariable %9 Function
+ %173 = OpVariable %9 Function
+ %175 = OpVariable %9 Function
+ %180 = OpVariable %9 Function
+ %182 = OpVariable %9 Function
+ %186 = OpVariable %9 Function
+ %188 = OpVariable %9 Function
+ %193 = OpVariable %9 Function
+ %195 = OpVariable %9 Function
+ %200 = OpVariable %9 Function
+ %202 = OpVariable %9 Function
+ %207 = OpVariable %9 Function
+ %209 = OpVariable %9 Function
+ %211 = OpVariable %9 Function
+ %212 = OpVariable %9 Function
+ %221 = OpVariable %9 Function
+ %222 = OpVariable %9 Function
+ OpStore %140 %24
+ %143 = OpAccessChain %66 %47 %24
+ %144 = OpLoad %7 %143
+ OpStore %142 %144
+ OpStore %145 %141
+ %146 = OpFunctionCall %2 %13 %142 %145
+ %147 = OpLoad %7 %142
+ %148 = OpAccessChain %66 %47 %24
+ OpStore %148 %147
+ %149 = OpLoad %6 %140
+ %150 = OpIAdd %6 %149 %27
+ OpStore %140 %150
+ %153 = OpLoad %6 %140
+ OpStore %152 %153
+ OpStore %154 %151
+ %155 = OpFunctionCall %2 %18 %152 %154
+ %156 = OpLoad %6 %140
+ %157 = OpIAdd %6 %156 %27
+ OpStore %140 %157
+ %160 = OpLoad %6 %140
+ OpStore %159 %160
+ OpStore %161 %158
+ %162 = OpFunctionCall %2 %18 %159 %161
+ %163 = OpLoad %6 %140
+ %164 = OpIAdd %6 %163 %27
+ OpStore %140 %164
+ %167 = OpLoad %6 %140
+ OpStore %166 %167
+ OpStore %168 %165
+ %169 = OpFunctionCall %2 %18 %166 %168
+ %170 = OpLoad %6 %140
+ %171 = OpIAdd %6 %170 %27
+ OpStore %140 %171
+ %174 = OpLoad %6 %140
+ OpStore %173 %174
+ OpStore %175 %172
+ %176 = OpFunctionCall %2 %18 %173 %175
+ %177 = OpLoad %6 %140
+ %178 = OpIAdd %6 %177 %27
+ OpStore %140 %178
+ %181 = OpLoad %6 %140
+ OpStore %180 %181
+ OpStore %182 %179
+ %183 = OpFunctionCall %2 %18 %180 %182
+ %184 = OpLoad %6 %140
+ %185 = OpIAdd %6 %184 %27
+ OpStore %140 %185
+ %187 = OpLoad %6 %140
+ OpStore %186 %187
+ OpStore %188 %30
+ %189 = OpFunctionCall %2 %18 %186 %188
+ %190 = OpLoad %6 %140
+ %191 = OpIAdd %6 %190 %27
+ OpStore %140 %191
+ %194 = OpLoad %6 %140
+ OpStore %193 %194
+ OpStore %195 %192
+ %196 = OpFunctionCall %2 %18 %193 %195
+ %197 = OpLoad %6 %140
+ %198 = OpIAdd %6 %197 %27
+ OpStore %140 %198
+ %201 = OpLoad %6 %140
+ OpStore %200 %201
+ OpStore %202 %199
+ %203 = OpFunctionCall %2 %18 %200 %202
+ %204 = OpLoad %6 %140
+ %205 = OpIAdd %6 %204 %27
+ OpStore %140 %205
+ %208 = OpLoad %6 %140
+ OpStore %207 %208
+ OpStore %209 %206
+ %210 = OpFunctionCall %2 %18 %207 %209
+ OpStore %211 %24
+ OpStore %212 %24
+ OpBranch %213
+ %213 = OpLabel
+ OpLoopMerge %215 %216 None
+ OpBranch %217
+ %217 = OpLabel
+ %218 = OpLoad %6 %212
+ %220 = OpSLessThan %40 %218 %219
+ OpBranchConditional %220 %214 %215
+ %214 = OpLabel
+ %223 = OpLoad %6 %212
+ OpStore %222 %223
+ %224 = OpFunctionCall %6 %22 %222
+ OpStore %221 %224
+ %225 = OpLoad %6 %212
+ OpSelectionMerge %228 None
+ OpSwitch %225 %227 9 %226 5 %226 12 %226 15 %226 7 %226 8 %226 2 %226 6 %226 17 %226 13 %226
+ %227 = OpLabel
+ %251 = OpLoad %6 %221
+ %252 = OpIEqual %40 %251 %28
+ OpSelectionMerge %254 None
+ OpBranchConditional %252 %253 %254
+ %253 = OpLabel
+ %255 = OpLoad %6 %211
+ %256 = OpIAdd %6 %255 %27
+ OpStore %211 %256
+ OpBranch %254
+ %254 = OpLabel
+ OpBranch %228
+ %226 = OpLabel
+ %229 = OpLoad %6 %221
+ %230 = OpLoad %6 %212
+ %231 = OpIEqual %40 %229 %230
+ %232 = OpLogicalNot %40 %231
+ OpSelectionMerge %234 None
+ OpBranchConditional %232 %233 %234
+ %233 = OpLabel
+ %241 = OpAccessChain %240 %238 %239
+ %242 = OpLoad %235 %241
+ %244 = OpFOrdLessThan %40 %242 %243
+ OpBranch %234
+ %234 = OpLabel
+ %245 = OpPhi %40 %231 %226 %244 %233
+ OpSelectionMerge %247 None
+ OpBranchConditional %245 %246 %247
+ %246 = OpLabel
+ %248 = OpLoad %6 %211
+ %249 = OpIAdd %6 %248 %27
+ OpStore %211 %249
+ OpBranch %247
+ %247 = OpLabel
+ OpBranch %228
+ %228 = OpLabel
+ OpBranch %216
+ %216 = OpLabel
+ %259 = OpLoad %6 %212
+ %260 = OpIAdd %6 %259 %27
+ OpStore %212 %260
+ OpBranch %213
+ %215 = OpLabel
+ %261 = OpLoad %6 %211
+ %262 = OpIEqual %40 %261 %219
+ OpSelectionMerge %264 None
+ OpBranchConditional %262 %263 %269
+ %263 = OpLabel
+ OpStore %266 %268
+ OpBranch %264
+ %269 = OpLabel
+ OpStore %266 %270
+ OpBranch %264
+ %264 = OpLabel
+ OpReturn
+ OpFunctionEnd
+ %13 = OpFunction %2 None %10
+ %11 = OpFunctionParameter %8
+ %12 = OpFunctionParameter %9
+ %14 = OpLabel
+ %25 = OpLoad %6 %12
+ %26 = OpAccessChain %9 %11 %24
+ OpStore %26 %25
+ %29 = OpAccessChain %9 %11 %27
+ OpStore %29 %28
+ %31 = OpAccessChain %9 %11 %30
+ OpStore %31 %28
+ OpReturn
+ OpFunctionEnd
+ %18 = OpFunction %2 None %15
+ %16 = OpFunctionParameter %9
+ %17 = OpFunctionParameter %9
+ %19 = OpLabel
+ %32 = OpVariable %9 Function
+ %65 = OpVariable %8 Function
+ %69 = OpVariable %9 Function
+ %91 = OpVariable %8 Function
+ %94 = OpVariable %9 Function
+ OpStore %32 %24
+ OpBranch %33
+ %33 = OpLabel
+ OpLoopMerge %35 %36 None
+ OpBranch %37
+ %37 = OpLabel
+ %38 = OpLoad %6 %32
+ %39 = OpLoad %6 %16
+ %41 = OpSLessThanEqual %40 %38 %39
+ OpBranchConditional %41 %34 %35
+ %34 = OpLabel
+ %42 = OpLoad %6 %17
+ %48 = OpLoad %6 %32
+ %50 = OpAccessChain %49 %47 %48 %24
+ %51 = OpLoad %6 %50
+ %52 = OpSLessThanEqual %40 %42 %51
+ OpSelectionMerge %54 None
+ OpBranchConditional %52 %53 %80
+ %53 = OpLabel
+ %55 = OpLoad %6 %32
+ %56 = OpAccessChain %49 %47 %55 %27
+ %57 = OpLoad %6 %56
+ %58 = OpIEqual %40 %57 %28
+ OpSelectionMerge %60 None
+ OpBranchConditional %58 %59 %75
+ %59 = OpLabel
+ %61 = OpLoad %6 %32
+ %62 = OpLoad %6 %16
+ %63 = OpAccessChain %49 %47 %61 %27
+ OpStore %63 %62
+ %64 = OpLoad %6 %16
+ %67 = OpAccessChain %66 %47 %64
+ %68 = OpLoad %7 %67
+ OpStore %65 %68
+ %70 = OpLoad %6 %17
+ OpStore %69 %70
+ %71 = OpFunctionCall %2 %13 %65 %69
+ %72 = OpLoad %7 %65
+ %73 = OpAccessChain %66 %47 %64
+ OpStore %73 %72
+ OpReturn
+ %75 = OpLabel
+ %76 = OpLoad %6 %32
+ %77 = OpAccessChain %49 %47 %76 %27
+ %78 = OpLoad %6 %77
+ OpStore %32 %78
+ OpBranch %36
+ %60 = OpLabel
+ OpUnreachable
+ %80 = OpLabel
+ %81 = OpLoad %6 %32
+ %82 = OpAccessChain %49 %47 %81 %30
+ %83 = OpLoad %6 %82
+ %84 = OpIEqual %40 %83 %28
+ OpSelectionMerge %86 None
+ OpBranchConditional %84 %85 %100
+ %85 = OpLabel
+ %87 = OpLoad %6 %32
+ %88 = OpLoad %6 %16
+ %89 = OpAccessChain %49 %47 %87 %30
+ OpStore %89 %88
+ %90 = OpLoad %6 %16
+ %92 = OpAccessChain %66 %47 %90
+ %93 = OpLoad %7 %92
+ OpStore %91 %93
+ %95 = OpLoad %6 %17
+ OpStore %94 %95
+ %96 = OpFunctionCall %2 %13 %91 %94
+ %97 = OpLoad %7 %91
+ %98 = OpAccessChain %66 %47 %90
+ OpStore %98 %97
+ OpReturn
+ %100 = OpLabel
+ %101 = OpLoad %6 %32
+ %102 = OpAccessChain %49 %47 %101 %30
+ %103 = OpLoad %6 %102
+ OpStore %32 %103
+ OpBranch %36
+ %86 = OpLabel
+ OpUnreachable
+ %54 = OpLabel
+ OpUnreachable
+ %36 = OpLabel
+ OpBranch %33
+ %35 = OpLabel
+ OpReturn
+ OpFunctionEnd
+ %22 = OpFunction %6 None %20
+ %21 = OpFunctionParameter %9
+ %23 = OpLabel
+ %105 = OpVariable %9 Function
+ %113 = OpVariable %8 Function
+ %129 = OpVariable %9 Function
+ OpStore %105 %24
+ OpBranch %106
+ %106 = OpLabel
+ OpLoopMerge %108 %109 None
+ OpBranch %110
+ %110 = OpLabel
+ %111 = OpLoad %6 %105
+ %112 = OpINotEqual %40 %111 %28
+ OpBranchConditional %112 %107 %108
+ %107 = OpLabel
+ %114 = OpLoad %6 %105
+ %115 = OpAccessChain %66 %47 %114
+ %116 = OpLoad %7 %115
+ OpStore %113 %116
+ %117 = OpAccessChain %9 %113 %24
+ %118 = OpLoad %6 %117
+ %119 = OpLoad %6 %21
+ %120 = OpIEqual %40 %118 %119
+ OpSelectionMerge %122 None
+ OpBranchConditional %120 %121 %122
+ %121 = OpLabel
+ %123 = OpLoad %6 %21
+ OpReturnValue %123
+ %122 = OpLabel
+ %125 = OpLoad %6 %21
+ %126 = OpAccessChain %9 %113 %24
+ %127 = OpLoad %6 %126
+ %128 = OpSGreaterThan %40 %125 %127
+ OpSelectionMerge %131 None
+ OpBranchConditional %128 %130 %134
+ %130 = OpLabel
+ %132 = OpAccessChain %9 %113 %30
+ %133 = OpLoad %6 %132
+ OpStore %129 %133
+ OpBranch %131
+ %134 = OpLabel
+ %135 = OpAccessChain %9 %113 %27
+ %136 = OpLoad %6 %135
+ OpStore %129 %136
+ OpBranch %131
+ %131 = OpLabel
+ %137 = OpLoad %6 %129
+ OpStore %105 %137
+ OpBranch %109
+ %109 = OpLabel
+ OpBranch %106
+ %108 = OpLabel
+ OpReturnValue %28
+ OpFunctionEnd
+END
+
+
+BUFFER variant_framebuffer FORMAT B8G8R8A8_UNORM
+
+PIPELINE graphics variant_pipeline
+ ATTACH variant_vertex_shader
+ ATTACH variant_fragment_shader
+ FRAMEBUFFER_SIZE 256 256
+ BIND BUFFER variant_framebuffer AS color LOCATION 0
+END
+CLEAR_COLOR variant_pipeline 0 0 0 255
+
+CLEAR variant_pipeline
+RUN variant_pipeline DRAW_RECT POS 0 0 SIZE 256 256
+
+EXPECT reference_framebuffer EQ_HISTOGRAM_EMD_BUFFER variant_framebuffer TOLERANCE 0.005
--- /dev/null
+#!amber
+
+# Copyright 2020 Google LLC
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+
+# A test for a bug found by the GraphicsFuzz project.
+
+# Short description: A fragment shader with two always false discards
+
+# The test passes because both shaders render the same image.
+
+# Optimized using spirv-opt with the following arguments:
+# '-O'
+# spirv-opt commit hash: 717e7877cac15d393fd3bb1bd872679de8b59add
+
+
+
+SHADER vertex reference_vertex_shader PASSTHROUGH
+
+# reference_fragment_shader is derived from the following GLSL:
+# #version 320 es
+# precision highp float;
+#
+# precision highp int;
+#
+# layout(location = 0) out vec4 _GLF_color;
+#
+# layout(set = 0, binding = 0) uniform buf0
+# {
+# vec2 resolution;
+# };
+# float compute_value(float limit, float thirty_two)
+# {
+# float result = -0.5;
+# for (int i = 1; i < 800; i++)
+# {
+# if ((i % 32) == 0)
+# {
+# result += 0.4;
+# }
+# else
+# {
+# if (mod(float(i), round(thirty_two)) <= 0.01)
+# {
+# result += 100.0;
+# }
+# }
+# if (float(i) >= limit)
+# {
+# return result;
+# }
+# }
+# return result;
+# }
+# void main()
+# {
+# vec3 c = vec3(7.0, 8.0, 9.0);
+# float thirty_two = round(resolution.x / 8.0);
+# c.x = compute_value(gl_FragCoord.x, thirty_two);
+# c.y = compute_value(gl_FragCoord.y, thirty_two);
+# c.z = c.x + c.y;
+# for (int i = 0; i < 3; i++)
+# {
+# if (c[i] >= 1.0)
+# {
+# c[i] = c[i] * c[i];
+# }
+# }
+# _GLF_color = vec4(normalize(abs(c)), 1.0);
+# }
+SHADER fragment reference_fragment_shader SPIRV-ASM TARGET_ENV spv1.0
+; SPIR-V
+; Version: 1.0
+; Generator: Khronos Glslang Reference Front End; 10
+; Bound: 290
+; Schema: 0
+ OpCapability Shader
+ %1 = OpExtInstImport "GLSL.std.450"
+ OpMemoryModel Logical GLSL450
+ OpEntryPoint Fragment %4 "main" %85 %137
+ OpExecutionMode %4 OriginUpperLeft
+ OpSource ESSL 320
+ OpName %4 "main"
+ OpName %66 "c"
+ OpName %73 "buf0"
+ OpMemberName %73 0 "resolution"
+ OpName %75 ""
+ OpName %85 "gl_FragCoord"
+ OpName %137 "_GLF_color"
+ OpMemberDecorate %73 0 Offset 0
+ OpDecorate %73 Block
+ OpDecorate %75 DescriptorSet 0
+ OpDecorate %75 Binding 0
+ OpDecorate %85 BuiltIn FragCoord
+ OpDecorate %137 Location 0
+ %2 = OpTypeVoid
+ %3 = OpTypeFunction %2
+ %6 = OpTypeFloat 32
+ %7 = OpTypePointer Function %6
+ %14 = OpConstant %6 -0.5
+ %15 = OpTypeInt 32 1
+ %18 = OpConstant %15 1
+ %25 = OpConstant %15 800
+ %26 = OpTypeBool
+ %29 = OpConstant %15 32
+ %31 = OpConstant %15 0
+ %35 = OpConstant %6 0.400000006
+ %44 = OpConstant %6 0.00999999978
+ %48 = OpConstant %6 100
+ %64 = OpTypeVector %6 3
+ %65 = OpTypePointer Function %64
+ %67 = OpConstant %6 7
+ %68 = OpConstant %6 8
+ %69 = OpConstant %6 9
+ %70 = OpConstantComposite %64 %67 %68 %69
+ %72 = OpTypeVector %6 2
+ %73 = OpTypeStruct %72
+ %74 = OpTypePointer Uniform %73
+ %75 = OpVariable %74 Uniform
+ %76 = OpTypeInt 32 0
+ %77 = OpConstant %76 0
+ %78 = OpTypePointer Uniform %6
+ %83 = OpTypeVector %6 4
+ %84 = OpTypePointer Input %83
+ %85 = OpVariable %84 Input
+ %87 = OpTypePointer Input %6
+ %95 = OpConstant %76 1
+ %107 = OpConstant %76 2
+ %116 = OpConstant %15 3
+ %121 = OpConstant %6 1
+ %136 = OpTypePointer Output %83
+ %137 = OpVariable %136 Output
+ %149 = OpConstantFalse %26
+ %152 = OpConstantTrue %26
+ %261 = OpUndef %6
+ %289 = OpConstant %6 0.125
+ %4 = OpFunction %2 None %3
+ %5 = OpLabel
+ %66 = OpVariable %65 Function
+ OpStore %66 %70
+ %79 = OpAccessChain %78 %75 %31 %77
+ %80 = OpLoad %6 %79
+ %81 = OpFMul %6 %80 %289
+ %82 = OpExtInst %6 %1 Round %81
+ %88 = OpAccessChain %87 %85 %77
+ %89 = OpLoad %6 %88
+ OpSelectionMerge %199 None
+ OpSwitch %77 %161
+ %161 = OpLabel
+ OpBranch %162
+ %162 = OpLabel
+ %248 = OpPhi %6 %14 %161 %251 %192
+ %247 = OpPhi %15 %18 %161 %194 %192
+ %165 = OpSLessThan %26 %247 %25
+ OpLoopMerge %195 %192 None
+ OpBranchConditional %165 %166 %195
+ %166 = OpLabel
+ %168 = OpSMod %15 %247 %29
+ %169 = OpIEqual %26 %168 %31
+ OpSelectionMerge %184 None
+ OpBranchConditional %169 %170 %173
+ %170 = OpLabel
+ %172 = OpFAdd %6 %248 %35
+ OpBranch %184
+ %173 = OpLabel
+ %175 = OpConvertSToF %6 %247
+ %177 = OpExtInst %6 %1 Round %82
+ %178 = OpFMod %6 %175 %177
+ %179 = OpFOrdLessThanEqual %26 %178 %44
+ OpSelectionMerge %183 None
+ OpBranchConditional %179 %180 %183
+ %180 = OpLabel
+ %182 = OpFAdd %6 %248 %48
+ OpBranch %183
+ %183 = OpLabel
+ %252 = OpPhi %6 %248 %173 %182 %180
+ OpBranch %184
+ %184 = OpLabel
+ %251 = OpPhi %6 %172 %170 %252 %183
+ %186 = OpConvertSToF %6 %247
+ %188 = OpFOrdGreaterThanEqual %26 %186 %89
+ OpSelectionMerge %191 None
+ OpBranchConditional %188 %189 %191
+ %189 = OpLabel
+ OpBranch %195
+ %191 = OpLabel
+ OpBranch %192
+ %192 = OpLabel
+ %194 = OpIAdd %15 %247 %18
+ OpBranch %162
+ %195 = OpLabel
+ %259 = OpPhi %6 %261 %162 %251 %189
+ %257 = OpPhi %6 %248 %162 %251 %189
+ %253 = OpPhi %26 %149 %162 %152 %189
+ OpSelectionMerge %197 None
+ OpBranchConditional %253 %199 %197
+ %197 = OpLabel
+ OpBranch %199
+ %199 = OpLabel
+ %258 = OpPhi %6 %259 %195 %257 %197
+ %93 = OpAccessChain %7 %66 %77
+ OpStore %93 %258
+ %96 = OpAccessChain %87 %85 %95
+ %97 = OpLoad %6 %96
+ OpSelectionMerge %245 None
+ OpSwitch %77 %207
+ %207 = OpLabel
+ OpBranch %208
+ %208 = OpLabel
+ %265 = OpPhi %6 %14 %207 %268 %238
+ %264 = OpPhi %15 %18 %207 %240 %238
+ %211 = OpSLessThan %26 %264 %25
+ OpLoopMerge %241 %238 None
+ OpBranchConditional %211 %212 %241
+ %212 = OpLabel
+ %214 = OpSMod %15 %264 %29
+ %215 = OpIEqual %26 %214 %31
+ OpSelectionMerge %230 None
+ OpBranchConditional %215 %216 %219
+ %216 = OpLabel
+ %218 = OpFAdd %6 %265 %35
+ OpBranch %230
+ %219 = OpLabel
+ %221 = OpConvertSToF %6 %264
+ %223 = OpExtInst %6 %1 Round %82
+ %224 = OpFMod %6 %221 %223
+ %225 = OpFOrdLessThanEqual %26 %224 %44
+ OpSelectionMerge %229 None
+ OpBranchConditional %225 %226 %229
+ %226 = OpLabel
+ %228 = OpFAdd %6 %265 %48
+ OpBranch %229
+ %229 = OpLabel
+ %269 = OpPhi %6 %265 %219 %228 %226
+ OpBranch %230
+ %230 = OpLabel
+ %268 = OpPhi %6 %218 %216 %269 %229
+ %232 = OpConvertSToF %6 %264
+ %234 = OpFOrdGreaterThanEqual %26 %232 %97
+ OpSelectionMerge %237 None
+ OpBranchConditional %234 %235 %237
+ %235 = OpLabel
+ OpBranch %241
+ %237 = OpLabel
+ OpBranch %238
+ %238 = OpLabel
+ %240 = OpIAdd %15 %264 %18
+ OpBranch %208
+ %241 = OpLabel
+ %276 = OpPhi %6 %261 %208 %268 %235
+ %274 = OpPhi %6 %265 %208 %268 %235
+ %270 = OpPhi %26 %149 %208 %152 %235
+ OpSelectionMerge %243 None
+ OpBranchConditional %270 %245 %243
+ %243 = OpLabel
+ OpBranch %245
+ %245 = OpLabel
+ %275 = OpPhi %6 %276 %241 %274 %243
+ %101 = OpAccessChain %7 %66 %95
+ OpStore %101 %275
+ %103 = OpLoad %6 %93
+ %105 = OpLoad %6 %101
+ %106 = OpFAdd %6 %103 %105
+ %108 = OpAccessChain %7 %66 %107
+ OpStore %108 %106
+ OpBranch %110
+ %110 = OpLabel
+ %285 = OpPhi %15 %31 %245 %135 %113
+ %117 = OpSLessThan %26 %285 %116
+ OpLoopMerge %112 %113 None
+ OpBranchConditional %117 %111 %112
+ %111 = OpLabel
+ %119 = OpAccessChain %7 %66 %285
+ %120 = OpLoad %6 %119
+ %122 = OpFOrdGreaterThanEqual %26 %120 %121
+ OpSelectionMerge %124 None
+ OpBranchConditional %122 %123 %124
+ %123 = OpLabel
+ %128 = OpLoad %6 %119
+ %131 = OpLoad %6 %119
+ %132 = OpFMul %6 %128 %131
+ OpStore %119 %132
+ OpBranch %124
+ %124 = OpLabel
+ OpBranch %113
+ %113 = OpLabel
+ %135 = OpIAdd %15 %285 %18
+ OpBranch %110
+ %112 = OpLabel
+ %138 = OpLoad %64 %66
+ %139 = OpExtInst %64 %1 FAbs %138
+ %140 = OpExtInst %64 %1 Normalize %139
+ %141 = OpCompositeExtract %6 %140 0
+ %142 = OpCompositeExtract %6 %140 1
+ %143 = OpCompositeExtract %6 %140 2
+ %144 = OpCompositeConstruct %83 %141 %142 %143 %121
+ OpStore %137 %144
+ OpReturn
+ OpFunctionEnd
+END
+
+# uniforms for reference
+
+# resolution
+BUFFER reference_resolution DATA_TYPE vec2<float> STD140 DATA
+ 256.0 256.0
+END
+
+BUFFER reference_framebuffer FORMAT B8G8R8A8_UNORM
+
+PIPELINE graphics reference_pipeline
+ ATTACH reference_vertex_shader
+ ATTACH reference_fragment_shader
+ FRAMEBUFFER_SIZE 256 256
+ BIND BUFFER reference_framebuffer AS color LOCATION 0
+ BIND BUFFER reference_resolution AS uniform DESCRIPTOR_SET 0 BINDING 0
+END
+CLEAR_COLOR reference_pipeline 0 0 0 255
+
+CLEAR reference_pipeline
+RUN reference_pipeline DRAW_RECT POS 0 0 SIZE 256 256
+
+
+SHADER vertex variant_vertex_shader PASSTHROUGH
+
+# variant_fragment_shader is derived from the following GLSL:
+# #version 320 es
+# precision highp float;
+#
+# precision highp int;
+#
+# layout(location = 0) out vec4 _GLF_color;
+#
+# layout(set = 0, binding = 0) uniform buf0
+# {
+# vec2 resolution;
+# };
+# layout(set = 0, binding = 1) uniform buf1
+# {
+# vec2 injectionSwitch; // x == 0.0, y == 1.0
+# };
+# float compute_value(float limit, float thirty_two)
+# {
+# float result = -0.5;
+# for (int i = 1; i < 800; i++)
+# {
+# if ((i % 32) == 0)
+# {
+# result += 0.4;
+# }
+# else
+# {
+# if (mod(float(i), round(thirty_two)) <= 0.01)
+# {
+# result += 100.0;
+# }
+# // Always false.
+# if (injectionSwitch.x > injectionSwitch.y)
+# {
+# discard;
+# }
+# }
+# if (float(i) >= limit)
+# {
+# return result;
+# }
+# }
+# return result;
+# }
+# void main()
+# {
+# vec3 c = vec3(7.0, 8.0, 9.0);
+# float thirty_two = round(resolution.x / 8.0);
+# c.x = compute_value(gl_FragCoord.x, thirty_two);
+# c.y = compute_value(gl_FragCoord.y, thirty_two);
+# c.z = c.x + c.y;
+# for (int i = 0; i < 3; i++)
+# {
+# if (c[i] >= 1.0)
+# {
+# c[i] = c[i] * c[i];
+# // Always false.
+# if ((injectionSwitch.x > injectionSwitch.y))
+# {
+# discard;
+# }
+# }
+# }
+# _GLF_color = vec4(normalize(abs(c)), 1.0);
+# }
+SHADER fragment variant_fragment_shader SPIRV-ASM TARGET_ENV spv1.0
+; SPIR-V
+; Version: 1.0
+; Generator: Khronos Glslang Reference Front End; 10
+; Bound: 325
+; Schema: 0
+ OpCapability Shader
+ %1 = OpExtInstImport "GLSL.std.450"
+ OpMemoryModel Logical GLSL450
+ OpEntryPoint Fragment %4 "main" %97 %156
+ OpExecutionMode %4 OriginUpperLeft
+ OpSource ESSL 320
+ OpName %4 "main"
+ OpName %52 "buf1"
+ OpMemberName %52 0 "injectionSwitch"
+ OpName %54 ""
+ OpName %82 "c"
+ OpName %88 "buf0"
+ OpMemberName %88 0 "resolution"
+ OpName %90 ""
+ OpName %97 "gl_FragCoord"
+ OpName %156 "_GLF_color"
+ OpMemberDecorate %52 0 Offset 0
+ OpDecorate %52 Block
+ OpDecorate %54 DescriptorSet 0
+ OpDecorate %54 Binding 1
+ OpMemberDecorate %88 0 Offset 0
+ OpDecorate %88 Block
+ OpDecorate %90 DescriptorSet 0
+ OpDecorate %90 Binding 0
+ OpDecorate %97 BuiltIn FragCoord
+ OpDecorate %156 Location 0
+ %2 = OpTypeVoid
+ %3 = OpTypeFunction %2
+ %6 = OpTypeFloat 32
+ %7 = OpTypePointer Function %6
+ %14 = OpConstant %6 -0.5
+ %15 = OpTypeInt 32 1
+ %18 = OpConstant %15 1
+ %25 = OpConstant %15 800
+ %26 = OpTypeBool
+ %29 = OpConstant %15 32
+ %31 = OpConstant %15 0
+ %35 = OpConstant %6 0.400000006
+ %44 = OpConstant %6 0.00999999978
+ %48 = OpConstant %6 100
+ %51 = OpTypeVector %6 2
+ %52 = OpTypeStruct %51
+ %53 = OpTypePointer Uniform %52
+ %54 = OpVariable %53 Uniform
+ %55 = OpTypeInt 32 0
+ %56 = OpConstant %55 0
+ %57 = OpTypePointer Uniform %6
+ %60 = OpConstant %55 1
+ %80 = OpTypeVector %6 3
+ %81 = OpTypePointer Function %80
+ %83 = OpConstant %6 7
+ %84 = OpConstant %6 8
+ %85 = OpConstant %6 9
+ %86 = OpConstantComposite %80 %83 %84 %85
+ %88 = OpTypeStruct %51
+ %89 = OpTypePointer Uniform %88
+ %90 = OpVariable %89 Uniform
+ %95 = OpTypeVector %6 4
+ %96 = OpTypePointer Input %95
+ %97 = OpVariable %96 Input
+ %99 = OpTypePointer Input %6
+ %118 = OpConstant %55 2
+ %127 = OpConstant %15 3
+ %132 = OpConstant %6 1
+ %155 = OpTypePointer Output %95
+ %156 = OpVariable %155 Output
+ %168 = OpConstantFalse %26
+ %171 = OpConstantTrue %26
+ %296 = OpUndef %6
+ %324 = OpConstant %6 0.125
+ %4 = OpFunction %2 None %3
+ %5 = OpLabel
+ %82 = OpVariable %81 Function
+ OpStore %82 %86
+ %91 = OpAccessChain %57 %90 %31 %56
+ %92 = OpLoad %6 %91
+ %93 = OpFMul %6 %92 %324
+ %94 = OpExtInst %6 %1 Round %93
+ %100 = OpAccessChain %99 %97 %56
+ %101 = OpLoad %6 %100
+ OpSelectionMerge %225 None
+ OpSwitch %56 %180
+ %180 = OpLabel
+ OpBranch %181
+ %181 = OpLabel
+ %283 = OpPhi %6 %14 %180 %286 %218
+ %282 = OpPhi %15 %18 %180 %220 %218
+ %184 = OpSLessThan %26 %282 %25
+ OpLoopMerge %221 %218 None
+ OpBranchConditional %184 %185 %221
+ %185 = OpLabel
+ %187 = OpSMod %15 %282 %29
+ %188 = OpIEqual %26 %187 %31
+ OpSelectionMerge %210 None
+ OpBranchConditional %188 %189 %192
+ %189 = OpLabel
+ %191 = OpFAdd %6 %283 %35
+ OpBranch %210
+ %192 = OpLabel
+ %194 = OpConvertSToF %6 %282
+ %196 = OpExtInst %6 %1 Round %94
+ %197 = OpFMod %6 %194 %196
+ %198 = OpFOrdLessThanEqual %26 %197 %44
+ OpSelectionMerge %202 None
+ OpBranchConditional %198 %199 %202
+ %199 = OpLabel
+ %201 = OpFAdd %6 %283 %48
+ OpBranch %202
+ %202 = OpLabel
+ %287 = OpPhi %6 %283 %192 %201 %199
+ %203 = OpAccessChain %57 %54 %31 %56
+ %204 = OpLoad %6 %203
+ %205 = OpAccessChain %57 %54 %31 %60
+ %206 = OpLoad %6 %205
+ %207 = OpFOrdGreaterThan %26 %204 %206
+ OpSelectionMerge %209 None
+ OpBranchConditional %207 %208 %209
+ %208 = OpLabel
+ OpKill
+ %209 = OpLabel
+ OpBranch %210
+ %210 = OpLabel
+ %286 = OpPhi %6 %191 %189 %287 %209
+ %212 = OpConvertSToF %6 %282
+ %214 = OpFOrdGreaterThanEqual %26 %212 %101
+ OpSelectionMerge %217 None
+ OpBranchConditional %214 %215 %217
+ %215 = OpLabel
+ OpBranch %221
+ %217 = OpLabel
+ OpBranch %218
+ %218 = OpLabel
+ %220 = OpIAdd %15 %282 %18
+ OpBranch %181
+ %221 = OpLabel
+ %294 = OpPhi %6 %296 %181 %286 %215
+ %292 = OpPhi %6 %283 %181 %286 %215
+ %288 = OpPhi %26 %168 %181 %171 %215
+ OpSelectionMerge %223 None
+ OpBranchConditional %288 %225 %223
+ %223 = OpLabel
+ OpBranch %225
+ %225 = OpLabel
+ %293 = OpPhi %6 %294 %221 %292 %223
+ %105 = OpAccessChain %7 %82 %56
+ OpStore %105 %293
+ %107 = OpAccessChain %99 %97 %60
+ %108 = OpLoad %6 %107
+ OpSelectionMerge %279 None
+ OpSwitch %56 %234
+ %234 = OpLabel
+ OpBranch %235
+ %235 = OpLabel
+ %300 = OpPhi %6 %14 %234 %303 %272
+ %299 = OpPhi %15 %18 %234 %274 %272
+ %238 = OpSLessThan %26 %299 %25
+ OpLoopMerge %275 %272 None
+ OpBranchConditional %238 %239 %275
+ %239 = OpLabel
+ %241 = OpSMod %15 %299 %29
+ %242 = OpIEqual %26 %241 %31
+ OpSelectionMerge %264 None
+ OpBranchConditional %242 %243 %246
+ %243 = OpLabel
+ %245 = OpFAdd %6 %300 %35
+ OpBranch %264
+ %246 = OpLabel
+ %248 = OpConvertSToF %6 %299
+ %250 = OpExtInst %6 %1 Round %94
+ %251 = OpFMod %6 %248 %250
+ %252 = OpFOrdLessThanEqual %26 %251 %44
+ OpSelectionMerge %256 None
+ OpBranchConditional %252 %253 %256
+ %253 = OpLabel
+ %255 = OpFAdd %6 %300 %48
+ OpBranch %256
+ %256 = OpLabel
+ %304 = OpPhi %6 %300 %246 %255 %253
+ %257 = OpAccessChain %57 %54 %31 %56
+ %258 = OpLoad %6 %257
+ %259 = OpAccessChain %57 %54 %31 %60
+ %260 = OpLoad %6 %259
+ %261 = OpFOrdGreaterThan %26 %258 %260
+ OpSelectionMerge %263 None
+ OpBranchConditional %261 %262 %263
+ %262 = OpLabel
+ OpKill
+ %263 = OpLabel
+ OpBranch %264
+ %264 = OpLabel
+ %303 = OpPhi %6 %245 %243 %304 %263
+ %266 = OpConvertSToF %6 %299
+ %268 = OpFOrdGreaterThanEqual %26 %266 %108
+ OpSelectionMerge %271 None
+ OpBranchConditional %268 %269 %271
+ %269 = OpLabel
+ OpBranch %275
+ %271 = OpLabel
+ OpBranch %272
+ %272 = OpLabel
+ %274 = OpIAdd %15 %299 %18
+ OpBranch %235
+ %275 = OpLabel
+ %311 = OpPhi %6 %296 %235 %303 %269
+ %309 = OpPhi %6 %300 %235 %303 %269
+ %305 = OpPhi %26 %168 %235 %171 %269
+ OpSelectionMerge %277 None
+ OpBranchConditional %305 %279 %277
+ %277 = OpLabel
+ OpBranch %279
+ %279 = OpLabel
+ %310 = OpPhi %6 %311 %275 %309 %277
+ %112 = OpAccessChain %7 %82 %60
+ OpStore %112 %310
+ %114 = OpLoad %6 %105
+ %116 = OpLoad %6 %112
+ %117 = OpFAdd %6 %114 %116
+ %119 = OpAccessChain %7 %82 %118
+ OpStore %119 %117
+ OpBranch %121
+ %121 = OpLabel
+ %320 = OpPhi %15 %31 %279 %154 %124
+ %128 = OpSLessThan %26 %320 %127
+ OpLoopMerge %123 %124 None
+ OpBranchConditional %128 %122 %123
+ %122 = OpLabel
+ %130 = OpAccessChain %7 %82 %320
+ %131 = OpLoad %6 %130
+ %133 = OpFOrdGreaterThanEqual %26 %131 %132
+ OpSelectionMerge %135 None
+ OpBranchConditional %133 %134 %135
+ %134 = OpLabel
+ %139 = OpLoad %6 %130
+ %142 = OpLoad %6 %130
+ %143 = OpFMul %6 %139 %142
+ OpStore %130 %143
+ %145 = OpAccessChain %57 %54 %31 %56
+ %146 = OpLoad %6 %145
+ %147 = OpAccessChain %57 %54 %31 %60
+ %148 = OpLoad %6 %147
+ %149 = OpFOrdGreaterThan %26 %146 %148
+ OpSelectionMerge %151 None
+ OpBranchConditional %149 %150 %151
+ %150 = OpLabel
+ OpKill
+ %151 = OpLabel
+ OpBranch %135
+ %135 = OpLabel
+ OpBranch %124
+ %124 = OpLabel
+ %154 = OpIAdd %15 %320 %18
+ OpBranch %121
+ %123 = OpLabel
+ %157 = OpLoad %80 %82
+ %158 = OpExtInst %80 %1 FAbs %157
+ %159 = OpExtInst %80 %1 Normalize %158
+ %160 = OpCompositeExtract %6 %159 0
+ %161 = OpCompositeExtract %6 %159 1
+ %162 = OpCompositeExtract %6 %159 2
+ %163 = OpCompositeConstruct %95 %160 %161 %162 %132
+ OpStore %156 %163
+ OpReturn
+ OpFunctionEnd
+END
+
+# uniforms for variant
+
+# resolution
+BUFFER variant_resolution DATA_TYPE vec2<float> STD140 DATA
+ 256.0 256.0
+END
+# injectionSwitch
+BUFFER variant_injectionSwitch DATA_TYPE vec2<float> STD140 DATA
+ 0.0 1.0
+END
+
+BUFFER variant_framebuffer FORMAT B8G8R8A8_UNORM
+
+PIPELINE graphics variant_pipeline
+ ATTACH variant_vertex_shader
+ ATTACH variant_fragment_shader
+ FRAMEBUFFER_SIZE 256 256
+ BIND BUFFER variant_framebuffer AS color LOCATION 0
+ BIND BUFFER variant_resolution AS uniform DESCRIPTOR_SET 0 BINDING 0
+ BIND BUFFER variant_injectionSwitch AS uniform DESCRIPTOR_SET 0 BINDING 1
+END
+CLEAR_COLOR variant_pipeline 0 0 0 255
+
+CLEAR variant_pipeline
+RUN variant_pipeline DRAW_RECT POS 0 0 SIZE 256 256
+
+EXPECT reference_framebuffer EQ_HISTOGRAM_EMD_BUFFER variant_framebuffer TOLERANCE 0.005
--- /dev/null
+#!amber
+
+# Copyright 2020 Google LLC
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+
+# A test for a bug found by the GraphicsFuzz project.
+
+# Short description: A fragment shader with for loop and always false if
+
+# The test passes because both shaders render the same image.
+
+# Optimized using spirv-opt with the following arguments:
+# '-O'
+# spirv-opt commit hash: 717e7877cac15d393fd3bb1bd872679de8b59add
+
+
+
+SHADER vertex reference_vertex_shader PASSTHROUGH
+
+# reference_fragment_shader is derived from the following GLSL:
+# #version 320 es
+# precision highp float;
+#
+# precision highp int;
+#
+# layout(location = 0) out vec4 _GLF_color;
+#
+# layout(set = 0, binding = 0) uniform buf0
+# {
+# vec2 injectionSwitch;
+# };
+# const int N = 10;
+#
+# int data[10], temp[10];
+#
+# void merge(int from, int mid, int to)
+# {
+# int k = from, i = from, j = mid + 1;
+# while (i <= mid && j <= to)
+# {
+# if (data[i] < data[j])
+# {
+# temp[k++] = data[i++];
+# }
+# else
+# {
+# temp[k++] = data[j++];
+# }
+# }
+# while (i < N && i <= mid)
+# {
+# temp[k++] = data[i++];
+# }
+# for (int i = from; i <= to; i++)
+# {
+# data[i] = temp[i];
+# }
+# }
+# void mergeSort()
+# {
+# int low = 0;
+# int high = N - 1;
+# for (int m = 1; m <= high; m = 2 * m)
+# {
+# for (int i = low; i < high; i += 2 * m)
+# {
+# int from = i;
+# int mid = i + m - 1;
+# int to = min(i + 2 * m - 1, high);
+# merge(from, mid, to);
+# }
+# }
+# }
+# void main()
+# {
+# int i = int(injectionSwitch.x);
+# do
+# {
+# switch (i)
+# {
+# case 0:
+# data[i] = 4;
+# break;
+# case 1:
+# data[i] = 3;
+# break;
+# case 2:
+# data[i] = 2;
+# break;
+# case 3:
+# data[i] = 1;
+# break;
+# case 4:
+# data[i] = 0;
+# break;
+# case 5:
+# data[i] = -1;
+# break;
+# case 6:
+# data[i] = -2;
+# break;
+# case 7:
+# data[i] = -3;
+# break;
+# case 8:
+# data[i] = -4;
+# break;
+# case 9:
+# data[i] = -5;
+# break;
+# }
+# i++;
+# } while (i < 10);
+# for (int j = 0; j < 10; j++)
+# {
+# temp[j] = data[j];
+# }
+# mergeSort();
+# float grey;
+# if (int(gl_FragCoord[1]) < 30)
+# {
+# grey = 0.5 + float(data[0]) / 10.0;
+# }
+# else
+# {
+# if (int(gl_FragCoord[1]) < 60)
+# {
+# grey = 0.5 + float(data[1]) / 10.0;
+# }
+# else
+# {
+# if (int(gl_FragCoord[1]) < 90)
+# {
+# grey = 0.5 + float(data[2]) / 10.0;
+# }
+# else
+# {
+# if (int(gl_FragCoord[1]) < 120)
+# {
+# grey = 0.5 + float(data[3]) / 10.0;
+# }
+# else
+# {
+# if (int(gl_FragCoord[1]) < 150)
+# {
+# discard;
+# }
+# else
+# {
+# if (int(gl_FragCoord[1]) < 180)
+# {
+# grey = 0.5 + float(data[5]) / 10.0;
+# }
+# else
+# {
+# if (int(gl_FragCoord[1]) < 210)
+# {
+# grey = 0.5 + float(data[6]) / 10.0;
+# }
+# else
+# {
+# if (int(gl_FragCoord[1]) < 240)
+# {
+# grey = 0.5 + float(data[7]) / 10.0;
+# }
+# else
+# {
+# if (int(gl_FragCoord[1]) < 270)
+# {
+# grey = 0.5 + float(data[8]) / 10.0;
+# }
+# else
+# {
+# discard;
+# }
+# }
+# }
+# }
+# }
+# }
+# }
+# }
+# }
+# _GLF_color = vec4(vec3(grey), 1.0);
+# }
+SHADER fragment reference_fragment_shader SPIRV-ASM TARGET_ENV spv1.0
+; SPIR-V
+; Version: 1.0
+; Generator: Khronos Glslang Reference Front End; 10
+; Bound: 540
+; Schema: 0
+ OpCapability Shader
+ %1 = OpExtInstImport "GLSL.std.450"
+ OpMemoryModel Logical GLSL450
+ OpEntryPoint Fragment %4 "main" %243 %369
+ OpExecutionMode %4 OriginUpperLeft
+ OpSource ESSL 320
+ OpName %4 "main"
+ OpName %41 "data"
+ OpName %52 "temp"
+ OpName %159 "buf0"
+ OpMemberName %159 0 "injectionSwitch"
+ OpName %161 ""
+ OpName %243 "gl_FragCoord"
+ OpName %369 "_GLF_color"
+ OpMemberDecorate %159 0 Offset 0
+ OpDecorate %159 Block
+ OpDecorate %161 DescriptorSet 0
+ OpDecorate %161 Binding 0
+ OpDecorate %243 BuiltIn FragCoord
+ OpDecorate %369 Location 0
+ %2 = OpTypeVoid
+ %3 = OpTypeFunction %2
+ %6 = OpTypeInt 32 1
+ %7 = OpTypePointer Function %6
+ %22 = OpConstant %6 1
+ %31 = OpTypeBool
+ %37 = OpTypeInt 32 0
+ %38 = OpConstant %37 10
+ %39 = OpTypeArray %6 %38
+ %74 = OpConstant %6 10
+ %105 = OpConstant %6 0
+ %107 = OpConstant %6 9
+ %136 = OpConstant %6 2
+ %157 = OpTypeFloat 32
+ %158 = OpTypeVector %157 2
+ %159 = OpTypeStruct %158
+ %160 = OpTypePointer Uniform %159
+ %161 = OpVariable %160 Uniform
+ %162 = OpConstant %37 0
+ %163 = OpTypePointer Uniform %157
+ %184 = OpConstant %6 4
+ %188 = OpConstant %6 3
+ %201 = OpConstant %6 -1
+ %205 = OpConstant %6 -2
+ %209 = OpConstant %6 -3
+ %213 = OpConstant %6 -4
+ %217 = OpConstant %6 -5
+ %241 = OpTypeVector %157 4
+ %242 = OpTypePointer Input %241
+ %243 = OpVariable %242 Input
+ %244 = OpConstant %37 1
+ %245 = OpTypePointer Input %157
+ %249 = OpConstant %6 30
+ %255 = OpConstant %157 0.5
+ %266 = OpConstant %6 60
+ %279 = OpConstant %6 90
+ %292 = OpConstant %6 120
+ %305 = OpConstant %6 150
+ %314 = OpConstant %6 180
+ %318 = OpConstant %6 5
+ %328 = OpConstant %6 210
+ %332 = OpConstant %6 6
+ %342 = OpConstant %6 240
+ %346 = OpConstant %6 7
+ %356 = OpConstant %6 270
+ %360 = OpConstant %6 8
+ %368 = OpTypePointer Output %241
+ %369 = OpVariable %368 Output
+ %373 = OpConstant %157 1
+ %507 = OpTypePointer Function %39
+ %539 = OpConstant %157 0.100000001
+ %4 = OpFunction %2 None %3
+ %5 = OpLabel
+ %52 = OpVariable %507 Function
+ %41 = OpVariable %507 Function
+ %164 = OpAccessChain %163 %161 %105 %162
+ %165 = OpLoad %157 %164
+ %166 = OpConvertFToS %6 %165
+ OpBranch %167
+ %167 = OpLabel
+ %508 = OpPhi %6 %166 %5 %222 %170
+ OpLoopMerge %169 %170 None
+ OpBranch %168
+ %168 = OpLabel
+ OpSelectionMerge %182 None
+ OpSwitch %508 %182 0 %172 1 %173 2 %174 3 %175 4 %176 5 %177 6 %178 7 %179 8 %180 9 %181
+ %172 = OpLabel
+ %185 = OpAccessChain %7 %41 %508
+ OpStore %185 %184
+ OpBranch %182
+ %173 = OpLabel
+ %189 = OpAccessChain %7 %41 %508
+ OpStore %189 %188
+ OpBranch %182
+ %174 = OpLabel
+ %192 = OpAccessChain %7 %41 %508
+ OpStore %192 %136
+ OpBranch %182
+ %175 = OpLabel
+ %195 = OpAccessChain %7 %41 %508
+ OpStore %195 %22
+ OpBranch %182
+ %176 = OpLabel
+ %198 = OpAccessChain %7 %41 %508
+ OpStore %198 %105
+ OpBranch %182
+ %177 = OpLabel
+ %202 = OpAccessChain %7 %41 %508
+ OpStore %202 %201
+ OpBranch %182
+ %178 = OpLabel
+ %206 = OpAccessChain %7 %41 %508
+ OpStore %206 %205
+ OpBranch %182
+ %179 = OpLabel
+ %210 = OpAccessChain %7 %41 %508
+ OpStore %210 %209
+ OpBranch %182
+ %180 = OpLabel
+ %214 = OpAccessChain %7 %41 %508
+ OpStore %214 %213
+ OpBranch %182
+ %181 = OpLabel
+ %218 = OpAccessChain %7 %41 %508
+ OpStore %218 %217
+ OpBranch %182
+ %182 = OpLabel
+ %222 = OpIAdd %6 %508 %22
+ OpBranch %170
+ %170 = OpLabel
+ %224 = OpSLessThan %31 %222 %74
+ OpBranchConditional %224 %167 %169
+ %169 = OpLabel
+ OpBranch %226
+ %226 = OpLabel
+ %510 = OpPhi %6 %105 %169 %239 %227
+ %232 = OpSLessThan %31 %510 %74
+ OpLoopMerge %228 %227 None
+ OpBranchConditional %232 %227 %228
+ %227 = OpLabel
+ %235 = OpAccessChain %7 %41 %510
+ %236 = OpLoad %6 %235
+ %237 = OpAccessChain %7 %52 %510
+ OpStore %237 %236
+ %239 = OpIAdd %6 %510 %22
+ OpBranch %226
+ %228 = OpLabel
+ OpBranch %389
+ %389 = OpLabel
+ %511 = OpPhi %6 %22 %228 %426 %424
+ %393 = OpSLessThanEqual %31 %511 %107
+ OpLoopMerge %427 %424 None
+ OpBranchConditional %393 %394 %427
+ %394 = OpLabel
+ OpBranch %396
+ %396 = OpLabel
+ %519 = OpPhi %6 %105 %394 %410 %418
+ %400 = OpSLessThan %31 %519 %107
+ OpLoopMerge %423 %418 None
+ OpBranchConditional %400 %401 %423
+ %401 = OpLabel
+ %405 = OpIAdd %6 %519 %511
+ %406 = OpISub %6 %405 %22
+ %409 = OpIMul %6 %136 %511
+ %410 = OpIAdd %6 %519 %409
+ %411 = OpISub %6 %410 %22
+ %413 = OpExtInst %6 %1 SMin %411 %107
+ OpBranch %437
+ %437 = OpLabel
+ %532 = OpPhi %6 %519 %401 %456 %471
+ %522 = OpPhi %6 %405 %401 %534 %471
+ %521 = OpPhi %6 %519 %401 %533 %471
+ %441 = OpSLessThanEqual %31 %521 %406
+ %444 = OpSLessThanEqual %31 %522 %413
+ %445 = OpLogicalAnd %31 %441 %444
+ OpLoopMerge %472 %471 None
+ OpBranchConditional %445 %446 %472
+ %446 = OpLabel
+ %448 = OpAccessChain %7 %41 %521
+ %449 = OpLoad %6 %448
+ %451 = OpAccessChain %7 %41 %522
+ %452 = OpLoad %6 %451
+ %453 = OpSLessThan %31 %449 %452
+ %456 = OpIAdd %6 %532 %22
+ OpSelectionMerge %470 None
+ OpBranchConditional %453 %454 %462
+ %454 = OpLabel
+ %458 = OpIAdd %6 %521 %22
+ %460 = OpLoad %6 %448
+ %461 = OpAccessChain %7 %52 %532
+ OpStore %461 %460
+ OpBranch %470
+ %462 = OpLabel
+ %466 = OpIAdd %6 %522 %22
+ %468 = OpLoad %6 %451
+ %469 = OpAccessChain %7 %52 %532
+ OpStore %469 %468
+ OpBranch %470
+ %470 = OpLabel
+ %534 = OpPhi %6 %522 %454 %466 %462
+ %533 = OpPhi %6 %458 %454 %521 %462
+ OpBranch %471
+ %471 = OpLabel
+ OpBranch %437
+ %472 = OpLabel
+ OpBranch %473
+ %473 = OpLabel
+ %531 = OpPhi %6 %532 %472 %483 %481
+ %523 = OpPhi %6 %521 %472 %485 %481
+ %476 = OpSLessThan %31 %523 %74
+ %479 = OpSLessThanEqual %31 %523 %406
+ %480 = OpLogicalAnd %31 %476 %479
+ OpLoopMerge %490 %481 None
+ OpBranchConditional %480 %481 %490
+ %481 = OpLabel
+ %483 = OpIAdd %6 %531 %22
+ %485 = OpIAdd %6 %523 %22
+ %486 = OpAccessChain %7 %41 %523
+ %487 = OpLoad %6 %486
+ %488 = OpAccessChain %7 %52 %531
+ OpStore %488 %487
+ OpBranch %473
+ %490 = OpLabel
+ OpBranch %492
+ %492 = OpLabel
+ %524 = OpPhi %6 %519 %490 %505 %497
+ %496 = OpSLessThanEqual %31 %524 %413
+ OpLoopMerge %506 %497 None
+ OpBranchConditional %496 %497 %506
+ %497 = OpLabel
+ %500 = OpAccessChain %7 %52 %524
+ %501 = OpLoad %6 %500
+ %502 = OpAccessChain %7 %41 %524
+ OpStore %502 %501
+ %505 = OpIAdd %6 %524 %22
+ OpBranch %492
+ %506 = OpLabel
+ OpBranch %418
+ %418 = OpLabel
+ OpBranch %396
+ %423 = OpLabel
+ OpBranch %424
+ %424 = OpLabel
+ %426 = OpIMul %6 %136 %511
+ OpBranch %389
+ %427 = OpLabel
+ %246 = OpAccessChain %245 %243 %244
+ %247 = OpLoad %157 %246
+ %248 = OpConvertFToS %6 %247
+ %250 = OpSLessThan %31 %248 %249
+ OpSelectionMerge %252 None
+ OpBranchConditional %250 %251 %262
+ %251 = OpLabel
+ %256 = OpAccessChain %7 %41 %105
+ %257 = OpLoad %6 %256
+ %258 = OpConvertSToF %157 %257
+ %260 = OpFMul %157 %258 %539
+ %261 = OpFAdd %157 %255 %260
+ OpBranch %252
+ %262 = OpLabel
+ %267 = OpSLessThan %31 %248 %266
+ OpSelectionMerge %269 None
+ OpBranchConditional %267 %268 %275
+ %268 = OpLabel
+ %270 = OpAccessChain %7 %41 %22
+ %271 = OpLoad %6 %270
+ %272 = OpConvertSToF %157 %271
+ %273 = OpFMul %157 %272 %539
+ %274 = OpFAdd %157 %255 %273
+ OpBranch %269
+ %275 = OpLabel
+ %280 = OpSLessThan %31 %248 %279
+ OpSelectionMerge %282 None
+ OpBranchConditional %280 %281 %288
+ %281 = OpLabel
+ %283 = OpAccessChain %7 %41 %136
+ %284 = OpLoad %6 %283
+ %285 = OpConvertSToF %157 %284
+ %286 = OpFMul %157 %285 %539
+ %287 = OpFAdd %157 %255 %286
+ OpBranch %282
+ %288 = OpLabel
+ %293 = OpSLessThan %31 %248 %292
+ OpSelectionMerge %295 None
+ OpBranchConditional %293 %294 %301
+ %294 = OpLabel
+ %296 = OpAccessChain %7 %41 %188
+ %297 = OpLoad %6 %296
+ %298 = OpConvertSToF %157 %297
+ %299 = OpFMul %157 %298 %539
+ %300 = OpFAdd %157 %255 %299
+ OpBranch %295
+ %301 = OpLabel
+ %306 = OpSLessThan %31 %248 %305
+ OpSelectionMerge %308 None
+ OpBranchConditional %306 %307 %310
+ %307 = OpLabel
+ OpKill
+ %310 = OpLabel
+ %315 = OpSLessThan %31 %248 %314
+ OpSelectionMerge %317 None
+ OpBranchConditional %315 %316 %324
+ %316 = OpLabel
+ %319 = OpAccessChain %7 %41 %318
+ %320 = OpLoad %6 %319
+ %321 = OpConvertSToF %157 %320
+ %322 = OpFMul %157 %321 %539
+ %323 = OpFAdd %157 %255 %322
+ OpBranch %317
+ %324 = OpLabel
+ %329 = OpSLessThan %31 %248 %328
+ OpSelectionMerge %331 None
+ OpBranchConditional %329 %330 %338
+ %330 = OpLabel
+ %333 = OpAccessChain %7 %41 %332
+ %334 = OpLoad %6 %333
+ %335 = OpConvertSToF %157 %334
+ %336 = OpFMul %157 %335 %539
+ %337 = OpFAdd %157 %255 %336
+ OpBranch %331
+ %338 = OpLabel
+ %343 = OpSLessThan %31 %248 %342
+ OpSelectionMerge %345 None
+ OpBranchConditional %343 %344 %352
+ %344 = OpLabel
+ %347 = OpAccessChain %7 %41 %346
+ %348 = OpLoad %6 %347
+ %349 = OpConvertSToF %157 %348
+ %350 = OpFMul %157 %349 %539
+ %351 = OpFAdd %157 %255 %350
+ OpBranch %345
+ %352 = OpLabel
+ %357 = OpSLessThan %31 %248 %356
+ OpSelectionMerge %358 None
+ OpBranchConditional %357 %358 %366
+ %358 = OpLabel
+ %361 = OpAccessChain %7 %41 %360
+ %362 = OpLoad %6 %361
+ %363 = OpConvertSToF %157 %362
+ %364 = OpFMul %157 %363 %539
+ %365 = OpFAdd %157 %255 %364
+ OpBranch %345
+ %366 = OpLabel
+ OpKill
+ %345 = OpLabel
+ %518 = OpPhi %157 %351 %344 %365 %358
+ OpBranch %331
+ %331 = OpLabel
+ %517 = OpPhi %157 %337 %330 %518 %345
+ OpBranch %317
+ %317 = OpLabel
+ %516 = OpPhi %157 %323 %316 %517 %331
+ OpBranch %308
+ %308 = OpLabel
+ OpBranch %295
+ %295 = OpLabel
+ %515 = OpPhi %157 %300 %294 %516 %308
+ OpBranch %282
+ %282 = OpLabel
+ %514 = OpPhi %157 %287 %281 %515 %295
+ OpBranch %269
+ %269 = OpLabel
+ %513 = OpPhi %157 %274 %268 %514 %282
+ OpBranch %252
+ %252 = OpLabel
+ %512 = OpPhi %157 %261 %251 %513 %269
+ %377 = OpCompositeConstruct %241 %512 %512 %512 %373
+ OpStore %369 %377
+ OpReturn
+ OpFunctionEnd
+END
+
+# uniforms for reference
+
+# injectionSwitch
+BUFFER reference_injectionSwitch DATA_TYPE vec2<float> STD140 DATA
+ 0.0 1.0
+END
+
+BUFFER reference_framebuffer FORMAT B8G8R8A8_UNORM
+
+PIPELINE graphics reference_pipeline
+ ATTACH reference_vertex_shader
+ ATTACH reference_fragment_shader
+ FRAMEBUFFER_SIZE 256 256
+ BIND BUFFER reference_framebuffer AS color LOCATION 0
+ BIND BUFFER reference_injectionSwitch AS uniform DESCRIPTOR_SET 0 BINDING 0
+END
+CLEAR_COLOR reference_pipeline 0 0 0 255
+
+CLEAR reference_pipeline
+RUN reference_pipeline DRAW_RECT POS 0 0 SIZE 256 256
+
+
+SHADER vertex variant_vertex_shader PASSTHROUGH
+
+# variant_fragment_shader is derived from the following GLSL:
+# #version 320 es
+# precision highp float;
+#
+# precision highp int;
+#
+# layout(location = 0) out vec4 _GLF_color;
+#
+# layout(set = 0, binding = 0) uniform buf0
+# {
+# vec2 injectionSwitch; // x == 0.0, y == 1.0
+# };
+# const int N = 10;
+#
+# int data[10], temp[10];
+#
+# void merge(int from, int mid, int to)
+# {
+# int k = from, i = from, j = mid + 1;
+# while (i <= mid && j <= to)
+# {
+# if (data[i] < data[j])
+# {
+# temp[k++] = data[i++];
+# }
+# else
+# {
+# temp[k++] = data[j++];
+# }
+# }
+# while (i < N && i <= mid)
+# {
+# temp[k++] = data[i++];
+# }
+# for (int i = from; i <= to; i++)
+# {
+# data[i] = temp[i];
+# }
+# }
+# void mergeSort()
+# {
+# int low = 0;
+# int high = N - 1;
+# for (int m = 1; m <= high; m = 2 * m)
+# {
+# for (int i = low; i < high; i += 2 * m)
+# {
+# int from = i;
+# int mid = i + m - 1;
+# int to = min(i + 2 * m - 1, high);
+# merge(from, mid, to);
+# }
+# }
+# }
+# void main()
+# {
+# int i = int(injectionSwitch.x);
+# do
+# {
+# switch (i)
+# {
+# case 0:
+# data[i] = 4;
+# break;
+# case 1:
+# data[i] = 3;
+# break;
+# case 2:
+# data[i] = 2;
+# break;
+# case 3:
+# data[i] = 1;
+# break;
+# case 4:
+# data[i] = 0;
+# break;
+# case 5:
+# data[i] = -1;
+# break;
+# case 6:
+# data[i] = -2;
+# break;
+# case 7:
+# data[i] = -3;
+# break;
+# case 8:
+# data[i] = -4;
+# break;
+# case 9:
+# data[i] = -5;
+# break;
+# }
+# i++;
+# } while (i < 10);
+# for (int j = 0; j < 10; j++)
+# {
+# temp[j] = data[j];
+# }
+# mergeSort();
+# float grey;
+# if (int(gl_FragCoord[1]) < 30)
+# {
+# grey = 0.5 + float(data[0]) / 10.0;
+# }
+# else
+# {
+# if (int(gl_FragCoord[1]) < 60)
+# {
+# grey = 0.5 + float(data[1]) / 10.0;
+# }
+# else
+# {
+# if (int(gl_FragCoord[1]) < 90)
+# {
+# grey = 0.5 + float(data[2]) / 10.0;
+# }
+# else
+# {
+# if (int(gl_FragCoord[1]) < 120)
+# {
+# grey = 0.5 + float(data[3]) / 10.0;
+# }
+# else
+# {
+# if (int(gl_FragCoord[1]) < 150)
+# {
+# discard;
+# }
+# else
+# {
+# if (int(gl_FragCoord[1]) < 180)
+# {
+# grey = 0.5 + float(data[5]) / 10.0;
+# }
+# else
+# {
+# if (int(gl_FragCoord[1]) < 210)
+# {
+# grey = 0.5 + float(data[6]) / 10.0;
+# }
+# else
+# {
+# if (int(gl_FragCoord[1]) < 240)
+# {
+# grey = 0.5 + float(data[7]) / 10.0;
+# }
+# else
+# {
+# if (int(gl_FragCoord[1]) < 270)
+# {
+# grey = 0.5 + float(data[8]) / 10.0;
+# }
+# else
+# {
+# discard;
+# }
+# }
+# }
+# }
+# // Code block bellow should not affect output image.
+# // Always false.
+# if (injectionSwitch.x > injectionSwitch.y)
+# {
+# _GLF_color = vec4(1.0);
+# }
+# vec2 a = vec2(1.0, 1.0);
+# for (int i = 0; i <= 32; i++)
+# {
+# // Always false.
+# if (a.x < 0.0)
+# {
+# // Always false.
+# if (injectionSwitch.x > injectionSwitch.y)
+# {
+# discard;
+# }
+# a.y++;
+# }
+# a.x += a.y;
+# }
+# // End of block.
+# }
+# }
+# }
+# }
+# }
+# _GLF_color = vec4(vec3(grey), 1.0);
+# }
+SHADER fragment variant_fragment_shader SPIRV-ASM TARGET_ENV spv1.0
+; SPIR-V
+; Version: 1.0
+; Generator: Khronos Glslang Reference Front End; 10
+; Bound: 602
+; Schema: 0
+ OpCapability Shader
+ %1 = OpExtInstImport "GLSL.std.450"
+ OpMemoryModel Logical GLSL450
+ OpEntryPoint Fragment %4 "main" %243 %376
+ OpExecutionMode %4 OriginUpperLeft
+ OpSource ESSL 320
+ OpName %4 "main"
+ OpName %41 "data"
+ OpName %52 "temp"
+ OpName %159 "buf0"
+ OpMemberName %159 0 "injectionSwitch"
+ OpName %161 ""
+ OpName %243 "gl_FragCoord"
+ OpName %376 "_GLF_color"
+ OpMemberDecorate %159 0 Offset 0
+ OpDecorate %159 Block
+ OpDecorate %161 DescriptorSet 0
+ OpDecorate %161 Binding 0
+ OpDecorate %243 BuiltIn FragCoord
+ OpDecorate %376 Location 0
+ %2 = OpTypeVoid
+ %3 = OpTypeFunction %2
+ %6 = OpTypeInt 32 1
+ %7 = OpTypePointer Function %6
+ %22 = OpConstant %6 1
+ %31 = OpTypeBool
+ %37 = OpTypeInt 32 0
+ %38 = OpConstant %37 10
+ %39 = OpTypeArray %6 %38
+ %74 = OpConstant %6 10
+ %105 = OpConstant %6 0
+ %107 = OpConstant %6 9
+ %136 = OpConstant %6 2
+ %157 = OpTypeFloat 32
+ %158 = OpTypeVector %157 2
+ %159 = OpTypeStruct %158
+ %160 = OpTypePointer Uniform %159
+ %161 = OpVariable %160 Uniform
+ %162 = OpConstant %37 0
+ %163 = OpTypePointer Uniform %157
+ %184 = OpConstant %6 4
+ %188 = OpConstant %6 3
+ %201 = OpConstant %6 -1
+ %205 = OpConstant %6 -2
+ %209 = OpConstant %6 -3
+ %213 = OpConstant %6 -4
+ %217 = OpConstant %6 -5
+ %241 = OpTypeVector %157 4
+ %242 = OpTypePointer Input %241
+ %243 = OpVariable %242 Input
+ %244 = OpConstant %37 1
+ %245 = OpTypePointer Input %157
+ %249 = OpConstant %6 30
+ %255 = OpConstant %157 0.5
+ %266 = OpConstant %6 60
+ %279 = OpConstant %6 90
+ %292 = OpConstant %6 120
+ %305 = OpConstant %6 150
+ %314 = OpConstant %6 180
+ %318 = OpConstant %6 5
+ %328 = OpConstant %6 210
+ %332 = OpConstant %6 6
+ %342 = OpConstant %6 240
+ %346 = OpConstant %6 7
+ %356 = OpConstant %6 270
+ %360 = OpConstant %6 8
+ %375 = OpTypePointer Output %241
+ %376 = OpVariable %375 Output
+ %377 = OpConstant %157 1
+ %378 = OpConstantComposite %241 %377 %377 %377 %377
+ %381 = OpConstantComposite %158 %377 %377
+ %389 = OpConstant %6 32
+ %393 = OpConstant %157 0
+ %552 = OpTypePointer Function %39
+ %601 = OpConstant %157 0.100000001
+ %4 = OpFunction %2 None %3
+ %5 = OpLabel
+ %52 = OpVariable %552 Function
+ %41 = OpVariable %552 Function
+ %164 = OpAccessChain %163 %161 %105 %162
+ %165 = OpLoad %157 %164
+ %166 = OpConvertFToS %6 %165
+ OpBranch %167
+ %167 = OpLabel
+ %561 = OpPhi %6 %166 %5 %222 %170
+ OpLoopMerge %169 %170 None
+ OpBranch %168
+ %168 = OpLabel
+ OpSelectionMerge %182 None
+ OpSwitch %561 %182 0 %172 1 %173 2 %174 3 %175 4 %176 5 %177 6 %178 7 %179 8 %180 9 %181
+ %172 = OpLabel
+ %185 = OpAccessChain %7 %41 %561
+ OpStore %185 %184
+ OpBranch %182
+ %173 = OpLabel
+ %189 = OpAccessChain %7 %41 %561
+ OpStore %189 %188
+ OpBranch %182
+ %174 = OpLabel
+ %192 = OpAccessChain %7 %41 %561
+ OpStore %192 %136
+ OpBranch %182
+ %175 = OpLabel
+ %195 = OpAccessChain %7 %41 %561
+ OpStore %195 %22
+ OpBranch %182
+ %176 = OpLabel
+ %198 = OpAccessChain %7 %41 %561
+ OpStore %198 %105
+ OpBranch %182
+ %177 = OpLabel
+ %202 = OpAccessChain %7 %41 %561
+ OpStore %202 %201
+ OpBranch %182
+ %178 = OpLabel
+ %206 = OpAccessChain %7 %41 %561
+ OpStore %206 %205
+ OpBranch %182
+ %179 = OpLabel
+ %210 = OpAccessChain %7 %41 %561
+ OpStore %210 %209
+ OpBranch %182
+ %180 = OpLabel
+ %214 = OpAccessChain %7 %41 %561
+ OpStore %214 %213
+ OpBranch %182
+ %181 = OpLabel
+ %218 = OpAccessChain %7 %41 %561
+ OpStore %218 %217
+ OpBranch %182
+ %182 = OpLabel
+ %222 = OpIAdd %6 %561 %22
+ OpBranch %170
+ %170 = OpLabel
+ %224 = OpSLessThan %31 %222 %74
+ OpBranchConditional %224 %167 %169
+ %169 = OpLabel
+ OpBranch %226
+ %226 = OpLabel
+ %563 = OpPhi %6 %105 %169 %239 %227
+ %232 = OpSLessThan %31 %563 %74
+ OpLoopMerge %228 %227 None
+ OpBranchConditional %232 %227 %228
+ %227 = OpLabel
+ %235 = OpAccessChain %7 %41 %563
+ %236 = OpLoad %6 %235
+ %237 = OpAccessChain %7 %52 %563
+ OpStore %237 %236
+ %239 = OpIAdd %6 %563 %22
+ OpBranch %226
+ %228 = OpLabel
+ OpBranch %434
+ %434 = OpLabel
+ %564 = OpPhi %6 %22 %228 %471 %469
+ %438 = OpSLessThanEqual %31 %564 %107
+ OpLoopMerge %472 %469 None
+ OpBranchConditional %438 %439 %472
+ %439 = OpLabel
+ OpBranch %441
+ %441 = OpLabel
+ %579 = OpPhi %6 %105 %439 %455 %463
+ %445 = OpSLessThan %31 %579 %107
+ OpLoopMerge %468 %463 None
+ OpBranchConditional %445 %446 %468
+ %446 = OpLabel
+ %450 = OpIAdd %6 %579 %564
+ %451 = OpISub %6 %450 %22
+ %454 = OpIMul %6 %136 %564
+ %455 = OpIAdd %6 %579 %454
+ %456 = OpISub %6 %455 %22
+ %458 = OpExtInst %6 %1 SMin %456 %107
+ OpBranch %482
+ %482 = OpLabel
+ %592 = OpPhi %6 %579 %446 %501 %516
+ %582 = OpPhi %6 %450 %446 %594 %516
+ %581 = OpPhi %6 %579 %446 %593 %516
+ %486 = OpSLessThanEqual %31 %581 %451
+ %489 = OpSLessThanEqual %31 %582 %458
+ %490 = OpLogicalAnd %31 %486 %489
+ OpLoopMerge %517 %516 None
+ OpBranchConditional %490 %491 %517
+ %491 = OpLabel
+ %493 = OpAccessChain %7 %41 %581
+ %494 = OpLoad %6 %493
+ %496 = OpAccessChain %7 %41 %582
+ %497 = OpLoad %6 %496
+ %498 = OpSLessThan %31 %494 %497
+ %501 = OpIAdd %6 %592 %22
+ OpSelectionMerge %515 None
+ OpBranchConditional %498 %499 %507
+ %499 = OpLabel
+ %503 = OpIAdd %6 %581 %22
+ %505 = OpLoad %6 %493
+ %506 = OpAccessChain %7 %52 %592
+ OpStore %506 %505
+ OpBranch %515
+ %507 = OpLabel
+ %511 = OpIAdd %6 %582 %22
+ %513 = OpLoad %6 %496
+ %514 = OpAccessChain %7 %52 %592
+ OpStore %514 %513
+ OpBranch %515
+ %515 = OpLabel
+ %594 = OpPhi %6 %582 %499 %511 %507
+ %593 = OpPhi %6 %503 %499 %581 %507
+ OpBranch %516
+ %516 = OpLabel
+ OpBranch %482
+ %517 = OpLabel
+ OpBranch %518
+ %518 = OpLabel
+ %591 = OpPhi %6 %592 %517 %528 %526
+ %583 = OpPhi %6 %581 %517 %530 %526
+ %521 = OpSLessThan %31 %583 %74
+ %524 = OpSLessThanEqual %31 %583 %451
+ %525 = OpLogicalAnd %31 %521 %524
+ OpLoopMerge %535 %526 None
+ OpBranchConditional %525 %526 %535
+ %526 = OpLabel
+ %528 = OpIAdd %6 %591 %22
+ %530 = OpIAdd %6 %583 %22
+ %531 = OpAccessChain %7 %41 %583
+ %532 = OpLoad %6 %531
+ %533 = OpAccessChain %7 %52 %591
+ OpStore %533 %532
+ OpBranch %518
+ %535 = OpLabel
+ OpBranch %537
+ %537 = OpLabel
+ %584 = OpPhi %6 %579 %535 %550 %542
+ %541 = OpSLessThanEqual %31 %584 %458
+ OpLoopMerge %551 %542 None
+ OpBranchConditional %541 %542 %551
+ %542 = OpLabel
+ %545 = OpAccessChain %7 %52 %584
+ %546 = OpLoad %6 %545
+ %547 = OpAccessChain %7 %41 %584
+ OpStore %547 %546
+ %550 = OpIAdd %6 %584 %22
+ OpBranch %537
+ %551 = OpLabel
+ OpBranch %463
+ %463 = OpLabel
+ OpBranch %441
+ %468 = OpLabel
+ OpBranch %469
+ %469 = OpLabel
+ %471 = OpIMul %6 %136 %564
+ OpBranch %434
+ %472 = OpLabel
+ %246 = OpAccessChain %245 %243 %244
+ %247 = OpLoad %157 %246
+ %248 = OpConvertFToS %6 %247
+ %250 = OpSLessThan %31 %248 %249
+ OpSelectionMerge %252 None
+ OpBranchConditional %250 %251 %262
+ %251 = OpLabel
+ %256 = OpAccessChain %7 %41 %105
+ %257 = OpLoad %6 %256
+ %258 = OpConvertSToF %157 %257
+ %260 = OpFMul %157 %258 %601
+ %261 = OpFAdd %157 %255 %260
+ OpBranch %252
+ %262 = OpLabel
+ %267 = OpSLessThan %31 %248 %266
+ OpSelectionMerge %269 None
+ OpBranchConditional %267 %268 %275
+ %268 = OpLabel
+ %270 = OpAccessChain %7 %41 %22
+ %271 = OpLoad %6 %270
+ %272 = OpConvertSToF %157 %271
+ %273 = OpFMul %157 %272 %601
+ %274 = OpFAdd %157 %255 %273
+ OpBranch %269
+ %275 = OpLabel
+ %280 = OpSLessThan %31 %248 %279
+ OpSelectionMerge %282 None
+ OpBranchConditional %280 %281 %288
+ %281 = OpLabel
+ %283 = OpAccessChain %7 %41 %136
+ %284 = OpLoad %6 %283
+ %285 = OpConvertSToF %157 %284
+ %286 = OpFMul %157 %285 %601
+ %287 = OpFAdd %157 %255 %286
+ OpBranch %282
+ %288 = OpLabel
+ %293 = OpSLessThan %31 %248 %292
+ OpSelectionMerge %295 None
+ OpBranchConditional %293 %294 %301
+ %294 = OpLabel
+ %296 = OpAccessChain %7 %41 %188
+ %297 = OpLoad %6 %296
+ %298 = OpConvertSToF %157 %297
+ %299 = OpFMul %157 %298 %601
+ %300 = OpFAdd %157 %255 %299
+ OpBranch %295
+ %301 = OpLabel
+ %306 = OpSLessThan %31 %248 %305
+ OpSelectionMerge %308 None
+ OpBranchConditional %306 %307 %310
+ %307 = OpLabel
+ OpKill
+ %310 = OpLabel
+ %315 = OpSLessThan %31 %248 %314
+ OpSelectionMerge %317 None
+ OpBranchConditional %315 %316 %324
+ %316 = OpLabel
+ %319 = OpAccessChain %7 %41 %318
+ %320 = OpLoad %6 %319
+ %321 = OpConvertSToF %157 %320
+ %322 = OpFMul %157 %321 %601
+ %323 = OpFAdd %157 %255 %322
+ OpBranch %317
+ %324 = OpLabel
+ %329 = OpSLessThan %31 %248 %328
+ OpSelectionMerge %331 None
+ OpBranchConditional %329 %330 %338
+ %330 = OpLabel
+ %333 = OpAccessChain %7 %41 %332
+ %334 = OpLoad %6 %333
+ %335 = OpConvertSToF %157 %334
+ %336 = OpFMul %157 %335 %601
+ %337 = OpFAdd %157 %255 %336
+ OpBranch %331
+ %338 = OpLabel
+ %343 = OpSLessThan %31 %248 %342
+ OpSelectionMerge %345 None
+ OpBranchConditional %343 %344 %352
+ %344 = OpLabel
+ %347 = OpAccessChain %7 %41 %346
+ %348 = OpLoad %6 %347
+ %349 = OpConvertSToF %157 %348
+ %350 = OpFMul %157 %349 %601
+ %351 = OpFAdd %157 %255 %350
+ OpBranch %345
+ %352 = OpLabel
+ %357 = OpSLessThan %31 %248 %356
+ OpSelectionMerge %358 None
+ OpBranchConditional %357 %358 %366
+ %358 = OpLabel
+ %361 = OpAccessChain %7 %41 %360
+ %362 = OpLoad %6 %361
+ %363 = OpConvertSToF %157 %362
+ %364 = OpFMul %157 %363 %601
+ %365 = OpFAdd %157 %255 %364
+ OpBranch %345
+ %366 = OpLabel
+ OpKill
+ %345 = OpLabel
+ %577 = OpPhi %157 %351 %344 %365 %358
+ OpBranch %331
+ %331 = OpLabel
+ %576 = OpPhi %157 %337 %330 %577 %345
+ OpBranch %317
+ %317 = OpLabel
+ %575 = OpPhi %157 %323 %316 %576 %331
+ %370 = OpAccessChain %163 %161 %105 %244
+ %371 = OpLoad %157 %370
+ %372 = OpFOrdGreaterThan %31 %165 %371
+ OpSelectionMerge %374 None
+ OpBranchConditional %372 %373 %374
+ %373 = OpLabel
+ OpStore %376 %378
+ OpBranch %374
+ %374 = OpLabel
+ OpBranch %383
+ %383 = OpLabel
+ %566 = OpPhi %158 %381 %374 %560 %386
+ %565 = OpPhi %6 %105 %374 %415 %386
+ %390 = OpSLessThanEqual %31 %565 %389
+ OpLoopMerge %385 %386 None
+ OpBranchConditional %390 %384 %385
+ %384 = OpLabel
+ %392 = OpCompositeExtract %157 %566 0
+ %394 = OpFOrdLessThan %31 %392 %393
+ OpSelectionMerge %396 None
+ OpBranchConditional %394 %395 %396
+ %395 = OpLabel
+ OpSelectionMerge %403 None
+ OpBranchConditional %372 %402 %403
+ %402 = OpLabel
+ OpKill
+ %403 = OpLabel
+ %406 = OpCompositeExtract %157 %566 1
+ %407 = OpFAdd %157 %406 %377
+ %556 = OpCompositeInsert %158 %407 %566 1
+ OpBranch %396
+ %396 = OpLabel
+ %567 = OpPhi %158 %566 %384 %556 %403
+ %409 = OpCompositeExtract %157 %567 1
+ %411 = OpCompositeExtract %157 %567 0
+ %412 = OpFAdd %157 %411 %409
+ %560 = OpCompositeInsert %158 %412 %567 0
+ OpBranch %386
+ %386 = OpLabel
+ %415 = OpIAdd %6 %565 %22
+ OpBranch %383
+ %385 = OpLabel
+ OpBranch %308
+ %308 = OpLabel
+ OpBranch %295
+ %295 = OpLabel
+ %572 = OpPhi %157 %300 %294 %575 %308
+ OpBranch %282
+ %282 = OpLabel
+ %571 = OpPhi %157 %287 %281 %572 %295
+ OpBranch %269
+ %269 = OpLabel
+ %570 = OpPhi %157 %274 %268 %571 %282
+ OpBranch %252
+ %252 = OpLabel
+ %569 = OpPhi %157 %261 %251 %570 %269
+ %422 = OpCompositeConstruct %241 %569 %569 %569 %377
+ OpStore %376 %422
+ OpReturn
+ OpFunctionEnd
+END
+
+# uniforms for variant
+
+# injectionSwitch
+BUFFER variant_injectionSwitch DATA_TYPE vec2<float> STD140 DATA
+ 0.0 1.0
+END
+
+BUFFER variant_framebuffer FORMAT B8G8R8A8_UNORM
+
+PIPELINE graphics variant_pipeline
+ ATTACH variant_vertex_shader
+ ATTACH variant_fragment_shader
+ FRAMEBUFFER_SIZE 256 256
+ BIND BUFFER variant_framebuffer AS color LOCATION 0
+ BIND BUFFER variant_injectionSwitch AS uniform DESCRIPTOR_SET 0 BINDING 0
+END
+CLEAR_COLOR variant_pipeline 0 0 0 255
+
+CLEAR variant_pipeline
+RUN variant_pipeline DRAW_RECT POS 0 0 SIZE 256 256
+
+EXPECT reference_framebuffer EQ_HISTOGRAM_EMD_BUFFER variant_framebuffer TOLERANCE 0.005
dEQP-VK.graphicsfuzz.spv-stable-quicksort-mat-func-param
dEQP-VK.graphicsfuzz.spv-stable-rects-Os-mutate-var-push-through-var
dEQP-VK.graphicsfuzz.stable-binarysearch-tree-false-if-discard-loop
+dEQP-VK.graphicsfuzz.stable-binarysearch-tree-fragcoord-less-than-zero
dEQP-VK.graphicsfuzz.stable-binarysearch-tree-nested-if-and-conditional
dEQP-VK.graphicsfuzz.stable-binarysearch-tree-with-loop-read-write-global
dEQP-VK.graphicsfuzz.stable-collatz-push-constant-with-nested-min-max
+dEQP-VK.graphicsfuzz.stable-colorgrid-modulo-double-always-false-discard
dEQP-VK.graphicsfuzz.stable-colorgrid-modulo-injected-conditional-true
dEQP-VK.graphicsfuzz.stable-colorgrid-modulo-true-conditional-simple-loop
dEQP-VK.graphicsfuzz.stable-colorgrid-modulo-vec3-values-from-matrix
+dEQP-VK.graphicsfuzz.stable-mergesort-for-always-false-if-discard
dEQP-VK.graphicsfuzz.stable-mergesort-reversed-for-loop
dEQP-VK.graphicsfuzz.stable-quicksort-for-loop-with-injection
dEQP-VK.graphicsfuzz.stable-quicksort-if-false-else-return