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:
28 # #define _int_3 _GLF_uniform_int_values[0]
29 # #define _int_1 _GLF_uniform_int_values[1]
30 # #define _int_0 _GLF_uniform_int_values[2]
31 # #define _int_2 _GLF_uniform_int_values[3]
32 # #define _float_1_0 _GLF_uniform_float_values[0]
34 # precision highp float;
35 # precision highp int;
37 # // Contents of _GLF_uniform_float_values: 1.0
38 # layout(set = 0, binding = 0) uniform buf0
40 # float _GLF_uniform_float_values[1];
43 # // Contents of _GLF_uniform_int_values: [3, 1, 0, 2]
44 # layout(set = 0, binding = 1) uniform buf1
46 # int _GLF_uniform_int_values[4];
49 # // Contents of zero: 0.0
50 # layout(set = 0, binding = 2) uniform buf2 {
54 # layout(location = 0) out vec4 _GLF_color;
58 # mat4 m = mat4(_int_1);
60 # vec4 v = vec4(_int_2);
63 # for(int i = _int_1; a < _int_3; i++)
67 # // Iterates for j = 1 and j = 0 when i = 1.
68 # for(int j = _int_1; i <= _int_1 && a < _int_3; j--)
73 # // v[1] = m[1][1] = 1
74 # // v[0] = m[0][1] = 0
78 # if(zero > _float_1_0)
86 # if(v == vec4(_int_0, _int_1, _int_2, _int_2))
88 # _GLF_color = vec4(_int_1, _int_0, _int_0, _int_1);
92 # _GLF_color = vec4(_int_0);
95 SHADER fragment variant_fragment_shader SPIRV-ASM TARGET_ENV spv1.0
98 ; Generator: Khronos Glslang Reference Front End; 10
102 %1 = OpExtInstImport "GLSL.std.450"
103 OpMemoryModel Logical GLSL450
104 OpEntryPoint Fragment %4 "main" %135
105 OpExecutionMode %4 OriginUpperLeft
110 OpMemberName %15 0 "_GLF_uniform_int_values"
117 OpMemberName %94 0 "zero"
120 OpMemberName %102 0 "_GLF_uniform_float_values"
122 OpName %135 "_GLF_color"
123 OpDecorate %14 ArrayStride 16
124 OpMemberDecorate %15 0 Offset 0
126 OpDecorate %17 DescriptorSet 0
127 OpDecorate %17 Binding 1
128 OpMemberDecorate %94 0 Offset 0
130 OpDecorate %96 DescriptorSet 0
131 OpDecorate %96 Binding 2
132 OpDecorate %101 ArrayStride 16
133 OpMemberDecorate %102 0 Offset 0
134 OpDecorate %102 Block
135 OpDecorate %104 DescriptorSet 0
136 OpDecorate %104 Binding 0
137 OpDecorate %135 Location 0
139 %3 = OpTypeFunction %2
141 %7 = OpTypeVector %6 4
142 %8 = OpTypeMatrix %7 4
143 %9 = OpTypePointer Function %8
146 %13 = OpConstant %12 4
147 %14 = OpTypeArray %11 %13
148 %15 = OpTypeStruct %14
149 %16 = OpTypePointer Uniform %15
150 %17 = OpVariable %16 Uniform
151 %18 = OpConstant %11 0
152 %19 = OpConstant %11 1
153 %20 = OpTypePointer Uniform %11
154 %24 = OpConstant %6 1
155 %25 = OpConstant %6 0
156 %39 = OpTypePointer Function %7
157 %41 = OpConstant %11 3
158 %46 = OpTypePointer Function %11
159 %48 = OpConstant %11 2
161 %90 = OpTypePointer Function %6
162 %94 = OpTypeStruct %6
163 %95 = OpTypePointer Uniform %94
164 %96 = OpVariable %95 Uniform
165 %97 = OpTypePointer Uniform %6
166 %100 = OpConstant %12 1
167 %101 = OpTypeArray %6 %100
168 %102 = OpTypeStruct %101
169 %103 = OpTypePointer Uniform %102
170 %104 = OpVariable %103 Uniform
171 %129 = OpTypeVector %62 4
172 %134 = OpTypePointer Output %7
173 %135 = OpVariable %134 Output
174 %4 = OpFunction %2 None %3
176 %10 = OpVariable %9 Function
177 %40 = OpVariable %39 Function
178 %47 = OpVariable %46 Function
179 %51 = OpVariable %46 Function
180 %66 = OpVariable %46 Function
181 %21 = OpAccessChain %20 %17 %18 %19
183 %23 = OpConvertSToF %6 %22
184 %26 = OpCompositeConstruct %7 %23 %25 %25 %25
185 %27 = OpCompositeConstruct %7 %25 %23 %25 %25
186 %28 = OpCompositeConstruct %7 %25 %25 %23 %25
187 %29 = OpCompositeConstruct %7 %25 %25 %25 %23
188 %30 = OpCompositeConstruct %8 %26 %27 %28 %29
190 %31 = OpAccessChain %20 %17 %18 %19
192 %33 = OpConvertSToF %6 %32
193 %34 = OpCompositeConstruct %7 %33 %25 %25 %25
194 %35 = OpCompositeConstruct %7 %25 %33 %25 %25
195 %36 = OpCompositeConstruct %7 %25 %25 %33 %25
196 %37 = OpCompositeConstruct %7 %25 %25 %25 %33
197 %38 = OpCompositeConstruct %8 %34 %35 %36 %37
199 %42 = OpAccessChain %20 %17 %18 %41
201 %44 = OpConvertSToF %6 %43
202 %45 = OpCompositeConstruct %7 %44 %44 %44 %44
204 %49 = OpAccessChain %20 %17 %18 %48
207 %52 = OpAccessChain %20 %17 %18 %19
212 OpLoopMerge %56 %57 None
216 %60 = OpAccessChain %20 %17 %18 %18
218 %63 = OpSLessThan %62 %59 %61
219 OpBranchConditional %63 %55 %56
222 %65 = OpIAdd %11 %64 %19
224 %67 = OpAccessChain %20 %17 %18 %19
229 OpLoopMerge %71 %72 None
233 %75 = OpAccessChain %20 %17 %18 %19
235 %77 = OpSLessThanEqual %62 %74 %76
236 OpSelectionMerge %79 None
237 OpBranchConditional %77 %78 %79
240 %81 = OpAccessChain %20 %17 %18 %18
242 %83 = OpSLessThan %62 %80 %82
245 %84 = OpPhi %62 %77 %73 %83 %78
246 OpBranchConditional %84 %70 %71
249 %86 = OpIAdd %11 %85 %19
254 %91 = OpAccessChain %90 %10 %88 %89
256 %93 = OpAccessChain %90 %40 %87
258 %98 = OpAccessChain %97 %96 %18
260 %105 = OpAccessChain %97 %104 %18 %18
261 %106 = OpLoad %6 %105
262 %107 = OpFOrdGreaterThan %62 %99 %106
263 OpSelectionMerge %109 None
264 OpBranchConditional %107 %108 %109
270 %111 = OpLoad %11 %66
271 %112 = OpISub %11 %111 %19
277 %113 = OpLoad %11 %51
278 %114 = OpIAdd %11 %113 %19
283 %116 = OpAccessChain %20 %17 %18 %48
284 %117 = OpLoad %11 %116
285 %118 = OpConvertSToF %6 %117
286 %119 = OpAccessChain %20 %17 %18 %19
287 %120 = OpLoad %11 %119
288 %121 = OpConvertSToF %6 %120
289 %122 = OpAccessChain %20 %17 %18 %41
290 %123 = OpLoad %11 %122
291 %124 = OpConvertSToF %6 %123
292 %125 = OpAccessChain %20 %17 %18 %41
293 %126 = OpLoad %11 %125
294 %127 = OpConvertSToF %6 %126
295 %128 = OpCompositeConstruct %7 %118 %121 %124 %127
296 %130 = OpFOrdEqual %129 %115 %128
297 %131 = OpAll %62 %130
298 OpSelectionMerge %133 None
299 OpBranchConditional %131 %132 %149
301 %136 = OpAccessChain %20 %17 %18 %19
302 %137 = OpLoad %11 %136
303 %138 = OpConvertSToF %6 %137
304 %139 = OpAccessChain %20 %17 %18 %48
305 %140 = OpLoad %11 %139
306 %141 = OpConvertSToF %6 %140
307 %142 = OpAccessChain %20 %17 %18 %48
308 %143 = OpLoad %11 %142
309 %144 = OpConvertSToF %6 %143
310 %145 = OpAccessChain %20 %17 %18 %19
311 %146 = OpLoad %11 %145
312 %147 = OpConvertSToF %6 %146
313 %148 = OpCompositeConstruct %7 %138 %141 %144 %147
317 %150 = OpAccessChain %20 %17 %18 %48
318 %151 = OpLoad %11 %150
319 %152 = OpConvertSToF %6 %151
320 %153 = OpCompositeConstruct %7 %152 %152 %152 %152
328 # uniforms for variant
331 BUFFER variant_zero DATA_TYPE float STD140 DATA
334 # _GLF_uniform_int_values
335 BUFFER variant__GLF_uniform_int_values DATA_TYPE int32[] STD140 DATA
338 # _GLF_uniform_float_values
339 BUFFER variant__GLF_uniform_float_values DATA_TYPE float[] STD140 DATA
343 BUFFER variant_framebuffer FORMAT B8G8R8A8_UNORM
345 PIPELINE graphics variant_pipeline
346 ATTACH variant_vertex_shader
347 ATTACH variant_fragment_shader
348 FRAMEBUFFER_SIZE 32 32
349 BIND BUFFER variant_framebuffer AS color LOCATION 0
350 BIND BUFFER variant_zero AS uniform DESCRIPTOR_SET 0 BINDING 2
351 BIND BUFFER variant__GLF_uniform_int_values AS uniform DESCRIPTOR_SET 0 BINDING 1
352 BIND BUFFER variant__GLF_uniform_float_values AS uniform DESCRIPTOR_SET 0 BINDING 0
354 CLEAR_COLOR variant_pipeline 0 0 0 255
356 CLEAR variant_pipeline
357 RUN variant_pipeline DRAW_RECT POS 0 0 SIZE 32 32
359 EXPECT variant_framebuffer IDX 0 0 SIZE 32 32 EQ_RGBA 255 0 0 255