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 LLVM 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# 29# #define _int_1 _GLF_uniform_int_values[0] 30# #define _int_0 _GLF_uniform_int_values[1] 31# #define _int_10 _GLF_uniform_int_values[2] 32# #define _int_6 _GLF_uniform_int_values[3] 33# 34# precision highp float; 35# precision highp int; 36# 37# // Contents of _GLF_uniform_int_values: [1, 0, 10, 6] 38# layout(set = 0, binding = 0) uniform buf0 39# { 40# int _GLF_uniform_int_values[4]; 41# }; 42# 43# const int _GLF_global_loop_bound = 10; 44# int _GLF_global_loop_count = 0; 45# 46# struct S 47# { 48# int data[10]; 49# }; 50# 51# layout(location = 0) out vec4 _GLF_color; 52# 53# void func() 54# { 55# int a = _int_1; 56# int b = _int_1; 57# 58# while (_GLF_global_loop_count < _GLF_global_loop_bound) 59# { 60# _GLF_global_loop_count ++; 61# 62# if(b == _int_6) 63# { 64# break; 65# } 66# 67# b++; 68# 69# // Always false. 70# if(int[10](_int_1, _int_1, _int_1, _int_1, _int_1, _int_1, _int_1, _int_1, _int_1, _int_1)[a] == _int_0) 71# { 72# return; 73# } 74# } 75# } 76# 77# void main() 78# { 79# S obj = S(int[10](_int_0, _int_0, _int_0, _int_0, _int_0, _int_0, _int_0, _int_0, _int_0, _int_0)); 80# 81# for(int i = _int_0; i < _int_10 && _GLF_global_loop_count < _GLF_global_loop_bound; i ++) 82# { 83# _GLF_global_loop_count ++; 84# 85# if(i == 0) 86# { 87# obj.data[i] = 1; 88# } 89# else if(i == 1) 90# { 91# // Calling func twice makes sure the global counter has reached its limit, and this 92# // loop will therefore end. 93# func(); 94# func(); 95# obj.data[i] = _int_1; 96# } 97# // Never executed. 98# else if(i == 4) 99# { 100# obj.data[i] = _int_1; 101# } 102# // Never executed. 103# else 104# { 105# discard; 106# } 107# } 108# 109# // Check results against reference values. 110# bool ok = true; 111# int ref[10] = int[10](_int_1, _int_1, _int_0, _int_0, _int_0, _int_0, _int_0, _int_0, _int_0, _int_0); 112# 113# for(int i = 0; i < 10; i ++) 114# { 115# if(obj.data[i] != ref[i]) 116# { 117# ok = false; 118# } 119# } 120# 121# if(ok) 122# { 123# _GLF_color = vec4(_int_1, _int_0, _int_0, _int_1); 124# } 125# else 126# { 127# _GLF_color = vec4(_int_0); 128# } 129# } 130SHADER fragment variant_fragment_shader SPIRV-ASM TARGET_ENV spv1.0 131; SPIR-V 132; Version: 1.0 133; Generator: Khronos Glslang Reference Front End; 10 134; Bound: 226 135; Schema: 0 136 OpCapability Shader 137 %1 = OpExtInstImport "GLSL.std.450" 138 OpMemoryModel Logical GLSL450 139 OpEntryPoint Fragment %4 "main" %207 140 OpExecutionMode %4 OriginUpperLeft 141 OpSource ESSL 320 142 OpName %4 "main" 143 OpName %6 "func(" 144 OpName %10 "_GLF_global_loop_count" 145 OpName %13 "a" 146 OpName %17 "buf0" 147 OpMemberName %17 0 "_GLF_uniform_int_values" 148 OpName %19 "" 149 OpName %23 "b" 150 OpName %73 "indexable" 151 OpName %82 "S" 152 OpMemberName %82 0 "data" 153 OpName %84 "obj" 154 OpName %107 "i" 155 OpName %157 "ok" 156 OpName %159 "ref" 157 OpName %181 "i" 158 OpName %207 "_GLF_color" 159 OpDecorate %16 ArrayStride 16 160 OpMemberDecorate %17 0 Offset 0 161 OpDecorate %17 Block 162 OpDecorate %19 DescriptorSet 0 163 OpDecorate %19 Binding 0 164 OpDecorate %207 Location 0 165 %2 = OpTypeVoid 166 %3 = OpTypeFunction %2 167 %8 = OpTypeInt 32 1 168 %9 = OpTypePointer Private %8 169 %10 = OpVariable %9 Private 170 %11 = OpConstant %8 0 171 %12 = OpTypePointer Function %8 172 %14 = OpTypeInt 32 0 173 %15 = OpConstant %14 4 174 %16 = OpTypeArray %8 %15 175 %17 = OpTypeStruct %16 176 %18 = OpTypePointer Uniform %17 177 %19 = OpVariable %18 Uniform 178 %20 = OpTypePointer Uniform %8 179 %32 = OpConstant %8 10 180 %33 = OpTypeBool 181 %36 = OpConstant %8 1 182 %39 = OpConstant %8 3 183 %68 = OpConstant %14 10 184 %69 = OpTypeArray %8 %68 185 %72 = OpTypePointer Function %69 186 %82 = OpTypeStruct %69 187 %83 = OpTypePointer Function %82 188 %116 = OpConstant %8 2 189 %144 = OpConstant %8 4 190 %156 = OpTypePointer Function %33 191 %158 = OpConstantTrue %33 192 %198 = OpConstantFalse %33 193 %204 = OpTypeFloat 32 194 %205 = OpTypeVector %204 4 195 %206 = OpTypePointer Output %205 196 %207 = OpVariable %206 Output 197 %4 = OpFunction %2 None %3 198 %5 = OpLabel 199 %84 = OpVariable %83 Function 200 %107 = OpVariable %12 Function 201 %157 = OpVariable %156 Function 202 %159 = OpVariable %72 Function 203 %181 = OpVariable %12 Function 204 OpStore %10 %11 205 %85 = OpAccessChain %20 %19 %11 %36 206 %86 = OpLoad %8 %85 207 %87 = OpAccessChain %20 %19 %11 %36 208 %88 = OpLoad %8 %87 209 %89 = OpAccessChain %20 %19 %11 %36 210 %90 = OpLoad %8 %89 211 %91 = OpAccessChain %20 %19 %11 %36 212 %92 = OpLoad %8 %91 213 %93 = OpAccessChain %20 %19 %11 %36 214 %94 = OpLoad %8 %93 215 %95 = OpAccessChain %20 %19 %11 %36 216 %96 = OpLoad %8 %95 217 %97 = OpAccessChain %20 %19 %11 %36 218 %98 = OpLoad %8 %97 219 %99 = OpAccessChain %20 %19 %11 %36 220 %100 = OpLoad %8 %99 221 %101 = OpAccessChain %20 %19 %11 %36 222 %102 = OpLoad %8 %101 223 %103 = OpAccessChain %20 %19 %11 %36 224 %104 = OpLoad %8 %103 225 %105 = OpCompositeConstruct %69 %86 %88 %90 %92 %94 %96 %98 %100 %102 %104 226 %106 = OpCompositeConstruct %82 %105 227 OpStore %84 %106 228 %108 = OpAccessChain %20 %19 %11 %36 229 %109 = OpLoad %8 %108 230 OpStore %107 %109 231 OpBranch %110 232 %110 = OpLabel 233 OpLoopMerge %112 %113 None 234 OpBranch %114 235 %114 = OpLabel 236 %115 = OpLoad %8 %107 237 %117 = OpAccessChain %20 %19 %11 %116 238 %118 = OpLoad %8 %117 239 %119 = OpSLessThan %33 %115 %118 240 %120 = OpLoad %8 %10 241 %121 = OpSLessThan %33 %120 %32 242 %122 = OpLogicalAnd %33 %119 %121 243 OpBranchConditional %122 %111 %112 244 %111 = OpLabel 245 %123 = OpLoad %8 %10 246 %124 = OpIAdd %8 %123 %36 247 OpStore %10 %124 248 %125 = OpLoad %8 %107 249 %126 = OpIEqual %33 %125 %11 250 OpSelectionMerge %128 None 251 OpBranchConditional %126 %127 %131 252 %127 = OpLabel 253 %129 = OpLoad %8 %107 254 %130 = OpAccessChain %12 %84 %11 %129 255 OpStore %130 %36 256 OpBranch %128 257 %131 = OpLabel 258 %132 = OpLoad %8 %107 259 %133 = OpIEqual %33 %132 %36 260 OpSelectionMerge %135 None 261 OpBranchConditional %133 %134 %142 262 %134 = OpLabel 263 %136 = OpFunctionCall %2 %6 264 %137 = OpFunctionCall %2 %6 265 %138 = OpLoad %8 %107 266 %139 = OpAccessChain %20 %19 %11 %11 267 %140 = OpLoad %8 %139 268 %141 = OpAccessChain %12 %84 %11 %138 269 OpStore %141 %140 270 OpBranch %135 271 %142 = OpLabel 272 %143 = OpLoad %8 %107 273 %145 = OpIEqual %33 %143 %144 274 OpSelectionMerge %147 None 275 OpBranchConditional %145 %146 %152 276 %146 = OpLabel 277 %148 = OpLoad %8 %107 278 %149 = OpAccessChain %20 %19 %11 %11 279 %150 = OpLoad %8 %149 280 %151 = OpAccessChain %12 %84 %11 %148 281 OpStore %151 %150 282 OpBranch %147 283 %152 = OpLabel 284 OpKill 285 %147 = OpLabel 286 OpBranch %135 287 %135 = OpLabel 288 OpBranch %128 289 %128 = OpLabel 290 OpBranch %113 291 %113 = OpLabel 292 %154 = OpLoad %8 %107 293 %155 = OpIAdd %8 %154 %36 294 OpStore %107 %155 295 OpBranch %110 296 %112 = OpLabel 297 OpStore %157 %158 298 %160 = OpAccessChain %20 %19 %11 %11 299 %161 = OpLoad %8 %160 300 %162 = OpAccessChain %20 %19 %11 %11 301 %163 = OpLoad %8 %162 302 %164 = OpAccessChain %20 %19 %11 %36 303 %165 = OpLoad %8 %164 304 %166 = OpAccessChain %20 %19 %11 %36 305 %167 = OpLoad %8 %166 306 %168 = OpAccessChain %20 %19 %11 %36 307 %169 = OpLoad %8 %168 308 %170 = OpAccessChain %20 %19 %11 %36 309 %171 = OpLoad %8 %170 310 %172 = OpAccessChain %20 %19 %11 %36 311 %173 = OpLoad %8 %172 312 %174 = OpAccessChain %20 %19 %11 %36 313 %175 = OpLoad %8 %174 314 %176 = OpAccessChain %20 %19 %11 %36 315 %177 = OpLoad %8 %176 316 %178 = OpAccessChain %20 %19 %11 %36 317 %179 = OpLoad %8 %178 318 %180 = OpCompositeConstruct %69 %161 %163 %165 %167 %169 %171 %173 %175 %177 %179 319 OpStore %159 %180 320 OpStore %181 %11 321 OpBranch %182 322 %182 = OpLabel 323 OpLoopMerge %184 %185 None 324 OpBranch %186 325 %186 = OpLabel 326 %187 = OpLoad %8 %181 327 %188 = OpSLessThan %33 %187 %32 328 OpBranchConditional %188 %183 %184 329 %183 = OpLabel 330 %189 = OpLoad %8 %181 331 %190 = OpAccessChain %12 %84 %11 %189 332 %191 = OpLoad %8 %190 333 %192 = OpLoad %8 %181 334 %193 = OpAccessChain %12 %159 %192 335 %194 = OpLoad %8 %193 336 %195 = OpINotEqual %33 %191 %194 337 OpSelectionMerge %197 None 338 OpBranchConditional %195 %196 %197 339 %196 = OpLabel 340 OpStore %157 %198 341 OpBranch %197 342 %197 = OpLabel 343 OpBranch %185 344 %185 = OpLabel 345 %199 = OpLoad %8 %181 346 %200 = OpIAdd %8 %199 %36 347 OpStore %181 %200 348 OpBranch %182 349 %184 = OpLabel 350 %201 = OpLoad %33 %157 351 OpSelectionMerge %203 None 352 OpBranchConditional %201 %202 %221 353 %202 = OpLabel 354 %208 = OpAccessChain %20 %19 %11 %11 355 %209 = OpLoad %8 %208 356 %210 = OpConvertSToF %204 %209 357 %211 = OpAccessChain %20 %19 %11 %36 358 %212 = OpLoad %8 %211 359 %213 = OpConvertSToF %204 %212 360 %214 = OpAccessChain %20 %19 %11 %36 361 %215 = OpLoad %8 %214 362 %216 = OpConvertSToF %204 %215 363 %217 = OpAccessChain %20 %19 %11 %11 364 %218 = OpLoad %8 %217 365 %219 = OpConvertSToF %204 %218 366 %220 = OpCompositeConstruct %205 %210 %213 %216 %219 367 OpStore %207 %220 368 OpBranch %203 369 %221 = OpLabel 370 %222 = OpAccessChain %20 %19 %11 %36 371 %223 = OpLoad %8 %222 372 %224 = OpConvertSToF %204 %223 373 %225 = OpCompositeConstruct %205 %224 %224 %224 %224 374 OpStore %207 %225 375 OpBranch %203 376 %203 = OpLabel 377 OpReturn 378 OpFunctionEnd 379 %6 = OpFunction %2 None %3 380 %7 = OpLabel 381 %13 = OpVariable %12 Function 382 %23 = OpVariable %12 Function 383 %73 = OpVariable %72 Function 384 %21 = OpAccessChain %20 %19 %11 %11 385 %22 = OpLoad %8 %21 386 OpStore %13 %22 387 %24 = OpAccessChain %20 %19 %11 %11 388 %25 = OpLoad %8 %24 389 OpStore %23 %25 390 OpBranch %26 391 %26 = OpLabel 392 OpLoopMerge %28 %29 None 393 OpBranch %30 394 %30 = OpLabel 395 %31 = OpLoad %8 %10 396 %34 = OpSLessThan %33 %31 %32 397 OpBranchConditional %34 %27 %28 398 %27 = OpLabel 399 %35 = OpLoad %8 %10 400 %37 = OpIAdd %8 %35 %36 401 OpStore %10 %37 402 %38 = OpLoad %8 %23 403 %40 = OpAccessChain %20 %19 %11 %39 404 %41 = OpLoad %8 %40 405 %42 = OpIEqual %33 %38 %41 406 OpSelectionMerge %44 None 407 OpBranchConditional %42 %43 %44 408 %43 = OpLabel 409 OpBranch %28 410 %44 = OpLabel 411 %46 = OpLoad %8 %23 412 %47 = OpIAdd %8 %46 %36 413 OpStore %23 %47 414 %48 = OpAccessChain %20 %19 %11 %11 415 %49 = OpLoad %8 %48 416 %50 = OpAccessChain %20 %19 %11 %11 417 %51 = OpLoad %8 %50 418 %52 = OpAccessChain %20 %19 %11 %11 419 %53 = OpLoad %8 %52 420 %54 = OpAccessChain %20 %19 %11 %11 421 %55 = OpLoad %8 %54 422 %56 = OpAccessChain %20 %19 %11 %11 423 %57 = OpLoad %8 %56 424 %58 = OpAccessChain %20 %19 %11 %11 425 %59 = OpLoad %8 %58 426 %60 = OpAccessChain %20 %19 %11 %11 427 %61 = OpLoad %8 %60 428 %62 = OpAccessChain %20 %19 %11 %11 429 %63 = OpLoad %8 %62 430 %64 = OpAccessChain %20 %19 %11 %11 431 %65 = OpLoad %8 %64 432 %66 = OpAccessChain %20 %19 %11 %11 433 %67 = OpLoad %8 %66 434 %70 = OpCompositeConstruct %69 %49 %51 %53 %55 %57 %59 %61 %63 %65 %67 435 %71 = OpLoad %8 %13 436 OpStore %73 %70 437 %74 = OpAccessChain %12 %73 %71 438 %75 = OpLoad %8 %74 439 %76 = OpAccessChain %20 %19 %11 %36 440 %77 = OpLoad %8 %76 441 %78 = OpIEqual %33 %75 %77 442 OpSelectionMerge %80 None 443 OpBranchConditional %78 %79 %80 444 %79 = OpLabel 445 OpReturn 446 %80 = OpLabel 447 OpBranch %29 448 %29 = OpLabel 449 OpBranch %26 450 %28 = OpLabel 451 OpReturn 452 OpFunctionEnd 453END 454 455# uniforms for variant 456 457# _GLF_uniform_int_values 458BUFFER variant__GLF_uniform_int_values DATA_TYPE int32[] STD140 DATA 459 1 0 10 6 460END 461 462BUFFER variant_framebuffer FORMAT B8G8R8A8_UNORM 463 464PIPELINE graphics variant_pipeline 465 ATTACH variant_vertex_shader 466 ATTACH variant_fragment_shader 467 FRAMEBUFFER_SIZE 256 256 468 BIND BUFFER variant_framebuffer AS color LOCATION 0 469 BIND BUFFER variant__GLF_uniform_int_values AS uniform DESCRIPTOR_SET 0 BINDING 0 470END 471CLEAR_COLOR variant_pipeline 0 0 0 255 472 473CLEAR variant_pipeline 474RUN variant_pipeline DRAW_RECT POS 0 0 SIZE 256 256 475 476EXPECT variant_framebuffer IDX 0 0 SIZE 256 256 EQ_RGBA 255 0 0 255 477