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