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_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 _uint_1 _GLF_uniform_uint_values[0]
33 # #define _float_1_0 _GLF_uniform_float_values[0]
34 # #define _float_2_0 _GLF_uniform_float_values[1]
35 # #define _float_3_0 _GLF_uniform_float_values[2]
36 # #define _float_4_0 _GLF_uniform_float_values[3]
37 # #define _float_5_0 _GLF_uniform_float_values[4]
39 # precision highp float;
40 # precision highp int;
42 # // Contents of _GLF_uniform_uint_values: 1
43 # layout(set = 0, binding = 0) uniform buf0
45 # uint _GLF_uniform_uint_values[1];
48 # // Contents of _GLF_uniform_int_values: [1, 0, 10]
49 # layout(set = 0, binding = 1) uniform buf1
51 # int _GLF_uniform_int_values[3];
54 # // Contents of _GLF_uniform_float_values: [1.0, 2.0, 3.0, 4.0, 5.0]
55 # layout(set = 0, binding = 2) uniform buf2
57 # float _GLF_uniform_float_values[5];
60 # const int _GLF_global_loop_bound = 10;
61 # int _GLF_global_loop_count = 0;
63 # layout(location = 0) out vec4 _GLF_color;
68 # float arr[16] = float[16](_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, _float_1_0, _float_1_0, _float_1_0, _float_1_0, _float_1_0, _float_1_0);
74 # // usubBorrow returns zero and sets a to zero. If this was to be iterated more usubBorrow would return -1.
75 # arr[i++] += float[5](_float_1_0, _float_2_0, _float_3_0, _float_4_0, _float_5_0)[usubBorrow(a, _uint_1, a)];
80 # if(arr[_int_1] == _float_2_0)
82 # _GLF_color = vec4(_int_1, _int_0, _int_0, _int_1);
86 # _GLF_color = vec4(_int_0);
89 SHADER fragment variant_fragment_shader SPIRV-ASM TARGET_ENV spv1.0
92 ; Generator: Khronos Glslang Reference Front End; 10
96 %1 = OpExtInstImport "GLSL.std.450"
97 OpMemoryModel Logical GLSL450
98 OpEntryPoint Fragment %4 "main" %128
99 OpExecutionMode %4 OriginUpperLeft
102 OpName %8 "_GLF_global_loop_count"
105 OpMemberName %15 0 "_GLF_uniform_uint_values"
109 OpMemberName %28 0 "_GLF_uniform_float_values"
113 OpMemberName %69 0 "_GLF_uniform_int_values"
116 OpName %104 "indexable"
117 OpName %128 "_GLF_color"
118 OpDecorate %14 ArrayStride 16
119 OpMemberDecorate %15 0 Offset 0
121 OpDecorate %17 DescriptorSet 0
122 OpDecorate %17 Binding 0
123 OpDecorate %27 ArrayStride 16
124 OpMemberDecorate %28 0 Offset 0
126 OpDecorate %30 DescriptorSet 0
127 OpDecorate %30 Binding 2
128 OpDecorate %68 ArrayStride 16
129 OpMemberDecorate %69 0 Offset 0
131 OpDecorate %71 DescriptorSet 0
132 OpDecorate %71 Binding 1
133 OpDecorate %128 Location 0
135 %3 = OpTypeFunction %2
137 %7 = OpTypePointer Private %6
138 %8 = OpVariable %7 Private
141 %11 = OpTypePointer Function %10
142 %13 = OpConstant %10 1
143 %14 = OpTypeArray %10 %13
144 %15 = OpTypeStruct %14
145 %16 = OpTypePointer Uniform %15
146 %17 = OpVariable %16 Uniform
147 %18 = OpTypePointer Uniform %10
149 %22 = OpConstant %10 16
150 %23 = OpTypeArray %21 %22
151 %24 = OpTypePointer Function %23
152 %26 = OpConstant %10 5
153 %27 = OpTypeArray %21 %26
154 %28 = OpTypeStruct %27
155 %29 = OpTypePointer Uniform %28
156 %30 = OpVariable %29 Uniform
157 %31 = OpTypePointer Uniform %21
158 %65 = OpTypePointer Function %6
159 %67 = OpConstant %10 3
160 %68 = OpTypeArray %6 %67
161 %69 = OpTypeStruct %68
162 %70 = OpTypePointer Uniform %69
163 %71 = OpVariable %70 Uniform
164 %72 = OpTypePointer Uniform %6
165 %80 = OpConstant %6 1
166 %86 = OpConstant %6 2
167 %89 = OpConstant %6 3
168 %92 = OpConstant %6 4
169 %99 = OpTypeStruct %10 %10
170 %103 = OpTypePointer Function %27
171 %105 = OpTypePointer Function %21
173 %126 = OpTypeVector %21 4
174 %127 = OpTypePointer Output %126
175 %128 = OpVariable %127 Output
176 %147 = OpConstant %6 10
177 %4 = OpFunction %2 None %3
179 %12 = OpVariable %11 Function
180 %25 = OpVariable %24 Function
181 %66 = OpVariable %65 Function
182 %104 = OpVariable %103 Function
184 %19 = OpAccessChain %18 %17 %9 %9
187 %32 = OpAccessChain %31 %30 %9 %9
189 %34 = OpAccessChain %31 %30 %9 %9
191 %36 = OpAccessChain %31 %30 %9 %9
193 %38 = OpAccessChain %31 %30 %9 %9
195 %40 = OpAccessChain %31 %30 %9 %9
197 %42 = OpAccessChain %31 %30 %9 %9
199 %44 = OpAccessChain %31 %30 %9 %9
201 %46 = OpAccessChain %31 %30 %9 %9
203 %48 = OpAccessChain %31 %30 %9 %9
205 %50 = OpAccessChain %31 %30 %9 %9
207 %52 = OpAccessChain %31 %30 %9 %9
209 %54 = OpAccessChain %31 %30 %9 %9
211 %56 = OpAccessChain %31 %30 %9 %9
213 %58 = OpAccessChain %31 %30 %9 %9
215 %60 = OpAccessChain %31 %30 %9 %9
217 %62 = OpAccessChain %31 %30 %9 %9
219 %64 = OpCompositeConstruct %23 %33 %35 %37 %39 %41 %43 %45 %47 %49 %51 %53 %55 %57 %59 %61 %63
221 %73 = OpAccessChain %72 %71 %9 %9
226 OpLoopMerge %77 %78 None
230 %81 = OpIAdd %6 %79 %80
232 %82 = OpAccessChain %31 %30 %9 %9
234 %84 = OpAccessChain %31 %30 %9 %80
236 %87 = OpAccessChain %31 %30 %9 %86
238 %90 = OpAccessChain %31 %30 %9 %89
240 %93 = OpAccessChain %31 %30 %9 %92
242 %95 = OpCompositeConstruct %27 %83 %85 %88 %91 %94
244 %97 = OpAccessChain %18 %17 %9 %9
246 %100 = OpISubBorrow %99 %96 %98
247 %101 = OpCompositeExtract %10 %100 1
249 %102 = OpCompositeExtract %10 %100 0
251 %106 = OpAccessChain %105 %104 %102
252 %107 = OpLoad %21 %106
253 %108 = OpAccessChain %105 %25 %79
254 %109 = OpLoad %21 %108
255 %110 = OpFAdd %21 %109 %107
256 %111 = OpAccessChain %105 %25 %79
261 %113 = OpAccessChain %72 %71 %9 %9
262 %114 = OpLoad %6 %113
263 %116 = OpSLessThan %115 %112 %114
264 OpBranchConditional %116 %75 %77
266 %117 = OpAccessChain %72 %71 %9 %9
267 %118 = OpLoad %6 %117
268 %119 = OpAccessChain %105 %25 %118
269 %120 = OpLoad %21 %119
270 %121 = OpAccessChain %31 %30 %9 %80
271 %122 = OpLoad %21 %121
272 %123 = OpFOrdEqual %115 %120 %122
273 OpSelectionMerge %125 None
274 OpBranchConditional %123 %124 %142
276 %129 = OpAccessChain %72 %71 %9 %9
277 %130 = OpLoad %6 %129
278 %131 = OpConvertSToF %21 %130
279 %132 = OpAccessChain %72 %71 %9 %80
280 %133 = OpLoad %6 %132
281 %134 = OpConvertSToF %21 %133
282 %135 = OpAccessChain %72 %71 %9 %80
283 %136 = OpLoad %6 %135
284 %137 = OpConvertSToF %21 %136
285 %138 = OpAccessChain %72 %71 %9 %9
286 %139 = OpLoad %6 %138
287 %140 = OpConvertSToF %21 %139
288 %141 = OpCompositeConstruct %126 %131 %134 %137 %140
292 %143 = OpAccessChain %72 %71 %9 %80
293 %144 = OpLoad %6 %143
294 %145 = OpConvertSToF %21 %144
295 %146 = OpCompositeConstruct %126 %145 %145 %145 %145
303 # uniforms for variant
305 # _GLF_uniform_float_values
306 BUFFER variant__GLF_uniform_float_values DATA_TYPE float[] STD140 DATA
309 # _GLF_uniform_int_values
310 BUFFER variant__GLF_uniform_int_values DATA_TYPE int32[] STD140 DATA
313 # _GLF_uniform_uint_values
314 BUFFER variant__GLF_uniform_uint_values DATA_TYPE int32[] STD140 DATA
318 BUFFER variant_framebuffer FORMAT B8G8R8A8_UNORM
320 PIPELINE graphics variant_pipeline
321 ATTACH variant_vertex_shader
322 ATTACH variant_fragment_shader
323 FRAMEBUFFER_SIZE 32 32
324 BIND BUFFER variant_framebuffer AS color LOCATION 0
325 BIND BUFFER variant__GLF_uniform_float_values AS uniform DESCRIPTOR_SET 0 BINDING 2
326 BIND BUFFER variant__GLF_uniform_int_values AS uniform DESCRIPTOR_SET 0 BINDING 1
327 BIND BUFFER variant__GLF_uniform_uint_values AS uniform DESCRIPTOR_SET 0 BINDING 0
329 CLEAR_COLOR variant_pipeline 0 0 0 255
331 CLEAR variant_pipeline
332 RUN variant_pipeline DRAW_RECT POS 0 0 SIZE 32 32
334 EXPECT variant_framebuffer IDX 0 0 SIZE 32 32 EQ_RGBA 255 0 0 255