• 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# #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]
33#
34# precision highp float;
35# precision highp int;
36#
37# // Contents of _GLF_uniform_float_values: 1.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: [3, 1, 0, 2]
44# layout(set = 0, binding = 1) uniform buf1
45# {
46#     int _GLF_uniform_int_values[4];
47# };
48#
49# // Contents of zero: 0.0
50# layout(set = 0, binding = 2) uniform buf2 {
51#     float zero;
52# };
53#
54# layout(location = 0) out vec4 _GLF_color;
55#
56# void main()
57# {
58#     mat4 m = mat4(_int_1);
59#     m = mat4(_int_1);
60#     vec4 v = vec4(_int_2);
61#     int a = _int_0;
62#
63#     for(int i = _int_1; a < _int_3; i++)
64#     {
65#         a++;
66#
67#         // Iterates for j = 1 and j = 0 when i = 1.
68#         for(int j = _int_1; i <= _int_1 && a < _int_3; j--)
69#         {
70#             a++;
71#
72#             // Executed twice:
73#             // v[1] = m[1][1] = 1
74#             // v[0] = m[0][1] = 0
75#             v[j] = m[j][i];
76#
77#             // Always false.
78#             if(zero > _float_1_0)
79#             {
80#                 discard;
81#             }
82#         }
83#     }
84#
85#     // Always true.
86#     if(v == vec4(_int_0, _int_1, _int_2, _int_2))
87#     {
88#         _GLF_color = vec4(_int_1, _int_0, _int_0, _int_1);
89#     }
90#     else
91#     {
92#         _GLF_color = vec4(_int_0);
93#     }
94# }
95SHADER fragment variant_fragment_shader SPIRV-ASM TARGET_ENV spv1.0
96; SPIR-V
97; Version: 1.0
98; Generator: Khronos Glslang Reference Front End; 10
99; Bound: 154
100; Schema: 0
101               OpCapability Shader
102          %1 = OpExtInstImport "GLSL.std.450"
103               OpMemoryModel Logical GLSL450
104               OpEntryPoint Fragment %4 "main" %135
105               OpExecutionMode %4 OriginUpperLeft
106               OpSource ESSL 320
107               OpName %4 "main"
108               OpName %10 "m"
109               OpName %15 "buf1"
110               OpMemberName %15 0 "_GLF_uniform_int_values"
111               OpName %17 ""
112               OpName %40 "v"
113               OpName %47 "a"
114               OpName %51 "i"
115               OpName %66 "j"
116               OpName %94 "buf2"
117               OpMemberName %94 0 "zero"
118               OpName %96 ""
119               OpName %102 "buf0"
120               OpMemberName %102 0 "_GLF_uniform_float_values"
121               OpName %104 ""
122               OpName %135 "_GLF_color"
123               OpDecorate %14 ArrayStride 16
124               OpMemberDecorate %15 0 Offset 0
125               OpDecorate %15 Block
126               OpDecorate %17 DescriptorSet 0
127               OpDecorate %17 Binding 1
128               OpMemberDecorate %94 0 Offset 0
129               OpDecorate %94 Block
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
138          %2 = OpTypeVoid
139          %3 = OpTypeFunction %2
140          %6 = OpTypeFloat 32
141          %7 = OpTypeVector %6 4
142          %8 = OpTypeMatrix %7 4
143          %9 = OpTypePointer Function %8
144         %11 = OpTypeInt 32 1
145         %12 = OpTypeInt 32 0
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
160         %62 = OpTypeBool
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
175          %5 = OpLabel
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
182         %22 = OpLoad %11 %21
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
189               OpStore %10 %30
190         %31 = OpAccessChain %20 %17 %18 %19
191         %32 = OpLoad %11 %31
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
198               OpStore %10 %38
199         %42 = OpAccessChain %20 %17 %18 %41
200         %43 = OpLoad %11 %42
201         %44 = OpConvertSToF %6 %43
202         %45 = OpCompositeConstruct %7 %44 %44 %44 %44
203               OpStore %40 %45
204         %49 = OpAccessChain %20 %17 %18 %48
205         %50 = OpLoad %11 %49
206               OpStore %47 %50
207         %52 = OpAccessChain %20 %17 %18 %19
208         %53 = OpLoad %11 %52
209               OpStore %51 %53
210               OpBranch %54
211         %54 = OpLabel
212               OpLoopMerge %56 %57 None
213               OpBranch %58
214         %58 = OpLabel
215         %59 = OpLoad %11 %47
216         %60 = OpAccessChain %20 %17 %18 %18
217         %61 = OpLoad %11 %60
218         %63 = OpSLessThan %62 %59 %61
219               OpBranchConditional %63 %55 %56
220         %55 = OpLabel
221         %64 = OpLoad %11 %47
222         %65 = OpIAdd %11 %64 %19
223               OpStore %47 %65
224         %67 = OpAccessChain %20 %17 %18 %19
225         %68 = OpLoad %11 %67
226               OpStore %66 %68
227               OpBranch %69
228         %69 = OpLabel
229               OpLoopMerge %71 %72 None
230               OpBranch %73
231         %73 = OpLabel
232         %74 = OpLoad %11 %51
233         %75 = OpAccessChain %20 %17 %18 %19
234         %76 = OpLoad %11 %75
235         %77 = OpSLessThanEqual %62 %74 %76
236               OpSelectionMerge %79 None
237               OpBranchConditional %77 %78 %79
238         %78 = OpLabel
239         %80 = OpLoad %11 %47
240         %81 = OpAccessChain %20 %17 %18 %18
241         %82 = OpLoad %11 %81
242         %83 = OpSLessThan %62 %80 %82
243               OpBranch %79
244         %79 = OpLabel
245         %84 = OpPhi %62 %77 %73 %83 %78
246               OpBranchConditional %84 %70 %71
247         %70 = OpLabel
248         %85 = OpLoad %11 %47
249         %86 = OpIAdd %11 %85 %19
250               OpStore %47 %86
251         %87 = OpLoad %11 %66
252         %88 = OpLoad %11 %66
253         %89 = OpLoad %11 %51
254         %91 = OpAccessChain %90 %10 %88 %89
255         %92 = OpLoad %6 %91
256         %93 = OpAccessChain %90 %40 %87
257               OpStore %93 %92
258         %98 = OpAccessChain %97 %96 %18
259         %99 = OpLoad %6 %98
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
265        %108 = OpLabel
266               OpKill
267        %109 = OpLabel
268               OpBranch %72
269         %72 = OpLabel
270        %111 = OpLoad %11 %66
271        %112 = OpISub %11 %111 %19
272               OpStore %66 %112
273               OpBranch %69
274         %71 = OpLabel
275               OpBranch %57
276         %57 = OpLabel
277        %113 = OpLoad %11 %51
278        %114 = OpIAdd %11 %113 %19
279               OpStore %51 %114
280               OpBranch %54
281         %56 = OpLabel
282        %115 = OpLoad %7 %40
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
300        %132 = OpLabel
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
314               OpStore %135 %148
315               OpBranch %133
316        %149 = OpLabel
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
321               OpStore %135 %153
322               OpBranch %133
323        %133 = OpLabel
324               OpReturn
325               OpFunctionEnd
326END
327
328# uniforms for variant
329
330# zero
331BUFFER variant_zero DATA_TYPE float STD140 DATA
332 0.0
333END
334# _GLF_uniform_int_values
335BUFFER variant__GLF_uniform_int_values DATA_TYPE int32[] STD140 DATA
336 3 1 0 2
337END
338# _GLF_uniform_float_values
339BUFFER variant__GLF_uniform_float_values DATA_TYPE float[] STD140 DATA
340 1.0
341END
342
343BUFFER variant_framebuffer FORMAT B8G8R8A8_UNORM
344
345PIPELINE 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
353END
354CLEAR_COLOR variant_pipeline 0 0 0 255
355
356CLEAR variant_pipeline
357RUN variant_pipeline DRAW_RECT POS 0 0 SIZE 32 32
358
359EXPECT variant_framebuffer IDX 0 0 SIZE 32 32 EQ_RGBA 255 0 0 255
360