1#!amber 2 3# Copyright 2022 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 LLVM 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# 29# #define _int_1 _GLF_uniform_int_values[0] 30# #define _int_0 _GLF_uniform_int_values[1] 31# #define _int_2 _GLF_uniform_int_values[2] 32# #define _int_3 _GLF_uniform_int_values[3] 33# #define _float_1_0 _GLF_uniform_float_values[0] 34# #define _float_9_0 _GLF_uniform_float_values[1] 35# #define _float_10_0 _GLF_uniform_float_values[2] 36# #define _float_2_0 _GLF_uniform_float_values[3] 37# 38# precision highp float; 39# precision highp int; 40# 41# // Contents of _GLF_uniform_int_values: [1, 0, 2, 3] 42# layout(set = 0, binding = 0) uniform buf0 43# { 44# int _GLF_uniform_int_values[4]; 45# }; 46# 47# // Contents of _GLF_uniform_float_values: [1.0, 9.0, 10.0, 2.0] 48# layout(set = 0, binding = 1) uniform buf1 49# { 50# float _GLF_uniform_float_values[4]; 51# }; 52# 53# layout(location = 0) out vec4 _GLF_color; 54# 55# void main() 56# { 57# float f = _float_2_0; 58# mat4 m = mat4(_float_1_0); 59# int a = 1; 60# 61# // i = 1: m[1][1] = m[1][1] - 5 * 2 = 1 - 10 = -9. 62# // i = 2: m[1][2] = m[1][1] - 1 = -9 - 1 = -10. 63# // i = 3: m[1][3] = m[1][1] - 1 = -9 - 1 = -10. 64# for(int i = 1; i < 4; i ++) 65# { 66# // Always false. 67# if(gl_FragCoord.x < 0.0) 68# { 69# break; 70# } 71# 72# // Always false. 73# if(a ++ >= 5) 74# { 75# break; 76# } 77# 78# for(int j = 1; j < 6; j++) 79# { 80# m[_int_1][i] = m[_int_1][_int_1] - f; 81# } 82# 83# f = _float_1_0; 84# } 85# 86# mat4 ref = mat4(_float_1_0); 87# ref[1][1] = -9.0; 88# ref[1][2] = -10.0; 89# ref[1][3] = -10.0; 90# 91# // Always true. 92# if(m == ref) 93# { 94# _GLF_color = vec4(_int_1, _int_0, _int_0, _int_1); 95# } 96# else 97# { 98# _GLF_color = vec4(_int_0); 99# } 100# } 101SHADER fragment variant_fragment_shader SPIRV-ASM TARGET_ENV spv1.0 102; SPIR-V 103; Version: 1.0 104; Generator: Khronos Glslang Reference Front End; 10 105; Bound: 156 106; Schema: 0 107 OpCapability Shader 108 %1 = OpExtInstImport "GLSL.std.450" 109 OpMemoryModel Logical GLSL450 110 OpEntryPoint Fragment %4 "main" %48 %137 111 OpExecutionMode %4 OriginUpperLeft 112 OpSource ESSL 320 113 OpName %4 "main" 114 OpName %8 "f" 115 OpName %12 "buf1" 116 OpMemberName %12 0 "_GLF_uniform_float_values" 117 OpName %14 "" 118 OpName %24 "m" 119 OpName %35 "a" 120 OpName %37 "i" 121 OpName %48 "gl_FragCoord" 122 OpName %64 "j" 123 OpName %74 "buf0" 124 OpMemberName %74 0 "_GLF_uniform_int_values" 125 OpName %76 "" 126 OpName %96 "ref" 127 OpName %137 "_GLF_color" 128 OpDecorate %11 ArrayStride 16 129 OpMemberDecorate %12 0 Offset 0 130 OpDecorate %12 Block 131 OpDecorate %14 DescriptorSet 0 132 OpDecorate %14 Binding 1 133 OpDecorate %48 BuiltIn FragCoord 134 OpDecorate %73 ArrayStride 16 135 OpMemberDecorate %74 0 Offset 0 136 OpDecorate %74 Block 137 OpDecorate %76 DescriptorSet 0 138 OpDecorate %76 Binding 0 139 OpDecorate %137 Location 0 140 %2 = OpTypeVoid 141 %3 = OpTypeFunction %2 142 %6 = OpTypeFloat 32 143 %7 = OpTypePointer Function %6 144 %9 = OpTypeInt 32 0 145 %10 = OpConstant %9 4 146 %11 = OpTypeArray %6 %10 147 %12 = OpTypeStruct %11 148 %13 = OpTypePointer Uniform %12 149 %14 = OpVariable %13 Uniform 150 %15 = OpTypeInt 32 1 151 %16 = OpConstant %15 0 152 %17 = OpConstant %15 3 153 %18 = OpTypePointer Uniform %6 154 %21 = OpTypeVector %6 4 155 %22 = OpTypeMatrix %21 4 156 %23 = OpTypePointer Function %22 157 %27 = OpConstant %6 1 158 %28 = OpConstant %6 0 159 %34 = OpTypePointer Function %15 160 %36 = OpConstant %15 1 161 %44 = OpConstant %15 4 162 %45 = OpTypeBool 163 %47 = OpTypePointer Input %21 164 %48 = OpVariable %47 Input 165 %49 = OpConstant %9 0 166 %50 = OpTypePointer Input %6 167 %59 = OpConstant %15 5 168 %71 = OpConstant %15 6 169 %73 = OpTypeArray %15 %10 170 %74 = OpTypeStruct %73 171 %75 = OpTypePointer Uniform %74 172 %76 = OpVariable %75 Uniform 173 %77 = OpTypePointer Uniform %15 174 %104 = OpConstant %6 -9 175 %105 = OpConstant %9 1 176 %107 = OpConstant %6 -10 177 %108 = OpConstant %9 2 178 %110 = OpConstant %9 3 179 %116 = OpTypeVector %45 4 180 %136 = OpTypePointer Output %21 181 %137 = OpVariable %136 Output 182 %4 = OpFunction %2 None %3 183 %5 = OpLabel 184 %8 = OpVariable %7 Function 185 %24 = OpVariable %23 Function 186 %35 = OpVariable %34 Function 187 %37 = OpVariable %34 Function 188 %64 = OpVariable %34 Function 189 %96 = OpVariable %23 Function 190 %19 = OpAccessChain %18 %14 %16 %17 191 %20 = OpLoad %6 %19 192 OpStore %8 %20 193 %25 = OpAccessChain %18 %14 %16 %16 194 %26 = OpLoad %6 %25 195 %29 = OpCompositeConstruct %21 %26 %28 %28 %28 196 %30 = OpCompositeConstruct %21 %28 %26 %28 %28 197 %31 = OpCompositeConstruct %21 %28 %28 %26 %28 198 %32 = OpCompositeConstruct %21 %28 %28 %28 %26 199 %33 = OpCompositeConstruct %22 %29 %30 %31 %32 200 OpStore %24 %33 201 OpStore %35 %36 202 OpStore %37 %36 203 OpBranch %38 204 %38 = OpLabel 205 OpLoopMerge %40 %41 None 206 OpBranch %42 207 %42 = OpLabel 208 %43 = OpLoad %15 %37 209 %46 = OpSLessThan %45 %43 %44 210 OpBranchConditional %46 %39 %40 211 %39 = OpLabel 212 %51 = OpAccessChain %50 %48 %49 213 %52 = OpLoad %6 %51 214 %53 = OpFOrdLessThan %45 %52 %28 215 OpSelectionMerge %55 None 216 OpBranchConditional %53 %54 %55 217 %54 = OpLabel 218 OpBranch %40 219 %55 = OpLabel 220 %57 = OpLoad %15 %35 221 %58 = OpIAdd %15 %57 %36 222 OpStore %35 %58 223 %60 = OpSGreaterThanEqual %45 %57 %59 224 OpSelectionMerge %62 None 225 OpBranchConditional %60 %61 %62 226 %61 = OpLabel 227 OpBranch %40 228 %62 = OpLabel 229 OpStore %64 %36 230 OpBranch %65 231 %65 = OpLabel 232 OpLoopMerge %67 %68 None 233 OpBranch %69 234 %69 = OpLabel 235 %70 = OpLoad %15 %64 236 %72 = OpSLessThan %45 %70 %71 237 OpBranchConditional %72 %66 %67 238 %66 = OpLabel 239 %78 = OpAccessChain %77 %76 %16 %16 240 %79 = OpLoad %15 %78 241 %80 = OpLoad %15 %37 242 %81 = OpAccessChain %77 %76 %16 %16 243 %82 = OpLoad %15 %81 244 %83 = OpAccessChain %77 %76 %16 %16 245 %84 = OpLoad %15 %83 246 %85 = OpAccessChain %7 %24 %82 %84 247 %86 = OpLoad %6 %85 248 %87 = OpLoad %6 %8 249 %88 = OpFSub %6 %86 %87 250 %89 = OpAccessChain %7 %24 %79 %80 251 OpStore %89 %88 252 OpBranch %68 253 %68 = OpLabel 254 %90 = OpLoad %15 %64 255 %91 = OpIAdd %15 %90 %36 256 OpStore %64 %91 257 OpBranch %65 258 %67 = OpLabel 259 %92 = OpAccessChain %18 %14 %16 %16 260 %93 = OpLoad %6 %92 261 OpStore %8 %93 262 OpBranch %41 263 %41 = OpLabel 264 %94 = OpLoad %15 %37 265 %95 = OpIAdd %15 %94 %36 266 OpStore %37 %95 267 OpBranch %38 268 %40 = OpLabel 269 %97 = OpAccessChain %18 %14 %16 %16 270 %98 = OpLoad %6 %97 271 %99 = OpCompositeConstruct %21 %98 %28 %28 %28 272 %100 = OpCompositeConstruct %21 %28 %98 %28 %28 273 %101 = OpCompositeConstruct %21 %28 %28 %98 %28 274 %102 = OpCompositeConstruct %21 %28 %28 %28 %98 275 %103 = OpCompositeConstruct %22 %99 %100 %101 %102 276 OpStore %96 %103 277 %106 = OpAccessChain %7 %96 %36 %105 278 OpStore %106 %104 279 %109 = OpAccessChain %7 %96 %36 %108 280 OpStore %109 %107 281 %111 = OpAccessChain %7 %96 %36 %110 282 OpStore %111 %107 283 %112 = OpLoad %22 %24 284 %113 = OpLoad %22 %96 285 %114 = OpCompositeExtract %21 %112 0 286 %115 = OpCompositeExtract %21 %113 0 287 %117 = OpFOrdEqual %116 %114 %115 288 %118 = OpAll %45 %117 289 %119 = OpCompositeExtract %21 %112 1 290 %120 = OpCompositeExtract %21 %113 1 291 %121 = OpFOrdEqual %116 %119 %120 292 %122 = OpAll %45 %121 293 %123 = OpLogicalAnd %45 %118 %122 294 %124 = OpCompositeExtract %21 %112 2 295 %125 = OpCompositeExtract %21 %113 2 296 %126 = OpFOrdEqual %116 %124 %125 297 %127 = OpAll %45 %126 298 %128 = OpLogicalAnd %45 %123 %127 299 %129 = OpCompositeExtract %21 %112 3 300 %130 = OpCompositeExtract %21 %113 3 301 %131 = OpFOrdEqual %116 %129 %130 302 %132 = OpAll %45 %131 303 %133 = OpLogicalAnd %45 %128 %132 304 OpSelectionMerge %135 None 305 OpBranchConditional %133 %134 %151 306 %134 = OpLabel 307 %138 = OpAccessChain %77 %76 %16 %16 308 %139 = OpLoad %15 %138 309 %140 = OpConvertSToF %6 %139 310 %141 = OpAccessChain %77 %76 %16 %36 311 %142 = OpLoad %15 %141 312 %143 = OpConvertSToF %6 %142 313 %144 = OpAccessChain %77 %76 %16 %36 314 %145 = OpLoad %15 %144 315 %146 = OpConvertSToF %6 %145 316 %147 = OpAccessChain %77 %76 %16 %16 317 %148 = OpLoad %15 %147 318 %149 = OpConvertSToF %6 %148 319 %150 = OpCompositeConstruct %21 %140 %143 %146 %149 320 OpStore %137 %150 321 OpBranch %135 322 %151 = OpLabel 323 %152 = OpAccessChain %77 %76 %16 %36 324 %153 = OpLoad %15 %152 325 %154 = OpConvertSToF %6 %153 326 %155 = OpCompositeConstruct %21 %154 %154 %154 %154 327 OpStore %137 %155 328 OpBranch %135 329 %135 = OpLabel 330 OpReturn 331 OpFunctionEnd 332END 333 334# uniforms for variant 335 336# _GLF_uniform_float_values 337BUFFER variant__GLF_uniform_float_values DATA_TYPE float[] STD140 DATA 338 1.0 9.0 10.0 2.0 339END 340# _GLF_uniform_int_values 341BUFFER variant__GLF_uniform_int_values DATA_TYPE int32[] STD140 DATA 342 1 0 2 3 343END 344 345BUFFER variant_framebuffer FORMAT B8G8R8A8_UNORM 346 347PIPELINE graphics variant_pipeline 348 ATTACH variant_vertex_shader 349 ATTACH variant_fragment_shader 350 FRAMEBUFFER_SIZE 32 32 351 BIND BUFFER variant_framebuffer AS color LOCATION 0 352 BIND BUFFER variant__GLF_uniform_float_values AS uniform DESCRIPTOR_SET 0 BINDING 1 353 BIND BUFFER variant__GLF_uniform_int_values AS uniform DESCRIPTOR_SET 0 BINDING 0 354END 355CLEAR_COLOR variant_pipeline 0 0 0 255 356 357CLEAR variant_pipeline 358RUN variant_pipeline DRAW_RECT POS 0 0 SIZE 32 32 359 360EXPECT variant_framebuffer IDX 0 0 SIZE 32 32 EQ_RGBA 255 0 0 255 361