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