#!amber # Copyright 2020 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 GraphicsFuzz. # Short description: A fragment shader that covers a specific set vector code path. # The test passes because shader always writes red. SHADER vertex variant_vertex_shader PASSTHROUGH # variant_fragment_shader is derived from the following GLSL: # #version 310 es # precision highp float; # precision highp int; # # layout(location = 0) out vec4 _GLF_color; # # layout(set = 0, binding = 0) uniform buf0 # { # float one; # }; # # void main() # { # vec2 a = vec2(1); # vec3 b = vec3(0); # # if(int(gl_FragCoord.y) < 40) # { # b = vec3(0.1); # } # else if(int(gl_FragCoord.y) < 60) # { # b = vec3(0.2); # } # else if(gl_FragCoord.y < 80.0) # { # b = cos(a.x + vec3(one)) + 0.01; # } # else if(int(gl_FragCoord.y) < 100) # { # b = cos(vec3(one)); # } # else if(int(gl_FragCoord.y) < 500) # { # b = cos(vec3(1.0, 1.0, 22.0)); # } # # // Always true. # if (b.x < 1.02 && b.y < 1.02 && b.z < 1.02) # _GLF_color = vec4(1, 0, 0, 1); # else # _GLF_color = vec4(0); # } SHADER fragment variant_fragment_shader SPIRV-ASM TARGET_ENV spv1.0 ; SPIR-V ; Version: 1.0 ; Generator: Khronos Glslang Reference Front End; 8 ; Bound: 116 ; Schema: 0 OpCapability Shader %1 = OpExtInstImport "GLSL.std.450" OpMemoryModel Logical GLSL450 OpEntryPoint Fragment %4 "main" %19 %112 OpExecutionMode %4 OriginUpperLeft OpSource ESSL 310 OpName %4 "main" OpName %9 "a" OpName %14 "b" OpName %19 "gl_FragCoord" OpName %55 "buf0" OpMemberName %55 0 "one" OpName %57 "" OpName %112 "_GLF_color" OpDecorate %19 BuiltIn FragCoord OpMemberDecorate %55 0 Offset 0 OpDecorate %55 Block OpDecorate %57 DescriptorSet 0 OpDecorate %57 Binding 0 OpDecorate %112 Location 0 %2 = OpTypeVoid %3 = OpTypeFunction %2 %6 = OpTypeFloat 32 %7 = OpTypeVector %6 2 %8 = OpTypePointer Function %7 %10 = OpConstant %6 1 %11 = OpConstantComposite %7 %10 %10 %12 = OpTypeVector %6 3 %13 = OpTypePointer Function %12 %15 = OpConstant %6 0 %16 = OpConstantComposite %12 %15 %15 %15 %17 = OpTypeVector %6 4 %18 = OpTypePointer Input %17 %19 = OpVariable %18 Input %20 = OpTypeInt 32 0 %21 = OpConstant %20 1 %22 = OpTypePointer Input %6 %25 = OpTypeInt 32 1 %27 = OpConstant %25 40 %28 = OpTypeBool %32 = OpConstant %6 0.100000001 %33 = OpConstantComposite %12 %32 %32 %32 %38 = OpConstant %25 60 %42 = OpConstant %6 0.200000003 %43 = OpConstantComposite %12 %42 %42 %42 %47 = OpConstant %6 80 %51 = OpConstant %20 0 %52 = OpTypePointer Function %6 %55 = OpTypeStruct %6 %56 = OpTypePointer Uniform %55 %57 = OpVariable %56 Uniform %58 = OpConstant %25 0 %59 = OpTypePointer Uniform %6 %66 = OpConstant %6 0.00999999978 %73 = OpConstant %25 100 %85 = OpConstant %25 500 %89 = OpConstant %6 0.540302277 %90 = OpConstant %6 -0.99996084 %91 = OpConstantComposite %12 %89 %89 %90 %94 = OpConstant %6 1.01999998 %104 = OpConstant %20 2 %111 = OpTypePointer Output %17 %112 = OpVariable %111 Output %113 = OpConstantComposite %17 %10 %15 %15 %10 %115 = OpConstantComposite %17 %15 %15 %15 %15 %4 = OpFunction %2 None %3 %5 = OpLabel %9 = OpVariable %8 Function %14 = OpVariable %13 Function OpStore %9 %11 OpStore %14 %16 %23 = OpAccessChain %22 %19 %21 %24 = OpLoad %6 %23 %26 = OpConvertFToS %25 %24 %29 = OpSLessThan %28 %26 %27 OpSelectionMerge %31 None OpBranchConditional %29 %30 %34 %30 = OpLabel OpStore %14 %33 OpBranch %31 %34 = OpLabel %35 = OpAccessChain %22 %19 %21 %36 = OpLoad %6 %35 %37 = OpConvertFToS %25 %36 %39 = OpSLessThan %28 %37 %38 OpSelectionMerge %41 None OpBranchConditional %39 %40 %44 %40 = OpLabel OpStore %14 %43 OpBranch %41 %44 = OpLabel %45 = OpAccessChain %22 %19 %21 %46 = OpLoad %6 %45 %48 = OpFOrdLessThan %28 %46 %47 OpSelectionMerge %50 None OpBranchConditional %48 %49 %69 %49 = OpLabel %53 = OpAccessChain %52 %9 %51 %54 = OpLoad %6 %53 %60 = OpAccessChain %59 %57 %58 %61 = OpLoad %6 %60 %62 = OpCompositeConstruct %12 %61 %61 %61 %63 = OpCompositeConstruct %12 %54 %54 %54 %64 = OpFAdd %12 %63 %62 %65 = OpExtInst %12 %1 Cos %64 %67 = OpCompositeConstruct %12 %66 %66 %66 %68 = OpFAdd %12 %65 %67 OpStore %14 %68 OpBranch %50 %69 = OpLabel %70 = OpAccessChain %22 %19 %21 %71 = OpLoad %6 %70 %72 = OpConvertFToS %25 %71 %74 = OpSLessThan %28 %72 %73 OpSelectionMerge %76 None OpBranchConditional %74 %75 %81 %75 = OpLabel %77 = OpAccessChain %59 %57 %58 %78 = OpLoad %6 %77 %79 = OpCompositeConstruct %12 %78 %78 %78 %80 = OpExtInst %12 %1 Cos %79 OpStore %14 %80 OpBranch %76 %81 = OpLabel %82 = OpAccessChain %22 %19 %21 %83 = OpLoad %6 %82 %84 = OpConvertFToS %25 %83 %86 = OpSLessThan %28 %84 %85 OpSelectionMerge %88 None OpBranchConditional %86 %87 %88 %87 = OpLabel OpStore %14 %91 OpBranch %88 %88 = OpLabel OpBranch %76 %76 = OpLabel OpBranch %50 %50 = OpLabel OpBranch %41 %41 = OpLabel OpBranch %31 %31 = OpLabel %92 = OpAccessChain %52 %14 %51 %93 = OpLoad %6 %92 %95 = OpFOrdLessThan %28 %93 %94 OpSelectionMerge %97 None OpBranchConditional %95 %96 %97 %96 = OpLabel %98 = OpAccessChain %52 %14 %21 %99 = OpLoad %6 %98 %100 = OpFOrdLessThan %28 %99 %94 OpBranch %97 %97 = OpLabel %101 = OpPhi %28 %95 %31 %100 %96 OpSelectionMerge %103 None OpBranchConditional %101 %102 %103 %102 = OpLabel %105 = OpAccessChain %52 %14 %104 %106 = OpLoad %6 %105 %107 = OpFOrdLessThan %28 %106 %94 OpBranch %103 %103 = OpLabel %108 = OpPhi %28 %101 %97 %107 %102 OpSelectionMerge %110 None OpBranchConditional %108 %109 %114 %109 = OpLabel OpStore %112 %113 OpBranch %110 %114 = OpLabel OpStore %112 %115 OpBranch %110 %110 = OpLabel OpReturn OpFunctionEnd END # uniforms for variant # one BUFFER variant_one DATA_TYPE float DATA 1.0 END BUFFER variant_framebuffer FORMAT B8G8R8A8_UNORM PIPELINE graphics variant_pipeline ATTACH variant_vertex_shader ATTACH variant_fragment_shader FRAMEBUFFER_SIZE 256 256 BIND BUFFER variant_framebuffer AS color LOCATION 0 BIND BUFFER variant_one 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 256 256 EXPECT variant_framebuffer IDX 0 0 SIZE 256 256 EQ_RGBA 255 0 0 255