3 # Copyright 2022 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_1 _GLF_uniform_int_values[0]
30 # #define _int_9 _GLF_uniform_int_values[1]
31 # #define _int_10 _GLF_uniform_int_values[2]
32 # #define _int_0 _GLF_uniform_int_values[3]
33 # #define _int_2 _GLF_uniform_int_values[4]
34 # #define _int_3 _GLF_uniform_int_values[5]
35 # #define _int_4 _GLF_uniform_int_values[6]
36 # #define _int_5 _GLF_uniform_int_values[7]
37 # #define _int_6 _GLF_uniform_int_values[8]
38 # #define _int_7 _GLF_uniform_int_values[9]
39 # #define _int_8 _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];
51 # // Contents of _GLF_uniform_int_values: [1, 9, 10, 0, 2, 3, 4, 5, 6, 7, 8]
52 # layout(set = 0, binding = 1) uniform buf1
54 # int _GLF_uniform_int_values[11];
57 # // Contents of zero: 0
58 # layout(set = 0, binding = 2) uniform buf2 {
62 # layout(location = 0) out vec4 _GLF_color;
66 # 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);
69 # // Iterates two times.
70 # for(int i = 1; i < _int_3; i++)
89 # // Iterates six times until breaks because of b >= 7.
90 # for(int j = 0; j < _int_10; j++)
100 # // j == 0 && i == 1
101 # // j == 1 && i == 1
102 # // j == 0 && i == 2
103 # // j == 1 && i == 2
104 # // j == 2 && i == 2
110 # arr[j] = arr[_int_1];
113 # while(gl_FragCoord.y < _float_0_0);
116 # _GLF_color = vec4(_int_1, _int_0, _int_0, _int_1);
118 # // Verify results and set color to black if failed.
119 # int ref[10] = int[10](_int_0, _int_1, _int_1, _int_1, _int_1, _int_1, _int_6, _int_7, _int_8, _int_9);
120 # for(int i = _int_0; i < _int_10; i++)
122 # if(arr[i] != ref[i])
124 # _GLF_color = vec4(_int_0);
128 SHADER fragment variant_fragment_shader SPIRV-ASM TARGET_ENV spv1.0
131 ; Generator: Khronos Glslang Reference Front End; 10
135 %1 = OpExtInstImport "GLSL.std.450"
136 OpMemoryModel Logical GLSL450
137 OpEntryPoint Fragment %4 "main" %128 %144
138 OpExecutionMode %4 OriginUpperLeft
143 OpMemberName %14 0 "_GLF_uniform_int_values"
148 OpMemberName %71 0 "zero"
152 OpName %128 "gl_FragCoord"
154 OpMemberName %134 0 "_GLF_uniform_float_values"
156 OpName %144 "_GLF_color"
159 OpDecorate %13 ArrayStride 16
160 OpMemberDecorate %14 0 Offset 0
162 OpDecorate %16 DescriptorSet 0
163 OpDecorate %16 Binding 1
164 OpMemberDecorate %71 0 Offset 0
166 OpDecorate %73 DescriptorSet 0
167 OpDecorate %73 Binding 2
168 OpDecorate %128 BuiltIn FragCoord
169 OpDecorate %133 ArrayStride 16
170 OpMemberDecorate %134 0 Offset 0
171 OpDecorate %134 Block
172 OpDecorate %136 DescriptorSet 0
173 OpDecorate %136 Binding 0
174 OpDecorate %144 Location 0
176 %3 = OpTypeFunction %2
179 %8 = OpConstant %7 10
180 %9 = OpTypeArray %6 %8
181 %10 = OpTypePointer Function %9
182 %12 = OpConstant %7 11
183 %13 = OpTypeArray %6 %12
184 %14 = OpTypeStruct %13
185 %15 = OpTypePointer Uniform %14
186 %16 = OpVariable %15 Uniform
187 %17 = OpConstant %6 0
188 %18 = OpConstant %6 3
189 %19 = OpTypePointer Uniform %6
190 %24 = OpConstant %6 4
191 %27 = OpConstant %6 5
192 %30 = OpConstant %6 6
193 %33 = OpConstant %6 7
194 %36 = OpConstant %6 8
195 %39 = OpConstant %6 9
196 %42 = OpConstant %6 10
197 %45 = OpConstant %6 1
198 %49 = OpTypePointer Function %6
200 %71 = OpTypeStruct %6
201 %72 = OpTypePointer Uniform %71
202 %73 = OpVariable %72 Uniform
203 %97 = OpConstant %6 2
204 %125 = OpTypeFloat 32
205 %126 = OpTypeVector %125 4
206 %127 = OpTypePointer Input %126
207 %128 = OpVariable %127 Input
208 %129 = OpConstant %7 1
209 %130 = OpTypePointer Input %125
210 %133 = OpTypeArray %125 %129
211 %134 = OpTypeStruct %133
212 %135 = OpTypePointer Uniform %134
213 %136 = OpVariable %135 Uniform
214 %137 = OpTypePointer Uniform %125
215 %143 = OpTypePointer Output %126
216 %144 = OpVariable %143 Output
217 %4 = OpFunction %2 None %3
219 %11 = OpVariable %10 Function
220 %50 = OpVariable %49 Function
221 %53 = OpVariable %49 Function
222 %83 = OpVariable %49 Function
223 %90 = OpVariable %49 Function
224 %158 = OpVariable %10 Function
225 %180 = OpVariable %49 Function
226 %20 = OpAccessChain %19 %16 %17 %18
228 %22 = OpAccessChain %19 %16 %17 %17
230 %25 = OpAccessChain %19 %16 %17 %24
232 %28 = OpAccessChain %19 %16 %17 %27
234 %31 = OpAccessChain %19 %16 %17 %30
236 %34 = OpAccessChain %19 %16 %17 %33
238 %37 = OpAccessChain %19 %16 %17 %36
240 %40 = OpAccessChain %19 %16 %17 %39
242 %43 = OpAccessChain %19 %16 %17 %42
244 %46 = OpAccessChain %19 %16 %17 %45
246 %48 = OpCompositeConstruct %9 %21 %23 %26 %29 %32 %35 %38 %41 %44 %47
248 %51 = OpAccessChain %19 %16 %17 %18
254 OpLoopMerge %56 %57 None
258 %60 = OpAccessChain %19 %16 %17 %27
260 %63 = OpSLessThan %62 %59 %61
261 OpBranchConditional %63 %55 %56
264 %65 = OpAccessChain %19 %16 %17 %17
266 %67 = OpSGreaterThanEqual %62 %64 %66
267 OpSelectionMerge %69 None
268 OpBranchConditional %67 %68 %69
272 %74 = OpAccessChain %19 %73 %17
274 %76 = OpAccessChain %19 %16 %17 %18
276 %78 = OpSLessThan %62 %75 %77
277 OpSelectionMerge %80 None
278 OpBranchConditional %78 %79 %80
281 %82 = OpIAdd %6 %81 %45
285 %84 = OpAccessChain %19 %16 %17 %17
290 OpLoopMerge %88 %89 None
296 OpLoopMerge %93 %94 None
300 %98 = OpAccessChain %19 %16 %17 %97
302 %100 = OpSLessThan %62 %96 %99
303 OpBranchConditional %100 %92 %93
306 %102 = OpAccessChain %19 %16 %17 %39
307 %103 = OpLoad %6 %102
308 %104 = OpSGreaterThanEqual %62 %101 %103
309 OpSelectionMerge %106 None
310 OpBranchConditional %104 %105 %106
315 %109 = OpIAdd %6 %108 %45
319 %112 = OpIAdd %6 %111 %45
320 %113 = OpSLessThan %62 %110 %112
321 OpSelectionMerge %115 None
322 OpBranchConditional %113 %114 %115
327 %118 = OpAccessChain %19 %16 %17 %17
328 %119 = OpLoad %6 %118
329 %120 = OpAccessChain %49 %11 %119
330 %121 = OpLoad %6 %120
331 %122 = OpAccessChain %49 %11 %117
336 %124 = OpIAdd %6 %123 %45
342 %131 = OpAccessChain %130 %128 %129
343 %132 = OpLoad %125 %131
344 %138 = OpAccessChain %137 %136 %17 %17
345 %139 = OpLoad %125 %138
346 %140 = OpFOrdLessThan %62 %132 %139
347 OpBranchConditional %140 %86 %88
352 %142 = OpIAdd %6 %141 %45
356 %145 = OpAccessChain %19 %16 %17 %17
357 %146 = OpLoad %6 %145
358 %147 = OpConvertSToF %125 %146
359 %148 = OpAccessChain %19 %16 %17 %18
360 %149 = OpLoad %6 %148
361 %150 = OpConvertSToF %125 %149
362 %151 = OpAccessChain %19 %16 %17 %18
363 %152 = OpLoad %6 %151
364 %153 = OpConvertSToF %125 %152
365 %154 = OpAccessChain %19 %16 %17 %17
366 %155 = OpLoad %6 %154
367 %156 = OpConvertSToF %125 %155
368 %157 = OpCompositeConstruct %126 %147 %150 %153 %156
370 %159 = OpAccessChain %19 %16 %17 %18
371 %160 = OpLoad %6 %159
372 %161 = OpAccessChain %19 %16 %17 %17
373 %162 = OpLoad %6 %161
374 %163 = OpAccessChain %19 %16 %17 %17
375 %164 = OpLoad %6 %163
376 %165 = OpAccessChain %19 %16 %17 %17
377 %166 = OpLoad %6 %165
378 %167 = OpAccessChain %19 %16 %17 %17
379 %168 = OpLoad %6 %167
380 %169 = OpAccessChain %19 %16 %17 %17
381 %170 = OpLoad %6 %169
382 %171 = OpAccessChain %19 %16 %17 %36
383 %172 = OpLoad %6 %171
384 %173 = OpAccessChain %19 %16 %17 %39
385 %174 = OpLoad %6 %173
386 %175 = OpAccessChain %19 %16 %17 %42
387 %176 = OpLoad %6 %175
388 %177 = OpAccessChain %19 %16 %17 %45
389 %178 = OpLoad %6 %177
390 %179 = OpCompositeConstruct %9 %160 %162 %164 %166 %168 %170 %172 %174 %176 %178
392 %181 = OpAccessChain %19 %16 %17 %18
393 %182 = OpLoad %6 %181
397 OpLoopMerge %185 %186 None
400 %188 = OpLoad %6 %180
401 %189 = OpAccessChain %19 %16 %17 %97
402 %190 = OpLoad %6 %189
403 %191 = OpSLessThan %62 %188 %190
404 OpBranchConditional %191 %184 %185
406 %192 = OpLoad %6 %180
407 %193 = OpAccessChain %49 %11 %192
408 %194 = OpLoad %6 %193
409 %195 = OpLoad %6 %180
410 %196 = OpAccessChain %49 %158 %195
411 %197 = OpLoad %6 %196
412 %198 = OpINotEqual %62 %194 %197
413 OpSelectionMerge %200 None
414 OpBranchConditional %198 %199 %200
416 %201 = OpAccessChain %19 %16 %17 %18
417 %202 = OpLoad %6 %201
418 %203 = OpConvertSToF %125 %202
419 %204 = OpCompositeConstruct %126 %203 %203 %203 %203
425 %205 = OpLoad %6 %180
426 %206 = OpIAdd %6 %205 %45
434 # uniforms for variant
437 BUFFER variant_zero DATA_TYPE int32 STD140 DATA
440 # _GLF_uniform_int_values
441 BUFFER variant__GLF_uniform_int_values DATA_TYPE int32[] STD140 DATA
442 1 9 10 0 2 3 4 5 6 7 8
444 # _GLF_uniform_float_values
445 BUFFER variant__GLF_uniform_float_values DATA_TYPE float[] STD140 DATA
449 BUFFER variant_framebuffer FORMAT B8G8R8A8_UNORM
451 PIPELINE graphics variant_pipeline
452 ATTACH variant_vertex_shader
453 ATTACH variant_fragment_shader
454 FRAMEBUFFER_SIZE 32 32
455 BIND BUFFER variant_framebuffer AS color LOCATION 0
456 BIND BUFFER variant_zero AS uniform DESCRIPTOR_SET 0 BINDING 2
457 BIND BUFFER variant__GLF_uniform_int_values AS uniform DESCRIPTOR_SET 0 BINDING 1
458 BIND BUFFER variant__GLF_uniform_float_values AS uniform DESCRIPTOR_SET 0 BINDING 0
460 CLEAR_COLOR variant_pipeline 0 0 0 255
462 CLEAR variant_pipeline
463 RUN variant_pipeline DRAW_RECT POS 0 0 SIZE 32 32
465 EXPECT variant_framebuffer IDX 0 0 SIZE 32 32 EQ_RGBA 255 0 0 255