3 # Copyright 2021 Google LLC
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
9 # http://www.apache.org/licenses/LICENSE-2.0
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.
18 # A test for a coverage-gap found by the GraphicsFuzz project.
20 # Short description: A fragment shader that covers specific LLVM code paths
22 # The test passes because the shader always writes red.
24 SHADER vertex variant_vertex_shader PASSTHROUGH
26 # variant_fragment_shader is derived from the following GLSL:
29 # #define _int_8 _GLF_uniform_int_values[0]
30 # #define _int_9 _GLF_uniform_int_values[1]
31 # #define _int_1 _GLF_uniform_int_values[2]
32 # #define _int_2 _GLF_uniform_int_values[3]
33 # #define _int_3 _GLF_uniform_int_values[4]
34 # #define _int_4 _GLF_uniform_int_values[5]
35 # #define _int_5 _GLF_uniform_int_values[6]
36 # #define _int_6 _GLF_uniform_int_values[7]
37 # #define _int_7 _GLF_uniform_int_values[8]
38 # #define _int_0 _GLF_uniform_int_values[9]
39 # #define _int_10 _GLF_uniform_int_values[10]
40 # #define _float_0_0 _GLF_uniform_float_values[0]
42 # precision highp float;
43 # precision highp int;
45 # // Contents of _GLF_uniform_float_values: 0.0
46 # layout(set = 0, binding = 0) uniform buf0
48 # float _GLF_uniform_float_values[1];
50 # // Contents of _GLF_uniform_int_values: [8, 9, 1, 2, 3, 4, 5, 6, 7, 0, 10]
51 # layout(set = 0, binding = 1) uniform buf1
53 # int _GLF_uniform_int_values[11];
56 # const int _GLF_global_loop_bound = 10;
57 # int _GLF_global_loop_count = 0;
59 # // Contents of zero: 0.0
60 # layout(push_constant) uniform buf_push
65 # layout(location = 0) out vec4 _GLF_color;
67 # // This function is called once with x = 0.
72 # while(_GLF_global_loop_count < _GLF_global_loop_bound)
74 # _GLF_global_loop_count ++;
80 # for(int k = int(zero); k != _int_1; k ++)
83 # if(gl_FragCoord.y >= 0.0)
89 # // Sets global loop count to global loop bound.
90 # for(int k = int(zero); k < _int_1 && _GLF_global_loop_count < _GLF_global_loop_bound; )
92 # _GLF_global_loop_count++;
103 # int a = _int_1, b = _int_1, c = -_int_1;
104 # int arr[10] = int[10](_int_0, _int_1, _int_2, _int_3, _int_4, _int_5, _int_6, _int_7, _int_8, _int_9);
107 # if(gl_FragCoord.y >= 0.0)
114 # while(c >= _int_0 && _GLF_global_loop_count < _GLF_global_loop_bound)
116 # _GLF_global_loop_count ++;
119 # if(gl_FragCoord.y > _float_0_0)
126 # if(zero == _float_0_0)
133 # // arr[0] becomes one and c becomes one.
137 # // Calling the function makes global loop count to reach the global loop bound. The function returns 2 making the condition false.
138 # if(func(a) < _int_1)
144 # // Check the array against reference values, and set output color to black if the check fails.
145 # int ref[10] = int[10](_int_1, _int_1, _int_2, _int_3, _int_4, _int_5, _int_6, _int_7, _int_8, _int_9);
146 # _GLF_color = vec4(_int_1, _int_0, _int_0, _int_1);
148 # for(int i = _int_0; i < _int_10; i ++)
150 # if(arr[i] != ref[i])
152 # _GLF_color = vec4(_int_0);
156 SHADER fragment variant_fragment_shader SPIRV-ASM TARGET_ENV spv1.0
159 ; Generator: Khronos Glslang Reference Front End; 10
163 %1 = OpExtInstImport "GLSL.std.450"
164 OpMemoryModel Logical GLSL450
165 OpEntryPoint Fragment %4 "main" %64 %235
166 OpExecutionMode %4 OriginUpperLeft
169 OpName %10 "func(i1;"
171 OpName %13 "_GLF_global_loop_count"
174 OpMemberName %19 0 "_GLF_uniform_int_values"
177 OpName %46 "buf_push"
178 OpMemberName %46 0 "zero"
180 OpName %64 "gl_FragCoord"
187 OpMemberName %167 0 "_GLF_uniform_float_values"
191 OpName %235 "_GLF_color"
193 OpDecorate %18 ArrayStride 16
194 OpMemberDecorate %19 0 Offset 0
196 OpDecorate %21 DescriptorSet 0
197 OpDecorate %21 Binding 1
198 OpMemberDecorate %46 0 Offset 0
200 OpDecorate %64 BuiltIn FragCoord
201 OpDecorate %166 ArrayStride 16
202 OpMemberDecorate %167 0 Offset 0
203 OpDecorate %167 Block
204 OpDecorate %169 DescriptorSet 0
205 OpDecorate %169 Binding 0
206 OpDecorate %235 Location 0
208 %3 = OpTypeFunction %2
210 %7 = OpTypePointer Function %6
211 %8 = OpTypeFunction %6 %7
212 %12 = OpTypePointer Private %6
213 %13 = OpVariable %12 Private
214 %14 = OpConstant %6 0
216 %17 = OpConstant %16 11
217 %18 = OpTypeArray %6 %17
218 %19 = OpTypeStruct %18
219 %20 = OpTypePointer Uniform %19
220 %21 = OpVariable %20 Uniform
221 %22 = OpConstant %6 2
222 %23 = OpTypePointer Uniform %6
223 %32 = OpConstant %6 10
225 %36 = OpConstant %6 1
227 %46 = OpTypeStruct %45
228 %47 = OpTypePointer PushConstant %46
229 %48 = OpVariable %47 PushConstant
230 %49 = OpTypePointer PushConstant %45
231 %62 = OpTypeVector %45 4
232 %63 = OpTypePointer Input %62
233 %64 = OpVariable %63 Input
234 %65 = OpConstant %16 1
235 %66 = OpTypePointer Input %45
236 %69 = OpConstant %45 0
237 %108 = OpConstant %16 10
238 %109 = OpTypeArray %6 %108
239 %110 = OpTypePointer Function %109
240 %112 = OpConstant %6 9
241 %117 = OpConstant %6 3
242 %120 = OpConstant %6 4
243 %123 = OpConstant %6 5
244 %126 = OpConstant %6 6
245 %129 = OpConstant %6 7
246 %132 = OpConstant %6 8
247 %166 = OpTypeArray %45 %65
248 %167 = OpTypeStruct %166
249 %168 = OpTypePointer Uniform %167
250 %169 = OpVariable %168 Uniform
251 %170 = OpTypePointer Uniform %45
252 %234 = OpTypePointer Output %62
253 %235 = OpVariable %234 Output
254 %4 = OpFunction %2 None %3
256 %98 = OpVariable %7 Function
257 %101 = OpVariable %7 Function
258 %104 = OpVariable %7 Function
259 %111 = OpVariable %110 Function
260 %200 = OpVariable %7 Function
261 %212 = OpVariable %110 Function
262 %249 = OpVariable %7 Function
264 %99 = OpAccessChain %23 %21 %14 %22
267 %102 = OpAccessChain %23 %21 %14 %22
268 %103 = OpLoad %6 %102
270 %105 = OpAccessChain %23 %21 %14 %22
271 %106 = OpLoad %6 %105
272 %107 = OpSNegate %6 %106
274 %113 = OpAccessChain %23 %21 %14 %112
275 %114 = OpLoad %6 %113
276 %115 = OpAccessChain %23 %21 %14 %22
277 %116 = OpLoad %6 %115
278 %118 = OpAccessChain %23 %21 %14 %117
279 %119 = OpLoad %6 %118
280 %121 = OpAccessChain %23 %21 %14 %120
281 %122 = OpLoad %6 %121
282 %124 = OpAccessChain %23 %21 %14 %123
283 %125 = OpLoad %6 %124
284 %127 = OpAccessChain %23 %21 %14 %126
285 %128 = OpLoad %6 %127
286 %130 = OpAccessChain %23 %21 %14 %129
287 %131 = OpLoad %6 %130
288 %133 = OpAccessChain %23 %21 %14 %132
289 %134 = OpLoad %6 %133
290 %135 = OpAccessChain %23 %21 %14 %14
291 %136 = OpLoad %6 %135
292 %137 = OpAccessChain %23 %21 %14 %36
293 %138 = OpLoad %6 %137
294 %139 = OpCompositeConstruct %109 %114 %116 %119 %122 %125 %128 %131 %134 %136 %138
296 %140 = OpAccessChain %66 %64 %65
297 %141 = OpLoad %45 %140
298 %142 = OpFOrdGreaterThanEqual %33 %141 %69
299 OpSelectionMerge %144 None
300 OpBranchConditional %142 %143 %144
302 %145 = OpLoad %6 %104
303 %146 = OpIAdd %6 %145 %36
305 %147 = OpAccessChain %23 %21 %14 %22
306 %148 = OpLoad %6 %147
307 %149 = OpAccessChain %7 %111 %146
313 OpLoopMerge %152 %153 None
316 %155 = OpLoad %6 %104
317 %156 = OpAccessChain %23 %21 %14 %112
318 %157 = OpLoad %6 %156
319 %158 = OpSGreaterThanEqual %33 %155 %157
321 %160 = OpSLessThan %33 %159 %32
322 %161 = OpLogicalAnd %33 %158 %160
323 OpBranchConditional %161 %151 %152
326 %163 = OpIAdd %6 %162 %36
328 %164 = OpAccessChain %66 %64 %65
329 %165 = OpLoad %45 %164
330 %171 = OpAccessChain %170 %169 %14 %14
331 %172 = OpLoad %45 %171
332 %173 = OpFOrdGreaterThan %33 %165 %172
333 OpSelectionMerge %175 None
334 OpBranchConditional %173 %174 %175
336 %176 = OpLoad %6 %104
337 %177 = OpAccessChain %7 %111 %176
338 %178 = OpLoad %6 %177
342 %179 = OpAccessChain %49 %48 %14
343 %180 = OpLoad %45 %179
344 %181 = OpAccessChain %170 %169 %14 %14
345 %182 = OpLoad %45 %181
346 %183 = OpFOrdEqual %33 %180 %182
347 OpSelectionMerge %185 None
348 OpBranchConditional %183 %184 %185
350 %186 = OpLoad %6 %104
351 %187 = OpAccessChain %7 %111 %186
352 %188 = OpLoad %6 %187
357 %190 = OpAccessChain %23 %21 %14 %22
358 %191 = OpLoad %6 %190
359 %192 = OpSLessThan %33 %189 %191
360 OpSelectionMerge %194 None
361 OpBranchConditional %192 %193 %194
363 %195 = OpLoad %6 %104
364 %196 = OpIAdd %6 %195 %36
366 %197 = OpAccessChain %23 %21 %14 %22
367 %198 = OpLoad %6 %197
368 %199 = OpAccessChain %7 %111 %196
374 %202 = OpFunctionCall %6 %10 %200
375 %203 = OpAccessChain %23 %21 %14 %22
376 %204 = OpLoad %6 %203
377 %205 = OpSLessThan %33 %202 %204
378 OpSelectionMerge %207 None
379 OpBranchConditional %205 %206 %207
381 %208 = OpLoad %6 %104
382 %209 = OpIAdd %6 %208 %36
384 %210 = OpLoad %6 %101
385 %211 = OpAccessChain %7 %111 %209
393 %213 = OpAccessChain %23 %21 %14 %22
394 %214 = OpLoad %6 %213
395 %215 = OpAccessChain %23 %21 %14 %22
396 %216 = OpLoad %6 %215
397 %217 = OpAccessChain %23 %21 %14 %117
398 %218 = OpLoad %6 %217
399 %219 = OpAccessChain %23 %21 %14 %120
400 %220 = OpLoad %6 %219
401 %221 = OpAccessChain %23 %21 %14 %123
402 %222 = OpLoad %6 %221
403 %223 = OpAccessChain %23 %21 %14 %126
404 %224 = OpLoad %6 %223
405 %225 = OpAccessChain %23 %21 %14 %129
406 %226 = OpLoad %6 %225
407 %227 = OpAccessChain %23 %21 %14 %132
408 %228 = OpLoad %6 %227
409 %229 = OpAccessChain %23 %21 %14 %14
410 %230 = OpLoad %6 %229
411 %231 = OpAccessChain %23 %21 %14 %36
412 %232 = OpLoad %6 %231
413 %233 = OpCompositeConstruct %109 %214 %216 %218 %220 %222 %224 %226 %228 %230 %232
415 %236 = OpAccessChain %23 %21 %14 %22
416 %237 = OpLoad %6 %236
417 %238 = OpConvertSToF %45 %237
418 %239 = OpAccessChain %23 %21 %14 %112
419 %240 = OpLoad %6 %239
420 %241 = OpConvertSToF %45 %240
421 %242 = OpAccessChain %23 %21 %14 %112
422 %243 = OpLoad %6 %242
423 %244 = OpConvertSToF %45 %243
424 %245 = OpAccessChain %23 %21 %14 %22
425 %246 = OpLoad %6 %245
426 %247 = OpConvertSToF %45 %246
427 %248 = OpCompositeConstruct %62 %238 %241 %244 %247
429 %250 = OpAccessChain %23 %21 %14 %112
430 %251 = OpLoad %6 %250
434 OpLoopMerge %254 %255 None
437 %257 = OpLoad %6 %249
438 %258 = OpAccessChain %23 %21 %14 %32
439 %259 = OpLoad %6 %258
440 %260 = OpSLessThan %33 %257 %259
441 OpBranchConditional %260 %253 %254
443 %261 = OpLoad %6 %249
444 %262 = OpAccessChain %7 %111 %261
445 %263 = OpLoad %6 %262
446 %264 = OpLoad %6 %249
447 %265 = OpAccessChain %7 %212 %264
448 %266 = OpLoad %6 %265
449 %267 = OpINotEqual %33 %263 %266
450 OpSelectionMerge %269 None
451 OpBranchConditional %267 %268 %269
453 %270 = OpAccessChain %23 %21 %14 %112
454 %271 = OpLoad %6 %270
455 %272 = OpConvertSToF %45 %271
456 %273 = OpCompositeConstruct %62 %272 %272 %272 %272
462 %274 = OpLoad %6 %249
463 %275 = OpIAdd %6 %274 %36
469 %10 = OpFunction %6 None %8
470 %9 = OpFunctionParameter %7
472 %15 = OpVariable %7 Function
473 %44 = OpVariable %7 Function
474 %77 = OpVariable %7 Function
475 %24 = OpAccessChain %23 %21 %14 %22
480 OpLoopMerge %28 %29 None
484 %34 = OpSLessThan %33 %31 %32
485 OpBranchConditional %34 %27 %28
488 %37 = OpIAdd %6 %35 %36
491 %39 = OpAccessChain %23 %21 %14 %22
493 %41 = OpSLessThanEqual %33 %38 %40
494 OpSelectionMerge %43 None
495 OpBranchConditional %41 %42 %43
497 %50 = OpAccessChain %49 %48 %14
499 %52 = OpConvertFToS %6 %51
503 OpLoopMerge %55 %56 None
507 %59 = OpAccessChain %23 %21 %14 %22
509 %61 = OpINotEqual %33 %58 %60
510 OpBranchConditional %61 %54 %55
512 %67 = OpAccessChain %66 %64 %65
514 %70 = OpFOrdGreaterThanEqual %33 %68 %69
515 OpSelectionMerge %72 None
516 OpBranchConditional %70 %71 %72
519 %74 = OpIAdd %6 %73 %36
526 %76 = OpIAdd %6 %75 %36
530 %78 = OpAccessChain %49 %48 %14
532 %80 = OpConvertFToS %6 %79
536 OpLoopMerge %83 %84 None
540 %87 = OpAccessChain %23 %21 %14 %22
542 %89 = OpSLessThan %33 %86 %88
544 %91 = OpSLessThan %33 %90 %32
545 %92 = OpLogicalAnd %33 %89 %91
546 OpBranchConditional %92 %82 %83
549 %94 = OpIAdd %6 %93 %36
566 # uniforms for variant
569 BUFFER variant_zero DATA_TYPE float STD140 DATA
572 # _GLF_uniform_int_values
573 BUFFER variant__GLF_uniform_int_values DATA_TYPE int32[] STD140 DATA
574 8 9 1 2 3 4 5 6 7 0 10
576 # _GLF_uniform_float_values
577 BUFFER variant__GLF_uniform_float_values DATA_TYPE float[] STD140 DATA
581 BUFFER variant_framebuffer FORMAT B8G8R8A8_UNORM
583 PIPELINE graphics variant_pipeline
584 ATTACH variant_vertex_shader
585 ATTACH variant_fragment_shader
586 FRAMEBUFFER_SIZE 16 16
587 BIND BUFFER variant_framebuffer AS color LOCATION 0
588 BIND BUFFER variant_zero AS push_constant
589 BIND BUFFER variant__GLF_uniform_int_values AS uniform DESCRIPTOR_SET 0 BINDING 1
590 BIND BUFFER variant__GLF_uniform_float_values AS uniform DESCRIPTOR_SET 0 BINDING 0
592 CLEAR_COLOR variant_pipeline 0 0 0 255
594 CLEAR variant_pipeline
595 RUN variant_pipeline DRAW_RECT POS 0 0 SIZE 16 16
597 EXPECT variant_framebuffer IDX 0 0 SIZE 16 16 EQ_RGBA 255 0 0 255