#!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 cover specific optimize phis 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_2 _GLF_uniform_int_values[0] # #define _int_0 _GLF_uniform_int_values[1] # #define _int_1 _GLF_uniform_int_values[2] # #define _float_1_0 _GLF_uniform_float_values[0] # #define _float_0_0 _GLF_uniform_float_values[1] # # precision highp float; # # // Contents of _GLF_uniform_float_values: [1.0, 0.0] # layout(set = 0, binding = 0) uniform buf0 # { # float _GLF_uniform_float_values[2]; # }; # # // Contents of _GLF_uniform_int_values: [2, 0, 1] # layout(set = 0, binding = 1) uniform buf1 # { # int _GLF_uniform_int_values[3]; # }; # # layout(location = 0) out vec4 _GLF_color; # # void main() # { # float a = _float_1_0; # float b = _float_0_0; # # for (int i = _int_0; i < _int_2; i++) # { # for (int i = _int_0; i < _int_2; i++) # { # for (int i = _int_0; i < _int_2; i++) # { # for (int i = _int_1; i < _int_2; i++) # { # for (int i = _int_1; i < _int_2; i++) # { # for (int i = _int_0; i < _int_2; i++) # { # for (int i = _int_0; i < _int_2; i++) # { # for (int i = _int_0; i < _int_2; i++) # { # for (int i = _int_0; i < _int_2; i++) # { # for (int i = _int_0; i < _int_2; i++) # { # for (int i = _int_0; i < _int_2; # i++) # { # a = _float_0_0; # if (gl_FragCoord.y > _float_0_0) # { # break; # } # } # } # } # } # } # } # } # } # } # } # b++; # } # _GLF_color = vec4(b, a, a, b); # } SHADER fragment variant_fragment_shader SPIRV-ASM TARGET_ENV spv1.0 ; SPIR-V ; Version: 1.0 ; Generator: Khronos Glslang Reference Front End; 8 ; Bound: 212 ; Schema: 0 OpCapability Shader %1 = OpExtInstImport "GLSL.std.450" OpMemoryModel Logical GLSL450 OpEntryPoint Fragment %4 "main" %169 %206 OpExecutionMode %4 OriginUpperLeft OpSource ESSL 310 OpName %4 "main" OpName %8 "a" OpName %12 "buf0" OpMemberName %12 0 "_GLF_uniform_float_values" OpName %14 "" OpName %20 "b" OpName %25 "i" OpName %28 "buf1" OpMemberName %28 0 "_GLF_uniform_int_values" OpName %30 "" OpName %44 "i" OpName %56 "i" OpName %68 "i" OpName %81 "i" OpName %93 "i" OpName %105 "i" OpName %117 "i" OpName %129 "i" OpName %141 "i" OpName %153 "i" OpName %169 "gl_FragCoord" OpName %206 "_GLF_color" OpDecorate %11 ArrayStride 16 OpMemberDecorate %12 0 Offset 0 OpDecorate %12 Block OpDecorate %14 DescriptorSet 0 OpDecorate %14 Binding 0 OpDecorate %25 RelaxedPrecision OpDecorate %27 ArrayStride 16 OpMemberDecorate %28 0 RelaxedPrecision OpMemberDecorate %28 0 Offset 0 OpDecorate %28 Block OpDecorate %30 DescriptorSet 0 OpDecorate %30 Binding 1 OpDecorate %33 RelaxedPrecision OpDecorate %39 RelaxedPrecision OpDecorate %41 RelaxedPrecision OpDecorate %44 RelaxedPrecision OpDecorate %46 RelaxedPrecision OpDecorate %52 RelaxedPrecision OpDecorate %54 RelaxedPrecision OpDecorate %56 RelaxedPrecision OpDecorate %58 RelaxedPrecision OpDecorate %64 RelaxedPrecision OpDecorate %66 RelaxedPrecision OpDecorate %68 RelaxedPrecision OpDecorate %71 RelaxedPrecision OpDecorate %77 RelaxedPrecision OpDecorate %79 RelaxedPrecision OpDecorate %81 RelaxedPrecision OpDecorate %83 RelaxedPrecision OpDecorate %89 RelaxedPrecision OpDecorate %91 RelaxedPrecision OpDecorate %93 RelaxedPrecision OpDecorate %95 RelaxedPrecision OpDecorate %101 RelaxedPrecision OpDecorate %103 RelaxedPrecision OpDecorate %105 RelaxedPrecision OpDecorate %107 RelaxedPrecision OpDecorate %113 RelaxedPrecision OpDecorate %115 RelaxedPrecision OpDecorate %117 RelaxedPrecision OpDecorate %119 RelaxedPrecision OpDecorate %125 RelaxedPrecision OpDecorate %127 RelaxedPrecision OpDecorate %129 RelaxedPrecision OpDecorate %131 RelaxedPrecision OpDecorate %137 RelaxedPrecision OpDecorate %139 RelaxedPrecision OpDecorate %141 RelaxedPrecision OpDecorate %143 RelaxedPrecision OpDecorate %149 RelaxedPrecision OpDecorate %151 RelaxedPrecision OpDecorate %153 RelaxedPrecision OpDecorate %155 RelaxedPrecision OpDecorate %161 RelaxedPrecision OpDecorate %163 RelaxedPrecision OpDecorate %169 BuiltIn FragCoord OpDecorate %180 RelaxedPrecision OpDecorate %181 RelaxedPrecision OpDecorate %182 RelaxedPrecision OpDecorate %183 RelaxedPrecision OpDecorate %184 RelaxedPrecision OpDecorate %185 RelaxedPrecision OpDecorate %186 RelaxedPrecision OpDecorate %187 RelaxedPrecision OpDecorate %188 RelaxedPrecision OpDecorate %189 RelaxedPrecision OpDecorate %190 RelaxedPrecision OpDecorate %191 RelaxedPrecision OpDecorate %192 RelaxedPrecision OpDecorate %193 RelaxedPrecision OpDecorate %194 RelaxedPrecision OpDecorate %195 RelaxedPrecision OpDecorate %196 RelaxedPrecision OpDecorate %197 RelaxedPrecision OpDecorate %198 RelaxedPrecision OpDecorate %199 RelaxedPrecision OpDecorate %203 RelaxedPrecision OpDecorate %204 RelaxedPrecision OpDecorate %206 Location 0 %2 = OpTypeVoid %3 = OpTypeFunction %2 %6 = OpTypeFloat 32 %7 = OpTypePointer Function %6 %9 = OpTypeInt 32 0 %10 = OpConstant %9 2 %11 = OpTypeArray %6 %10 %12 = OpTypeStruct %11 %13 = OpTypePointer Uniform %12 %14 = OpVariable %13 Uniform %15 = OpTypeInt 32 1 %16 = OpConstant %15 0 %17 = OpTypePointer Uniform %6 %21 = OpConstant %15 1 %24 = OpTypePointer Function %15 %26 = OpConstant %9 3 %27 = OpTypeArray %15 %26 %28 = OpTypeStruct %27 %29 = OpTypePointer Uniform %28 %30 = OpVariable %29 Uniform %31 = OpTypePointer Uniform %15 %42 = OpTypeBool %69 = OpConstant %15 2 %167 = OpTypeVector %6 4 %168 = OpTypePointer Input %167 %169 = OpVariable %168 Input %170 = OpConstant %9 1 %171 = OpTypePointer Input %6 %201 = OpConstant %6 1 %205 = OpTypePointer Output %167 %206 = OpVariable %205 Output %4 = OpFunction %2 None %3 %5 = OpLabel %8 = OpVariable %7 Function %20 = OpVariable %7 Function %25 = OpVariable %24 Function %44 = OpVariable %24 Function %56 = OpVariable %24 Function %68 = OpVariable %24 Function %81 = OpVariable %24 Function %93 = OpVariable %24 Function %105 = OpVariable %24 Function %117 = OpVariable %24 Function %129 = OpVariable %24 Function %141 = OpVariable %24 Function %153 = OpVariable %24 Function %18 = OpAccessChain %17 %14 %16 %16 %19 = OpLoad %6 %18 OpStore %8 %19 %22 = OpAccessChain %17 %14 %16 %21 %23 = OpLoad %6 %22 OpStore %20 %23 %32 = OpAccessChain %31 %30 %16 %21 %33 = OpLoad %15 %32 OpStore %25 %33 OpBranch %34 %34 = OpLabel OpLoopMerge %36 %37 None OpBranch %38 %38 = OpLabel %39 = OpLoad %15 %25 %40 = OpAccessChain %31 %30 %16 %16 %41 = OpLoad %15 %40 %43 = OpSLessThan %42 %39 %41 OpBranchConditional %43 %35 %36 %35 = OpLabel %45 = OpAccessChain %31 %30 %16 %21 %46 = OpLoad %15 %45 OpStore %44 %46 OpBranch %47 %47 = OpLabel OpLoopMerge %49 %50 None OpBranch %51 %51 = OpLabel %52 = OpLoad %15 %44 %53 = OpAccessChain %31 %30 %16 %16 %54 = OpLoad %15 %53 %55 = OpSLessThan %42 %52 %54 OpBranchConditional %55 %48 %49 %48 = OpLabel %57 = OpAccessChain %31 %30 %16 %21 %58 = OpLoad %15 %57 OpStore %56 %58 OpBranch %59 %59 = OpLabel OpLoopMerge %61 %62 None OpBranch %63 %63 = OpLabel %64 = OpLoad %15 %56 %65 = OpAccessChain %31 %30 %16 %16 %66 = OpLoad %15 %65 %67 = OpSLessThan %42 %64 %66 OpBranchConditional %67 %60 %61 %60 = OpLabel %70 = OpAccessChain %31 %30 %16 %69 %71 = OpLoad %15 %70 OpStore %68 %71 OpBranch %72 %72 = OpLabel OpLoopMerge %74 %75 None OpBranch %76 %76 = OpLabel %77 = OpLoad %15 %68 %78 = OpAccessChain %31 %30 %16 %16 %79 = OpLoad %15 %78 %80 = OpSLessThan %42 %77 %79 OpBranchConditional %80 %73 %74 %73 = OpLabel %82 = OpAccessChain %31 %30 %16 %69 %83 = OpLoad %15 %82 OpStore %81 %83 OpBranch %84 %84 = OpLabel OpLoopMerge %86 %87 None OpBranch %88 %88 = OpLabel %89 = OpLoad %15 %81 %90 = OpAccessChain %31 %30 %16 %16 %91 = OpLoad %15 %90 %92 = OpSLessThan %42 %89 %91 OpBranchConditional %92 %85 %86 %85 = OpLabel %94 = OpAccessChain %31 %30 %16 %21 %95 = OpLoad %15 %94 OpStore %93 %95 OpBranch %96 %96 = OpLabel OpLoopMerge %98 %99 None OpBranch %100 %100 = OpLabel %101 = OpLoad %15 %93 %102 = OpAccessChain %31 %30 %16 %16 %103 = OpLoad %15 %102 %104 = OpSLessThan %42 %101 %103 OpBranchConditional %104 %97 %98 %97 = OpLabel %106 = OpAccessChain %31 %30 %16 %21 %107 = OpLoad %15 %106 OpStore %105 %107 OpBranch %108 %108 = OpLabel OpLoopMerge %110 %111 None OpBranch %112 %112 = OpLabel %113 = OpLoad %15 %105 %114 = OpAccessChain %31 %30 %16 %16 %115 = OpLoad %15 %114 %116 = OpSLessThan %42 %113 %115 OpBranchConditional %116 %109 %110 %109 = OpLabel %118 = OpAccessChain %31 %30 %16 %21 %119 = OpLoad %15 %118 OpStore %117 %119 OpBranch %120 %120 = OpLabel OpLoopMerge %122 %123 None OpBranch %124 %124 = OpLabel %125 = OpLoad %15 %117 %126 = OpAccessChain %31 %30 %16 %16 %127 = OpLoad %15 %126 %128 = OpSLessThan %42 %125 %127 OpBranchConditional %128 %121 %122 %121 = OpLabel %130 = OpAccessChain %31 %30 %16 %21 %131 = OpLoad %15 %130 OpStore %129 %131 OpBranch %132 %132 = OpLabel OpLoopMerge %134 %135 None OpBranch %136 %136 = OpLabel %137 = OpLoad %15 %129 %138 = OpAccessChain %31 %30 %16 %16 %139 = OpLoad %15 %138 %140 = OpSLessThan %42 %137 %139 OpBranchConditional %140 %133 %134 %133 = OpLabel %142 = OpAccessChain %31 %30 %16 %21 %143 = OpLoad %15 %142 OpStore %141 %143 OpBranch %144 %144 = OpLabel OpLoopMerge %146 %147 None OpBranch %148 %148 = OpLabel %149 = OpLoad %15 %141 %150 = OpAccessChain %31 %30 %16 %16 %151 = OpLoad %15 %150 %152 = OpSLessThan %42 %149 %151 OpBranchConditional %152 %145 %146 %145 = OpLabel %154 = OpAccessChain %31 %30 %16 %21 %155 = OpLoad %15 %154 OpStore %153 %155 OpBranch %156 %156 = OpLabel OpLoopMerge %158 %159 None OpBranch %160 %160 = OpLabel %161 = OpLoad %15 %153 %162 = OpAccessChain %31 %30 %16 %16 %163 = OpLoad %15 %162 %164 = OpSLessThan %42 %161 %163 OpBranchConditional %164 %157 %158 %157 = OpLabel %165 = OpAccessChain %17 %14 %16 %21 %166 = OpLoad %6 %165 OpStore %8 %166 %172 = OpAccessChain %171 %169 %170 %173 = OpLoad %6 %172 %174 = OpAccessChain %17 %14 %16 %21 %175 = OpLoad %6 %174 %176 = OpFOrdGreaterThan %42 %173 %175 OpSelectionMerge %178 None OpBranchConditional %176 %177 %178 %177 = OpLabel OpBranch %158 %178 = OpLabel OpBranch %159 %159 = OpLabel %180 = OpLoad %15 %153 %181 = OpIAdd %15 %180 %21 OpStore %153 %181 OpBranch %156 %158 = OpLabel OpBranch %147 %147 = OpLabel %182 = OpLoad %15 %141 %183 = OpIAdd %15 %182 %21 OpStore %141 %183 OpBranch %144 %146 = OpLabel OpBranch %135 %135 = OpLabel %184 = OpLoad %15 %129 %185 = OpIAdd %15 %184 %21 OpStore %129 %185 OpBranch %132 %134 = OpLabel OpBranch %123 %123 = OpLabel %186 = OpLoad %15 %117 %187 = OpIAdd %15 %186 %21 OpStore %117 %187 OpBranch %120 %122 = OpLabel OpBranch %111 %111 = OpLabel %188 = OpLoad %15 %105 %189 = OpIAdd %15 %188 %21 OpStore %105 %189 OpBranch %108 %110 = OpLabel OpBranch %99 %99 = OpLabel %190 = OpLoad %15 %93 %191 = OpIAdd %15 %190 %21 OpStore %93 %191 OpBranch %96 %98 = OpLabel OpBranch %87 %87 = OpLabel %192 = OpLoad %15 %81 %193 = OpIAdd %15 %192 %21 OpStore %81 %193 OpBranch %84 %86 = OpLabel OpBranch %75 %75 = OpLabel %194 = OpLoad %15 %68 %195 = OpIAdd %15 %194 %21 OpStore %68 %195 OpBranch %72 %74 = OpLabel OpBranch %62 %62 = OpLabel %196 = OpLoad %15 %56 %197 = OpIAdd %15 %196 %21 OpStore %56 %197 OpBranch %59 %61 = OpLabel OpBranch %50 %50 = OpLabel %198 = OpLoad %15 %44 %199 = OpIAdd %15 %198 %21 OpStore %44 %199 OpBranch %47 %49 = OpLabel %200 = OpLoad %6 %20 %202 = OpFAdd %6 %200 %201 OpStore %20 %202 OpBranch %37 %37 = OpLabel %203 = OpLoad %15 %25 %204 = OpIAdd %15 %203 %21 OpStore %25 %204 OpBranch %34 %36 = OpLabel %207 = OpLoad %6 %20 %208 = OpLoad %6 %8 %209 = OpLoad %6 %8 %210 = OpLoad %6 %20 %211 = OpCompositeConstruct %167 %207 %208 %209 %210 OpStore %206 %211 OpReturn OpFunctionEnd END # uniforms for variant # _GLF_uniform_int_values BUFFER variant__GLF_uniform_int_values DATA_TYPE int32[] STD140 DATA 2 0 1 END # _GLF_uniform_float_values BUFFER variant__GLF_uniform_float_values DATA_TYPE float[] STD140 DATA 1.0 0.0 END BUFFER variant_framebuffer FORMAT B8G8R8A8_UNORM PIPELINE graphics variant_pipeline ATTACH variant_vertex_shader ATTACH variant_fragment_shader FRAMEBUFFER_SIZE 16 16 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 16 16 EXPECT variant_framebuffer IDX 0 0 SIZE 16 16 EQ_RGBA 255 0 0 255