#!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: A fragment shader that covers a specific instruction simplify path # 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_2 _GLF_uniform_int_values[0] # #define _int_1 _GLF_uniform_int_values[1] # #define _int_0 _GLF_uniform_int_values[2] # #define _int_15 _GLF_uniform_int_values[3] # #define _float_1_0 _GLF_uniform_float_values[0] # # precision highp float; # # precision highp int; # # // Contents of _GLF_uniform_float_values: 1.0 # layout(set = 0, binding = 0) uniform buf0 # { # float _GLF_uniform_float_values[1]; # }; # # // Contents of _GLF_uniform_int_values: [2, 1, 0, 15] # layout(set = 0, binding = 1) uniform buf1 # { # int _GLF_uniform_int_values[4]; # }; # # layout(location = 0) out vec4 _GLF_color; # # void main() # { # vec4 data[2] = vec4[2](vec4(_float_1_0), vec4(_float_1_0)); # # int b = _int_1; # # // This results in an undefined value, but not in undefined behavior. y becomes # // undefined with some of the window coordinate values. Doesn't matter since # // b's value is checked at the same time with y. # int y = clamp(int(gl_FragCoord.y), _int_1 | int(gl_FragCoord.y), _int_1); # # for (int i = _int_1; i < _int_2; i++) # { # if (b > _int_2 && y > _int_1) # { # break; # } # b++; # } # # if (b == _int_2) # { # data[clamp(_int_0, _int_1, _int_15)] = # vec4(_int_1, _int_0, _int_0, _int_1); # } # _GLF_color = vec4(data[_int_1]); # } SHADER fragment variant_fragment_shader SPIRV-ASM TARGET_ENV spv1.0 ; SPIR-V ; Version: 1.0 ; Generator: Khronos Glslang Reference Front End; 10 ; Bound: 127 ; Schema: 0 OpCapability Shader %1 = OpExtInstImport "GLSL.std.450" OpMemoryModel Logical GLSL450 OpEntryPoint Fragment %4 "main" %41 %117 OpExecutionMode %4 OriginUpperLeft OpSource ESSL 310 OpName %4 "main" OpName %12 "data" OpName %15 "buf0" OpMemberName %15 0 "_GLF_uniform_float_values" OpName %17 "" OpName %29 "b" OpName %32 "buf1" OpMemberName %32 0 "_GLF_uniform_int_values" OpName %34 "" OpName %39 "y" OpName %41 "gl_FragCoord" OpName %55 "i" OpName %117 "_GLF_color" OpDecorate %14 ArrayStride 16 OpMemberDecorate %15 0 Offset 0 OpDecorate %15 Block OpDecorate %17 DescriptorSet 0 OpDecorate %17 Binding 0 OpDecorate %31 ArrayStride 16 OpMemberDecorate %32 0 Offset 0 OpDecorate %32 Block OpDecorate %34 DescriptorSet 0 OpDecorate %34 Binding 1 OpDecorate %41 BuiltIn FragCoord OpDecorate %117 Location 0 %2 = OpTypeVoid %3 = OpTypeFunction %2 %6 = OpTypeFloat 32 %7 = OpTypeVector %6 4 %8 = OpTypeInt 32 0 %9 = OpConstant %8 2 %10 = OpTypeArray %7 %9 %11 = OpTypePointer Function %10 %13 = OpConstant %8 1 %14 = OpTypeArray %6 %13 %15 = OpTypeStruct %14 %16 = OpTypePointer Uniform %15 %17 = OpVariable %16 Uniform %18 = OpTypeInt 32 1 %19 = OpConstant %18 0 %20 = OpTypePointer Uniform %6 %28 = OpTypePointer Function %18 %30 = OpConstant %8 4 %31 = OpTypeArray %18 %30 %32 = OpTypeStruct %31 %33 = OpTypePointer Uniform %32 %34 = OpVariable %33 Uniform %35 = OpConstant %18 1 %36 = OpTypePointer Uniform %18 %40 = OpTypePointer Input %7 %41 = OpVariable %40 Input %42 = OpTypePointer Input %6 %66 = OpTypeBool %92 = OpConstant %18 2 %97 = OpConstant %18 3 %114 = OpTypePointer Function %7 %116 = OpTypePointer Output %7 %117 = OpVariable %116 Output %4 = OpFunction %2 None %3 %5 = OpLabel %12 = OpVariable %11 Function %29 = OpVariable %28 Function %39 = OpVariable %28 Function %55 = OpVariable %28 Function %21 = OpAccessChain %20 %17 %19 %19 %22 = OpLoad %6 %21 %23 = OpCompositeConstruct %7 %22 %22 %22 %22 %24 = OpAccessChain %20 %17 %19 %19 %25 = OpLoad %6 %24 %26 = OpCompositeConstruct %7 %25 %25 %25 %25 %27 = OpCompositeConstruct %10 %23 %26 OpStore %12 %27 %37 = OpAccessChain %36 %34 %19 %35 %38 = OpLoad %18 %37 OpStore %29 %38 %43 = OpAccessChain %42 %41 %13 %44 = OpLoad %6 %43 %45 = OpConvertFToS %18 %44 %46 = OpAccessChain %36 %34 %19 %35 %47 = OpLoad %18 %46 %48 = OpAccessChain %42 %41 %13 %49 = OpLoad %6 %48 %50 = OpConvertFToS %18 %49 %51 = OpBitwiseOr %18 %47 %50 %52 = OpAccessChain %36 %34 %19 %35 %53 = OpLoad %18 %52 %54 = OpExtInst %18 %1 SClamp %45 %51 %53 OpStore %39 %54 %56 = OpAccessChain %36 %34 %19 %35 %57 = OpLoad %18 %56 OpStore %55 %57 OpBranch %58 %58 = OpLabel OpLoopMerge %60 %61 None OpBranch %62 %62 = OpLabel %63 = OpLoad %18 %55 %64 = OpAccessChain %36 %34 %19 %19 %65 = OpLoad %18 %64 %67 = OpSLessThan %66 %63 %65 OpBranchConditional %67 %59 %60 %59 = OpLabel %68 = OpLoad %18 %29 %69 = OpAccessChain %36 %34 %19 %19 %70 = OpLoad %18 %69 %71 = OpSGreaterThan %66 %68 %70 OpSelectionMerge %73 None OpBranchConditional %71 %72 %73 %72 = OpLabel %74 = OpLoad %18 %39 %75 = OpAccessChain %36 %34 %19 %35 %76 = OpLoad %18 %75 %77 = OpSGreaterThan %66 %74 %76 OpBranch %73 %73 = OpLabel %78 = OpPhi %66 %71 %59 %77 %72 OpSelectionMerge %80 None OpBranchConditional %78 %79 %80 %79 = OpLabel OpBranch %60 %80 = OpLabel %82 = OpLoad %18 %29 %83 = OpIAdd %18 %82 %35 OpStore %29 %83 OpBranch %61 %61 = OpLabel %84 = OpLoad %18 %55 %85 = OpIAdd %18 %84 %35 OpStore %55 %85 OpBranch %58 %60 = OpLabel %86 = OpLoad %18 %29 %87 = OpAccessChain %36 %34 %19 %19 %88 = OpLoad %18 %87 %89 = OpIEqual %66 %86 %88 OpSelectionMerge %91 None OpBranchConditional %89 %90 %91 %90 = OpLabel %93 = OpAccessChain %36 %34 %19 %92 %94 = OpLoad %18 %93 %95 = OpAccessChain %36 %34 %19 %35 %96 = OpLoad %18 %95 %98 = OpAccessChain %36 %34 %19 %97 %99 = OpLoad %18 %98 %100 = OpExtInst %18 %1 SClamp %94 %96 %99 %101 = OpAccessChain %36 %34 %19 %35 %102 = OpLoad %18 %101 %103 = OpConvertSToF %6 %102 %104 = OpAccessChain %36 %34 %19 %92 %105 = OpLoad %18 %104 %106 = OpConvertSToF %6 %105 %107 = OpAccessChain %36 %34 %19 %92 %108 = OpLoad %18 %107 %109 = OpConvertSToF %6 %108 %110 = OpAccessChain %36 %34 %19 %35 %111 = OpLoad %18 %110 %112 = OpConvertSToF %6 %111 %113 = OpCompositeConstruct %7 %103 %106 %109 %112 %115 = OpAccessChain %114 %12 %100 OpStore %115 %113 OpBranch %91 %91 = OpLabel %118 = OpAccessChain %36 %34 %19 %35 %119 = OpLoad %18 %118 %120 = OpAccessChain %114 %12 %119 %121 = OpLoad %7 %120 %122 = OpCompositeExtract %6 %121 0 %123 = OpCompositeExtract %6 %121 1 %124 = OpCompositeExtract %6 %121 2 %125 = OpCompositeExtract %6 %121 3 %126 = OpCompositeConstruct %7 %122 %123 %124 %125 OpStore %117 %126 OpReturn OpFunctionEnd END # uniforms for variant # _GLF_uniform_int_values BUFFER variant__GLF_uniform_int_values DATA_TYPE int32[] STD140 DATA 2 1 0 15 END # _GLF_uniform_float_values BUFFER variant__GLF_uniform_float_values DATA_TYPE float[] STD140 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__GLF_uniform_int_values AS uniform DESCRIPTOR_SET 0 BINDING 1 BIND BUFFER variant__GLF_uniform_float_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