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 coverage-gap found by the GraphicsFuzz project. 19 20# Short description: A fragment shader that cover specific optimize phis code paths 21 22# The test passes because the shader always writes red. 23 24SHADER vertex variant_vertex_shader PASSTHROUGH 25 26# variant_fragment_shader is derived from the following GLSL: 27# #version 310 es 28# #define _int_2 _GLF_uniform_int_values[0] 29# #define _int_0 _GLF_uniform_int_values[1] 30# #define _int_1 _GLF_uniform_int_values[2] 31# #define _float_1_0 _GLF_uniform_float_values[0] 32# #define _float_0_0 _GLF_uniform_float_values[1] 33# 34# precision highp float; 35# 36# // Contents of _GLF_uniform_float_values: [1.0, 0.0] 37# layout(set = 0, binding = 0) uniform buf0 38# { 39# float _GLF_uniform_float_values[2]; 40# }; 41# 42# // Contents of _GLF_uniform_int_values: [2, 0, 1] 43# layout(set = 0, binding = 1) uniform buf1 44# { 45# int _GLF_uniform_int_values[3]; 46# }; 47# 48# layout(location = 0) out vec4 _GLF_color; 49# 50# void main() 51# { 52# float a = _float_1_0; 53# float b = _float_0_0; 54# 55# for (int i = _int_0; i < _int_2; i++) 56# { 57# for (int i = _int_0; i < _int_2; i++) 58# { 59# for (int i = _int_0; i < _int_2; i++) 60# { 61# for (int i = _int_1; i < _int_2; i++) 62# { 63# for (int i = _int_1; i < _int_2; i++) 64# { 65# for (int i = _int_0; i < _int_2; i++) 66# { 67# for (int i = _int_0; i < _int_2; i++) 68# { 69# for (int i = _int_0; i < _int_2; i++) 70# { 71# for (int i = _int_0; i < _int_2; i++) 72# { 73# for (int i = _int_0; i < _int_2; i++) 74# { 75# for (int i = _int_0; i < _int_2; 76# i++) 77# { 78# a = _float_0_0; 79# if (gl_FragCoord.y > _float_0_0) 80# { 81# break; 82# } 83# } 84# } 85# } 86# } 87# } 88# } 89# } 90# } 91# } 92# } 93# b++; 94# } 95# _GLF_color = vec4(b, a, a, b); 96# } 97SHADER fragment variant_fragment_shader SPIRV-ASM TARGET_ENV spv1.0 98; SPIR-V 99; Version: 1.0 100; Generator: Khronos Glslang Reference Front End; 8 101; Bound: 212 102; Schema: 0 103 OpCapability Shader 104 %1 = OpExtInstImport "GLSL.std.450" 105 OpMemoryModel Logical GLSL450 106 OpEntryPoint Fragment %4 "main" %169 %206 107 OpExecutionMode %4 OriginUpperLeft 108 OpSource ESSL 310 109 OpName %4 "main" 110 OpName %8 "a" 111 OpName %12 "buf0" 112 OpMemberName %12 0 "_GLF_uniform_float_values" 113 OpName %14 "" 114 OpName %20 "b" 115 OpName %25 "i" 116 OpName %28 "buf1" 117 OpMemberName %28 0 "_GLF_uniform_int_values" 118 OpName %30 "" 119 OpName %44 "i" 120 OpName %56 "i" 121 OpName %68 "i" 122 OpName %81 "i" 123 OpName %93 "i" 124 OpName %105 "i" 125 OpName %117 "i" 126 OpName %129 "i" 127 OpName %141 "i" 128 OpName %153 "i" 129 OpName %169 "gl_FragCoord" 130 OpName %206 "_GLF_color" 131 OpDecorate %11 ArrayStride 16 132 OpMemberDecorate %12 0 Offset 0 133 OpDecorate %12 Block 134 OpDecorate %14 DescriptorSet 0 135 OpDecorate %14 Binding 0 136 OpDecorate %25 RelaxedPrecision 137 OpDecorate %27 ArrayStride 16 138 OpMemberDecorate %28 0 RelaxedPrecision 139 OpMemberDecorate %28 0 Offset 0 140 OpDecorate %28 Block 141 OpDecorate %30 DescriptorSet 0 142 OpDecorate %30 Binding 1 143 OpDecorate %33 RelaxedPrecision 144 OpDecorate %39 RelaxedPrecision 145 OpDecorate %41 RelaxedPrecision 146 OpDecorate %44 RelaxedPrecision 147 OpDecorate %46 RelaxedPrecision 148 OpDecorate %52 RelaxedPrecision 149 OpDecorate %54 RelaxedPrecision 150 OpDecorate %56 RelaxedPrecision 151 OpDecorate %58 RelaxedPrecision 152 OpDecorate %64 RelaxedPrecision 153 OpDecorate %66 RelaxedPrecision 154 OpDecorate %68 RelaxedPrecision 155 OpDecorate %71 RelaxedPrecision 156 OpDecorate %77 RelaxedPrecision 157 OpDecorate %79 RelaxedPrecision 158 OpDecorate %81 RelaxedPrecision 159 OpDecorate %83 RelaxedPrecision 160 OpDecorate %89 RelaxedPrecision 161 OpDecorate %91 RelaxedPrecision 162 OpDecorate %93 RelaxedPrecision 163 OpDecorate %95 RelaxedPrecision 164 OpDecorate %101 RelaxedPrecision 165 OpDecorate %103 RelaxedPrecision 166 OpDecorate %105 RelaxedPrecision 167 OpDecorate %107 RelaxedPrecision 168 OpDecorate %113 RelaxedPrecision 169 OpDecorate %115 RelaxedPrecision 170 OpDecorate %117 RelaxedPrecision 171 OpDecorate %119 RelaxedPrecision 172 OpDecorate %125 RelaxedPrecision 173 OpDecorate %127 RelaxedPrecision 174 OpDecorate %129 RelaxedPrecision 175 OpDecorate %131 RelaxedPrecision 176 OpDecorate %137 RelaxedPrecision 177 OpDecorate %139 RelaxedPrecision 178 OpDecorate %141 RelaxedPrecision 179 OpDecorate %143 RelaxedPrecision 180 OpDecorate %149 RelaxedPrecision 181 OpDecorate %151 RelaxedPrecision 182 OpDecorate %153 RelaxedPrecision 183 OpDecorate %155 RelaxedPrecision 184 OpDecorate %161 RelaxedPrecision 185 OpDecorate %163 RelaxedPrecision 186 OpDecorate %169 BuiltIn FragCoord 187 OpDecorate %180 RelaxedPrecision 188 OpDecorate %181 RelaxedPrecision 189 OpDecorate %182 RelaxedPrecision 190 OpDecorate %183 RelaxedPrecision 191 OpDecorate %184 RelaxedPrecision 192 OpDecorate %185 RelaxedPrecision 193 OpDecorate %186 RelaxedPrecision 194 OpDecorate %187 RelaxedPrecision 195 OpDecorate %188 RelaxedPrecision 196 OpDecorate %189 RelaxedPrecision 197 OpDecorate %190 RelaxedPrecision 198 OpDecorate %191 RelaxedPrecision 199 OpDecorate %192 RelaxedPrecision 200 OpDecorate %193 RelaxedPrecision 201 OpDecorate %194 RelaxedPrecision 202 OpDecorate %195 RelaxedPrecision 203 OpDecorate %196 RelaxedPrecision 204 OpDecorate %197 RelaxedPrecision 205 OpDecorate %198 RelaxedPrecision 206 OpDecorate %199 RelaxedPrecision 207 OpDecorate %203 RelaxedPrecision 208 OpDecorate %204 RelaxedPrecision 209 OpDecorate %206 Location 0 210 %2 = OpTypeVoid 211 %3 = OpTypeFunction %2 212 %6 = OpTypeFloat 32 213 %7 = OpTypePointer Function %6 214 %9 = OpTypeInt 32 0 215 %10 = OpConstant %9 2 216 %11 = OpTypeArray %6 %10 217 %12 = OpTypeStruct %11 218 %13 = OpTypePointer Uniform %12 219 %14 = OpVariable %13 Uniform 220 %15 = OpTypeInt 32 1 221 %16 = OpConstant %15 0 222 %17 = OpTypePointer Uniform %6 223 %21 = OpConstant %15 1 224 %24 = OpTypePointer Function %15 225 %26 = OpConstant %9 3 226 %27 = OpTypeArray %15 %26 227 %28 = OpTypeStruct %27 228 %29 = OpTypePointer Uniform %28 229 %30 = OpVariable %29 Uniform 230 %31 = OpTypePointer Uniform %15 231 %42 = OpTypeBool 232 %69 = OpConstant %15 2 233 %167 = OpTypeVector %6 4 234 %168 = OpTypePointer Input %167 235 %169 = OpVariable %168 Input 236 %170 = OpConstant %9 1 237 %171 = OpTypePointer Input %6 238 %201 = OpConstant %6 1 239 %205 = OpTypePointer Output %167 240 %206 = OpVariable %205 Output 241 %4 = OpFunction %2 None %3 242 %5 = OpLabel 243 %8 = OpVariable %7 Function 244 %20 = OpVariable %7 Function 245 %25 = OpVariable %24 Function 246 %44 = OpVariable %24 Function 247 %56 = OpVariable %24 Function 248 %68 = OpVariable %24 Function 249 %81 = OpVariable %24 Function 250 %93 = OpVariable %24 Function 251 %105 = OpVariable %24 Function 252 %117 = OpVariable %24 Function 253 %129 = OpVariable %24 Function 254 %141 = OpVariable %24 Function 255 %153 = OpVariable %24 Function 256 %18 = OpAccessChain %17 %14 %16 %16 257 %19 = OpLoad %6 %18 258 OpStore %8 %19 259 %22 = OpAccessChain %17 %14 %16 %21 260 %23 = OpLoad %6 %22 261 OpStore %20 %23 262 %32 = OpAccessChain %31 %30 %16 %21 263 %33 = OpLoad %15 %32 264 OpStore %25 %33 265 OpBranch %34 266 %34 = OpLabel 267 OpLoopMerge %36 %37 None 268 OpBranch %38 269 %38 = OpLabel 270 %39 = OpLoad %15 %25 271 %40 = OpAccessChain %31 %30 %16 %16 272 %41 = OpLoad %15 %40 273 %43 = OpSLessThan %42 %39 %41 274 OpBranchConditional %43 %35 %36 275 %35 = OpLabel 276 %45 = OpAccessChain %31 %30 %16 %21 277 %46 = OpLoad %15 %45 278 OpStore %44 %46 279 OpBranch %47 280 %47 = OpLabel 281 OpLoopMerge %49 %50 None 282 OpBranch %51 283 %51 = OpLabel 284 %52 = OpLoad %15 %44 285 %53 = OpAccessChain %31 %30 %16 %16 286 %54 = OpLoad %15 %53 287 %55 = OpSLessThan %42 %52 %54 288 OpBranchConditional %55 %48 %49 289 %48 = OpLabel 290 %57 = OpAccessChain %31 %30 %16 %21 291 %58 = OpLoad %15 %57 292 OpStore %56 %58 293 OpBranch %59 294 %59 = OpLabel 295 OpLoopMerge %61 %62 None 296 OpBranch %63 297 %63 = OpLabel 298 %64 = OpLoad %15 %56 299 %65 = OpAccessChain %31 %30 %16 %16 300 %66 = OpLoad %15 %65 301 %67 = OpSLessThan %42 %64 %66 302 OpBranchConditional %67 %60 %61 303 %60 = OpLabel 304 %70 = OpAccessChain %31 %30 %16 %69 305 %71 = OpLoad %15 %70 306 OpStore %68 %71 307 OpBranch %72 308 %72 = OpLabel 309 OpLoopMerge %74 %75 None 310 OpBranch %76 311 %76 = OpLabel 312 %77 = OpLoad %15 %68 313 %78 = OpAccessChain %31 %30 %16 %16 314 %79 = OpLoad %15 %78 315 %80 = OpSLessThan %42 %77 %79 316 OpBranchConditional %80 %73 %74 317 %73 = OpLabel 318 %82 = OpAccessChain %31 %30 %16 %69 319 %83 = OpLoad %15 %82 320 OpStore %81 %83 321 OpBranch %84 322 %84 = OpLabel 323 OpLoopMerge %86 %87 None 324 OpBranch %88 325 %88 = OpLabel 326 %89 = OpLoad %15 %81 327 %90 = OpAccessChain %31 %30 %16 %16 328 %91 = OpLoad %15 %90 329 %92 = OpSLessThan %42 %89 %91 330 OpBranchConditional %92 %85 %86 331 %85 = OpLabel 332 %94 = OpAccessChain %31 %30 %16 %21 333 %95 = OpLoad %15 %94 334 OpStore %93 %95 335 OpBranch %96 336 %96 = OpLabel 337 OpLoopMerge %98 %99 None 338 OpBranch %100 339 %100 = OpLabel 340 %101 = OpLoad %15 %93 341 %102 = OpAccessChain %31 %30 %16 %16 342 %103 = OpLoad %15 %102 343 %104 = OpSLessThan %42 %101 %103 344 OpBranchConditional %104 %97 %98 345 %97 = OpLabel 346 %106 = OpAccessChain %31 %30 %16 %21 347 %107 = OpLoad %15 %106 348 OpStore %105 %107 349 OpBranch %108 350 %108 = OpLabel 351 OpLoopMerge %110 %111 None 352 OpBranch %112 353 %112 = OpLabel 354 %113 = OpLoad %15 %105 355 %114 = OpAccessChain %31 %30 %16 %16 356 %115 = OpLoad %15 %114 357 %116 = OpSLessThan %42 %113 %115 358 OpBranchConditional %116 %109 %110 359 %109 = OpLabel 360 %118 = OpAccessChain %31 %30 %16 %21 361 %119 = OpLoad %15 %118 362 OpStore %117 %119 363 OpBranch %120 364 %120 = OpLabel 365 OpLoopMerge %122 %123 None 366 OpBranch %124 367 %124 = OpLabel 368 %125 = OpLoad %15 %117 369 %126 = OpAccessChain %31 %30 %16 %16 370 %127 = OpLoad %15 %126 371 %128 = OpSLessThan %42 %125 %127 372 OpBranchConditional %128 %121 %122 373 %121 = OpLabel 374 %130 = OpAccessChain %31 %30 %16 %21 375 %131 = OpLoad %15 %130 376 OpStore %129 %131 377 OpBranch %132 378 %132 = OpLabel 379 OpLoopMerge %134 %135 None 380 OpBranch %136 381 %136 = OpLabel 382 %137 = OpLoad %15 %129 383 %138 = OpAccessChain %31 %30 %16 %16 384 %139 = OpLoad %15 %138 385 %140 = OpSLessThan %42 %137 %139 386 OpBranchConditional %140 %133 %134 387 %133 = OpLabel 388 %142 = OpAccessChain %31 %30 %16 %21 389 %143 = OpLoad %15 %142 390 OpStore %141 %143 391 OpBranch %144 392 %144 = OpLabel 393 OpLoopMerge %146 %147 None 394 OpBranch %148 395 %148 = OpLabel 396 %149 = OpLoad %15 %141 397 %150 = OpAccessChain %31 %30 %16 %16 398 %151 = OpLoad %15 %150 399 %152 = OpSLessThan %42 %149 %151 400 OpBranchConditional %152 %145 %146 401 %145 = OpLabel 402 %154 = OpAccessChain %31 %30 %16 %21 403 %155 = OpLoad %15 %154 404 OpStore %153 %155 405 OpBranch %156 406 %156 = OpLabel 407 OpLoopMerge %158 %159 None 408 OpBranch %160 409 %160 = OpLabel 410 %161 = OpLoad %15 %153 411 %162 = OpAccessChain %31 %30 %16 %16 412 %163 = OpLoad %15 %162 413 %164 = OpSLessThan %42 %161 %163 414 OpBranchConditional %164 %157 %158 415 %157 = OpLabel 416 %165 = OpAccessChain %17 %14 %16 %21 417 %166 = OpLoad %6 %165 418 OpStore %8 %166 419 %172 = OpAccessChain %171 %169 %170 420 %173 = OpLoad %6 %172 421 %174 = OpAccessChain %17 %14 %16 %21 422 %175 = OpLoad %6 %174 423 %176 = OpFOrdGreaterThan %42 %173 %175 424 OpSelectionMerge %178 None 425 OpBranchConditional %176 %177 %178 426 %177 = OpLabel 427 OpBranch %158 428 %178 = OpLabel 429 OpBranch %159 430 %159 = OpLabel 431 %180 = OpLoad %15 %153 432 %181 = OpIAdd %15 %180 %21 433 OpStore %153 %181 434 OpBranch %156 435 %158 = OpLabel 436 OpBranch %147 437 %147 = OpLabel 438 %182 = OpLoad %15 %141 439 %183 = OpIAdd %15 %182 %21 440 OpStore %141 %183 441 OpBranch %144 442 %146 = OpLabel 443 OpBranch %135 444 %135 = OpLabel 445 %184 = OpLoad %15 %129 446 %185 = OpIAdd %15 %184 %21 447 OpStore %129 %185 448 OpBranch %132 449 %134 = OpLabel 450 OpBranch %123 451 %123 = OpLabel 452 %186 = OpLoad %15 %117 453 %187 = OpIAdd %15 %186 %21 454 OpStore %117 %187 455 OpBranch %120 456 %122 = OpLabel 457 OpBranch %111 458 %111 = OpLabel 459 %188 = OpLoad %15 %105 460 %189 = OpIAdd %15 %188 %21 461 OpStore %105 %189 462 OpBranch %108 463 %110 = OpLabel 464 OpBranch %99 465 %99 = OpLabel 466 %190 = OpLoad %15 %93 467 %191 = OpIAdd %15 %190 %21 468 OpStore %93 %191 469 OpBranch %96 470 %98 = OpLabel 471 OpBranch %87 472 %87 = OpLabel 473 %192 = OpLoad %15 %81 474 %193 = OpIAdd %15 %192 %21 475 OpStore %81 %193 476 OpBranch %84 477 %86 = OpLabel 478 OpBranch %75 479 %75 = OpLabel 480 %194 = OpLoad %15 %68 481 %195 = OpIAdd %15 %194 %21 482 OpStore %68 %195 483 OpBranch %72 484 %74 = OpLabel 485 OpBranch %62 486 %62 = OpLabel 487 %196 = OpLoad %15 %56 488 %197 = OpIAdd %15 %196 %21 489 OpStore %56 %197 490 OpBranch %59 491 %61 = OpLabel 492 OpBranch %50 493 %50 = OpLabel 494 %198 = OpLoad %15 %44 495 %199 = OpIAdd %15 %198 %21 496 OpStore %44 %199 497 OpBranch %47 498 %49 = OpLabel 499 %200 = OpLoad %6 %20 500 %202 = OpFAdd %6 %200 %201 501 OpStore %20 %202 502 OpBranch %37 503 %37 = OpLabel 504 %203 = OpLoad %15 %25 505 %204 = OpIAdd %15 %203 %21 506 OpStore %25 %204 507 OpBranch %34 508 %36 = OpLabel 509 %207 = OpLoad %6 %20 510 %208 = OpLoad %6 %8 511 %209 = OpLoad %6 %8 512 %210 = OpLoad %6 %20 513 %211 = OpCompositeConstruct %167 %207 %208 %209 %210 514 OpStore %206 %211 515 OpReturn 516 OpFunctionEnd 517END 518 519# uniforms for variant 520 521# _GLF_uniform_int_values 522BUFFER variant__GLF_uniform_int_values DATA_TYPE int32[] STD140 DATA 523 2 0 1 524END 525# _GLF_uniform_float_values 526BUFFER variant__GLF_uniform_float_values DATA_TYPE float[] STD140 DATA 527 1.0 0.0 528END 529 530BUFFER variant_framebuffer FORMAT B8G8R8A8_UNORM 531 532PIPELINE graphics variant_pipeline 533 ATTACH variant_vertex_shader 534 ATTACH variant_fragment_shader 535 FRAMEBUFFER_SIZE 16 16 536 BIND BUFFER variant_framebuffer AS color LOCATION 0 537 BIND BUFFER variant__GLF_uniform_int_values AS uniform DESCRIPTOR_SET 0 BINDING 1 538 BIND BUFFER variant__GLF_uniform_float_values AS uniform DESCRIPTOR_SET 0 BINDING 0 539END 540CLEAR_COLOR variant_pipeline 0 0 0 255 541 542CLEAR variant_pipeline 543RUN variant_pipeline DRAW_RECT POS 0 0 SIZE 16 16 544 545EXPECT variant_framebuffer IDX 0 0 SIZE 16 16 EQ_RGBA 255 0 0 255 546