#!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 instr info code 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_0 _GLF_uniform_int_values[0] # #define _int_1 _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; # # layout(location = 0) out vec4 _GLF_color; # # // Contents of _GLF_uniform_int_values: [0, 1] # 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]; # }; # # int data[10]; # # void f1() # { # _GLF_color = vec4(0); # # for (int i = _int_1; i < _int_10; i++) # { # data[i] = _int_0; # } # # float a = determinant(mat2(1.0, 1.0, 1.0, 1.0)); # float b = determinant(mat2(0.0, 0.0, 0.0, 0.0)); # # mat2x4 m24a = mat2x4(a, _float_1_0, _float_1_0, _float_1_0, _float_1_0, # _float_1_0, _float_1_0, _float_1_0); # mat2x4 m24b = mat2x4(b, _float_1_0, _float_1_0, _float_1_0, _float_1_0, # _float_1_0, _float_1_0, _float_1_0); # # float c = min(float(m24a), float(m24b)); # # if (c < _float_1_0 && a == 0.0 && b == 0.0) # { # data[0] = _int_1; # } # } # # void main() # { # for (int i = 0; i <= 10; i++) # { # f1(); # } # # _GLF_color = vec4(data[0], _float_0_0, _float_0_0, data[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: 152 ; Schema: 0 OpCapability Shader %1 = OpExtInstImport "GLSL.std.450" OpMemoryModel Logical GLSL450 OpEntryPoint Fragment %4 "main" %11 OpExecutionMode %4 OriginUpperLeft OpSource ESSL 310 OpName %4 "main" OpName %6 "f1(" OpName %11 "_GLF_color" OpName %16 "i" OpName %20 "buf0" OpMemberName %20 0 "_GLF_uniform_int_values" OpName %22 "" OpName %42 "data" OpName %51 "a" OpName %58 "b" OpName %64 "m24a" OpName %68 "buf1" OpMemberName %68 0 "_GLF_uniform_float_values" OpName %70 "" OpName %89 "m24b" OpName %108 "c" OpName %129 "i" OpDecorate %11 Location 0 OpDecorate %19 ArrayStride 16 OpMemberDecorate %20 0 Offset 0 OpDecorate %20 Block OpDecorate %22 DescriptorSet 0 OpDecorate %22 Binding 0 OpDecorate %67 ArrayStride 16 OpMemberDecorate %68 0 Offset 0 OpDecorate %68 Block OpDecorate %70 DescriptorSet 0 OpDecorate %70 Binding 1 %2 = OpTypeVoid %3 = OpTypeFunction %2 %8 = OpTypeFloat 32 %9 = OpTypeVector %8 4 %10 = OpTypePointer Output %9 %11 = OpVariable %10 Output %12 = OpConstant %8 0 %13 = OpConstantComposite %9 %12 %12 %12 %12 %14 = OpTypeInt 32 1 %15 = OpTypePointer Function %14 %17 = OpTypeInt 32 0 %18 = OpConstant %17 3 %19 = OpTypeArray %14 %18 %20 = OpTypeStruct %19 %21 = OpTypePointer Uniform %20 %22 = OpVariable %21 Uniform %23 = OpConstant %14 0 %24 = OpConstant %14 1 %25 = OpTypePointer Uniform %14 %34 = OpConstant %14 2 %37 = OpTypeBool %39 = OpConstant %17 10 %40 = OpTypeArray %14 %39 %41 = OpTypePointer Private %40 %42 = OpVariable %41 Private %46 = OpTypePointer Private %14 %50 = OpTypePointer Function %8 %52 = OpTypeVector %8 2 %53 = OpTypeMatrix %52 2 %54 = OpConstant %8 1 %55 = OpConstantComposite %52 %54 %54 %56 = OpConstantComposite %53 %55 %55 %59 = OpConstantComposite %52 %12 %12 %60 = OpConstantComposite %53 %59 %59 %62 = OpTypeMatrix %9 2 %63 = OpTypePointer Function %62 %66 = OpConstant %17 2 %67 = OpTypeArray %8 %66 %68 = OpTypeStruct %67 %69 = OpTypePointer Uniform %68 %70 = OpVariable %69 Uniform %71 = OpTypePointer Uniform %8 %136 = OpConstant %14 10 %4 = OpFunction %2 None %3 %5 = OpLabel %129 = OpVariable %15 Function OpStore %129 %23 OpBranch %130 %130 = OpLabel OpLoopMerge %132 %133 None OpBranch %134 %134 = OpLabel %135 = OpLoad %14 %129 %137 = OpSLessThanEqual %37 %135 %136 OpBranchConditional %137 %131 %132 %131 = OpLabel %138 = OpFunctionCall %2 %6 OpBranch %133 %133 = OpLabel %139 = OpLoad %14 %129 %140 = OpIAdd %14 %139 %24 OpStore %129 %140 OpBranch %130 %132 = OpLabel %141 = OpAccessChain %46 %42 %23 %142 = OpLoad %14 %141 %143 = OpConvertSToF %8 %142 %144 = OpAccessChain %71 %70 %23 %23 %145 = OpLoad %8 %144 %146 = OpAccessChain %71 %70 %23 %23 %147 = OpLoad %8 %146 %148 = OpAccessChain %46 %42 %23 %149 = OpLoad %14 %148 %150 = OpConvertSToF %8 %149 %151 = OpCompositeConstruct %9 %143 %145 %147 %150 OpStore %11 %151 OpReturn OpFunctionEnd %6 = OpFunction %2 None %3 %7 = OpLabel %16 = OpVariable %15 Function %51 = OpVariable %50 Function %58 = OpVariable %50 Function %64 = OpVariable %63 Function %89 = OpVariable %63 Function %108 = OpVariable %50 Function OpStore %11 %13 %26 = OpAccessChain %25 %22 %23 %24 %27 = OpLoad %14 %26 OpStore %16 %27 OpBranch %28 %28 = OpLabel OpLoopMerge %30 %31 None OpBranch %32 %32 = OpLabel %33 = OpLoad %14 %16 %35 = OpAccessChain %25 %22 %23 %34 %36 = OpLoad %14 %35 %38 = OpSLessThan %37 %33 %36 OpBranchConditional %38 %29 %30 %29 = OpLabel %43 = OpLoad %14 %16 %44 = OpAccessChain %25 %22 %23 %23 %45 = OpLoad %14 %44 %47 = OpAccessChain %46 %42 %43 OpStore %47 %45 OpBranch %31 %31 = OpLabel %48 = OpLoad %14 %16 %49 = OpIAdd %14 %48 %24 OpStore %16 %49 OpBranch %28 %30 = OpLabel %57 = OpExtInst %8 %1 Determinant %56 OpStore %51 %57 %61 = OpExtInst %8 %1 Determinant %60 OpStore %58 %61 %65 = OpLoad %8 %51 %72 = OpAccessChain %71 %70 %23 %24 %73 = OpLoad %8 %72 %74 = OpAccessChain %71 %70 %23 %24 %75 = OpLoad %8 %74 %76 = OpAccessChain %71 %70 %23 %24 %77 = OpLoad %8 %76 %78 = OpAccessChain %71 %70 %23 %24 %79 = OpLoad %8 %78 %80 = OpAccessChain %71 %70 %23 %24 %81 = OpLoad %8 %80 %82 = OpAccessChain %71 %70 %23 %24 %83 = OpLoad %8 %82 %84 = OpAccessChain %71 %70 %23 %24 %85 = OpLoad %8 %84 %86 = OpCompositeConstruct %9 %65 %73 %75 %77 %87 = OpCompositeConstruct %9 %79 %81 %83 %85 %88 = OpCompositeConstruct %62 %86 %87 OpStore %64 %88 %90 = OpLoad %8 %58 %91 = OpAccessChain %71 %70 %23 %24 %92 = OpLoad %8 %91 %93 = OpAccessChain %71 %70 %23 %24 %94 = OpLoad %8 %93 %95 = OpAccessChain %71 %70 %23 %24 %96 = OpLoad %8 %95 %97 = OpAccessChain %71 %70 %23 %24 %98 = OpLoad %8 %97 %99 = OpAccessChain %71 %70 %23 %24 %100 = OpLoad %8 %99 %101 = OpAccessChain %71 %70 %23 %24 %102 = OpLoad %8 %101 %103 = OpAccessChain %71 %70 %23 %24 %104 = OpLoad %8 %103 %105 = OpCompositeConstruct %9 %90 %92 %94 %96 %106 = OpCompositeConstruct %9 %98 %100 %102 %104 %107 = OpCompositeConstruct %62 %105 %106 OpStore %89 %107 %109 = OpLoad %62 %64 %110 = OpCompositeExtract %8 %109 0 0 %111 = OpLoad %62 %89 %112 = OpCompositeExtract %8 %111 0 0 %113 = OpExtInst %8 %1 FMin %110 %112 OpStore %108 %113 %114 = OpLoad %8 %108 %115 = OpAccessChain %71 %70 %23 %24 %116 = OpLoad %8 %115 %117 = OpFOrdLessThan %37 %114 %116 %118 = OpLoad %8 %51 %119 = OpFOrdEqual %37 %118 %12 %120 = OpLogicalAnd %37 %117 %119 %121 = OpLoad %8 %58 %122 = OpFOrdEqual %37 %121 %12 %123 = OpLogicalAnd %37 %120 %122 OpSelectionMerge %125 None OpBranchConditional %123 %124 %125 %124 = OpLabel %126 = OpAccessChain %25 %22 %23 %24 %127 = OpLoad %14 %126 %128 = OpAccessChain %46 %42 %23 OpStore %128 %127 OpBranch %125 %125 = OpLabel OpReturn OpFunctionEnd END # uniforms for variant # _GLF_uniform_int_values BUFFER variant__GLF_uniform_int_values DATA_TYPE int32[] STD140 DATA 0 1 10 END # _GLF_uniform_float_values BUFFER variant__GLF_uniform_float_values DATA_TYPE float[] STD140 DATA 0.0 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 0 BIND BUFFER variant__GLF_uniform_float_values AS uniform DESCRIPTOR_SET 0 BINDING 1 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