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