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_1 _GLF_uniform_int_values[0]
30 # #define _int_0 _GLF_uniform_int_values[1]
31 # #define _int_10 _GLF_uniform_int_values[2]
32 # #define _float_1_0 _GLF_uniform_float_values[0]
33 # #define _float_2_0 _GLF_uniform_float_values[1]
34 # #define _float_3_0 _GLF_uniform_float_values[2]
35 # #define _float_4_0 _GLF_uniform_float_values[3]
36 # #define _float_5_0 _GLF_uniform_float_values[4]
37 # #define _float_6_0 _GLF_uniform_float_values[5]
38 # #define _float_7_0 _GLF_uniform_float_values[6]
39 # #define _float_8_0 _GLF_uniform_float_values[7]
40 # #define _float_9_0 _GLF_uniform_float_values[8]
41 # #define _float_10_0 _GLF_uniform_float_values[9]
42 # #define _float_0_0 _GLF_uniform_float_values[10]
44 # precision highp float;
45 # precision highp int;
47 # // Contents of _GLF_uniform_float_values: [1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 0.0]
48 # layout(set = 0, binding = 0) uniform buf0
50 # float _GLF_uniform_float_values[11];
52 # // Contents of _GLF_uniform_int_values: [1, 0, 10]
53 # layout(set = 0, binding = 1) uniform buf1
55 # int _GLF_uniform_int_values[3];
57 # // Contents of injectionSwitch: [0.0, 1.0]
58 # layout(set = 0, binding = 2) uniform buf2
60 # vec2 injectionSwitch;
62 # layout(location = 0) out vec4 _GLF_color;
66 # float data[10] = float[10](_float_1_0, _float_2_0, _float_3_0, _float_4_0, _float_5_0, _float_6_0, _float_7_0, _float_8_0, _float_9_0, _float_10_0);
68 # // This loop copies data[1] to indices two and up.
69 # for(int i = 0; i < 10; i ++)
71 # for(int j = 0; j < 10; j ++)
73 # // Skips all other iterations except j >= i. The inner loop has no dependency of j,
74 # // thus it just does data[i] = data[1] multiple times when i > 1.
81 # float f1 = data[_int_1];
83 # // Always selects f0 > f1 which is true when i > 1.
84 # bool b = injectionSwitch.x > _float_0_0 ? injectionSwitch.x < injectionSwitch.y : f0 > f1;
88 # data[i] = data[_int_1];
93 # // Compare against expected results.
94 # float ref[10] = float[10](_float_1_0, _float_2_0, _float_2_0, _float_2_0, _float_2_0, _float_2_0, _float_2_0, _float_2_0, _float_2_0, _float_2_0);
95 # _GLF_color = vec4(_int_1, _int_0, _int_0, _int_1);
97 # for(int i = _int_0; i < _int_10; i ++)
99 # if(data[i] != ref[i])
101 # _GLF_color = vec4(_int_0);
105 SHADER fragment variant_fragment_shader SPIRV-ASM TARGET_ENV spv1.0
108 ; Generator: Khronos Glslang Reference Front End; 10
112 %1 = OpExtInstImport "GLSL.std.450"
113 OpMemoryModel Logical GLSL450
114 OpEntryPoint Fragment %4 "main" %154
115 OpExecutionMode %4 OriginUpperLeft
120 OpMemberName %14 0 "_GLF_uniform_float_values"
127 OpMemberName %83 0 "_GLF_uniform_int_values"
131 OpMemberName %94 0 "injectionSwitch"
134 OpName %154 "_GLF_color"
136 OpDecorate %13 ArrayStride 16
137 OpMemberDecorate %14 0 Offset 0
139 OpDecorate %16 DescriptorSet 0
140 OpDecorate %16 Binding 0
141 OpDecorate %82 ArrayStride 16
142 OpMemberDecorate %83 0 Offset 0
144 OpDecorate %85 DescriptorSet 0
145 OpDecorate %85 Binding 1
146 OpMemberDecorate %94 0 Offset 0
148 OpDecorate %96 DescriptorSet 0
149 OpDecorate %96 Binding 2
150 OpDecorate %154 Location 0
152 %3 = OpTypeFunction %2
155 %8 = OpConstant %7 10
156 %9 = OpTypeArray %6 %8
157 %10 = OpTypePointer Function %9
158 %12 = OpConstant %7 11
159 %13 = OpTypeArray %6 %12
160 %14 = OpTypeStruct %13
161 %15 = OpTypePointer Uniform %14
162 %16 = OpVariable %15 Uniform
164 %18 = OpConstant %17 0
165 %19 = OpTypePointer Uniform %6
166 %22 = OpConstant %17 1
167 %25 = OpConstant %17 2
168 %28 = OpConstant %17 3
169 %31 = OpConstant %17 4
170 %34 = OpConstant %17 5
171 %37 = OpConstant %17 6
172 %40 = OpConstant %17 7
173 %43 = OpConstant %17 8
174 %46 = OpConstant %17 9
175 %50 = OpTypePointer Function %17
176 %58 = OpConstant %17 10
178 %75 = OpTypePointer Function %6
179 %81 = OpConstant %7 3
180 %82 = OpTypeArray %17 %81
181 %83 = OpTypeStruct %82
182 %84 = OpTypePointer Uniform %83
183 %85 = OpVariable %84 Uniform
184 %86 = OpTypePointer Uniform %17
185 %91 = OpTypePointer Function %59
186 %93 = OpTypeVector %6 2
187 %94 = OpTypeStruct %93
188 %95 = OpTypePointer Uniform %94
189 %96 = OpVariable %95 Uniform
190 %97 = OpConstant %7 0
191 %108 = OpConstant %7 1
192 %152 = OpTypeVector %6 4
193 %153 = OpTypePointer Output %152
194 %154 = OpVariable %153 Output
195 %4 = OpFunction %2 None %3
197 %11 = OpVariable %10 Function
198 %51 = OpVariable %50 Function
199 %61 = OpVariable %50 Function
200 %76 = OpVariable %75 Function
201 %80 = OpVariable %75 Function
202 %92 = OpVariable %91 Function
203 %103 = OpVariable %91 Function
204 %130 = OpVariable %10 Function
205 %168 = OpVariable %50 Function
206 %20 = OpAccessChain %19 %16 %18 %18
208 %23 = OpAccessChain %19 %16 %18 %22
210 %26 = OpAccessChain %19 %16 %18 %25
212 %29 = OpAccessChain %19 %16 %18 %28
214 %32 = OpAccessChain %19 %16 %18 %31
216 %35 = OpAccessChain %19 %16 %18 %34
218 %38 = OpAccessChain %19 %16 %18 %37
220 %41 = OpAccessChain %19 %16 %18 %40
222 %44 = OpAccessChain %19 %16 %18 %43
224 %47 = OpAccessChain %19 %16 %18 %46
226 %49 = OpCompositeConstruct %9 %21 %24 %27 %30 %33 %36 %39 %42 %45 %48
231 OpLoopMerge %54 %55 None
235 %60 = OpSLessThan %59 %57 %58
236 OpBranchConditional %60 %53 %54
241 OpLoopMerge %64 %65 None
245 %68 = OpSLessThan %59 %67 %58
246 OpBranchConditional %68 %63 %64
250 %71 = OpSLessThan %59 %69 %70
251 OpSelectionMerge %73 None
252 OpBranchConditional %71 %72 %73
257 %78 = OpAccessChain %75 %11 %77
260 %87 = OpAccessChain %86 %85 %18 %18
262 %89 = OpAccessChain %75 %11 %88
265 %98 = OpAccessChain %19 %96 %18 %97
267 %100 = OpAccessChain %19 %16 %18 %58
268 %101 = OpLoad %6 %100
269 %102 = OpFOrdGreaterThan %59 %99 %101
270 OpSelectionMerge %105 None
271 OpBranchConditional %102 %104 %112
273 %106 = OpAccessChain %19 %96 %18 %97
274 %107 = OpLoad %6 %106
275 %109 = OpAccessChain %19 %96 %18 %108
276 %110 = OpLoad %6 %109
277 %111 = OpFOrdLessThan %59 %107 %110
283 %115 = OpFOrdGreaterThan %59 %113 %114
287 %116 = OpLoad %59 %103
289 %117 = OpLoad %59 %92
290 OpSelectionMerge %119 None
291 OpBranchConditional %117 %118 %119
293 %120 = OpLoad %17 %51
294 %121 = OpAccessChain %86 %85 %18 %18
295 %122 = OpLoad %17 %121
296 %123 = OpAccessChain %75 %11 %122
297 %124 = OpLoad %6 %123
298 %125 = OpAccessChain %75 %11 %120
304 %126 = OpLoad %17 %61
305 %127 = OpIAdd %17 %126 %22
311 %128 = OpLoad %17 %51
312 %129 = OpIAdd %17 %128 %22
316 %131 = OpAccessChain %19 %16 %18 %18
317 %132 = OpLoad %6 %131
318 %133 = OpAccessChain %19 %16 %18 %22
319 %134 = OpLoad %6 %133
320 %135 = OpAccessChain %19 %16 %18 %22
321 %136 = OpLoad %6 %135
322 %137 = OpAccessChain %19 %16 %18 %22
323 %138 = OpLoad %6 %137
324 %139 = OpAccessChain %19 %16 %18 %22
325 %140 = OpLoad %6 %139
326 %141 = OpAccessChain %19 %16 %18 %22
327 %142 = OpLoad %6 %141
328 %143 = OpAccessChain %19 %16 %18 %22
329 %144 = OpLoad %6 %143
330 %145 = OpAccessChain %19 %16 %18 %22
331 %146 = OpLoad %6 %145
332 %147 = OpAccessChain %19 %16 %18 %22
333 %148 = OpLoad %6 %147
334 %149 = OpAccessChain %19 %16 %18 %22
335 %150 = OpLoad %6 %149
336 %151 = OpCompositeConstruct %9 %132 %134 %136 %138 %140 %142 %144 %146 %148 %150
338 %155 = OpAccessChain %86 %85 %18 %18
339 %156 = OpLoad %17 %155
340 %157 = OpConvertSToF %6 %156
341 %158 = OpAccessChain %86 %85 %18 %22
342 %159 = OpLoad %17 %158
343 %160 = OpConvertSToF %6 %159
344 %161 = OpAccessChain %86 %85 %18 %22
345 %162 = OpLoad %17 %161
346 %163 = OpConvertSToF %6 %162
347 %164 = OpAccessChain %86 %85 %18 %18
348 %165 = OpLoad %17 %164
349 %166 = OpConvertSToF %6 %165
350 %167 = OpCompositeConstruct %152 %157 %160 %163 %166
352 %169 = OpAccessChain %86 %85 %18 %22
353 %170 = OpLoad %17 %169
357 OpLoopMerge %173 %174 None
360 %176 = OpLoad %17 %168
361 %177 = OpAccessChain %86 %85 %18 %25
362 %178 = OpLoad %17 %177
363 %179 = OpSLessThan %59 %176 %178
364 OpBranchConditional %179 %172 %173
366 %180 = OpLoad %17 %168
367 %181 = OpAccessChain %75 %11 %180
368 %182 = OpLoad %6 %181
369 %183 = OpLoad %17 %168
370 %184 = OpAccessChain %75 %130 %183
371 %185 = OpLoad %6 %184
372 %186 = OpFUnordNotEqual %59 %182 %185
373 OpSelectionMerge %188 None
374 OpBranchConditional %186 %187 %188
376 %189 = OpAccessChain %86 %85 %18 %22
377 %190 = OpLoad %17 %189
378 %191 = OpConvertSToF %6 %190
379 %192 = OpCompositeConstruct %152 %191 %191 %191 %191
385 %193 = OpLoad %17 %168
386 %194 = OpIAdd %17 %193 %22
394 # uniforms for variant
397 BUFFER variant_injectionSwitch DATA_TYPE vec2<float> STD140 DATA
400 # _GLF_uniform_int_values
401 BUFFER variant__GLF_uniform_int_values DATA_TYPE int32[] STD140 DATA
404 # _GLF_uniform_float_values
405 BUFFER variant__GLF_uniform_float_values DATA_TYPE float[] STD140 DATA
406 1.0 2.0 3.0 4.0 5.0 6.0 7.0 8.0 9.0 10.0 0.0
409 BUFFER variant_framebuffer FORMAT B8G8R8A8_UNORM
411 PIPELINE graphics variant_pipeline
412 ATTACH variant_vertex_shader
413 ATTACH variant_fragment_shader
414 FRAMEBUFFER_SIZE 256 256
415 BIND BUFFER variant_framebuffer AS color LOCATION 0
416 BIND BUFFER variant_injectionSwitch AS uniform DESCRIPTOR_SET 0 BINDING 2
417 BIND BUFFER variant__GLF_uniform_int_values AS uniform DESCRIPTOR_SET 0 BINDING 1
418 BIND BUFFER variant__GLF_uniform_float_values AS uniform DESCRIPTOR_SET 0 BINDING 0
420 CLEAR_COLOR variant_pipeline 0 0 0 255
422 CLEAR variant_pipeline
423 RUN variant_pipeline DRAW_RECT POS 0 0 SIZE 256 256
425 EXPECT variant_framebuffer IDX 0 0 SIZE 256 256 EQ_RGBA 255 0 0 255