• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1#!amber
2
3# Copyright 2021 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_1 _GLF_uniform_int_values[1]
31# #define _int_2 _GLF_uniform_int_values[2]
32# #define _float_1_0 _GLF_uniform_float_values[0]
33# #define _float_0_0 _GLF_uniform_float_values[1]
34#
35# precision highp float;
36#
37# precision highp int;
38#
39# // Contents of _GLF_uniform_int_values: [0, 1, 2]
40# layout(set = 0, binding = 0) uniform buf0
41# {
42#     int _GLF_uniform_int_values[3];
43# };
44# // Contents of _GLF_uniform_float_values: [1.0, 0.0]
45# layout(set = 0, binding = 1) uniform buf1
46# {
47#     float _GLF_uniform_float_values[2];
48# };
49# layout(location = 0) out vec4 _GLF_color;
50#
51# int arr[64] = int[64](1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1);
52#
53# void main()
54# {
55#     ivec2 v = ivec2(_int_1);
56#     bool b = false;
57#     _GLF_color = vec4(_int_1);
58#
59#     do
60#     {
61#         // True for the second iteration.
62#         if(v.x > _int_1)
63#         {
64#             break;
65#         }
66#
67#         for(int i = 1; i < 8; i ++)
68#         {
69#             for(int j = 1; j < 8; j ++)
70#             {
71#                 // Always true.
72#                 if(arr[i] == _int_1)
73#                 {
74#                     v = ivec2(j, i);
75#
76#                     // Always false.
77#                     if(gl_FragCoord.x < _float_0_0)
78#                     {
79#                         continue;
80#                     }
81#
82#                     b = true;
83#
84#                     // Always false.
85#                     if(gl_FragCoord.y < _float_0_0)
86#                     {
87#                         _GLF_color = vec4(_int_0);
88#
89#                         if(gl_FragCoord.y < _float_1_0)
90#                         {
91#                             if(gl_FragCoord.y >= _float_1_0)
92#                             {
93#                                 _GLF_color = vec4(_float_1_0);
94#                             }
95#                             return;
96#                         }
97#                     }
98#                 }
99#             }
100#         }
101#
102#         // Overwrites a value that is already one.
103#         arr[v.x + v.y] = _int_1;
104#
105#         // Always false.
106#         if(arr[_int_1] == _int_2)
107#         {
108#             discard;
109#         }
110#     }
111#     while(b);
112#
113#     _GLF_color = vec4(_int_1, _int_0, _int_0, _int_1);
114# }
115SHADER fragment variant_fragment_shader SPIRV-ASM TARGET_ENV spv1.0
116; SPIR-V
117; Version: 1.0
118; Generator: Khronos Glslang Reference Front End; 10
119; Bound: 167
120; Schema: 0
121               OpCapability Shader
122          %1 = OpExtInstImport "GLSL.std.450"
123               OpMemoryModel Logical GLSL450
124               OpEntryPoint Fragment %4 "main" %34 %83
125               OpExecutionMode %4 OriginUpperLeft
126               OpSource ESSL 320
127               OpName %4 "main"
128               OpName %11 "arr"
129               OpName %16 "v"
130               OpName %19 "buf0"
131               OpMemberName %19 0 "_GLF_uniform_int_values"
132               OpName %21 ""
133               OpName %29 "b"
134               OpName %34 "_GLF_color"
135               OpName %53 "i"
136               OpName %62 "j"
137               OpName %83 "gl_FragCoord"
138               OpName %89 "buf1"
139               OpMemberName %89 0 "_GLF_uniform_float_values"
140               OpName %91 ""
141               OpDecorate %18 ArrayStride 16
142               OpMemberDecorate %19 0 Offset 0
143               OpDecorate %19 Block
144               OpDecorate %21 DescriptorSet 0
145               OpDecorate %21 Binding 0
146               OpDecorate %34 Location 0
147               OpDecorate %83 BuiltIn FragCoord
148               OpDecorate %88 ArrayStride 16
149               OpMemberDecorate %89 0 Offset 0
150               OpDecorate %89 Block
151               OpDecorate %91 DescriptorSet 0
152               OpDecorate %91 Binding 1
153          %2 = OpTypeVoid
154          %3 = OpTypeFunction %2
155          %6 = OpTypeInt 32 1
156          %7 = OpTypeInt 32 0
157          %8 = OpConstant %7 64
158          %9 = OpTypeArray %6 %8
159         %10 = OpTypePointer Private %9
160         %11 = OpVariable %10 Private
161         %12 = OpConstant %6 1
162         %13 = OpConstantComposite %9 %12 %12 %12 %12 %12 %12 %12 %12 %12 %12 %12 %12 %12 %12 %12 %12 %12 %12 %12 %12 %12 %12 %12 %12 %12 %12 %12 %12 %12 %12 %12 %12 %12 %12 %12 %12 %12 %12 %12 %12 %12 %12 %12 %12 %12 %12 %12 %12 %12 %12 %12 %12 %12 %12 %12 %12 %12 %12 %12 %12 %12 %12 %12 %12
163         %14 = OpTypeVector %6 2
164         %15 = OpTypePointer Function %14
165         %17 = OpConstant %7 3
166         %18 = OpTypeArray %6 %17
167         %19 = OpTypeStruct %18
168         %20 = OpTypePointer Uniform %19
169         %21 = OpVariable %20 Uniform
170         %22 = OpConstant %6 0
171         %23 = OpTypePointer Uniform %6
172         %27 = OpTypeBool
173         %28 = OpTypePointer Function %27
174         %30 = OpConstantFalse %27
175         %31 = OpTypeFloat 32
176         %32 = OpTypeVector %31 4
177         %33 = OpTypePointer Output %32
178         %34 = OpVariable %33 Output
179         %43 = OpConstant %7 0
180         %44 = OpTypePointer Function %6
181         %60 = OpConstant %6 8
182         %71 = OpTypePointer Private %6
183         %82 = OpTypePointer Input %32
184         %83 = OpVariable %82 Input
185         %84 = OpTypePointer Input %31
186         %87 = OpConstant %7 2
187         %88 = OpTypeArray %31 %87
188         %89 = OpTypeStruct %88
189         %90 = OpTypePointer Uniform %89
190         %91 = OpVariable %90 Uniform
191         %92 = OpTypePointer Uniform %31
192         %99 = OpConstantTrue %27
193        %100 = OpConstant %7 1
194        %146 = OpConstant %6 2
195          %4 = OpFunction %2 None %3
196          %5 = OpLabel
197         %16 = OpVariable %15 Function
198         %29 = OpVariable %28 Function
199         %53 = OpVariable %44 Function
200         %62 = OpVariable %44 Function
201               OpStore %11 %13
202         %24 = OpAccessChain %23 %21 %22 %12
203         %25 = OpLoad %6 %24
204         %26 = OpCompositeConstruct %14 %25 %25
205               OpStore %16 %26
206               OpStore %29 %30
207         %35 = OpAccessChain %23 %21 %22 %12
208         %36 = OpLoad %6 %35
209         %37 = OpConvertSToF %31 %36
210         %38 = OpCompositeConstruct %32 %37 %37 %37 %37
211               OpStore %34 %38
212               OpBranch %39
213         %39 = OpLabel
214               OpLoopMerge %41 %42 None
215               OpBranch %40
216         %40 = OpLabel
217         %45 = OpAccessChain %44 %16 %43
218         %46 = OpLoad %6 %45
219         %47 = OpAccessChain %23 %21 %22 %12
220         %48 = OpLoad %6 %47
221         %49 = OpSGreaterThan %27 %46 %48
222               OpSelectionMerge %51 None
223               OpBranchConditional %49 %50 %51
224         %50 = OpLabel
225               OpBranch %41
226         %51 = OpLabel
227               OpStore %53 %12
228               OpBranch %54
229         %54 = OpLabel
230               OpLoopMerge %56 %57 None
231               OpBranch %58
232         %58 = OpLabel
233         %59 = OpLoad %6 %53
234         %61 = OpSLessThan %27 %59 %60
235               OpBranchConditional %61 %55 %56
236         %55 = OpLabel
237               OpStore %62 %12
238               OpBranch %63
239         %63 = OpLabel
240               OpLoopMerge %65 %66 None
241               OpBranch %67
242         %67 = OpLabel
243         %68 = OpLoad %6 %62
244         %69 = OpSLessThan %27 %68 %60
245               OpBranchConditional %69 %64 %65
246         %64 = OpLabel
247         %70 = OpLoad %6 %53
248         %72 = OpAccessChain %71 %11 %70
249         %73 = OpLoad %6 %72
250         %74 = OpAccessChain %23 %21 %22 %12
251         %75 = OpLoad %6 %74
252         %76 = OpIEqual %27 %73 %75
253               OpSelectionMerge %78 None
254               OpBranchConditional %76 %77 %78
255         %77 = OpLabel
256         %79 = OpLoad %6 %62
257         %80 = OpLoad %6 %53
258         %81 = OpCompositeConstruct %14 %79 %80
259               OpStore %16 %81
260         %85 = OpAccessChain %84 %83 %43
261         %86 = OpLoad %31 %85
262         %93 = OpAccessChain %92 %91 %22 %12
263         %94 = OpLoad %31 %93
264         %95 = OpFOrdLessThan %27 %86 %94
265               OpSelectionMerge %97 None
266               OpBranchConditional %95 %96 %97
267         %96 = OpLabel
268               OpBranch %66
269         %97 = OpLabel
270               OpStore %29 %99
271        %101 = OpAccessChain %84 %83 %100
272        %102 = OpLoad %31 %101
273        %103 = OpAccessChain %92 %91 %22 %12
274        %104 = OpLoad %31 %103
275        %105 = OpFOrdLessThan %27 %102 %104
276               OpSelectionMerge %107 None
277               OpBranchConditional %105 %106 %107
278        %106 = OpLabel
279        %108 = OpAccessChain %23 %21 %22 %22
280        %109 = OpLoad %6 %108
281        %110 = OpConvertSToF %31 %109
282        %111 = OpCompositeConstruct %32 %110 %110 %110 %110
283               OpStore %34 %111
284        %112 = OpAccessChain %84 %83 %100
285        %113 = OpLoad %31 %112
286        %114 = OpAccessChain %92 %91 %22 %22
287        %115 = OpLoad %31 %114
288        %116 = OpFOrdLessThan %27 %113 %115
289               OpSelectionMerge %118 None
290               OpBranchConditional %116 %117 %118
291        %117 = OpLabel
292        %119 = OpAccessChain %84 %83 %100
293        %120 = OpLoad %31 %119
294        %121 = OpAccessChain %92 %91 %22 %22
295        %122 = OpLoad %31 %121
296        %123 = OpFOrdGreaterThanEqual %27 %120 %122
297               OpSelectionMerge %125 None
298               OpBranchConditional %123 %124 %125
299        %124 = OpLabel
300        %126 = OpAccessChain %92 %91 %22 %22
301        %127 = OpLoad %31 %126
302        %128 = OpCompositeConstruct %32 %127 %127 %127 %127
303               OpStore %34 %128
304               OpBranch %125
305        %125 = OpLabel
306               OpReturn
307        %118 = OpLabel
308               OpBranch %107
309        %107 = OpLabel
310               OpBranch %78
311         %78 = OpLabel
312               OpBranch %66
313         %66 = OpLabel
314        %130 = OpLoad %6 %62
315        %131 = OpIAdd %6 %130 %12
316               OpStore %62 %131
317               OpBranch %63
318         %65 = OpLabel
319               OpBranch %57
320         %57 = OpLabel
321        %132 = OpLoad %6 %53
322        %133 = OpIAdd %6 %132 %12
323               OpStore %53 %133
324               OpBranch %54
325         %56 = OpLabel
326        %134 = OpAccessChain %44 %16 %43
327        %135 = OpLoad %6 %134
328        %136 = OpAccessChain %44 %16 %100
329        %137 = OpLoad %6 %136
330        %138 = OpIAdd %6 %135 %137
331        %139 = OpAccessChain %23 %21 %22 %12
332        %140 = OpLoad %6 %139
333        %141 = OpAccessChain %71 %11 %138
334               OpStore %141 %140
335        %142 = OpAccessChain %23 %21 %22 %12
336        %143 = OpLoad %6 %142
337        %144 = OpAccessChain %71 %11 %143
338        %145 = OpLoad %6 %144
339        %147 = OpAccessChain %23 %21 %22 %146
340        %148 = OpLoad %6 %147
341        %149 = OpIEqual %27 %145 %148
342               OpSelectionMerge %151 None
343               OpBranchConditional %149 %150 %151
344        %150 = OpLabel
345               OpKill
346        %151 = OpLabel
347               OpBranch %42
348         %42 = OpLabel
349        %153 = OpLoad %27 %29
350               OpBranchConditional %153 %39 %41
351         %41 = OpLabel
352        %154 = OpAccessChain %23 %21 %22 %12
353        %155 = OpLoad %6 %154
354        %156 = OpConvertSToF %31 %155
355        %157 = OpAccessChain %23 %21 %22 %22
356        %158 = OpLoad %6 %157
357        %159 = OpConvertSToF %31 %158
358        %160 = OpAccessChain %23 %21 %22 %22
359        %161 = OpLoad %6 %160
360        %162 = OpConvertSToF %31 %161
361        %163 = OpAccessChain %23 %21 %22 %12
362        %164 = OpLoad %6 %163
363        %165 = OpConvertSToF %31 %164
364        %166 = OpCompositeConstruct %32 %156 %159 %162 %165
365               OpStore %34 %166
366               OpReturn
367               OpFunctionEnd
368END
369
370# uniforms for variant
371
372# _GLF_uniform_float_values
373BUFFER variant__GLF_uniform_float_values DATA_TYPE float[] STD140 DATA
374 1.0 0.0
375END
376# _GLF_uniform_int_values
377BUFFER variant__GLF_uniform_int_values DATA_TYPE int32[] STD140 DATA
378 0 1 2
379END
380
381BUFFER variant_framebuffer FORMAT B8G8R8A8_UNORM
382
383PIPELINE graphics variant_pipeline
384  ATTACH variant_vertex_shader
385  ATTACH variant_fragment_shader
386  FRAMEBUFFER_SIZE 16 16
387  BIND BUFFER variant_framebuffer AS color LOCATION 0
388  BIND BUFFER variant__GLF_uniform_float_values AS uniform DESCRIPTOR_SET 0 BINDING 1
389  BIND BUFFER variant__GLF_uniform_int_values AS uniform DESCRIPTOR_SET 0 BINDING 0
390END
391CLEAR_COLOR variant_pipeline 0 0 0 255
392
393CLEAR variant_pipeline
394RUN variant_pipeline DRAW_RECT POS 0 0 SIZE 16 16
395
396EXPECT variant_framebuffer IDX 0 0 SIZE 16 16 EQ_RGBA 255 0 0 255
397