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_2 _GLF_uniform_int_values[0]
30 # #define _int_1 _GLF_uniform_int_values[1]
31 # #define _int_0 _GLF_uniform_int_values[2]
32 # #define _int_6 _GLF_uniform_int_values[3]
34 # precision highp float;
35 # precision highp int;
37 # // Contents of _GLF_uniform_int_values: [2, 1, 0, 6]
38 # layout(set = 0, binding = 0) uniform buf0
40 # int _GLF_uniform_int_values[4];
43 # int arr0[10] = int[10](0, 0, 0, 0, 0, 0, 0, 0, 0, 0), arr1[10] = int[10](1, 1, 1, 1, 1, 1, 1, 1, 1, 1);
45 # layout(location = 0) out vec4 _GLF_color;
47 # void func(int x, int y)
49 # // Sets arr1[1..5] = arr0[1] = 0.
50 # for(int i = _int_1; i < _int_6; i++)
52 # arr1[i] = arr0[_int_1];
57 # // Sets arr0[x..min(x+8, 9)] = arr1[1] = 0.
58 # for(int i = x; i < y; i++)
65 # arr0[i] = arr1[_int_1];
73 # // Iterates i = 1, 2, 2, 2, 2.
74 # for(int i = 1; a < 6; i = _int_2, a++)
76 # // Iterates j = 1..9 during the first round, and
77 # // j = 1, 3, 5, 7, 9 for the other rounds.
78 # for(int j = 1; j < 10; j += i)
84 # // Sets _GLF_color to (1, 0, 0, 1).
85 # _GLF_color = vec4(arr1[_int_0], arr0[_int_0], arr1[_int_1], arr1[_int_6]);
87 SHADER fragment variant_fragment_shader SPIRV-ASM TARGET_ENV spv1.0
90 ; Generator: Khronos Glslang Reference Front End; 10
94 %1 = OpExtInstImport "GLSL.std.450"
95 OpMemoryModel Logical GLSL450
96 OpEntryPoint Fragment %4 "main" %110
97 OpExecutionMode %4 OriginUpperLeft
100 OpName %11 "func(i1;i1;"
107 OpMemberName %26 0 "_GLF_uniform_int_values"
116 OpName %110 "_GLF_color"
117 OpDecorate %25 ArrayStride 16
118 OpMemberDecorate %26 0 Offset 0
120 OpDecorate %28 DescriptorSet 0
121 OpDecorate %28 Binding 0
122 OpDecorate %110 Location 0
124 %3 = OpTypeFunction %2
126 %7 = OpTypePointer Function %6
127 %8 = OpTypeFunction %2 %7 %7
129 %14 = OpConstant %13 10
130 %15 = OpTypeArray %6 %14
131 %16 = OpTypePointer Private %15
132 %17 = OpVariable %16 Private
133 %18 = OpConstant %6 0
134 %19 = OpConstantComposite %15 %18 %18 %18 %18 %18 %18 %18 %18 %18 %18
135 %20 = OpVariable %16 Private
136 %21 = OpConstant %6 1
137 %22 = OpConstantComposite %15 %21 %21 %21 %21 %21 %21 %21 %21 %21 %21
138 %24 = OpConstant %13 4
139 %25 = OpTypeArray %6 %24
140 %26 = OpTypeStruct %25
141 %27 = OpTypePointer Uniform %26
142 %28 = OpVariable %27 Uniform
143 %29 = OpTypePointer Uniform %6
144 %38 = OpConstant %6 3
146 %46 = OpTypePointer Private %6
147 %65 = OpConstant %6 6
148 %94 = OpConstant %6 10
149 %107 = OpTypeFloat 32
150 %108 = OpTypeVector %107 4
151 %109 = OpTypePointer Output %108
152 %110 = OpVariable %109 Output
153 %111 = OpConstant %6 2
154 %4 = OpFunction %2 None %3
156 %78 = OpVariable %7 Function
157 %79 = OpVariable %7 Function
158 %87 = OpVariable %7 Function
159 %96 = OpVariable %7 Function
160 %98 = OpVariable %7 Function
167 OpLoopMerge %82 %83 None
171 %86 = OpSLessThan %41 %85 %65
172 OpBranchConditional %86 %81 %82
177 OpLoopMerge %90 %91 None
181 %95 = OpSLessThan %41 %93 %94
182 OpBranchConditional %95 %89 %90
187 %99 = OpFunctionCall %2 %11 %96 %98
192 %102 = OpIAdd %6 %101 %100
198 %103 = OpAccessChain %29 %28 %18 %18
199 %104 = OpLoad %6 %103
202 %106 = OpIAdd %6 %105 %21
206 %112 = OpAccessChain %29 %28 %18 %111
207 %113 = OpLoad %6 %112
208 %114 = OpAccessChain %46 %20 %113
209 %115 = OpLoad %6 %114
210 %116 = OpConvertSToF %107 %115
211 %117 = OpAccessChain %29 %28 %18 %111
212 %118 = OpLoad %6 %117
213 %119 = OpAccessChain %46 %17 %118
214 %120 = OpLoad %6 %119
215 %121 = OpConvertSToF %107 %120
216 %122 = OpAccessChain %29 %28 %18 %21
217 %123 = OpLoad %6 %122
218 %124 = OpAccessChain %46 %20 %123
219 %125 = OpLoad %6 %124
220 %126 = OpConvertSToF %107 %125
221 %127 = OpAccessChain %29 %28 %18 %38
222 %128 = OpLoad %6 %127
223 %129 = OpAccessChain %46 %20 %128
224 %130 = OpLoad %6 %129
225 %131 = OpConvertSToF %107 %130
226 %132 = OpCompositeConstruct %108 %116 %121 %126 %131
230 %11 = OpFunction %2 None %8
231 %9 = OpFunctionParameter %7
232 %10 = OpFunctionParameter %7
234 %23 = OpVariable %7 Function
235 %52 = OpVariable %7 Function
236 %53 = OpVariable %7 Function
237 %30 = OpAccessChain %29 %28 %18 %21
242 OpLoopMerge %34 %35 None
246 %39 = OpAccessChain %29 %28 %18 %38
248 %42 = OpSLessThan %41 %37 %40
249 OpBranchConditional %42 %33 %34
252 %44 = OpAccessChain %29 %28 %18 %21
254 %47 = OpAccessChain %46 %17 %45
256 %49 = OpAccessChain %46 %20 %43
261 %51 = OpIAdd %6 %50 %21
270 OpLoopMerge %57 %58 None
275 %62 = OpSLessThan %41 %60 %61
276 OpBranchConditional %62 %56 %57
279 %64 = OpIAdd %6 %63 %21
281 %66 = OpSGreaterThan %41 %63 %65
282 OpSelectionMerge %68 None
283 OpBranchConditional %66 %67 %68
288 %71 = OpAccessChain %29 %28 %18 %21
290 %73 = OpAccessChain %46 %20 %72
292 %75 = OpAccessChain %46 %17 %70
297 %77 = OpIAdd %6 %76 %21
305 # uniforms for variant
307 # _GLF_uniform_int_values
308 BUFFER variant__GLF_uniform_int_values DATA_TYPE int32[] STD140 DATA
312 BUFFER variant_framebuffer FORMAT B8G8R8A8_UNORM
314 PIPELINE graphics variant_pipeline
315 ATTACH variant_vertex_shader
316 ATTACH variant_fragment_shader
317 FRAMEBUFFER_SIZE 16 16
318 BIND BUFFER variant_framebuffer AS color LOCATION 0
319 BIND BUFFER variant__GLF_uniform_int_values AS uniform DESCRIPTOR_SET 0 BINDING 0
321 CLEAR_COLOR variant_pipeline 0 0 0 255
323 CLEAR variant_pipeline
324 RUN variant_pipeline DRAW_RECT POS 0 0 SIZE 16 16
326 EXPECT variant_framebuffer IDX 0 0 SIZE 16 16 EQ_RGBA 255 0 0 255