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