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