#!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 live interval 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; # # vec3 func() # { # vec2 v = vec2(1); # int i = 0; # for(int k = 0; k < 2; k++) # { # if(v.y + 1.0 > 4.0) // Always false. # break; # # v.y = 1.0; # i++; # } # # if(i < 10) // Always true. # return vec3(1, 0, 0); # else # return vec3(0, 0, 1); # } # # void main() # { # vec3 data[2]; # # // Writes data[0] = (1, 0, 0). # for(int j = 0; j < 1; j++) # data[j] = func(); # # // Writes data[1] = (1, 0, 0). # for(int j = 0; j < 1; j++) # data[4*j + 1] = func(); # # _GLF_color = vec4(data[0], 1); # } SHADER fragment variant_fragment_shader SPIRV-ASM TARGET_ENV spv1.0 ; SPIR-V ; Version: 1.0 ; Generator: Khronos Glslang Reference Front End; 8 ; Bound: 102 ; Schema: 0 OpCapability Shader %1 = OpExtInstImport "GLSL.std.450" OpMemoryModel Logical GLSL450 OpEntryPoint Fragment %4 "main" %95 OpExecutionMode %4 OriginUpperLeft OpSource ESSL 310 OpName %4 "main" OpName %9 "func(" OpName %13 "v" OpName %18 "i" OpName %20 "k" OpName %59 "j" OpName %70 "data" OpName %77 "j" OpName %95 "_GLF_color" OpDecorate %95 Location 0 %2 = OpTypeVoid %3 = OpTypeFunction %2 %6 = OpTypeFloat 32 %7 = OpTypeVector %6 3 %8 = OpTypeFunction %7 %11 = OpTypeVector %6 2 %12 = OpTypePointer Function %11 %14 = OpConstant %6 1 %15 = OpConstantComposite %11 %14 %14 %16 = OpTypeInt 32 1 %17 = OpTypePointer Function %16 %19 = OpConstant %16 0 %27 = OpConstant %16 2 %28 = OpTypeBool %30 = OpTypeInt 32 0 %31 = OpConstant %30 1 %32 = OpTypePointer Function %6 %36 = OpConstant %6 4 %43 = OpConstant %16 1 %48 = OpConstant %16 10 %52 = OpConstant %6 0 %53 = OpConstantComposite %7 %14 %52 %52 %56 = OpConstantComposite %7 %52 %52 %14 %67 = OpConstant %30 2 %68 = OpTypeArray %7 %67 %69 = OpTypePointer Function %68 %73 = OpTypePointer Function %7 %85 = OpConstant %16 4 %93 = OpTypeVector %6 4 %94 = OpTypePointer Output %93 %95 = OpVariable %94 Output %4 = OpFunction %2 None %3 %5 = OpLabel %59 = OpVariable %17 Function %70 = OpVariable %69 Function %77 = OpVariable %17 Function OpStore %59 %19 OpBranch %60 %60 = OpLabel OpLoopMerge %62 %63 None OpBranch %64 %64 = OpLabel %65 = OpLoad %16 %59 %66 = OpSLessThan %28 %65 %43 OpBranchConditional %66 %61 %62 %61 = OpLabel %71 = OpLoad %16 %59 %72 = OpFunctionCall %7 %9 %74 = OpAccessChain %73 %70 %71 OpStore %74 %72 OpBranch %63 %63 = OpLabel %75 = OpLoad %16 %59 %76 = OpIAdd %16 %75 %43 OpStore %59 %76 OpBranch %60 %62 = OpLabel OpStore %77 %19 OpBranch %78 %78 = OpLabel OpLoopMerge %80 %81 None OpBranch %82 %82 = OpLabel %83 = OpLoad %16 %77 %84 = OpSLessThan %28 %83 %43 OpBranchConditional %84 %79 %80 %79 = OpLabel %86 = OpLoad %16 %77 %87 = OpIMul %16 %85 %86 %88 = OpIAdd %16 %87 %43 %89 = OpFunctionCall %7 %9 %90 = OpAccessChain %73 %70 %88 OpStore %90 %89 OpBranch %81 %81 = OpLabel %91 = OpLoad %16 %77 %92 = OpIAdd %16 %91 %43 OpStore %77 %92 OpBranch %78 %80 = OpLabel %96 = OpAccessChain %73 %70 %19 %97 = OpLoad %7 %96 %98 = OpCompositeExtract %6 %97 0 %99 = OpCompositeExtract %6 %97 1 %100 = OpCompositeExtract %6 %97 2 %101 = OpCompositeConstruct %93 %98 %99 %100 %14 OpStore %95 %101 OpReturn OpFunctionEnd %9 = OpFunction %7 None %8 %10 = OpLabel %13 = OpVariable %12 Function %18 = OpVariable %17 Function %20 = OpVariable %17 Function OpStore %13 %15 OpStore %18 %19 OpStore %20 %19 OpBranch %21 %21 = OpLabel OpLoopMerge %23 %24 None OpBranch %25 %25 = OpLabel %26 = OpLoad %16 %20 %29 = OpSLessThan %28 %26 %27 OpBranchConditional %29 %22 %23 %22 = OpLabel %33 = OpAccessChain %32 %13 %31 %34 = OpLoad %6 %33 %35 = OpFAdd %6 %34 %14 %37 = OpFOrdGreaterThan %28 %35 %36 OpSelectionMerge %39 None OpBranchConditional %37 %38 %39 %38 = OpLabel OpBranch %23 %39 = OpLabel %41 = OpAccessChain %32 %13 %31 OpStore %41 %14 %42 = OpLoad %16 %18 %44 = OpIAdd %16 %42 %43 OpStore %18 %44 OpBranch %24 %24 = OpLabel %45 = OpLoad %16 %20 %46 = OpIAdd %16 %45 %43 OpStore %20 %46 OpBranch %21 %23 = OpLabel %47 = OpLoad %16 %18 %49 = OpSLessThan %28 %47 %48 OpSelectionMerge %51 None OpBranchConditional %49 %50 %55 %50 = OpLabel OpReturnValue %53 %55 = OpLabel OpReturnValue %56 %51 = OpLabel OpUnreachable OpFunctionEnd 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 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