1#!amber 2 3# Copyright 2020 Google LLC 4# 5# Licensed under the Apache License, Version 2.0 (the "License"); 6# you may not use this file except in compliance with the License. 7# You may obtain a copy of the License at 8# 9# http://www.apache.org/licenses/LICENSE-2.0 10# 11# Unless required by applicable law or agreed to in writing, software 12# distributed under the License is distributed on an "AS IS" BASIS, 13# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14# See the License for the specific language governing permissions and 15# limitations under the License. 16 17 18# A test for a coverage-gap found by the GraphicsFuzz project. 19 20# Short description: A fragment shader that covers a specific floating point code path 21 22# The test passes because the shader always writes red. 23 24SHADER vertex variant_vertex_shader PASSTHROUGH 25 26# variant_fragment_shader is derived from the following GLSL: 27# #version 310 es 28# #define _int_1 _GLF_uniform_int_values[0] 29# #define _int_0 _GLF_uniform_int_values[1] 30# #define _float_0_0 _GLF_uniform_float_values[0] 31# 32# precision highp float; 33# precision highp int; 34# 35# // Contents of _GLF_uniform_int_values: [1, 0] 36# layout(set = 0, binding = 0) uniform buf0 37# { 38# int _GLF_uniform_int_values[2]; 39# }; 40# 41# // Contents of _GLF_uniform_float_values: 0.0 42# layout(set = 0, binding = 1) uniform buf1 43# { 44# float _GLF_uniform_float_values[1]; 45# }; 46# 47# layout(location = 0) out vec4 _GLF_color; 48# 49# void main() 50# { 51# float edge = determinant(mat3(1)); 52# if (step(edge, vec4(-3.0)) == vec4(_float_0_0)) 53# { 54# _GLF_color = vec4(_int_1, _int_0, _int_0, _int_1); 55# } 56# else 57# { 58# _GLF_color = vec4(_int_0); 59# } 60# } 61SHADER fragment variant_fragment_shader SPIRV-ASM TARGET_ENV spv1.0 62; SPIR-V 63; Version: 1.0 64; Generator: Khronos Glslang Reference Front End; 8 65; Bound: 69 66; Schema: 0 67 OpCapability Shader 68 %1 = OpExtInstImport "GLSL.std.450" 69 OpMemoryModel Logical GLSL450 70 OpEntryPoint Fragment %4 "main" %43 71 OpExecutionMode %4 OriginUpperLeft 72 OpSource ESSL 310 73 OpName %4 "main" 74 OpName %8 "edge" 75 OpName %27 "buf1" 76 OpMemberName %27 0 "_GLF_uniform_float_values" 77 OpName %29 "" 78 OpName %43 "_GLF_color" 79 OpName %46 "buf0" 80 OpMemberName %46 0 "_GLF_uniform_int_values" 81 OpName %48 "" 82 OpDecorate %26 ArrayStride 16 83 OpMemberDecorate %27 0 Offset 0 84 OpDecorate %27 Block 85 OpDecorate %29 DescriptorSet 0 86 OpDecorate %29 Binding 1 87 OpDecorate %43 Location 0 88 OpDecorate %45 ArrayStride 16 89 OpMemberDecorate %46 0 Offset 0 90 OpDecorate %46 Block 91 OpDecorate %48 DescriptorSet 0 92 OpDecorate %48 Binding 0 93 %2 = OpTypeVoid 94 %3 = OpTypeFunction %2 95 %6 = OpTypeFloat 32 96 %7 = OpTypePointer Function %6 97 %9 = OpTypeVector %6 3 98 %10 = OpTypeMatrix %9 3 99 %11 = OpConstant %6 1 100 %12 = OpConstant %6 0 101 %13 = OpConstantComposite %9 %11 %12 %12 102 %14 = OpConstantComposite %9 %12 %11 %12 103 %15 = OpConstantComposite %9 %12 %12 %11 104 %16 = OpConstantComposite %10 %13 %14 %15 105 %19 = OpTypeVector %6 4 106 %20 = OpConstant %6 -3 107 %21 = OpConstantComposite %19 %20 %20 %20 %20 108 %24 = OpTypeInt 32 0 109 %25 = OpConstant %24 1 110 %26 = OpTypeArray %6 %25 111 %27 = OpTypeStruct %26 112 %28 = OpTypePointer Uniform %27 113 %29 = OpVariable %28 Uniform 114 %30 = OpTypeInt 32 1 115 %31 = OpConstant %30 0 116 %32 = OpTypePointer Uniform %6 117 %36 = OpTypeBool 118 %37 = OpTypeVector %36 4 119 %42 = OpTypePointer Output %19 120 %43 = OpVariable %42 Output 121 %44 = OpConstant %24 2 122 %45 = OpTypeArray %30 %44 123 %46 = OpTypeStruct %45 124 %47 = OpTypePointer Uniform %46 125 %48 = OpVariable %47 Uniform 126 %49 = OpTypePointer Uniform %30 127 %53 = OpConstant %30 1 128 %4 = OpFunction %2 None %3 129 %5 = OpLabel 130 %8 = OpVariable %7 Function 131 %17 = OpExtInst %6 %1 Determinant %16 132 OpStore %8 %17 133 %18 = OpLoad %6 %8 134 %22 = OpCompositeConstruct %19 %18 %18 %18 %18 135 %23 = OpExtInst %19 %1 Step %22 %21 136 %33 = OpAccessChain %32 %29 %31 %31 137 %34 = OpLoad %6 %33 138 %35 = OpCompositeConstruct %19 %34 %34 %34 %34 139 %38 = OpFOrdEqual %37 %23 %35 140 %39 = OpAll %36 %38 141 OpSelectionMerge %41 None 142 OpBranchConditional %39 %40 %64 143 %40 = OpLabel 144 %50 = OpAccessChain %49 %48 %31 %31 145 %51 = OpLoad %30 %50 146 %52 = OpConvertSToF %6 %51 147 %54 = OpAccessChain %49 %48 %31 %53 148 %55 = OpLoad %30 %54 149 %56 = OpConvertSToF %6 %55 150 %57 = OpAccessChain %49 %48 %31 %53 151 %58 = OpLoad %30 %57 152 %59 = OpConvertSToF %6 %58 153 %60 = OpAccessChain %49 %48 %31 %31 154 %61 = OpLoad %30 %60 155 %62 = OpConvertSToF %6 %61 156 %63 = OpCompositeConstruct %19 %52 %56 %59 %62 157 OpStore %43 %63 158 OpBranch %41 159 %64 = OpLabel 160 %65 = OpAccessChain %49 %48 %31 %53 161 %66 = OpLoad %30 %65 162 %67 = OpConvertSToF %6 %66 163 %68 = OpCompositeConstruct %19 %67 %67 %67 %67 164 OpStore %43 %68 165 OpBranch %41 166 %41 = OpLabel 167 OpReturn 168 OpFunctionEnd 169END 170 171# uniforms for variant 172 173# _GLF_uniform_float_values 174BUFFER variant__GLF_uniform_float_values DATA_TYPE float[] STD140 DATA 175 0.0 176END 177# _GLF_uniform_int_values 178BUFFER variant__GLF_uniform_int_values DATA_TYPE int32[] STD140 DATA 179 1 0 180END 181 182BUFFER variant_framebuffer FORMAT B8G8R8A8_UNORM 183 184PIPELINE graphics variant_pipeline 185 ATTACH variant_vertex_shader 186 ATTACH variant_fragment_shader 187 FRAMEBUFFER_SIZE 256 256 188 BIND BUFFER variant_framebuffer AS color LOCATION 0 189 BIND BUFFER variant__GLF_uniform_float_values AS uniform DESCRIPTOR_SET 0 BINDING 1 190 BIND BUFFER variant__GLF_uniform_int_values AS uniform DESCRIPTOR_SET 0 BINDING 0 191END 192CLEAR_COLOR variant_pipeline 0 0 0 255 193 194CLEAR variant_pipeline 195RUN variant_pipeline DRAW_RECT POS 0 0 SIZE 256 256 196 197EXPECT variant_framebuffer IDX 0 0 SIZE 256 256 EQ_RGBA 255 0 0 255 198