3 # Copyright 2020 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 cover specific optimize phis 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:
28 # #define _int_2 _GLF_uniform_int_values[0]
29 # #define _int_0 _GLF_uniform_int_values[1]
30 # #define _int_1 _GLF_uniform_int_values[2]
31 # #define _float_1_0 _GLF_uniform_float_values[0]
32 # #define _float_0_0 _GLF_uniform_float_values[1]
34 # precision highp float;
36 # // Contents of _GLF_uniform_float_values: [1.0, 0.0]
37 # layout(set = 0, binding = 0) uniform buf0
39 # float _GLF_uniform_float_values[2];
42 # // Contents of _GLF_uniform_int_values: [2, 0, 1]
43 # layout(set = 0, binding = 1) uniform buf1
45 # int _GLF_uniform_int_values[3];
48 # layout(location = 0) out vec4 _GLF_color;
52 # float a = _float_1_0;
53 # float b = _float_0_0;
55 # for (int i = _int_0; i < _int_2; i++)
57 # for (int i = _int_0; i < _int_2; i++)
59 # for (int i = _int_0; i < _int_2; i++)
61 # for (int i = _int_1; i < _int_2; i++)
63 # for (int i = _int_1; i < _int_2; i++)
65 # for (int i = _int_0; i < _int_2; i++)
67 # for (int i = _int_0; i < _int_2; i++)
69 # for (int i = _int_0; i < _int_2; i++)
71 # for (int i = _int_0; i < _int_2; i++)
73 # for (int i = _int_0; i < _int_2; i++)
75 # for (int i = _int_0; i < _int_2;
79 # if (gl_FragCoord.y > _float_0_0)
95 # _GLF_color = vec4(b, a, a, b);
97 SHADER fragment variant_fragment_shader SPIRV-ASM TARGET_ENV spv1.0
100 ; Generator: Khronos Glslang Reference Front End; 8
104 %1 = OpExtInstImport "GLSL.std.450"
105 OpMemoryModel Logical GLSL450
106 OpEntryPoint Fragment %4 "main" %169 %206
107 OpExecutionMode %4 OriginUpperLeft
112 OpMemberName %12 0 "_GLF_uniform_float_values"
117 OpMemberName %28 0 "_GLF_uniform_int_values"
129 OpName %169 "gl_FragCoord"
130 OpName %206 "_GLF_color"
131 OpDecorate %11 ArrayStride 16
132 OpMemberDecorate %12 0 Offset 0
134 OpDecorate %14 DescriptorSet 0
135 OpDecorate %14 Binding 0
136 OpDecorate %25 RelaxedPrecision
137 OpDecorate %27 ArrayStride 16
138 OpMemberDecorate %28 0 RelaxedPrecision
139 OpMemberDecorate %28 0 Offset 0
141 OpDecorate %30 DescriptorSet 0
142 OpDecorate %30 Binding 1
143 OpDecorate %33 RelaxedPrecision
144 OpDecorate %39 RelaxedPrecision
145 OpDecorate %41 RelaxedPrecision
146 OpDecorate %44 RelaxedPrecision
147 OpDecorate %46 RelaxedPrecision
148 OpDecorate %52 RelaxedPrecision
149 OpDecorate %54 RelaxedPrecision
150 OpDecorate %56 RelaxedPrecision
151 OpDecorate %58 RelaxedPrecision
152 OpDecorate %64 RelaxedPrecision
153 OpDecorate %66 RelaxedPrecision
154 OpDecorate %68 RelaxedPrecision
155 OpDecorate %71 RelaxedPrecision
156 OpDecorate %77 RelaxedPrecision
157 OpDecorate %79 RelaxedPrecision
158 OpDecorate %81 RelaxedPrecision
159 OpDecorate %83 RelaxedPrecision
160 OpDecorate %89 RelaxedPrecision
161 OpDecorate %91 RelaxedPrecision
162 OpDecorate %93 RelaxedPrecision
163 OpDecorate %95 RelaxedPrecision
164 OpDecorate %101 RelaxedPrecision
165 OpDecorate %103 RelaxedPrecision
166 OpDecorate %105 RelaxedPrecision
167 OpDecorate %107 RelaxedPrecision
168 OpDecorate %113 RelaxedPrecision
169 OpDecorate %115 RelaxedPrecision
170 OpDecorate %117 RelaxedPrecision
171 OpDecorate %119 RelaxedPrecision
172 OpDecorate %125 RelaxedPrecision
173 OpDecorate %127 RelaxedPrecision
174 OpDecorate %129 RelaxedPrecision
175 OpDecorate %131 RelaxedPrecision
176 OpDecorate %137 RelaxedPrecision
177 OpDecorate %139 RelaxedPrecision
178 OpDecorate %141 RelaxedPrecision
179 OpDecorate %143 RelaxedPrecision
180 OpDecorate %149 RelaxedPrecision
181 OpDecorate %151 RelaxedPrecision
182 OpDecorate %153 RelaxedPrecision
183 OpDecorate %155 RelaxedPrecision
184 OpDecorate %161 RelaxedPrecision
185 OpDecorate %163 RelaxedPrecision
186 OpDecorate %169 BuiltIn FragCoord
187 OpDecorate %180 RelaxedPrecision
188 OpDecorate %181 RelaxedPrecision
189 OpDecorate %182 RelaxedPrecision
190 OpDecorate %183 RelaxedPrecision
191 OpDecorate %184 RelaxedPrecision
192 OpDecorate %185 RelaxedPrecision
193 OpDecorate %186 RelaxedPrecision
194 OpDecorate %187 RelaxedPrecision
195 OpDecorate %188 RelaxedPrecision
196 OpDecorate %189 RelaxedPrecision
197 OpDecorate %190 RelaxedPrecision
198 OpDecorate %191 RelaxedPrecision
199 OpDecorate %192 RelaxedPrecision
200 OpDecorate %193 RelaxedPrecision
201 OpDecorate %194 RelaxedPrecision
202 OpDecorate %195 RelaxedPrecision
203 OpDecorate %196 RelaxedPrecision
204 OpDecorate %197 RelaxedPrecision
205 OpDecorate %198 RelaxedPrecision
206 OpDecorate %199 RelaxedPrecision
207 OpDecorate %203 RelaxedPrecision
208 OpDecorate %204 RelaxedPrecision
209 OpDecorate %206 Location 0
211 %3 = OpTypeFunction %2
213 %7 = OpTypePointer Function %6
215 %10 = OpConstant %9 2
216 %11 = OpTypeArray %6 %10
217 %12 = OpTypeStruct %11
218 %13 = OpTypePointer Uniform %12
219 %14 = OpVariable %13 Uniform
221 %16 = OpConstant %15 0
222 %17 = OpTypePointer Uniform %6
223 %21 = OpConstant %15 1
224 %24 = OpTypePointer Function %15
225 %26 = OpConstant %9 3
226 %27 = OpTypeArray %15 %26
227 %28 = OpTypeStruct %27
228 %29 = OpTypePointer Uniform %28
229 %30 = OpVariable %29 Uniform
230 %31 = OpTypePointer Uniform %15
232 %69 = OpConstant %15 2
233 %167 = OpTypeVector %6 4
234 %168 = OpTypePointer Input %167
235 %169 = OpVariable %168 Input
236 %170 = OpConstant %9 1
237 %171 = OpTypePointer Input %6
238 %201 = OpConstant %6 1
239 %205 = OpTypePointer Output %167
240 %206 = OpVariable %205 Output
241 %4 = OpFunction %2 None %3
243 %8 = OpVariable %7 Function
244 %20 = OpVariable %7 Function
245 %25 = OpVariable %24 Function
246 %44 = OpVariable %24 Function
247 %56 = OpVariable %24 Function
248 %68 = OpVariable %24 Function
249 %81 = OpVariable %24 Function
250 %93 = OpVariable %24 Function
251 %105 = OpVariable %24 Function
252 %117 = OpVariable %24 Function
253 %129 = OpVariable %24 Function
254 %141 = OpVariable %24 Function
255 %153 = OpVariable %24 Function
256 %18 = OpAccessChain %17 %14 %16 %16
259 %22 = OpAccessChain %17 %14 %16 %21
262 %32 = OpAccessChain %31 %30 %16 %21
267 OpLoopMerge %36 %37 None
271 %40 = OpAccessChain %31 %30 %16 %16
273 %43 = OpSLessThan %42 %39 %41
274 OpBranchConditional %43 %35 %36
276 %45 = OpAccessChain %31 %30 %16 %21
281 OpLoopMerge %49 %50 None
285 %53 = OpAccessChain %31 %30 %16 %16
287 %55 = OpSLessThan %42 %52 %54
288 OpBranchConditional %55 %48 %49
290 %57 = OpAccessChain %31 %30 %16 %21
295 OpLoopMerge %61 %62 None
299 %65 = OpAccessChain %31 %30 %16 %16
301 %67 = OpSLessThan %42 %64 %66
302 OpBranchConditional %67 %60 %61
304 %70 = OpAccessChain %31 %30 %16 %69
309 OpLoopMerge %74 %75 None
313 %78 = OpAccessChain %31 %30 %16 %16
315 %80 = OpSLessThan %42 %77 %79
316 OpBranchConditional %80 %73 %74
318 %82 = OpAccessChain %31 %30 %16 %69
323 OpLoopMerge %86 %87 None
327 %90 = OpAccessChain %31 %30 %16 %16
329 %92 = OpSLessThan %42 %89 %91
330 OpBranchConditional %92 %85 %86
332 %94 = OpAccessChain %31 %30 %16 %21
337 OpLoopMerge %98 %99 None
340 %101 = OpLoad %15 %93
341 %102 = OpAccessChain %31 %30 %16 %16
342 %103 = OpLoad %15 %102
343 %104 = OpSLessThan %42 %101 %103
344 OpBranchConditional %104 %97 %98
346 %106 = OpAccessChain %31 %30 %16 %21
347 %107 = OpLoad %15 %106
351 OpLoopMerge %110 %111 None
354 %113 = OpLoad %15 %105
355 %114 = OpAccessChain %31 %30 %16 %16
356 %115 = OpLoad %15 %114
357 %116 = OpSLessThan %42 %113 %115
358 OpBranchConditional %116 %109 %110
360 %118 = OpAccessChain %31 %30 %16 %21
361 %119 = OpLoad %15 %118
365 OpLoopMerge %122 %123 None
368 %125 = OpLoad %15 %117
369 %126 = OpAccessChain %31 %30 %16 %16
370 %127 = OpLoad %15 %126
371 %128 = OpSLessThan %42 %125 %127
372 OpBranchConditional %128 %121 %122
374 %130 = OpAccessChain %31 %30 %16 %21
375 %131 = OpLoad %15 %130
379 OpLoopMerge %134 %135 None
382 %137 = OpLoad %15 %129
383 %138 = OpAccessChain %31 %30 %16 %16
384 %139 = OpLoad %15 %138
385 %140 = OpSLessThan %42 %137 %139
386 OpBranchConditional %140 %133 %134
388 %142 = OpAccessChain %31 %30 %16 %21
389 %143 = OpLoad %15 %142
393 OpLoopMerge %146 %147 None
396 %149 = OpLoad %15 %141
397 %150 = OpAccessChain %31 %30 %16 %16
398 %151 = OpLoad %15 %150
399 %152 = OpSLessThan %42 %149 %151
400 OpBranchConditional %152 %145 %146
402 %154 = OpAccessChain %31 %30 %16 %21
403 %155 = OpLoad %15 %154
407 OpLoopMerge %158 %159 None
410 %161 = OpLoad %15 %153
411 %162 = OpAccessChain %31 %30 %16 %16
412 %163 = OpLoad %15 %162
413 %164 = OpSLessThan %42 %161 %163
414 OpBranchConditional %164 %157 %158
416 %165 = OpAccessChain %17 %14 %16 %21
417 %166 = OpLoad %6 %165
419 %172 = OpAccessChain %171 %169 %170
420 %173 = OpLoad %6 %172
421 %174 = OpAccessChain %17 %14 %16 %21
422 %175 = OpLoad %6 %174
423 %176 = OpFOrdGreaterThan %42 %173 %175
424 OpSelectionMerge %178 None
425 OpBranchConditional %176 %177 %178
431 %180 = OpLoad %15 %153
432 %181 = OpIAdd %15 %180 %21
438 %182 = OpLoad %15 %141
439 %183 = OpIAdd %15 %182 %21
445 %184 = OpLoad %15 %129
446 %185 = OpIAdd %15 %184 %21
452 %186 = OpLoad %15 %117
453 %187 = OpIAdd %15 %186 %21
459 %188 = OpLoad %15 %105
460 %189 = OpIAdd %15 %188 %21
466 %190 = OpLoad %15 %93
467 %191 = OpIAdd %15 %190 %21
473 %192 = OpLoad %15 %81
474 %193 = OpIAdd %15 %192 %21
480 %194 = OpLoad %15 %68
481 %195 = OpIAdd %15 %194 %21
487 %196 = OpLoad %15 %56
488 %197 = OpIAdd %15 %196 %21
494 %198 = OpLoad %15 %44
495 %199 = OpIAdd %15 %198 %21
500 %202 = OpFAdd %6 %200 %201
504 %203 = OpLoad %15 %25
505 %204 = OpIAdd %15 %203 %21
513 %211 = OpCompositeConstruct %167 %207 %208 %209 %210
519 # uniforms for variant
521 # _GLF_uniform_int_values
522 BUFFER variant__GLF_uniform_int_values DATA_TYPE int32[] STD140 DATA
525 # _GLF_uniform_float_values
526 BUFFER variant__GLF_uniform_float_values DATA_TYPE float[] STD140 DATA
530 BUFFER variant_framebuffer FORMAT B8G8R8A8_UNORM
532 PIPELINE graphics variant_pipeline
533 ATTACH variant_vertex_shader
534 ATTACH variant_fragment_shader
535 FRAMEBUFFER_SIZE 16 16
536 BIND BUFFER variant_framebuffer AS color LOCATION 0
537 BIND BUFFER variant__GLF_uniform_int_values AS uniform DESCRIPTOR_SET 0 BINDING 1
538 BIND BUFFER variant__GLF_uniform_float_values AS uniform DESCRIPTOR_SET 0 BINDING 0
540 CLEAR_COLOR variant_pipeline 0 0 0 255
542 CLEAR variant_pipeline
543 RUN variant_pipeline DRAW_RECT POS 0 0 SIZE 16 16
545 EXPECT variant_framebuffer IDX 0 0 SIZE 16 16 EQ_RGBA 255 0 0 255