#!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 calculates refraction with certain values # 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 _float_1_0 _GLF_uniform_float_values[0] # #define _float_0_0 _GLF_uniform_float_values[1] # #define _float_0_1 _GLF_uniform_float_values[2] # # precision highp float; # # // Contents of _GLF_uniform_int_values: [1, 0] # layout(set = 0, binding = 0) uniform buf0 # { # int _GLF_uniform_int_values[2]; # }; # # // Contents of _GLF_uniform_float_values: [1.0, 0.0, 0.1] # layout(set = 0, binding = 1) uniform buf1 # { # float _GLF_uniform_float_values[3]; # }; # # layout(location = 0) out vec4 _GLF_color; # # void main() # { # float I = -1.0; # // N becomes 0. # float N = dFdx(determinant(mat3(1.0))); # // Usually eta is normalized, but the spec doesn't forbid other values. # float eta = -1.1; # # // Refraction calculated by the formula from the spec. # float R; # float k = _float_1_0 - eta * eta * (_float_1_0 - dot(N, I) * dot(N, I)); # # if (k < _float_0_0) # { # R = _float_0_0; # } # else # { # R = eta * I - (eta * dot(N, I) + sqrt(k)) * N; # } # # if (abs(R - refract(I, N, eta)) < _float_0_1) # { # _GLF_color = vec4(_int_1, _int_0, _int_0, _int_1); # } # else # { # _GLF_color = vec4(_int_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: 116 ; Schema: 0 OpCapability Shader %1 = OpExtInstImport "GLSL.std.450" OpMemoryModel Logical GLSL450 OpEntryPoint Fragment %4 "main" %91 OpExecutionMode %4 OriginUpperLeft OpSource ESSL 310 OpName %4 "main" OpName %8 "I" OpName %10 "N" OpName %21 "eta" OpName %23 "k" OpName %27 "buf1" OpMemberName %27 0 "_GLF_uniform_float_values" OpName %29 "" OpName %58 "R" OpName %91 "_GLF_color" OpName %94 "buf0" OpMemberName %94 0 "_GLF_uniform_int_values" OpName %96 "" OpDecorate %26 ArrayStride 16 OpMemberDecorate %27 0 Offset 0 OpDecorate %27 Block OpDecorate %29 DescriptorSet 0 OpDecorate %29 Binding 1 OpDecorate %91 Location 0 OpDecorate %93 ArrayStride 16 OpMemberDecorate %94 0 RelaxedPrecision OpMemberDecorate %94 0 Offset 0 OpDecorate %94 Block OpDecorate %96 DescriptorSet 0 OpDecorate %96 Binding 0 OpDecorate %99 RelaxedPrecision OpDecorate %102 RelaxedPrecision OpDecorate %105 RelaxedPrecision OpDecorate %108 RelaxedPrecision OpDecorate %113 RelaxedPrecision %2 = OpTypeVoid %3 = OpTypeFunction %2 %6 = OpTypeFloat 32 %7 = OpTypePointer Function %6 %9 = OpConstant %6 -1 %11 = OpTypeVector %6 3 %12 = OpTypeMatrix %11 3 %13 = OpConstant %6 1 %14 = OpConstant %6 0 %15 = OpConstantComposite %11 %13 %14 %14 %16 = OpConstantComposite %11 %14 %13 %14 %17 = OpConstantComposite %11 %14 %14 %13 %18 = OpConstantComposite %12 %15 %16 %17 %22 = OpConstant %6 -1.10000002 %24 = OpTypeInt 32 0 %25 = OpConstant %24 3 %26 = OpTypeArray %6 %25 %27 = OpTypeStruct %26 %28 = OpTypePointer Uniform %27 %29 = OpVariable %28 Uniform %30 = OpTypeInt 32 1 %31 = OpConstant %30 0 %32 = OpTypePointer Uniform %6 %51 = OpConstant %30 1 %54 = OpTypeBool %83 = OpConstant %30 2 %89 = OpTypeVector %6 4 %90 = OpTypePointer Output %89 %91 = OpVariable %90 Output %92 = OpConstant %24 2 %93 = OpTypeArray %30 %92 %94 = OpTypeStruct %93 %95 = OpTypePointer Uniform %94 %96 = OpVariable %95 Uniform %97 = OpTypePointer Uniform %30 %4 = OpFunction %2 None %3 %5 = OpLabel %8 = OpVariable %7 Function %10 = OpVariable %7 Function %21 = OpVariable %7 Function %23 = OpVariable %7 Function %58 = OpVariable %7 Function OpStore %8 %9 %19 = OpExtInst %6 %1 Determinant %18 %20 = OpDPdx %6 %19 OpStore %10 %20 OpStore %21 %22 %33 = OpAccessChain %32 %29 %31 %31 %34 = OpLoad %6 %33 %35 = OpLoad %6 %21 %36 = OpLoad %6 %21 %37 = OpFMul %6 %35 %36 %38 = OpAccessChain %32 %29 %31 %31 %39 = OpLoad %6 %38 %40 = OpLoad %6 %10 %41 = OpLoad %6 %8 %42 = OpFMul %6 %40 %41 %43 = OpLoad %6 %10 %44 = OpLoad %6 %8 %45 = OpFMul %6 %43 %44 %46 = OpFMul %6 %42 %45 %47 = OpFSub %6 %39 %46 %48 = OpFMul %6 %37 %47 %49 = OpFSub %6 %34 %48 OpStore %23 %49 %50 = OpLoad %6 %23 %52 = OpAccessChain %32 %29 %31 %51 %53 = OpLoad %6 %52 %55 = OpFOrdLessThan %54 %50 %53 OpSelectionMerge %57 None OpBranchConditional %55 %56 %61 %56 = OpLabel %59 = OpAccessChain %32 %29 %31 %51 %60 = OpLoad %6 %59 OpStore %58 %60 OpBranch %57 %61 = OpLabel %62 = OpLoad %6 %21 %63 = OpLoad %6 %8 %64 = OpFMul %6 %62 %63 %65 = OpLoad %6 %21 %66 = OpLoad %6 %10 %67 = OpLoad %6 %8 %68 = OpFMul %6 %66 %67 %69 = OpFMul %6 %65 %68 %70 = OpLoad %6 %23 %71 = OpExtInst %6 %1 Sqrt %70 %72 = OpFAdd %6 %69 %71 %73 = OpLoad %6 %10 %74 = OpFMul %6 %72 %73 %75 = OpFSub %6 %64 %74 OpStore %58 %75 OpBranch %57 %57 = OpLabel %76 = OpLoad %6 %58 %77 = OpLoad %6 %8 %78 = OpLoad %6 %10 %79 = OpLoad %6 %21 %80 = OpExtInst %6 %1 Refract %77 %78 %79 %81 = OpFSub %6 %76 %80 %82 = OpExtInst %6 %1 FAbs %81 %84 = OpAccessChain %32 %29 %31 %83 %85 = OpLoad %6 %84 %86 = OpFOrdLessThan %54 %82 %85 OpSelectionMerge %88 None OpBranchConditional %86 %87 %111 %87 = OpLabel %98 = OpAccessChain %97 %96 %31 %31 %99 = OpLoad %30 %98 %100 = OpConvertSToF %6 %99 %101 = OpAccessChain %97 %96 %31 %51 %102 = OpLoad %30 %101 %103 = OpConvertSToF %6 %102 %104 = OpAccessChain %97 %96 %31 %51 %105 = OpLoad %30 %104 %106 = OpConvertSToF %6 %105 %107 = OpAccessChain %97 %96 %31 %31 %108 = OpLoad %30 %107 %109 = OpConvertSToF %6 %108 %110 = OpCompositeConstruct %89 %100 %103 %106 %109 OpStore %91 %110 OpBranch %88 %111 = OpLabel %112 = OpAccessChain %97 %96 %31 %51 %113 = OpLoad %30 %112 %114 = OpConvertSToF %6 %113 %115 = OpCompositeConstruct %89 %114 %114 %114 %114 OpStore %91 %115 OpBranch %88 %88 = OpLabel OpReturn OpFunctionEnd END # uniforms for variant # _GLF_uniform_float_values BUFFER variant__GLF_uniform_float_values DATA_TYPE float[] STD140 DATA 1.0 0.0 0.1 END # _GLF_uniform_int_values BUFFER variant__GLF_uniform_int_values DATA_TYPE int32[] 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_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