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 array and nested loops 21 22# The test passes because both shaders render the same image. 23 24# Optimized using spirv-opt with the following arguments: 25# '--private-to-local' 26# '--copy-propagate-arrays' 27# '--if-conversion' 28# '--private-to-local' 29# '--eliminate-dead-inserts' 30# '--if-conversion' 31# '--if-conversion' 32# '--scalar-replacement=100' 33# '--private-to-local' 34# '--reduce-load-size' 35# '--ccp' 36# '--scalar-replacement=100' 37# '--eliminate-dead-branches' 38# '--eliminate-dead-branches' 39# '--merge-return' 40# '--private-to-local' 41# '--redundancy-elimination' 42# '--combine-access-chains' 43# '--eliminate-local-multi-store' 44# '--ccp' 45# '--convert-local-access-chains' 46# '--reduce-load-size' 47# '--private-to-local' 48# '--vector-dce' 49# spirv-opt commit hash: 230f363e6da32791f640b02205e0645cc67c3f1d 50 51 52 53SHADER vertex reference_vertex_shader PASSTHROUGH 54 55# reference_fragment_shader is derived from the following GLSL: 56# #version 320 es 57# precision highp float; 58# 59# precision highp int; 60# 61# layout(location = 0) out vec4 _GLF_color; 62# 63# layout(set = 0, binding = 0) uniform buf0 64# { 65# vec2 resolution; 66# }; 67# float cross2d(vec2 a, vec2 b) 68# { 69# return ((a.x) * (b.y) - (b.x) * (a.y)); 70# } 71# int pointInTriangle(vec2 p, vec2 a, vec2 b, vec2 c) 72# { 73# float pab = cross2d(vec2(p.x - a.x, p.y - a.y), vec2(b.x - a.x, b.y - a.y)); 74# float pbc = cross2d(vec2(p.x - b.x, p.y - b.y), vec2(c.x - b.x, c.y - b.y)); 75# if (!((pab < 0.0 && pbc < 0.0) || (pab >= 0.0 && pbc >= 0.0))) 76# { 77# return 0; 78# } 79# float pca = cross2d(vec2(p.x - c.x, p.y - c.y), vec2(a.x - c.x, a.y - c.y)); 80# if (!((pab < 0.0 && pca < 0.0) || (pab >= 0.0 && pca >= 0.0))) 81# { 82# return 0; 83# } 84# return 1; 85# } 86# void main() 87# { 88# vec2 pos = gl_FragCoord.xy / resolution; 89# if (pointInTriangle(pos, vec2(0.7, 0.3), vec2(0.5, 0.9), vec2(0.1, 0.4)) == 1) 90# { 91# _GLF_color = vec4(1.0, 0.0, 0.0, 1.0); 92# } 93# else 94# { 95# _GLF_color = vec4(0.0, 0.0, 0.0, 1.0); 96# } 97# } 98SHADER fragment reference_fragment_shader SPIRV-ASM TARGET_ENV spv1.0 99; SPIR-V 100; Version: 1.0 101; Generator: Khronos Glslang Reference Front End; 10 102; Bound: 207 103; Schema: 0 104 OpCapability Shader 105 %1 = OpExtInstImport "GLSL.std.450" 106 OpMemoryModel Logical GLSL450 107 OpEntryPoint Fragment %4 "main" %162 %191 108 OpExecutionMode %4 OriginUpperLeft 109 OpSource ESSL 320 110 OpName %4 "main" 111 OpName %12 "cross2d(vf2;vf2;" 112 OpName %10 "a" 113 OpName %11 "b" 114 OpName %20 "pointInTriangle(vf2;vf2;vf2;vf2;" 115 OpName %16 "p" 116 OpName %17 "a" 117 OpName %18 "b" 118 OpName %19 "c" 119 OpName %39 "pab" 120 OpName %62 "param" 121 OpName %63 "param" 122 OpName %65 "pbc" 123 OpName %88 "param" 124 OpName %89 "param" 125 OpName %112 "pca" 126 OpName %135 "param" 127 OpName %136 "param" 128 OpName %159 "pos" 129 OpName %162 "gl_FragCoord" 130 OpName %165 "buf0" 131 OpMemberName %165 0 "resolution" 132 OpName %167 "" 133 OpName %181 "param" 134 OpName %183 "param" 135 OpName %184 "param" 136 OpName %185 "param" 137 OpName %191 "_GLF_color" 138 OpDecorate %162 BuiltIn FragCoord 139 OpMemberDecorate %165 0 Offset 0 140 OpDecorate %165 Block 141 OpDecorate %167 DescriptorSet 0 142 OpDecorate %167 Binding 0 143 OpDecorate %191 Location 0 144 %2 = OpTypeVoid 145 %3 = OpTypeFunction %2 146 %6 = OpTypeFloat 32 147 %7 = OpTypeVector %6 2 148 %8 = OpTypePointer Function %7 149 %9 = OpTypeFunction %6 %8 %8 150 %14 = OpTypeInt 32 1 151 %15 = OpTypeFunction %14 %8 %8 %8 %8 152 %22 = OpTypeInt 32 0 153 %23 = OpConstant %22 0 154 %24 = OpTypePointer Function %6 155 %27 = OpConstant %22 1 156 %91 = OpTypeBool 157 %93 = OpConstant %6 0 158 %110 = OpConstant %14 0 159 %156 = OpConstant %14 1 160 %160 = OpTypeVector %6 4 161 %161 = OpTypePointer Input %160 162 %162 = OpVariable %161 Input 163 %165 = OpTypeStruct %7 164 %166 = OpTypePointer Uniform %165 165 %167 = OpVariable %166 Uniform 166 %168 = OpTypePointer Uniform %7 167 %172 = OpConstant %6 0.699999988 168 %173 = OpConstant %6 0.300000012 169 %174 = OpConstantComposite %7 %172 %173 170 %175 = OpConstant %6 0.5 171 %176 = OpConstant %6 0.899999976 172 %177 = OpConstantComposite %7 %175 %176 173 %178 = OpConstant %6 0.100000001 174 %179 = OpConstant %6 0.400000006 175 %180 = OpConstantComposite %7 %178 %179 176 %190 = OpTypePointer Output %160 177 %191 = OpVariable %190 Output 178 %192 = OpConstant %6 1 179 %193 = OpConstantComposite %160 %192 %93 %93 %192 180 %195 = OpConstantComposite %160 %93 %93 %93 %192 181 %197 = OpTypePointer Function %14 182 %201 = OpConstantFalse %91 183 %202 = OpTypePointer Function %91 184 %204 = OpConstantTrue %91 185 %4 = OpFunction %2 None %3 186 %5 = OpLabel 187 %159 = OpVariable %8 Function 188 %181 = OpVariable %8 Function 189 %183 = OpVariable %8 Function 190 %184 = OpVariable %8 Function 191 %185 = OpVariable %8 Function 192 %163 = OpLoad %160 %162 193 %164 = OpVectorShuffle %7 %163 %163 0 1 194 %169 = OpAccessChain %168 %167 %110 195 %170 = OpLoad %7 %169 196 %171 = OpFDiv %7 %164 %170 197 OpStore %159 %171 198 OpStore %181 %171 199 OpStore %183 %174 200 OpStore %184 %177 201 OpStore %185 %180 202 %186 = OpFunctionCall %14 %20 %181 %183 %184 %185 203 %187 = OpIEqual %91 %186 %156 204 OpSelectionMerge %189 None 205 OpBranchConditional %187 %188 %194 206 %188 = OpLabel 207 OpStore %191 %193 208 OpBranch %189 209 %194 = OpLabel 210 OpStore %191 %195 211 OpBranch %189 212 %189 = OpLabel 213 OpReturn 214 OpFunctionEnd 215 %12 = OpFunction %6 None %9 216 %10 = OpFunctionParameter %8 217 %11 = OpFunctionParameter %8 218 %13 = OpLabel 219 %25 = OpAccessChain %24 %10 %23 220 %26 = OpLoad %6 %25 221 %28 = OpAccessChain %24 %11 %27 222 %29 = OpLoad %6 %28 223 %30 = OpFMul %6 %26 %29 224 %31 = OpAccessChain %24 %11 %23 225 %32 = OpLoad %6 %31 226 %33 = OpAccessChain %24 %10 %27 227 %34 = OpLoad %6 %33 228 %35 = OpFMul %6 %32 %34 229 %36 = OpFSub %6 %30 %35 230 OpReturnValue %36 231 OpFunctionEnd 232 %20 = OpFunction %14 None %15 233 %16 = OpFunctionParameter %8 234 %17 = OpFunctionParameter %8 235 %18 = OpFunctionParameter %8 236 %19 = OpFunctionParameter %8 237 %21 = OpLabel 238 %203 = OpVariable %202 Function %201 239 %198 = OpVariable %197 Function 240 %39 = OpVariable %24 Function 241 %62 = OpVariable %8 Function 242 %63 = OpVariable %8 Function 243 %65 = OpVariable %24 Function 244 %88 = OpVariable %8 Function 245 %89 = OpVariable %8 Function 246 %112 = OpVariable %24 Function 247 %135 = OpVariable %8 Function 248 %136 = OpVariable %8 Function 249 OpSelectionMerge %196 None 250 OpSwitch %23 %200 251 %200 = OpLabel 252 %40 = OpAccessChain %24 %16 %23 253 %41 = OpLoad %6 %40 254 %42 = OpAccessChain %24 %17 %23 255 %43 = OpLoad %6 %42 256 %44 = OpFSub %6 %41 %43 257 %45 = OpAccessChain %24 %16 %27 258 %46 = OpLoad %6 %45 259 %47 = OpAccessChain %24 %17 %27 260 %48 = OpLoad %6 %47 261 %49 = OpFSub %6 %46 %48 262 %50 = OpCompositeConstruct %7 %44 %49 263 %51 = OpAccessChain %24 %18 %23 264 %52 = OpLoad %6 %51 265 %54 = OpLoad %6 %42 266 %55 = OpFSub %6 %52 %54 267 %56 = OpAccessChain %24 %18 %27 268 %57 = OpLoad %6 %56 269 %59 = OpLoad %6 %47 270 %60 = OpFSub %6 %57 %59 271 %61 = OpCompositeConstruct %7 %55 %60 272 OpStore %62 %50 273 OpStore %63 %61 274 %64 = OpFunctionCall %6 %12 %62 %63 275 OpStore %39 %64 276 %67 = OpLoad %6 %40 277 %69 = OpLoad %6 %51 278 %70 = OpFSub %6 %67 %69 279 %72 = OpLoad %6 %45 280 %74 = OpLoad %6 %56 281 %75 = OpFSub %6 %72 %74 282 %76 = OpCompositeConstruct %7 %70 %75 283 %77 = OpAccessChain %24 %19 %23 284 %78 = OpLoad %6 %77 285 %80 = OpLoad %6 %51 286 %81 = OpFSub %6 %78 %80 287 %82 = OpAccessChain %24 %19 %27 288 %83 = OpLoad %6 %82 289 %85 = OpLoad %6 %56 290 %86 = OpFSub %6 %83 %85 291 %87 = OpCompositeConstruct %7 %81 %86 292 OpStore %88 %76 293 OpStore %89 %87 294 %90 = OpFunctionCall %6 %12 %88 %89 295 OpStore %65 %90 296 %94 = OpFOrdLessThan %91 %64 %93 297 %96 = OpFOrdLessThan %91 %90 %93 298 %97 = OpLogicalAnd %91 %94 %96 299 %98 = OpLogicalNot %91 %97 300 OpSelectionMerge %100 None 301 OpBranchConditional %98 %99 %100 302 %99 = OpLabel 303 %102 = OpFOrdGreaterThanEqual %91 %64 %93 304 %104 = OpFOrdGreaterThanEqual %91 %90 %93 305 %105 = OpLogicalAnd %91 %102 %104 306 OpBranch %100 307 %100 = OpLabel 308 %106 = OpPhi %91 %97 %200 %105 %99 309 %107 = OpLogicalNot %91 %106 310 OpSelectionMerge %109 None 311 OpBranchConditional %107 %108 %109 312 %108 = OpLabel 313 OpStore %203 %204 314 OpStore %198 %110 315 OpBranch %196 316 %109 = OpLabel 317 %114 = OpLoad %6 %40 318 %116 = OpLoad %6 %77 319 %117 = OpFSub %6 %114 %116 320 %119 = OpLoad %6 %45 321 %121 = OpLoad %6 %82 322 %122 = OpFSub %6 %119 %121 323 %123 = OpCompositeConstruct %7 %117 %122 324 %125 = OpLoad %6 %42 325 %127 = OpLoad %6 %77 326 %128 = OpFSub %6 %125 %127 327 %130 = OpLoad %6 %47 328 %132 = OpLoad %6 %82 329 %133 = OpFSub %6 %130 %132 330 %134 = OpCompositeConstruct %7 %128 %133 331 OpStore %135 %123 332 OpStore %136 %134 333 %137 = OpFunctionCall %6 %12 %135 %136 334 OpStore %112 %137 335 %139 = OpFOrdLessThan %91 %64 %93 336 %141 = OpFOrdLessThan %91 %137 %93 337 %142 = OpLogicalAnd %91 %139 %141 338 %143 = OpLogicalNot %91 %142 339 OpSelectionMerge %145 None 340 OpBranchConditional %143 %144 %145 341 %144 = OpLabel 342 %147 = OpFOrdGreaterThanEqual %91 %64 %93 343 %149 = OpFOrdGreaterThanEqual %91 %137 %93 344 %150 = OpLogicalAnd %91 %147 %149 345 OpBranch %145 346 %145 = OpLabel 347 %151 = OpPhi %91 %142 %109 %150 %144 348 %152 = OpLogicalNot %91 %151 349 OpSelectionMerge %154 None 350 OpBranchConditional %152 %153 %154 351 %153 = OpLabel 352 OpStore %203 %204 353 OpStore %198 %110 354 OpBranch %196 355 %154 = OpLabel 356 OpStore %203 %204 357 OpStore %198 %156 358 OpBranch %196 359 %196 = OpLabel 360 %206 = OpPhi %14 %110 %108 %110 %153 %156 %154 361 OpReturnValue %206 362 OpFunctionEnd 363END 364 365# uniforms for reference 366 367# resolution 368BUFFER reference_resolution DATA_TYPE vec2<float> DATA 369 256.0 256.0 370END 371 372BUFFER reference_framebuffer FORMAT B8G8R8A8_UNORM 373 374PIPELINE graphics reference_pipeline 375 ATTACH reference_vertex_shader 376 ATTACH reference_fragment_shader 377 FRAMEBUFFER_SIZE 256 256 378 BIND BUFFER reference_framebuffer AS color LOCATION 0 379 BIND BUFFER reference_resolution AS uniform DESCRIPTOR_SET 0 BINDING 0 380END 381CLEAR_COLOR reference_pipeline 0 0 0 255 382 383CLEAR reference_pipeline 384RUN reference_pipeline DRAW_RECT POS 0 0 SIZE 256 256 385 386 387SHADER vertex variant_vertex_shader PASSTHROUGH 388 389# variant_fragment_shader is derived from the following GLSL: 390# #version 320 es 391# precision highp float; 392# 393# precision highp int; 394# 395# layout(location = 0) out vec4 _GLF_color; 396# 397# layout(set = 0, binding = 0) uniform buf0 398# { 399# vec2 resolution; 400# }; 401# float cross2d(vec2 a, vec2 b) 402# { 403# return ((a.x) * (b.y) - (b.x) * (a.y)); 404# } 405# int pointInTriangle(vec2 p, vec2 a, vec2 b, vec2 c) 406# { 407# const int array_size = 256; 408# int array_a[array_size]; 409# float pab = cross2d(vec2(p.x - a.x, p.y - a.y), vec2(b.x - a.x, b.y - a.y)); 410# float pbc = cross2d(vec2(p.x - b.x, p.y - b.y), vec2(c.x - b.x, c.y - b.y)); 411# if (!((pab < 0.0 && pbc < 0.0) || (pab >= 0.0 && pbc >= 0.0))) 412# { 413# // Injected live code block has no impact on rest of the code in the shader. 414# // Initialize array to known values. 415# for (int i = 0; i < array_size; i++) 416# { 417# array_a[i] = 0; 418# } 419# // Total loop iteration count: 6x4x4x4 = 384. 420# for (int int_a = 0; int_a < 6; ) 421# { 422# int_a++; 423# int int_c = 1; 424# int int_h = 1; 425# int int_d = 0; 426# do 427# { 428# int_d++; 429# int int_e = 0; 430# for (int int_f = 0; int_f < 4; int_c++) 431# { 432# int_f++; 433# for (int int_g = 0; int_g < 4; int_e++) 434# { 435# int_g++; 436# if (array_a[clamp(int_e * 2 + 32, 0, array_size - 1)] == 0) 437# { 438# int_h = int_c; 439# } 440# } 441# } 442# array_a[clamp(1 + int_h * 16, 0, array_size - 1)] = 1; 443# } while (int_d < 4); 444# } 445# return 0; 446# } 447# float pca = cross2d(vec2(p.x - c.x, p.y - c.y), vec2(a.x - c.x, a.y - c.y)); 448# if (!((pab < 0.0 && pca < 0.0) || (pab >= 0.0 && pca >= 0.0))) 449# { 450# return 0; 451# } 452# return 1; 453# } 454# void main() 455# { 456# vec2 pos = gl_FragCoord.xy / resolution; 457# if (pointInTriangle(pos, vec2(0.7, 0.3), vec2(0.5, 0.9), vec2(0.1, 0.4)) == 1) 458# { 459# _GLF_color = vec4(1.0, 0.0, 0.0, 1.0); 460# } 461# else 462# { 463# _GLF_color = vec4(0.0, 0.0, 0.0, 1.0); 464# } 465# } 466SHADER fragment variant_fragment_shader SPIRV-ASM TARGET_ENV spv1.0 467; SPIR-V 468; Version: 1.0 469; Generator: Khronos Glslang Reference Front End; 10 470; Bound: 318 471; Schema: 0 472 OpCapability Shader 473 %1 = OpExtInstImport "GLSL.std.450" 474 OpMemoryModel Logical GLSL450 475 OpEntryPoint Fragment %4 "main" %247 %276 476 OpExecutionMode %4 OriginUpperLeft 477 OpSource ESSL 320 478 OpName %4 "main" 479 OpName %12 "cross2d(vf2;vf2;" 480 OpName %10 "a" 481 OpName %11 "b" 482 OpName %20 "pointInTriangle(vf2;vf2;vf2;vf2;" 483 OpName %16 "p" 484 OpName %17 "a" 485 OpName %18 "b" 486 OpName %19 "c" 487 OpName %39 "pab" 488 OpName %62 "param" 489 OpName %63 "param" 490 OpName %65 "pbc" 491 OpName %88 "param" 492 OpName %89 "param" 493 OpName %111 "i" 494 OpName %124 "array_a" 495 OpName %130 "int_a" 496 OpName %141 "int_c" 497 OpName %142 "int_h" 498 OpName %143 "int_d" 499 OpName %150 "int_e" 500 OpName %151 "int_f" 501 OpName %162 "int_g" 502 OpName %198 "pca" 503 OpName %221 "param" 504 OpName %222 "param" 505 OpName %244 "pos" 506 OpName %247 "gl_FragCoord" 507 OpName %250 "buf0" 508 OpMemberName %250 0 "resolution" 509 OpName %252 "" 510 OpName %266 "param" 511 OpName %268 "param" 512 OpName %269 "param" 513 OpName %270 "param" 514 OpName %276 "_GLF_color" 515 OpDecorate %247 BuiltIn FragCoord 516 OpMemberDecorate %250 0 Offset 0 517 OpDecorate %250 Block 518 OpDecorate %252 DescriptorSet 0 519 OpDecorate %252 Binding 0 520 OpDecorate %276 Location 0 521 %2 = OpTypeVoid 522 %3 = OpTypeFunction %2 523 %6 = OpTypeFloat 32 524 %7 = OpTypeVector %6 2 525 %8 = OpTypePointer Function %7 526 %9 = OpTypeFunction %6 %8 %8 527 %14 = OpTypeInt 32 1 528 %15 = OpTypeFunction %14 %8 %8 %8 %8 529 %22 = OpTypeInt 32 0 530 %23 = OpConstant %22 0 531 %24 = OpTypePointer Function %6 532 %27 = OpConstant %22 1 533 %91 = OpTypeBool 534 %93 = OpConstant %6 0 535 %110 = OpTypePointer Function %14 536 %112 = OpConstant %14 0 537 %119 = OpConstant %14 256 538 %121 = OpConstant %22 256 539 %122 = OpTypeArray %14 %121 540 %123 = OpTypePointer Function %122 541 %128 = OpConstant %14 1 542 %137 = OpConstant %14 6 543 %158 = OpConstant %14 4 544 %173 = OpConstant %14 2 545 %175 = OpConstant %14 32 546 %177 = OpConstant %14 255 547 %190 = OpConstant %14 16 548 %245 = OpTypeVector %6 4 549 %246 = OpTypePointer Input %245 550 %247 = OpVariable %246 Input 551 %250 = OpTypeStruct %7 552 %251 = OpTypePointer Uniform %250 553 %252 = OpVariable %251 Uniform 554 %253 = OpTypePointer Uniform %7 555 %257 = OpConstant %6 0.699999988 556 %258 = OpConstant %6 0.300000012 557 %259 = OpConstantComposite %7 %257 %258 558 %260 = OpConstant %6 0.5 559 %261 = OpConstant %6 0.899999976 560 %262 = OpConstantComposite %7 %260 %261 561 %263 = OpConstant %6 0.100000001 562 %264 = OpConstant %6 0.400000006 563 %265 = OpConstantComposite %7 %263 %264 564 %275 = OpTypePointer Output %245 565 %276 = OpVariable %275 Output 566 %277 = OpConstant %6 1 567 %278 = OpConstantComposite %245 %277 %93 %93 %277 568 %280 = OpConstantComposite %245 %93 %93 %93 %277 569 %285 = OpConstantFalse %91 570 %286 = OpTypePointer Function %91 571 %288 = OpConstantTrue %91 572 %317 = OpConstant %14 17 573 %4 = OpFunction %2 None %3 574 %5 = OpLabel 575 %244 = OpVariable %8 Function 576 %266 = OpVariable %8 Function 577 %268 = OpVariable %8 Function 578 %269 = OpVariable %8 Function 579 %270 = OpVariable %8 Function 580 %248 = OpLoad %245 %247 581 %249 = OpVectorShuffle %7 %248 %248 0 1 582 %254 = OpAccessChain %253 %252 %112 583 %255 = OpLoad %7 %254 584 %256 = OpFDiv %7 %249 %255 585 OpStore %244 %256 586 OpStore %266 %256 587 OpStore %268 %259 588 OpStore %269 %262 589 OpStore %270 %265 590 %271 = OpFunctionCall %14 %20 %266 %268 %269 %270 591 %272 = OpIEqual %91 %271 %128 592 OpSelectionMerge %274 None 593 OpBranchConditional %272 %273 %279 594 %273 = OpLabel 595 OpStore %276 %278 596 OpBranch %274 597 %279 = OpLabel 598 OpStore %276 %280 599 OpBranch %274 600 %274 = OpLabel 601 OpReturn 602 OpFunctionEnd 603 %12 = OpFunction %6 None %9 604 %10 = OpFunctionParameter %8 605 %11 = OpFunctionParameter %8 606 %13 = OpLabel 607 %25 = OpAccessChain %24 %10 %23 608 %26 = OpLoad %6 %25 609 %28 = OpAccessChain %24 %11 %27 610 %29 = OpLoad %6 %28 611 %30 = OpFMul %6 %26 %29 612 %31 = OpAccessChain %24 %11 %23 613 %32 = OpLoad %6 %31 614 %33 = OpAccessChain %24 %10 %27 615 %34 = OpLoad %6 %33 616 %35 = OpFMul %6 %32 %34 617 %36 = OpFSub %6 %30 %35 618 OpReturnValue %36 619 OpFunctionEnd 620 %20 = OpFunction %14 None %15 621 %16 = OpFunctionParameter %8 622 %17 = OpFunctionParameter %8 623 %18 = OpFunctionParameter %8 624 %19 = OpFunctionParameter %8 625 %21 = OpLabel 626 %287 = OpVariable %286 Function %285 627 %282 = OpVariable %110 Function 628 %39 = OpVariable %24 Function 629 %62 = OpVariable %8 Function 630 %63 = OpVariable %8 Function 631 %65 = OpVariable %24 Function 632 %88 = OpVariable %8 Function 633 %89 = OpVariable %8 Function 634 %111 = OpVariable %110 Function 635 %124 = OpVariable %123 Function 636 %130 = OpVariable %110 Function 637 %141 = OpVariable %110 Function 638 %142 = OpVariable %110 Function 639 %143 = OpVariable %110 Function 640 %150 = OpVariable %110 Function 641 %151 = OpVariable %110 Function 642 %162 = OpVariable %110 Function 643 %198 = OpVariable %24 Function 644 %221 = OpVariable %8 Function 645 %222 = OpVariable %8 Function 646 OpSelectionMerge %281 None 647 OpSwitch %23 %284 648 %284 = OpLabel 649 %40 = OpAccessChain %24 %16 %23 650 %41 = OpLoad %6 %40 651 %42 = OpAccessChain %24 %17 %23 652 %43 = OpLoad %6 %42 653 %44 = OpFSub %6 %41 %43 654 %45 = OpAccessChain %24 %16 %27 655 %46 = OpLoad %6 %45 656 %47 = OpAccessChain %24 %17 %27 657 %48 = OpLoad %6 %47 658 %49 = OpFSub %6 %46 %48 659 %50 = OpCompositeConstruct %7 %44 %49 660 %51 = OpAccessChain %24 %18 %23 661 %52 = OpLoad %6 %51 662 %54 = OpLoad %6 %42 663 %55 = OpFSub %6 %52 %54 664 %56 = OpAccessChain %24 %18 %27 665 %57 = OpLoad %6 %56 666 %59 = OpLoad %6 %47 667 %60 = OpFSub %6 %57 %59 668 %61 = OpCompositeConstruct %7 %55 %60 669 OpStore %62 %50 670 OpStore %63 %61 671 %64 = OpFunctionCall %6 %12 %62 %63 672 OpStore %39 %64 673 %67 = OpLoad %6 %40 674 %69 = OpLoad %6 %51 675 %70 = OpFSub %6 %67 %69 676 %72 = OpLoad %6 %45 677 %74 = OpLoad %6 %56 678 %75 = OpFSub %6 %72 %74 679 %76 = OpCompositeConstruct %7 %70 %75 680 %77 = OpAccessChain %24 %19 %23 681 %78 = OpLoad %6 %77 682 %80 = OpLoad %6 %51 683 %81 = OpFSub %6 %78 %80 684 %82 = OpAccessChain %24 %19 %27 685 %83 = OpLoad %6 %82 686 %85 = OpLoad %6 %56 687 %86 = OpFSub %6 %83 %85 688 %87 = OpCompositeConstruct %7 %81 %86 689 OpStore %88 %76 690 OpStore %89 %87 691 %90 = OpFunctionCall %6 %12 %88 %89 692 OpStore %65 %90 693 %94 = OpFOrdLessThan %91 %64 %93 694 %96 = OpFOrdLessThan %91 %90 %93 695 %97 = OpLogicalAnd %91 %94 %96 696 %98 = OpLogicalNot %91 %97 697 OpSelectionMerge %100 None 698 OpBranchConditional %98 %99 %100 699 %99 = OpLabel 700 %102 = OpFOrdGreaterThanEqual %91 %64 %93 701 %104 = OpFOrdGreaterThanEqual %91 %90 %93 702 %105 = OpLogicalAnd %91 %102 %104 703 OpBranch %100 704 %100 = OpLabel 705 %106 = OpPhi %91 %97 %284 %105 %99 706 %107 = OpLogicalNot %91 %106 707 OpSelectionMerge %109 None 708 OpBranchConditional %107 %108 %109 709 %108 = OpLabel 710 OpStore %111 %112 711 OpBranch %113 712 %113 = OpLabel 713 %290 = OpPhi %14 %112 %108 %129 %116 714 OpLoopMerge %115 %116 None 715 OpBranch %117 716 %117 = OpLabel 717 %120 = OpSLessThan %91 %290 %119 718 OpBranchConditional %120 %114 %115 719 %114 = OpLabel 720 %126 = OpAccessChain %110 %124 %290 721 OpStore %126 %112 722 OpBranch %116 723 %116 = OpLabel 724 %129 = OpIAdd %14 %290 %128 725 OpStore %111 %129 726 OpBranch %113 727 %115 = OpLabel 728 OpStore %130 %112 729 OpBranch %131 730 %131 = OpLabel 731 %291 = OpPhi %14 %112 %115 %306 %134 732 OpLoopMerge %133 %134 None 733 OpBranch %135 734 %135 = OpLabel 735 %138 = OpSLessThan %91 %291 %137 736 OpBranchConditional %138 %132 %133 737 %132 = OpLabel 738 %140 = OpIAdd %14 %291 %128 739 OpStore %130 %140 740 OpStore %141 %128 741 OpStore %142 %128 742 OpStore %143 %112 743 OpBranch %144 744 %144 = OpLabel 745 %296 = OpPhi %14 %128 %132 %295 %147 746 %293 = OpPhi %14 %112 %132 %149 %147 747 %306 = OpPhi %14 %140 %132 %306 %147 748 %301 = OpPhi %14 %128 %132 %300 %147 749 OpLoopMerge %146 %147 None 750 OpBranch %145 751 %145 = OpLabel 752 %149 = OpIAdd %14 %293 %128 753 OpStore %143 %149 754 OpStore %150 %112 755 OpStore %151 %112 756 OpBranch %152 757 %152 = OpLabel 758 %300 = OpPhi %14 %301 %145 %188 %155 759 %295 = OpPhi %14 %296 %145 %311 %155 760 %294 = OpPhi %14 %112 %145 %161 %155 761 %303 = OpPhi %14 %112 %145 %302 %155 762 OpLoopMerge %154 %155 None 763 OpBranch %156 764 %156 = OpLabel 765 %159 = OpSLessThan %91 %294 %158 766 OpBranchConditional %159 %153 %154 767 %153 = OpLabel 768 %161 = OpIAdd %14 %294 %128 769 OpStore %151 %161 770 OpStore %162 %112 771 OpBranch %163 772 %163 = OpLabel 773 %302 = OpPhi %14 %303 %153 %186 %166 774 %298 = OpPhi %14 %112 %153 %171 %166 775 %311 = OpPhi %14 %295 %153 %312 %166 776 OpLoopMerge %165 %166 None 777 OpBranch %167 778 %167 = OpLabel 779 %169 = OpSLessThan %91 %298 %158 780 OpBranchConditional %169 %164 %165 781 %164 = OpLabel 782 %171 = OpIAdd %14 %298 %128 783 OpStore %162 %171 784 %174 = OpIMul %14 %302 %173 785 %176 = OpIAdd %14 %174 %175 786 %178 = OpExtInst %14 %1 SClamp %176 %112 %177 787 %179 = OpAccessChain %110 %124 %178 788 %180 = OpLoad %14 %179 789 %181 = OpIEqual %91 %180 %112 790 OpSelectionMerge %183 None 791 OpBranchConditional %181 %182 %183 792 %182 = OpLabel 793 OpStore %142 %300 794 OpBranch %183 795 %183 = OpLabel 796 %312 = OpPhi %14 %311 %164 %300 %182 797 OpBranch %166 798 %166 = OpLabel 799 %186 = OpIAdd %14 %302 %128 800 OpStore %150 %186 801 OpBranch %163 802 %165 = OpLabel 803 OpBranch %155 804 %155 = OpLabel 805 %188 = OpIAdd %14 %300 %128 806 OpStore %141 %188 807 OpBranch %152 808 %154 = OpLabel 809 %191 = OpIMul %14 %295 %190 810 %192 = OpIAdd %14 %128 %191 811 %193 = OpExtInst %14 %1 SClamp %192 %112 %177 812 %194 = OpAccessChain %110 %124 %193 813 OpStore %194 %128 814 OpBranch %147 815 %147 = OpLabel 816 %196 = OpSLessThan %91 %149 %158 817 OpBranchConditional %196 %144 %146 818 %146 = OpLabel 819 OpBranch %134 820 %134 = OpLabel 821 OpBranch %131 822 %133 = OpLabel 823 OpStore %287 %288 824 OpStore %282 %112 825 OpBranch %281 826 %109 = OpLabel 827 %200 = OpLoad %6 %40 828 %202 = OpLoad %6 %77 829 %203 = OpFSub %6 %200 %202 830 %205 = OpLoad %6 %45 831 %207 = OpLoad %6 %82 832 %208 = OpFSub %6 %205 %207 833 %209 = OpCompositeConstruct %7 %203 %208 834 %211 = OpLoad %6 %42 835 %213 = OpLoad %6 %77 836 %214 = OpFSub %6 %211 %213 837 %216 = OpLoad %6 %47 838 %218 = OpLoad %6 %82 839 %219 = OpFSub %6 %216 %218 840 %220 = OpCompositeConstruct %7 %214 %219 841 OpStore %221 %209 842 OpStore %222 %220 843 %223 = OpFunctionCall %6 %12 %221 %222 844 OpStore %198 %223 845 %225 = OpFOrdLessThan %91 %64 %93 846 %227 = OpFOrdLessThan %91 %223 %93 847 %228 = OpLogicalAnd %91 %225 %227 848 %229 = OpLogicalNot %91 %228 849 OpSelectionMerge %231 None 850 OpBranchConditional %229 %230 %231 851 %230 = OpLabel 852 %233 = OpFOrdGreaterThanEqual %91 %64 %93 853 %235 = OpFOrdGreaterThanEqual %91 %223 %93 854 %236 = OpLogicalAnd %91 %233 %235 855 OpBranch %231 856 %231 = OpLabel 857 %237 = OpPhi %91 %228 %109 %236 %230 858 %238 = OpLogicalNot %91 %237 859 OpSelectionMerge %240 None 860 OpBranchConditional %238 %239 %240 861 %239 = OpLabel 862 OpStore %287 %288 863 OpStore %282 %112 864 OpBranch %281 865 %240 = OpLabel 866 OpStore %287 %288 867 OpStore %282 %128 868 OpBranch %281 869 %281 = OpLabel 870 %292 = OpPhi %14 %112 %133 %112 %239 %128 %240 871 OpReturnValue %292 872 OpFunctionEnd 873END 874 875# uniforms for variant 876 877# resolution 878BUFFER variant_resolution DATA_TYPE vec2<float> DATA 879 256.0 256.0 880END 881 882BUFFER variant_framebuffer FORMAT B8G8R8A8_UNORM 883 884PIPELINE graphics variant_pipeline 885 ATTACH variant_vertex_shader 886 ATTACH variant_fragment_shader 887 FRAMEBUFFER_SIZE 256 256 888 BIND BUFFER variant_framebuffer AS color LOCATION 0 889 BIND BUFFER variant_resolution AS uniform DESCRIPTOR_SET 0 BINDING 0 890END 891CLEAR_COLOR variant_pipeline 0 0 0 255 892 893CLEAR variant_pipeline 894RUN variant_pipeline DRAW_RECT POS 0 0 SIZE 256 256 895 896EXPECT reference_framebuffer EQ_HISTOGRAM_EMD_BUFFER variant_framebuffer TOLERANCE 0.005 897