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