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