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