1#!amber 2 3# Copyright 2021 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 specific BRW code paths 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 320 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# #define _float_1_0 _GLF_uniform_float_values[1] 32# 33# precision highp float; 34# precision highp int; 35# 36# // Contents of _GLF_uniform_int_values: [1, 0] 37# layout(set = 0, binding = 0) uniform buf0 38# { 39# int _GLF_uniform_int_values[2]; 40# }; 41# 42# // Contents of _GLF_uniform_float_values: [0.0, 1.0] 43# layout(set = 0, binding = 1) uniform buf1 44# { 45# float _GLF_uniform_float_values[2]; 46# }; 47# 48# // Contents of zero: 0.0 49# layout(set = 0, binding = 2) uniform buf2 { 50# float zero; 51# }; 52# 53# layout(location = 0) out vec4 _GLF_color; 54# 55# bool func(vec2 pos) 56# { 57# // Always false. 58# if(pos.x < _float_0_0) 59# { 60# return true; 61# } 62# 63# // Always true. 64# if(pos.y > _float_0_0) 65# { 66# return false; 67# } 68# 69# if(zero > _float_1_0) 70# { 71# return true; 72# } 73# 74# return true; 75# } 76# 77# void main() 78# { 79# // Always false. 80# if (func(gl_FragCoord.xy)) 81# { 82# discard; 83# } 84# 85# _GLF_color = vec4(_int_1, _int_0, _int_0, _int_1); 86# } 87SHADER fragment variant_fragment_shader SPIRV-ASM TARGET_ENV spv1.0 88; SPIR-V 89; Version: 1.0 90; Generator: Khronos Glslang Reference Front End; 10 91; Bound: 88 92; Schema: 0 93 OpCapability Shader 94 %1 = OpExtInstImport "GLSL.std.450" 95 OpMemoryModel Logical GLSL450 96 OpEntryPoint Fragment %4 "main" %60 %69 97 OpExecutionMode %4 OriginUpperLeft 98 OpSource ESSL 320 99 OpName %4 "main" 100 OpName %12 "func(vf2;" 101 OpName %11 "pos" 102 OpName %21 "buf1" 103 OpMemberName %21 0 "_GLF_uniform_float_values" 104 OpName %23 "" 105 OpName %44 "buf2" 106 OpMemberName %44 0 "zero" 107 OpName %46 "" 108 OpName %60 "gl_FragCoord" 109 OpName %61 "param" 110 OpName %69 "_GLF_color" 111 OpName %71 "buf0" 112 OpMemberName %71 0 "_GLF_uniform_int_values" 113 OpName %73 "" 114 OpDecorate %20 ArrayStride 16 115 OpMemberDecorate %21 0 Offset 0 116 OpDecorate %21 Block 117 OpDecorate %23 DescriptorSet 0 118 OpDecorate %23 Binding 1 119 OpMemberDecorate %44 0 Offset 0 120 OpDecorate %44 Block 121 OpDecorate %46 DescriptorSet 0 122 OpDecorate %46 Binding 2 123 OpDecorate %60 BuiltIn FragCoord 124 OpDecorate %69 Location 0 125 OpDecorate %70 ArrayStride 16 126 OpMemberDecorate %71 0 Offset 0 127 OpDecorate %71 Block 128 OpDecorate %73 DescriptorSet 0 129 OpDecorate %73 Binding 0 130 %2 = OpTypeVoid 131 %3 = OpTypeFunction %2 132 %6 = OpTypeFloat 32 133 %7 = OpTypeVector %6 2 134 %8 = OpTypePointer Function %7 135 %9 = OpTypeBool 136 %10 = OpTypeFunction %9 %8 137 %14 = OpTypeInt 32 0 138 %15 = OpConstant %14 0 139 %16 = OpTypePointer Function %6 140 %19 = OpConstant %14 2 141 %20 = OpTypeArray %6 %19 142 %21 = OpTypeStruct %20 143 %22 = OpTypePointer Uniform %21 144 %23 = OpVariable %22 Uniform 145 %24 = OpTypeInt 32 1 146 %25 = OpConstant %24 0 147 %26 = OpTypePointer Uniform %6 148 %32 = OpConstantTrue %9 149 %34 = OpConstant %14 1 150 %42 = OpConstantFalse %9 151 %44 = OpTypeStruct %6 152 %45 = OpTypePointer Uniform %44 153 %46 = OpVariable %45 Uniform 154 %49 = OpConstant %24 1 155 %58 = OpTypeVector %6 4 156 %59 = OpTypePointer Input %58 157 %60 = OpVariable %59 Input 158 %68 = OpTypePointer Output %58 159 %69 = OpVariable %68 Output 160 %70 = OpTypeArray %24 %19 161 %71 = OpTypeStruct %70 162 %72 = OpTypePointer Uniform %71 163 %73 = OpVariable %72 Uniform 164 %74 = OpTypePointer Uniform %24 165 %4 = OpFunction %2 None %3 166 %5 = OpLabel 167 %61 = OpVariable %8 Function 168 %62 = OpLoad %58 %60 169 %63 = OpVectorShuffle %7 %62 %62 0 1 170 OpStore %61 %63 171 %64 = OpFunctionCall %9 %12 %61 172 OpSelectionMerge %66 None 173 OpBranchConditional %64 %65 %66 174 %65 = OpLabel 175 OpKill 176 %66 = OpLabel 177 %75 = OpAccessChain %74 %73 %25 %25 178 %76 = OpLoad %24 %75 179 %77 = OpConvertSToF %6 %76 180 %78 = OpAccessChain %74 %73 %25 %49 181 %79 = OpLoad %24 %78 182 %80 = OpConvertSToF %6 %79 183 %81 = OpAccessChain %74 %73 %25 %49 184 %82 = OpLoad %24 %81 185 %83 = OpConvertSToF %6 %82 186 %84 = OpAccessChain %74 %73 %25 %25 187 %85 = OpLoad %24 %84 188 %86 = OpConvertSToF %6 %85 189 %87 = OpCompositeConstruct %58 %77 %80 %83 %86 190 OpStore %69 %87 191 OpReturn 192 OpFunctionEnd 193 %12 = OpFunction %9 None %10 194 %11 = OpFunctionParameter %8 195 %13 = OpLabel 196 %17 = OpAccessChain %16 %11 %15 197 %18 = OpLoad %6 %17 198 %27 = OpAccessChain %26 %23 %25 %25 199 %28 = OpLoad %6 %27 200 %29 = OpFOrdLessThan %9 %18 %28 201 OpSelectionMerge %31 None 202 OpBranchConditional %29 %30 %31 203 %30 = OpLabel 204 OpReturnValue %32 205 %31 = OpLabel 206 %35 = OpAccessChain %16 %11 %34 207 %36 = OpLoad %6 %35 208 %37 = OpAccessChain %26 %23 %25 %25 209 %38 = OpLoad %6 %37 210 %39 = OpFOrdGreaterThan %9 %36 %38 211 OpSelectionMerge %41 None 212 OpBranchConditional %39 %40 %41 213 %40 = OpLabel 214 OpReturnValue %42 215 %41 = OpLabel 216 %47 = OpAccessChain %26 %46 %25 217 %48 = OpLoad %6 %47 218 %50 = OpAccessChain %26 %23 %25 %49 219 %51 = OpLoad %6 %50 220 %52 = OpFOrdGreaterThan %9 %48 %51 221 OpSelectionMerge %54 None 222 OpBranchConditional %52 %53 %54 223 %53 = OpLabel 224 OpReturnValue %32 225 %54 = OpLabel 226 OpReturnValue %32 227 OpFunctionEnd 228END 229 230# uniforms for variant 231 232# zero 233BUFFER variant_zero DATA_TYPE float STD140 DATA 234 0.0 235END 236# _GLF_uniform_float_values 237BUFFER variant__GLF_uniform_float_values DATA_TYPE float[] STD140 DATA 238 0.0 1.0 239END 240# _GLF_uniform_int_values 241BUFFER variant__GLF_uniform_int_values DATA_TYPE int32[] STD140 DATA 242 1 0 243END 244 245BUFFER variant_framebuffer FORMAT B8G8R8A8_UNORM 246 247PIPELINE graphics variant_pipeline 248 ATTACH variant_vertex_shader 249 ATTACH variant_fragment_shader 250 FRAMEBUFFER_SIZE 256 256 251 BIND BUFFER variant_framebuffer AS color LOCATION 0 252 BIND BUFFER variant_zero AS uniform DESCRIPTOR_SET 0 BINDING 2 253 BIND BUFFER variant__GLF_uniform_float_values AS uniform DESCRIPTOR_SET 0 BINDING 1 254 BIND BUFFER variant__GLF_uniform_int_values AS uniform DESCRIPTOR_SET 0 BINDING 0 255END 256CLEAR_COLOR variant_pipeline 0 0 0 255 257 258CLEAR variant_pipeline 259RUN variant_pipeline DRAW_RECT POS 0 0 SIZE 256 256 260 261EXPECT variant_framebuffer IDX 0 0 SIZE 256 256 EQ_RGBA 255 0 0 255 262