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 # Optimized using spirv-opt with the following arguments:
25 # '--eliminate-dead-branches'
27 # '--eliminate-local-multi-store'
28 # '--inline-entry-points-exhaustive'
29 # '--eliminate-dead-branches'
31 # '--redundancy-elimination'
32 # '--reduce-load-size'
33 # '--simplify-instructions'
34 # '--simplify-instructions'
35 # '--eliminate-dead-branches'
37 # spirv-opt commit hash: a0370efd589be33d5d9a85cfde2f85841b3755af
41 SHADER vertex variant_vertex_shader PASSTHROUGH
43 # variant_fragment_shader is derived from the following GLSL:
45 # #define _int_3 _GLF_uniform_int_values[0]
46 # #define _int_5 _GLF_uniform_int_values[1]
47 # #define _int_2 _GLF_uniform_int_values[2]
48 # #define _int_1 _GLF_uniform_int_values[3]
49 # #define _int_0 _GLF_uniform_int_values[4]
50 # #define _float_1_0 _GLF_uniform_float_values[0]
51 # #define _float_19_0 _GLF_uniform_float_values[1]
53 # precision highp float;
54 # precision highp int;
56 # // Contents of _GLF_uniform_float_values: [1.0, 19.0]
57 # layout(set = 0, binding = 0) uniform buf0
59 # float _GLF_uniform_float_values[2];
62 # // Contents of _GLF_uniform_int_values: [3, 5, 2, 1, 0]
63 # layout(set = 0, binding = 1) uniform buf1
65 # int _GLF_uniform_int_values[5];
68 # layout(location = 0) out vec4 _GLF_color;
72 # float arr[9] = float[9](_float_1_0, _float_1_0, _float_1_0, _float_1_0, _float_1_0, _float_1_0, _float_1_0, _float_1_0, _float_1_0);
74 # for(int i = _int_1; i < _int_5; i ++)
76 # for(int j = 2; j <= 4; j ++)
78 # for(int k = 0; k < j; k ++)
80 # for(int l = 0; l < 2; l ++)
82 # // Iterated 18 times for each value of i.
86 # arr[i] += _float_1_0;
89 # arr[i] += _float_1_0;
91 # // Matrices only contain zero values.
93 # arr[i] += mat2x4(0.0)[clamp(k, _int_0, _int_1)][l];
96 # arr[i] += mat3x2(0.0)[clamp(k, _int_0, _int_2)][l];
99 # arr[i] += mat3(0.0)[clamp(k, _int_0, _int_2)][l];
101 # // Cases below are never executed.
103 # arr[i] += mat3x4(0.0)[clamp(k, 0, _int_2)][l];
106 # arr[i] += mat4x2(0.0)[clamp(k, 0, 3)][l];
109 # arr[i] += mat4x3(0.0)[clamp(k, 0, 3)][l];
112 # arr[i] += mat4(0.0)[clamp(k, 0, _int_3)][l];
121 # if(arr[_int_0] == _float_1_0 && arr[_int_1] == _float_19_0 && arr[_int_2] == _float_1_0)
123 # _GLF_color = vec4(_int_1, _int_0, _int_0, _int_1);
127 # _GLF_color = vec4(_int_0);
130 SHADER fragment variant_fragment_shader SPIRV-ASM TARGET_ENV spv1.0
133 ; Generator: Khronos Glslang Reference Front End; 10
137 %1 = OpExtInstImport "GLSL.std.450"
138 OpMemoryModel Logical GLSL450
139 OpEntryPoint Fragment %4 "main" %282
140 OpExecutionMode %4 OriginUpperLeft
145 OpMemberName %14 0 "_GLF_uniform_float_values"
149 OpMemberName %43 0 "_GLF_uniform_int_values"
154 OpName %130 "indexable"
155 OpName %151 "indexable"
156 OpName %172 "indexable"
157 OpName %189 "indexable"
158 OpName %204 "indexable"
159 OpName %219 "indexable"
160 OpName %235 "indexable"
161 OpName %282 "_GLF_color"
162 OpDecorate %13 ArrayStride 16
163 OpMemberDecorate %14 0 Offset 0
165 OpDecorate %16 DescriptorSet 0
166 OpDecorate %16 Binding 0
167 OpDecorate %42 ArrayStride 16
168 OpMemberDecorate %43 0 Offset 0
170 OpDecorate %45 DescriptorSet 0
171 OpDecorate %45 Binding 1
172 OpDecorate %282 Location 0
174 %3 = OpTypeFunction %2
178 %9 = OpTypeArray %6 %8
179 %10 = OpTypePointer Function %9
180 %12 = OpConstant %7 2
181 %13 = OpTypeArray %6 %12
182 %14 = OpTypeStruct %13
183 %15 = OpTypePointer Uniform %14
184 %16 = OpVariable %15 Uniform
186 %18 = OpConstant %17 0
187 %19 = OpTypePointer Uniform %6
188 %39 = OpTypePointer Function %17
189 %41 = OpConstant %7 5
190 %42 = OpTypeArray %17 %41
191 %43 = OpTypeStruct %42
192 %44 = OpTypePointer Uniform %43
193 %45 = OpVariable %44 Uniform
194 %46 = OpConstant %17 3
195 %47 = OpTypePointer Uniform %17
196 %56 = OpConstant %17 1
198 %62 = OpConstant %17 2
199 %69 = OpConstant %17 4
200 %102 = OpTypePointer Function %6
201 %117 = OpTypeVector %6 4
202 %118 = OpTypeMatrix %117 2
203 %119 = OpConstant %6 0
204 %120 = OpConstantComposite %117 %119 %119 %119 %119
205 %121 = OpConstantComposite %118 %120 %120
206 %129 = OpTypePointer Function %118
207 %139 = OpTypeVector %6 2
208 %140 = OpTypeMatrix %139 3
209 %141 = OpConstantComposite %139 %119 %119
210 %142 = OpConstantComposite %140 %141 %141 %141
211 %150 = OpTypePointer Function %140
212 %160 = OpTypeVector %6 3
213 %161 = OpTypeMatrix %160 3
214 %162 = OpConstantComposite %160 %119 %119 %119
215 %163 = OpConstantComposite %161 %162 %162 %162
216 %171 = OpTypePointer Function %161
217 %181 = OpTypeMatrix %117 3
218 %182 = OpConstantComposite %181 %120 %120 %120
219 %188 = OpTypePointer Function %181
220 %198 = OpTypeMatrix %139 4
221 %199 = OpConstantComposite %198 %141 %141 %141 %141
222 %203 = OpTypePointer Function %198
223 %213 = OpTypeMatrix %160 4
224 %214 = OpConstantComposite %213 %162 %162 %162 %162
225 %218 = OpTypePointer Function %213
226 %227 = OpTypeMatrix %117 4
227 %228 = OpConstantComposite %227 %120 %120 %120 %120
228 %234 = OpTypePointer Function %227
229 %281 = OpTypePointer Output %117
230 %282 = OpVariable %281 Output
231 %4 = OpFunction %2 None %3
233 %11 = OpVariable %10 Function
234 %40 = OpVariable %39 Function
235 %61 = OpVariable %39 Function
236 %71 = OpVariable %39 Function
237 %80 = OpVariable %39 Function
238 %130 = OpVariable %129 Function
239 %151 = OpVariable %150 Function
240 %172 = OpVariable %171 Function
241 %189 = OpVariable %188 Function
242 %204 = OpVariable %203 Function
243 %219 = OpVariable %218 Function
244 %235 = OpVariable %234 Function
245 %20 = OpAccessChain %19 %16 %18 %18
247 %38 = OpCompositeConstruct %9 %21 %21 %21 %21 %21 %21 %21 %21 %21
249 %48 = OpAccessChain %47 %45 %18 %46
254 %301 = OpPhi %17 %49 %5 %251 %53
255 OpLoopMerge %52 %53 None
258 %57 = OpAccessChain %47 %45 %18 %56
260 %60 = OpSLessThan %59 %301 %58
261 OpBranchConditional %60 %51 %52
266 %302 = OpPhi %17 %62 %51 %249 %66
267 OpLoopMerge %65 %66 None
270 %70 = OpSLessThanEqual %59 %302 %69
271 OpBranchConditional %70 %64 %65
276 %304 = OpPhi %17 %18 %64 %247 %75
277 OpLoopMerge %74 %75 None
280 %79 = OpSLessThan %59 %304 %302
281 OpBranchConditional %79 %73 %74
286 %306 = OpPhi %17 %18 %73 %245 %84
287 OpLoopMerge %83 %84 None
290 %87 = OpSLessThan %59 %306 %62
291 OpBranchConditional %87 %82 %83
293 OpSelectionMerge %98 None
294 OpSwitch %301 %98 0 %89 1 %90 2 %91 3 %92 4 %93 5 %94 6 %95 7 %96 8 %97
296 %103 = OpAccessChain %102 %11 %301
297 %104 = OpLoad %6 %103
298 %105 = OpFAdd %6 %104 %21
302 %111 = OpAccessChain %102 %11 %301
303 %112 = OpLoad %6 %111
304 %113 = OpFAdd %6 %112 %21
308 %123 = OpAccessChain %47 %45 %18 %69
309 %124 = OpLoad %17 %123
310 %127 = OpExtInst %17 %1 SClamp %304 %124 %49
312 %131 = OpAccessChain %102 %130 %127 %306
313 %132 = OpLoad %6 %131
314 %133 = OpAccessChain %102 %11 %301
315 %134 = OpLoad %6 %133
316 %135 = OpFAdd %6 %134 %132
320 %144 = OpAccessChain %47 %45 %18 %69
321 %145 = OpLoad %17 %144
322 %146 = OpAccessChain %47 %45 %18 %62
323 %147 = OpLoad %17 %146
324 %148 = OpExtInst %17 %1 SClamp %304 %145 %147
326 %152 = OpAccessChain %102 %151 %148 %306
327 %153 = OpLoad %6 %152
328 %154 = OpAccessChain %102 %11 %301
329 %155 = OpLoad %6 %154
330 %156 = OpFAdd %6 %155 %153
334 %165 = OpAccessChain %47 %45 %18 %69
335 %166 = OpLoad %17 %165
336 %167 = OpAccessChain %47 %45 %18 %62
337 %168 = OpLoad %17 %167
338 %169 = OpExtInst %17 %1 SClamp %304 %166 %168
340 %173 = OpAccessChain %102 %172 %169 %306
341 %174 = OpLoad %6 %173
342 %175 = OpAccessChain %102 %11 %301
343 %176 = OpLoad %6 %175
344 %177 = OpFAdd %6 %176 %174
348 %184 = OpAccessChain %47 %45 %18 %62
349 %185 = OpLoad %17 %184
350 %186 = OpExtInst %17 %1 SClamp %304 %18 %185
352 %190 = OpAccessChain %102 %189 %186 %306
353 %191 = OpLoad %6 %190
354 %192 = OpAccessChain %102 %11 %301
355 %193 = OpLoad %6 %192
356 %194 = OpFAdd %6 %193 %191
360 %201 = OpExtInst %17 %1 SClamp %304 %18 %46
362 %205 = OpAccessChain %102 %204 %201 %306
363 %206 = OpLoad %6 %205
364 %207 = OpAccessChain %102 %11 %301
365 %208 = OpLoad %6 %207
366 %209 = OpFAdd %6 %208 %206
370 %216 = OpExtInst %17 %1 SClamp %304 %18 %46
372 %220 = OpAccessChain %102 %219 %216 %306
373 %221 = OpLoad %6 %220
374 %222 = OpAccessChain %102 %11 %301
375 %223 = OpLoad %6 %222
376 %224 = OpFAdd %6 %223 %221
380 %230 = OpAccessChain %47 %45 %18 %18
381 %231 = OpLoad %17 %230
382 %232 = OpExtInst %17 %1 SClamp %304 %18 %231
384 %236 = OpAccessChain %102 %235 %232 %306
385 %237 = OpLoad %6 %236
386 %238 = OpAccessChain %102 %11 %301
387 %239 = OpLoad %6 %238
388 %240 = OpFAdd %6 %239 %237
394 %245 = OpIAdd %17 %306 %56
400 %247 = OpIAdd %17 %304 %56
406 %249 = OpIAdd %17 %302 %56
412 %251 = OpIAdd %17 %301 %56
416 %252 = OpAccessChain %47 %45 %18 %69
417 %253 = OpLoad %17 %252
418 %254 = OpAccessChain %102 %11 %253
419 %255 = OpLoad %6 %254
420 %258 = OpFOrdEqual %59 %255 %21
421 OpSelectionMerge %260 None
422 OpBranchConditional %258 %259 %260
424 %263 = OpAccessChain %102 %11 %49
425 %264 = OpLoad %6 %263
426 %265 = OpAccessChain %19 %16 %18 %56
427 %266 = OpLoad %6 %265
428 %267 = OpFOrdEqual %59 %264 %266
431 %268 = OpPhi %59 %258 %52 %267 %259
432 OpSelectionMerge %270 None
433 OpBranchConditional %268 %269 %270
435 %271 = OpAccessChain %47 %45 %18 %62
436 %272 = OpLoad %17 %271
437 %273 = OpAccessChain %102 %11 %272
438 %274 = OpLoad %6 %273
439 %277 = OpFOrdEqual %59 %274 %21
442 %278 = OpPhi %59 %268 %260 %277 %269
443 OpSelectionMerge %280 None
444 OpBranchConditional %278 %279 %296
446 %285 = OpConvertSToF %6 %49
447 %288 = OpConvertSToF %6 %253
448 %295 = OpCompositeConstruct %117 %285 %288 %288 %285
452 %299 = OpConvertSToF %6 %253
453 %300 = OpCompositeConstruct %117 %299 %299 %299 %299
461 # uniforms for variant
463 # _GLF_uniform_int_values
464 BUFFER variant__GLF_uniform_int_values DATA_TYPE int32[] STD140 DATA
467 # _GLF_uniform_float_values
468 BUFFER variant__GLF_uniform_float_values DATA_TYPE float[] STD140 DATA
472 BUFFER variant_framebuffer FORMAT B8G8R8A8_UNORM
474 PIPELINE graphics variant_pipeline
475 ATTACH variant_vertex_shader
476 ATTACH variant_fragment_shader
477 FRAMEBUFFER_SIZE 32 32
478 BIND BUFFER variant_framebuffer AS color LOCATION 0
479 BIND BUFFER variant__GLF_uniform_int_values AS uniform DESCRIPTOR_SET 0 BINDING 1
480 BIND BUFFER variant__GLF_uniform_float_values AS uniform DESCRIPTOR_SET 0 BINDING 0
482 CLEAR_COLOR variant_pipeline 0 0 0 255
484 CLEAR variant_pipeline
485 RUN variant_pipeline DRAW_RECT POS 0 0 SIZE 32 32
487 EXPECT variant_framebuffer IDX 0 0 SIZE 32 32 EQ_RGBA 255 0 0 255