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:
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_10 _GLF_uniform_int_values[3]
33 # #define _float_2_0 _GLF_uniform_float_values[0]
34 # #define _float_1_0 _GLF_uniform_float_values[1]
35 # #define _float_0_0 _GLF_uniform_float_values[2]
37 # precision highp float;
38 # precision highp int;
40 # // Contents of _GLF_uniform_int_values: [2, 1, 0, 10]
41 # layout(set = 0, binding = 0) uniform buf0
43 # int _GLF_uniform_int_values[4];
46 # // Contents of _GLF_uniform_float_values: [2.0, 1.0, 0.0]
47 # layout(set = 0, binding = 1) uniform buf1
49 # float _GLF_uniform_float_values[3];
52 # // Contents of zero: 0.0
53 # layout(set = 0, binding = 2) uniform buf2
58 # layout(location = 0) out vec4 _GLF_color;
62 # float data[10] = float[10](_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, _float_1_0);
64 # // Set elements 1..9 to zero.
65 # for(int i = _int_1; i < _int_10; i ++)
70 # for(int i = 0; i < 9; i ++)
73 # if(data[i] < _float_1_0)
75 # data[i] = _float_2_0;
81 # if(data[_int_0] == _float_1_0 && data[_int_1] == _float_2_0 && data[_int_2] == _float_0_0)
83 # _GLF_color = vec4(_int_1, _int_0, _int_0, _int_1);
87 # _GLF_color = vec4(_int_0);
90 SHADER fragment variant_fragment_shader SPIRV-ASM TARGET_ENV spv1.0
93 ; Generator: Khronos Glslang Reference Front End; 10
97 %1 = OpExtInstImport "GLSL.std.450"
98 OpMemoryModel Logical GLSL450
99 OpEntryPoint Fragment %4 "main" %129
100 OpExecutionMode %4 OriginUpperLeft
105 OpMemberName %14 0 "_GLF_uniform_float_values"
109 OpMemberName %46 0 "_GLF_uniform_int_values"
112 OpMemberName %64 0 "zero"
115 OpName %129 "_GLF_color"
116 OpDecorate %13 ArrayStride 16
117 OpMemberDecorate %14 0 Offset 0
119 OpDecorate %16 DescriptorSet 0
120 OpDecorate %16 Binding 1
121 OpDecorate %45 ArrayStride 16
122 OpMemberDecorate %46 0 Offset 0
124 OpDecorate %48 DescriptorSet 0
125 OpDecorate %48 Binding 0
126 OpMemberDecorate %64 0 Offset 0
128 OpDecorate %66 DescriptorSet 0
129 OpDecorate %66 Binding 2
130 OpDecorate %129 Location 0
132 %3 = OpTypeFunction %2
135 %8 = OpConstant %7 10
136 %9 = OpTypeArray %6 %8
137 %10 = OpTypePointer Function %9
138 %12 = OpConstant %7 3
139 %13 = OpTypeArray %6 %12
140 %14 = OpTypeStruct %13
141 %15 = OpTypePointer Uniform %14
142 %16 = OpVariable %15 Uniform
144 %18 = OpConstant %17 0
145 %19 = OpConstant %17 1
146 %20 = OpTypePointer Uniform %6
147 %42 = OpTypePointer Function %17
148 %44 = OpConstant %7 4
149 %45 = OpTypeArray %17 %44
150 %46 = OpTypeStruct %45
151 %47 = OpTypePointer Uniform %46
152 %48 = OpVariable %47 Uniform
153 %49 = OpTypePointer Uniform %17
154 %58 = OpConstant %17 3
156 %64 = OpTypeStruct %6
157 %65 = OpTypePointer Uniform %64
158 %66 = OpVariable %65 Uniform
159 %69 = OpTypePointer Function %6
160 %80 = OpConstant %17 9
161 %97 = OpConstant %17 2
162 %127 = OpTypeVector %6 4
163 %128 = OpTypePointer Output %127
164 %129 = OpVariable %128 Output
165 %4 = OpFunction %2 None %3
167 %11 = OpVariable %10 Function
168 %43 = OpVariable %42 Function
169 %73 = OpVariable %42 Function
170 %21 = OpAccessChain %20 %16 %18 %19
172 %23 = OpAccessChain %20 %16 %18 %19
174 %25 = OpAccessChain %20 %16 %18 %19
176 %27 = OpAccessChain %20 %16 %18 %19
178 %29 = OpAccessChain %20 %16 %18 %19
180 %31 = OpAccessChain %20 %16 %18 %19
182 %33 = OpAccessChain %20 %16 %18 %19
184 %35 = OpAccessChain %20 %16 %18 %19
186 %37 = OpAccessChain %20 %16 %18 %19
188 %39 = OpAccessChain %20 %16 %18 %19
190 %41 = OpCompositeConstruct %9 %22 %24 %26 %28 %30 %32 %34 %36 %38 %40
192 %50 = OpAccessChain %49 %48 %18 %19
197 OpLoopMerge %54 %55 None
201 %59 = OpAccessChain %49 %48 %18 %58
203 %62 = OpSLessThan %61 %57 %60
204 OpBranchConditional %62 %53 %54
207 %67 = OpAccessChain %20 %66 %18
209 %70 = OpAccessChain %69 %11 %63
214 %72 = OpIAdd %17 %71 %19
221 OpLoopMerge %76 %77 None
225 %81 = OpSLessThan %61 %79 %80
226 OpBranchConditional %81 %75 %76
229 %83 = OpAccessChain %69 %11 %82
231 %85 = OpAccessChain %20 %16 %18 %19
233 %87 = OpFOrdLessThan %61 %84 %86
234 OpSelectionMerge %89 None
235 OpBranchConditional %87 %88 %89
238 %91 = OpAccessChain %20 %16 %18 %18
240 %93 = OpAccessChain %69 %11 %90
247 %96 = OpIAdd %17 %95 %19
251 %98 = OpAccessChain %49 %48 %18 %97
253 %100 = OpAccessChain %69 %11 %99
254 %101 = OpLoad %6 %100
255 %102 = OpAccessChain %20 %16 %18 %19
256 %103 = OpLoad %6 %102
257 %104 = OpFOrdEqual %61 %101 %103
258 OpSelectionMerge %106 None
259 OpBranchConditional %104 %105 %106
261 %107 = OpAccessChain %49 %48 %18 %19
262 %108 = OpLoad %17 %107
263 %109 = OpAccessChain %69 %11 %108
264 %110 = OpLoad %6 %109
265 %111 = OpAccessChain %20 %16 %18 %18
266 %112 = OpLoad %6 %111
267 %113 = OpFOrdEqual %61 %110 %112
270 %114 = OpPhi %61 %104 %76 %113 %105
271 OpSelectionMerge %116 None
272 OpBranchConditional %114 %115 %116
274 %117 = OpAccessChain %49 %48 %18 %18
275 %118 = OpLoad %17 %117
276 %119 = OpAccessChain %69 %11 %118
277 %120 = OpLoad %6 %119
278 %121 = OpAccessChain %20 %16 %18 %97
279 %122 = OpLoad %6 %121
280 %123 = OpFOrdEqual %61 %120 %122
283 %124 = OpPhi %61 %114 %106 %123 %115
284 OpSelectionMerge %126 None
285 OpBranchConditional %124 %125 %143
287 %130 = OpAccessChain %49 %48 %18 %19
288 %131 = OpLoad %17 %130
289 %132 = OpConvertSToF %6 %131
290 %133 = OpAccessChain %49 %48 %18 %97
291 %134 = OpLoad %17 %133
292 %135 = OpConvertSToF %6 %134
293 %136 = OpAccessChain %49 %48 %18 %97
294 %137 = OpLoad %17 %136
295 %138 = OpConvertSToF %6 %137
296 %139 = OpAccessChain %49 %48 %18 %19
297 %140 = OpLoad %17 %139
298 %141 = OpConvertSToF %6 %140
299 %142 = OpCompositeConstruct %127 %132 %135 %138 %141
303 %144 = OpAccessChain %49 %48 %18 %97
304 %145 = OpLoad %17 %144
305 %146 = OpConvertSToF %6 %145
306 %147 = OpCompositeConstruct %127 %146 %146 %146 %146
314 # uniforms for variant
317 BUFFER variant_zero DATA_TYPE float STD140 DATA
320 # _GLF_uniform_float_values
321 BUFFER variant__GLF_uniform_float_values DATA_TYPE float[] STD140 DATA
324 # _GLF_uniform_int_values
325 BUFFER variant__GLF_uniform_int_values DATA_TYPE int32[] STD140 DATA
329 BUFFER variant_framebuffer FORMAT B8G8R8A8_UNORM
331 PIPELINE graphics variant_pipeline
332 ATTACH variant_vertex_shader
333 ATTACH variant_fragment_shader
334 FRAMEBUFFER_SIZE 32 32
335 BIND BUFFER variant_framebuffer AS color LOCATION 0
336 BIND BUFFER variant_zero AS uniform DESCRIPTOR_SET 0 BINDING 2
337 BIND BUFFER variant__GLF_uniform_float_values AS uniform DESCRIPTOR_SET 0 BINDING 1
338 BIND BUFFER variant__GLF_uniform_int_values AS uniform DESCRIPTOR_SET 0 BINDING 0
340 CLEAR_COLOR variant_pipeline 0 0 0 255
342 CLEAR variant_pipeline
343 RUN variant_pipeline DRAW_RECT POS 0 0 SIZE 32 32
345 EXPECT variant_framebuffer IDX 0 0 SIZE 32 32 EQ_RGBA 255 0 0 255