• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1#!amber
2
3# Copyright 2022 Google LLC
4#
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
8#
9#     http://www.apache.org/licenses/LICENSE-2.0
10#
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.
16
17
18# A test for a coverage-gap found by the GraphicsFuzz project.
19
20# Short description: A fragment shader that covers specific LLVM code paths
21
22# The test passes because the shader always writes red.
23
24SHADER vertex variant_vertex_shader PASSTHROUGH
25
26# variant_fragment_shader is derived from the following GLSL:
27# #version 320 es
28#
29# #define _int_0 _GLF_uniform_int_values[0]
30# #define _int_5 _GLF_uniform_int_values[1]
31# #define _int_1 _GLF_uniform_int_values[2]
32# #define _float_2_0 _GLF_uniform_float_values[0]
33#
34# precision highp float;
35# precision highp int;
36#
37# // Contents of _GLF_uniform_float_values: 2.0
38# layout(set = 0, binding = 0) uniform buf0
39# {
40#     float _GLF_uniform_float_values[1];
41# };
42#
43# // Contents of _GLF_uniform_int_values: [0, 5, 1]
44# layout(set = 0, binding = 1) uniform buf1
45# {
46#     int _GLF_uniform_int_values[3];
47# };
48#
49# layout(location = 0) out vec4 _GLF_color;
50#
51# void main()
52# {
53#     vec4 v = vec4(_int_1);
54#     int a = _int_0;
55#
56#     // Iterates once.
57#     for(int m = 1; m <= 1; m *= 2)
58#     {
59#         // Iterates five times.
60#         for(int i = 1; i < 10; i += 2 * m)
61#         {
62#             a++;
63#
64#             // min(i - 1, 10) is always i - 1 because i < 10 from the loop condition above.
65#             // Therefore the condition below becomes i <= i - 1, which is always false.
66#             while(i <= min(i - 1, 10))
67#             {
68#                 for(int j = 3; j >= 1; j--)
69#                 {
70#                     v[j] /= _float_2_0;
71#                 }
72#             }
73#         }
74#     }
75#
76#     // Always true.
77#     if(a == _int_5 && v == vec4(_int_1))
78#     {
79#         _GLF_color = vec4(_int_1, _int_0, _int_0, _int_1);
80#     }
81#     else
82#     {
83#         _GLF_color = vec4(_int_0);
84#     }
85# }
86SHADER fragment variant_fragment_shader SPIRV-ASM TARGET_ENV spv1.0
87; SPIR-V
88; Version: 1.0
89; Generator: Khronos Glslang Reference Front End; 10
90; Bound: 127
91; Schema: 0
92               OpCapability Shader
93          %1 = OpExtInstImport "GLSL.std.450"
94               OpMemoryModel Logical GLSL450
95               OpEntryPoint Fragment %4 "main" %108
96               OpExecutionMode %4 OriginUpperLeft
97               OpSource ESSL 320
98               OpName %4 "main"
99               OpName %9 "v"
100               OpName %14 "buf1"
101               OpMemberName %14 0 "_GLF_uniform_int_values"
102               OpName %16 ""
103               OpName %25 "a"
104               OpName %28 "m"
105               OpName %38 "i"
106               OpName %59 "j"
107               OpName %71 "buf0"
108               OpMemberName %71 0 "_GLF_uniform_float_values"
109               OpName %73 ""
110               OpName %108 "_GLF_color"
111               OpDecorate %13 ArrayStride 16
112               OpMemberDecorate %14 0 Offset 0
113               OpDecorate %14 Block
114               OpDecorate %16 DescriptorSet 0
115               OpDecorate %16 Binding 1
116               OpDecorate %70 ArrayStride 16
117               OpMemberDecorate %71 0 Offset 0
118               OpDecorate %71 Block
119               OpDecorate %73 DescriptorSet 0
120               OpDecorate %73 Binding 0
121               OpDecorate %108 Location 0
122          %2 = OpTypeVoid
123          %3 = OpTypeFunction %2
124          %6 = OpTypeFloat 32
125          %7 = OpTypeVector %6 4
126          %8 = OpTypePointer Function %7
127         %10 = OpTypeInt 32 1
128         %11 = OpTypeInt 32 0
129         %12 = OpConstant %11 3
130         %13 = OpTypeArray %10 %12
131         %14 = OpTypeStruct %13
132         %15 = OpTypePointer Uniform %14
133         %16 = OpVariable %15 Uniform
134         %17 = OpConstant %10 0
135         %18 = OpConstant %10 2
136         %19 = OpTypePointer Uniform %10
137         %24 = OpTypePointer Function %10
138         %29 = OpConstant %10 1
139         %36 = OpTypeBool
140         %45 = OpConstant %10 10
141         %60 = OpConstant %10 3
142         %69 = OpConstant %11 1
143         %70 = OpTypeArray %6 %69
144         %71 = OpTypeStruct %70
145         %72 = OpTypePointer Uniform %71
146         %73 = OpVariable %72 Uniform
147         %74 = OpTypePointer Uniform %6
148         %77 = OpTypePointer Function %6
149        %101 = OpTypeVector %36 4
150        %107 = OpTypePointer Output %7
151        %108 = OpVariable %107 Output
152          %4 = OpFunction %2 None %3
153          %5 = OpLabel
154          %9 = OpVariable %8 Function
155         %25 = OpVariable %24 Function
156         %28 = OpVariable %24 Function
157         %38 = OpVariable %24 Function
158         %59 = OpVariable %24 Function
159         %20 = OpAccessChain %19 %16 %17 %18
160         %21 = OpLoad %10 %20
161         %22 = OpConvertSToF %6 %21
162         %23 = OpCompositeConstruct %7 %22 %22 %22 %22
163               OpStore %9 %23
164         %26 = OpAccessChain %19 %16 %17 %17
165         %27 = OpLoad %10 %26
166               OpStore %25 %27
167               OpStore %28 %29
168               OpBranch %30
169         %30 = OpLabel
170               OpLoopMerge %32 %33 None
171               OpBranch %34
172         %34 = OpLabel
173         %35 = OpLoad %10 %28
174         %37 = OpSLessThanEqual %36 %35 %29
175               OpBranchConditional %37 %31 %32
176         %31 = OpLabel
177               OpStore %38 %29
178               OpBranch %39
179         %39 = OpLabel
180               OpLoopMerge %41 %42 None
181               OpBranch %43
182         %43 = OpLabel
183         %44 = OpLoad %10 %38
184         %46 = OpSLessThan %36 %44 %45
185               OpBranchConditional %46 %40 %41
186         %40 = OpLabel
187         %47 = OpLoad %10 %25
188         %48 = OpIAdd %10 %47 %29
189               OpStore %25 %48
190               OpBranch %49
191         %49 = OpLabel
192               OpLoopMerge %51 %52 None
193               OpBranch %53
194         %53 = OpLabel
195         %54 = OpLoad %10 %38
196         %55 = OpLoad %10 %38
197         %56 = OpISub %10 %55 %29
198         %57 = OpExtInst %10 %1 SMin %56 %45
199         %58 = OpSLessThanEqual %36 %54 %57
200               OpBranchConditional %58 %50 %51
201         %50 = OpLabel
202               OpStore %59 %60
203               OpBranch %61
204         %61 = OpLabel
205               OpLoopMerge %63 %64 None
206               OpBranch %65
207         %65 = OpLabel
208         %66 = OpLoad %10 %59
209         %67 = OpSGreaterThanEqual %36 %66 %29
210               OpBranchConditional %67 %62 %63
211         %62 = OpLabel
212         %68 = OpLoad %10 %59
213         %75 = OpAccessChain %74 %73 %17 %17
214         %76 = OpLoad %6 %75
215         %78 = OpAccessChain %77 %9 %68
216         %79 = OpLoad %6 %78
217         %80 = OpFDiv %6 %79 %76
218         %81 = OpAccessChain %77 %9 %68
219               OpStore %81 %80
220               OpBranch %64
221         %64 = OpLabel
222         %82 = OpLoad %10 %59
223         %83 = OpISub %10 %82 %29
224               OpStore %59 %83
225               OpBranch %61
226         %63 = OpLabel
227               OpBranch %52
228         %52 = OpLabel
229               OpBranch %49
230         %51 = OpLabel
231               OpBranch %42
232         %42 = OpLabel
233         %84 = OpLoad %10 %28
234         %85 = OpIMul %10 %18 %84
235         %86 = OpLoad %10 %38
236         %87 = OpIAdd %10 %86 %85
237               OpStore %38 %87
238               OpBranch %39
239         %41 = OpLabel
240               OpBranch %33
241         %33 = OpLabel
242         %88 = OpLoad %10 %28
243         %89 = OpIMul %10 %88 %18
244               OpStore %28 %89
245               OpBranch %30
246         %32 = OpLabel
247         %90 = OpLoad %10 %25
248         %91 = OpAccessChain %19 %16 %17 %29
249         %92 = OpLoad %10 %91
250         %93 = OpIEqual %36 %90 %92
251               OpSelectionMerge %95 None
252               OpBranchConditional %93 %94 %95
253         %94 = OpLabel
254         %96 = OpLoad %7 %9
255         %97 = OpAccessChain %19 %16 %17 %18
256         %98 = OpLoad %10 %97
257         %99 = OpConvertSToF %6 %98
258        %100 = OpCompositeConstruct %7 %99 %99 %99 %99
259        %102 = OpFOrdEqual %101 %96 %100
260        %103 = OpAll %36 %102
261               OpBranch %95
262         %95 = OpLabel
263        %104 = OpPhi %36 %93 %32 %103 %94
264               OpSelectionMerge %106 None
265               OpBranchConditional %104 %105 %122
266        %105 = OpLabel
267        %109 = OpAccessChain %19 %16 %17 %18
268        %110 = OpLoad %10 %109
269        %111 = OpConvertSToF %6 %110
270        %112 = OpAccessChain %19 %16 %17 %17
271        %113 = OpLoad %10 %112
272        %114 = OpConvertSToF %6 %113
273        %115 = OpAccessChain %19 %16 %17 %17
274        %116 = OpLoad %10 %115
275        %117 = OpConvertSToF %6 %116
276        %118 = OpAccessChain %19 %16 %17 %18
277        %119 = OpLoad %10 %118
278        %120 = OpConvertSToF %6 %119
279        %121 = OpCompositeConstruct %7 %111 %114 %117 %120
280               OpStore %108 %121
281               OpBranch %106
282        %122 = OpLabel
283        %123 = OpAccessChain %19 %16 %17 %17
284        %124 = OpLoad %10 %123
285        %125 = OpConvertSToF %6 %124
286        %126 = OpCompositeConstruct %7 %125 %125 %125 %125
287               OpStore %108 %126
288               OpBranch %106
289        %106 = OpLabel
290               OpReturn
291               OpFunctionEnd
292END
293
294# uniforms for variant
295
296# _GLF_uniform_int_values
297BUFFER variant__GLF_uniform_int_values DATA_TYPE int32[] STD140 DATA
298 0 5 1
299END
300# _GLF_uniform_float_values
301BUFFER variant__GLF_uniform_float_values DATA_TYPE float[] STD140 DATA
302 2.0
303END
304
305BUFFER variant_framebuffer FORMAT B8G8R8A8_UNORM
306
307PIPELINE graphics variant_pipeline
308  ATTACH variant_vertex_shader
309  ATTACH variant_fragment_shader
310  FRAMEBUFFER_SIZE 32 32
311  BIND BUFFER variant_framebuffer AS color LOCATION 0
312  BIND BUFFER variant__GLF_uniform_int_values AS uniform DESCRIPTOR_SET 0 BINDING 1
313  BIND BUFFER variant__GLF_uniform_float_values AS uniform DESCRIPTOR_SET 0 BINDING 0
314END
315CLEAR_COLOR variant_pipeline 0 0 0 255
316
317CLEAR variant_pipeline
318RUN variant_pipeline DRAW_RECT POS 0 0 SIZE 32 32
319
320EXPECT variant_framebuffer IDX 0 0 SIZE 32 32 EQ_RGBA 255 0 0 255
321