#!amber # Copyright 2022 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. # A test for a coverage-gap found by the GraphicsFuzz project. # Short description: A fragment shader that covers specific LLVM code paths # The test passes because the shader always writes red. SHADER vertex variant_vertex_shader PASSTHROUGH # variant_fragment_shader is derived from the following GLSL: # #version 320 es # # #define _int_1 _GLF_uniform_int_values[0] # #define _int_0 _GLF_uniform_int_values[1] # #define _int_2 _GLF_uniform_int_values[2] # # precision highp float; # precision highp int; # # // Contents of _GLF_uniform_int_values: [1, 0, 2] # layout(set = 0, binding = 0) uniform buf0 # { # int _GLF_uniform_int_values[3]; # }; # # layout(location = 0) out vec4 _GLF_color; # # void main() # { # int arr[10] = int[10](_int_1, _int_1, _int_1, _int_1, _int_1, _int_1, _int_1, _int_1, _int_1, _int_1); # ivec2 v = ivec2(_int_1); # int a = 1; # # // Always true. # if(arr[_int_1] == _int_1) # { # a++; # } # # // Always false. # if (_int_1 == 0) # { # // Modulus of a negative value is undefined, but this is never executed. # if(-5 % a >= _int_1) # { # arr[v.x + v.y] = _int_0; # } # } # else # { # // arr[2] becomes two. # arr[v.x + v.y] = _int_2; # } # # // Always true. # if(a == _int_2 && arr[_int_2] == _int_2) # { # _GLF_color = vec4(_int_1, _int_0, _int_0, _int_1); # } # else # { # _GLF_color = vec4(_int_0); # } # } SHADER fragment variant_fragment_shader SPIRV-ASM TARGET_ENV spv1.0 ; SPIR-V ; Version: 1.0 ; Generator: Khronos Glslang Reference Front End; 10 ; Bound: 132 ; Schema: 0 OpCapability Shader %1 = OpExtInstImport "GLSL.std.450" OpMemoryModel Logical GLSL450 OpEntryPoint Fragment %4 "main" %113 OpExecutionMode %4 OriginUpperLeft OpSource ESSL 320 OpName %4 "main" OpName %11 "arr" OpName %14 "buf0" OpMemberName %14 0 "_GLF_uniform_int_values" OpName %16 "" OpName %42 "v" OpName %47 "a" OpName %113 "_GLF_color" OpDecorate %13 ArrayStride 16 OpMemberDecorate %14 0 Offset 0 OpDecorate %14 Block OpDecorate %16 DescriptorSet 0 OpDecorate %16 Binding 0 OpDecorate %113 Location 0 %2 = OpTypeVoid %3 = OpTypeFunction %2 %6 = OpTypeInt 32 1 %7 = OpTypeInt 32 0 %8 = OpConstant %7 10 %9 = OpTypeArray %6 %8 %10 = OpTypePointer Function %9 %12 = OpConstant %7 3 %13 = OpTypeArray %6 %12 %14 = OpTypeStruct %13 %15 = OpTypePointer Uniform %14 %16 = OpVariable %15 Uniform %17 = OpConstant %6 0 %18 = OpTypePointer Uniform %6 %40 = OpTypeVector %6 2 %41 = OpTypePointer Function %40 %46 = OpTypePointer Function %6 %48 = OpConstant %6 1 %55 = OpTypeBool %66 = OpConstant %6 -5 %74 = OpConstant %7 0 %77 = OpConstant %7 1 %90 = OpConstant %6 2 %110 = OpTypeFloat 32 %111 = OpTypeVector %110 4 %112 = OpTypePointer Output %111 %113 = OpVariable %112 Output %4 = OpFunction %2 None %3 %5 = OpLabel %11 = OpVariable %10 Function %42 = OpVariable %41 Function %47 = OpVariable %46 Function %19 = OpAccessChain %18 %16 %17 %17 %20 = OpLoad %6 %19 %21 = OpAccessChain %18 %16 %17 %17 %22 = OpLoad %6 %21 %23 = OpAccessChain %18 %16 %17 %17 %24 = OpLoad %6 %23 %25 = OpAccessChain %18 %16 %17 %17 %26 = OpLoad %6 %25 %27 = OpAccessChain %18 %16 %17 %17 %28 = OpLoad %6 %27 %29 = OpAccessChain %18 %16 %17 %17 %30 = OpLoad %6 %29 %31 = OpAccessChain %18 %16 %17 %17 %32 = OpLoad %6 %31 %33 = OpAccessChain %18 %16 %17 %17 %34 = OpLoad %6 %33 %35 = OpAccessChain %18 %16 %17 %17 %36 = OpLoad %6 %35 %37 = OpAccessChain %18 %16 %17 %17 %38 = OpLoad %6 %37 %39 = OpCompositeConstruct %9 %20 %22 %24 %26 %28 %30 %32 %34 %36 %38 OpStore %11 %39 %43 = OpAccessChain %18 %16 %17 %17 %44 = OpLoad %6 %43 %45 = OpCompositeConstruct %40 %44 %44 OpStore %42 %45 OpStore %47 %48 %49 = OpAccessChain %18 %16 %17 %17 %50 = OpLoad %6 %49 %51 = OpAccessChain %46 %11 %50 %52 = OpLoad %6 %51 %53 = OpAccessChain %18 %16 %17 %17 %54 = OpLoad %6 %53 %56 = OpIEqual %55 %52 %54 OpSelectionMerge %58 None OpBranchConditional %56 %57 %58 %57 = OpLabel %59 = OpLoad %6 %47 %60 = OpIAdd %6 %59 %48 OpStore %47 %60 OpBranch %58 %58 = OpLabel %61 = OpAccessChain %18 %16 %17 %17 %62 = OpLoad %6 %61 %63 = OpIEqual %55 %62 %17 OpSelectionMerge %65 None OpBranchConditional %63 %64 %84 %64 = OpLabel %67 = OpLoad %6 %47 %68 = OpSMod %6 %66 %67 %69 = OpAccessChain %18 %16 %17 %17 %70 = OpLoad %6 %69 %71 = OpSGreaterThanEqual %55 %68 %70 OpSelectionMerge %73 None OpBranchConditional %71 %72 %73 %72 = OpLabel %75 = OpAccessChain %46 %42 %74 %76 = OpLoad %6 %75 %78 = OpAccessChain %46 %42 %77 %79 = OpLoad %6 %78 %80 = OpIAdd %6 %76 %79 %81 = OpAccessChain %18 %16 %17 %48 %82 = OpLoad %6 %81 %83 = OpAccessChain %46 %11 %80 OpStore %83 %82 OpBranch %73 %73 = OpLabel OpBranch %65 %84 = OpLabel %85 = OpAccessChain %46 %42 %74 %86 = OpLoad %6 %85 %87 = OpAccessChain %46 %42 %77 %88 = OpLoad %6 %87 %89 = OpIAdd %6 %86 %88 %91 = OpAccessChain %18 %16 %17 %90 %92 = OpLoad %6 %91 %93 = OpAccessChain %46 %11 %89 OpStore %93 %92 OpBranch %65 %65 = OpLabel %94 = OpLoad %6 %47 %95 = OpAccessChain %18 %16 %17 %90 %96 = OpLoad %6 %95 %97 = OpIEqual %55 %94 %96 OpSelectionMerge %99 None OpBranchConditional %97 %98 %99 %98 = OpLabel %100 = OpAccessChain %18 %16 %17 %90 %101 = OpLoad %6 %100 %102 = OpAccessChain %46 %11 %101 %103 = OpLoad %6 %102 %104 = OpAccessChain %18 %16 %17 %90 %105 = OpLoad %6 %104 %106 = OpIEqual %55 %103 %105 OpBranch %99 %99 = OpLabel %107 = OpPhi %55 %97 %65 %106 %98 OpSelectionMerge %109 None OpBranchConditional %107 %108 %127 %108 = OpLabel %114 = OpAccessChain %18 %16 %17 %17 %115 = OpLoad %6 %114 %116 = OpConvertSToF %110 %115 %117 = OpAccessChain %18 %16 %17 %48 %118 = OpLoad %6 %117 %119 = OpConvertSToF %110 %118 %120 = OpAccessChain %18 %16 %17 %48 %121 = OpLoad %6 %120 %122 = OpConvertSToF %110 %121 %123 = OpAccessChain %18 %16 %17 %17 %124 = OpLoad %6 %123 %125 = OpConvertSToF %110 %124 %126 = OpCompositeConstruct %111 %116 %119 %122 %125 OpStore %113 %126 OpBranch %109 %127 = OpLabel %128 = OpAccessChain %18 %16 %17 %48 %129 = OpLoad %6 %128 %130 = OpConvertSToF %110 %129 %131 = OpCompositeConstruct %111 %130 %130 %130 %130 OpStore %113 %131 OpBranch %109 %109 = OpLabel OpReturn OpFunctionEnd END # uniforms for variant # _GLF_uniform_int_values BUFFER variant__GLF_uniform_int_values DATA_TYPE int32[] STD140 DATA 1 0 2 END BUFFER variant_framebuffer FORMAT B8G8R8A8_UNORM PIPELINE graphics variant_pipeline ATTACH variant_vertex_shader ATTACH variant_fragment_shader FRAMEBUFFER_SIZE 32 32 BIND BUFFER variant_framebuffer AS color LOCATION 0 BIND BUFFER variant__GLF_uniform_int_values AS uniform DESCRIPTOR_SET 0 BINDING 0 END CLEAR_COLOR variant_pipeline 0 0 0 255 CLEAR variant_pipeline RUN variant_pipeline DRAW_RECT POS 0 0 SIZE 32 32 EXPECT variant_framebuffer IDX 0 0 SIZE 32 32 EQ_RGBA 255 0 0 255