#!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 the GraphicsFuzz project. # Short description: Covers peephole optimizer and instr info 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 310 es # #define _int_1 _GLF_uniform_int_values[0] # #define _int_0 _GLF_uniform_int_values[1] # #define _int_10 _GLF_uniform_int_values[2] # #define _float_0_0 _GLF_uniform_float_values[0] # #define _float_1_0 _GLF_uniform_float_values[1] # # precision highp float; # # precision highp int; # # // Contents of _GLF_uniform_int_values: [1, 0, 10] # layout(set = 0, binding = 0) uniform buf0 # { # int _GLF_uniform_int_values[3]; # }; # # // Contents of _GLF_uniform_float_values: [0.0, 1.0] # layout(set = 0, binding = 1) uniform buf1 # { # float _GLF_uniform_float_values[2]; # }; # # layout(location = 0) out vec4 _GLF_color; # # void main() # { # _GLF_color = vec4(_int_0); # for (int i = _int_0; i < _int_10; i++) # { # // Always false. # if (gl_FragCoord.y < _float_0_0) # { # // Always false. # if (gl_FragCoord.x < _float_0_0) # { # return; # } # # // Always false. # if (_float_1_0 > _float_1_0) # { # return; # } # discard; # } # # // Always true. # if (_float_1_0 > _float_0_0) # { # _GLF_color = vec4(_int_1, _int_0, _int_0, _int_1); # break; # } # # // Always false. # if (_float_0_0 < 0.0) # { # discard; # } # } # } SHADER fragment variant_fragment_shader SPIRV-ASM TARGET_ENV spv1.0 ; SPIR-V ; Version: 1.0 ; Generator: Khronos Glslang Reference Front End; 8 ; Bound: 104 ; Schema: 0 OpCapability Shader %1 = OpExtInstImport "GLSL.std.450" OpMemoryModel Logical GLSL450 OpEntryPoint Fragment %4 "main" %9 %40 OpExecutionMode %4 OriginUpperLeft OpSource ESSL 310 OpName %4 "main" OpName %9 "_GLF_color" OpName %14 "buf0" OpMemberName %14 0 "_GLF_uniform_int_values" OpName %16 "" OpName %25 "i" OpName %40 "gl_FragCoord" OpName %47 "buf1" OpMemberName %47 0 "_GLF_uniform_float_values" OpName %49 "" OpDecorate %9 Location 0 OpDecorate %13 ArrayStride 16 OpMemberDecorate %14 0 Offset 0 OpDecorate %14 Block OpDecorate %16 DescriptorSet 0 OpDecorate %16 Binding 0 OpDecorate %40 BuiltIn FragCoord OpDecorate %46 ArrayStride 16 OpMemberDecorate %47 0 Offset 0 OpDecorate %47 Block OpDecorate %49 DescriptorSet 0 OpDecorate %49 Binding 1 %2 = OpTypeVoid %3 = OpTypeFunction %2 %6 = OpTypeFloat 32 %7 = OpTypeVector %6 4 %8 = OpTypePointer Output %7 %9 = OpVariable %8 Output %10 = OpTypeInt 32 1 %11 = OpTypeInt 32 0 %12 = OpConstant %11 3 %13 = OpTypeArray %10 %12 %14 = OpTypeStruct %13 %15 = OpTypePointer Uniform %14 %16 = OpVariable %15 Uniform %17 = OpConstant %10 0 %18 = OpConstant %10 1 %19 = OpTypePointer Uniform %10 %24 = OpTypePointer Function %10 %34 = OpConstant %10 2 %37 = OpTypeBool %39 = OpTypePointer Input %7 %40 = OpVariable %39 Input %41 = OpConstant %11 1 %42 = OpTypePointer Input %6 %45 = OpConstant %11 2 %46 = OpTypeArray %6 %45 %47 = OpTypeStruct %46 %48 = OpTypePointer Uniform %47 %49 = OpVariable %48 Uniform %50 = OpTypePointer Uniform %6 %56 = OpConstant %11 0 %97 = OpConstant %6 0 %4 = OpFunction %2 None %3 %5 = OpLabel %25 = OpVariable %24 Function %20 = OpAccessChain %19 %16 %17 %18 %21 = OpLoad %10 %20 %22 = OpConvertSToF %6 %21 %23 = OpCompositeConstruct %7 %22 %22 %22 %22 OpStore %9 %23 %26 = OpAccessChain %19 %16 %17 %18 %27 = OpLoad %10 %26 OpStore %25 %27 OpBranch %28 %28 = OpLabel OpLoopMerge %30 %31 None OpBranch %32 %32 = OpLabel %33 = OpLoad %10 %25 %35 = OpAccessChain %19 %16 %17 %34 %36 = OpLoad %10 %35 %38 = OpSLessThan %37 %33 %36 OpBranchConditional %38 %29 %30 %29 = OpLabel %43 = OpAccessChain %42 %40 %41 %44 = OpLoad %6 %43 %51 = OpAccessChain %50 %49 %17 %17 %52 = OpLoad %6 %51 %53 = OpFOrdLessThan %37 %44 %52 OpSelectionMerge %55 None OpBranchConditional %53 %54 %55 %54 = OpLabel %57 = OpAccessChain %42 %40 %56 %58 = OpLoad %6 %57 %59 = OpAccessChain %50 %49 %17 %17 %60 = OpLoad %6 %59 %61 = OpFOrdLessThan %37 %58 %60 OpSelectionMerge %63 None OpBranchConditional %61 %62 %63 %62 = OpLabel OpReturn %63 = OpLabel %65 = OpAccessChain %50 %49 %17 %18 %66 = OpLoad %6 %65 %67 = OpAccessChain %50 %49 %17 %18 %68 = OpLoad %6 %67 %69 = OpFOrdGreaterThan %37 %66 %68 OpSelectionMerge %71 None OpBranchConditional %69 %70 %71 %70 = OpLabel OpReturn %71 = OpLabel OpKill %55 = OpLabel %74 = OpAccessChain %50 %49 %17 %18 %75 = OpLoad %6 %74 %76 = OpAccessChain %50 %49 %17 %17 %77 = OpLoad %6 %76 %78 = OpFOrdGreaterThan %37 %75 %77 OpSelectionMerge %80 None OpBranchConditional %78 %79 %80 %79 = OpLabel %81 = OpAccessChain %19 %16 %17 %17 %82 = OpLoad %10 %81 %83 = OpConvertSToF %6 %82 %84 = OpAccessChain %19 %16 %17 %18 %85 = OpLoad %10 %84 %86 = OpConvertSToF %6 %85 %87 = OpAccessChain %19 %16 %17 %18 %88 = OpLoad %10 %87 %89 = OpConvertSToF %6 %88 %90 = OpAccessChain %19 %16 %17 %17 %91 = OpLoad %10 %90 %92 = OpConvertSToF %6 %91 %93 = OpCompositeConstruct %7 %83 %86 %89 %92 OpStore %9 %93 OpBranch %30 %80 = OpLabel %95 = OpAccessChain %50 %49 %17 %17 %96 = OpLoad %6 %95 %98 = OpFOrdLessThan %37 %96 %97 OpSelectionMerge %100 None OpBranchConditional %98 %99 %100 %99 = OpLabel OpKill %100 = OpLabel OpBranch %31 %31 = OpLabel %102 = OpLoad %10 %25 %103 = OpIAdd %10 %102 %18 OpStore %25 %103 OpBranch %28 %30 = OpLabel OpReturn OpFunctionEnd END # uniforms for variant # _GLF_uniform_float_values BUFFER variant__GLF_uniform_float_values DATA_TYPE float[] STD140 DATA 0.0 1.0 END # _GLF_uniform_int_values BUFFER variant__GLF_uniform_int_values DATA_TYPE int32[] STD140 DATA 1 0 10 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__GLF_uniform_float_values AS uniform DESCRIPTOR_SET 0 BINDING 1 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 256 256 EXPECT variant_framebuffer IDX 0 0 SIZE 256 256 EQ_RGBA 255 0 0 255