• 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 NIR 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_8 _GLF_uniform_int_values[0]
30# #define _int_10 _GLF_uniform_int_values[1]
31# #define _int_1 _GLF_uniform_int_values[2]
32# #define _int_0 _GLF_uniform_int_values[3]
33# #define _int_2 _GLF_uniform_int_values[4]
34# #define _int_3 _GLF_uniform_int_values[5]
35# #define _int_4 _GLF_uniform_int_values[6]
36# #define _int_5 _GLF_uniform_int_values[7]
37# #define _int_6 _GLF_uniform_int_values[8]
38# #define _int_7 _GLF_uniform_int_values[9]
39# #define _int_9 _GLF_uniform_int_values[10]
40# #define _int_17 _GLF_uniform_int_values[11]
41# #define _int_11 _GLF_uniform_int_values[12]
42# #define _int_15 _GLF_uniform_int_values[13]
43# #define _int_16 _GLF_uniform_int_values[14]
44# #define _int_12 _GLF_uniform_int_values[15]
45# #define _int_13 _GLF_uniform_int_values[16]
46# #define _int_14 _GLF_uniform_int_values[17]
47# #define _int_18 _GLF_uniform_int_values[18]
48# #define _int_19 _GLF_uniform_int_values[19]
49#
50# precision highp float;
51# precision highp int;
52#
53# // Contents of _GLF_uniform_int_values: [8, 10, 1, 0, 2, 3, 4, 5, 6, 7, 9, 17, 11, 15, 16, 12, 13, 14, 18, 19]
54# layout(set = 0, binding = 0) uniform buf0
55# {
56#     int _GLF_uniform_int_values[20];
57# };
58#
59# // Contents of one: 1
60# layout(set = 0, binding = 1) uniform buf1
61# {
62#     int one;
63# };
64#
65# layout(location = 0) out vec4 _GLF_color;
66#
67# void main()
68# {
69#     int arr0[10] = int[10](_int_0, _int_1, _int_2, _int_3, _int_4, _int_5, _int_6, _int_7, _int_8, _int_9);
70#     int arr1[10] = int[10](_int_10, _int_11, _int_12, _int_13, _int_14, _int_15, _int_16, _int_17, _int_18, _int_19);
71#
72#     for(int a = _int_6; a < _int_8; a++)
73#     {
74#         int limiter0 = _int_0;
75#         while(limiter0 < _int_2)
76#         {
77#             limiter0++;
78#
79#             int limiter1 = _int_1;
80#             // Iterated for b = 0..3.
81#             for(int b = _int_0; b < _int_10; b ++)
82#             {
83#                 if(limiter1 > _int_3)
84#                 {
85#                     break;
86#                 }
87#                 limiter1++;
88#                 arr0[b] = arr1[a];
89#             }
90#         }
91#
92#         int limiter2 = 0;
93#         // Does the same assignment five times.
94#         while(limiter2 < 5)
95#         {
96#             limiter2++;
97#             arr0[1] = arr1[1];
98#         }
99#
100#         // Iterated once.
101#         do
102#         {
103#             int limiter3 = 0;
104#             // Iterated for d = 0..4.
105#             for(int d = 0; d < 10; d ++)
106#             {
107#                 if(limiter3 > 4)
108#                 {
109#                     break;
110#                 }
111#                 limiter3 ++;
112#                 arr1[d] = arr0[d];
113#             }
114#         }
115#         while(_int_1 == _int_0);
116#     }
117#
118#     // Reference values.
119#     int ref0[10] = int[10](_int_17, _int_11, _int_17, _int_3, _int_4, _int_5, _int_6, _int_7, _int_8, _int_9);
120#     int ref1[10] = int[10](_int_17, _int_11, _int_17, _int_3, _int_4, _int_15, _int_16, _int_17, _int_18, _int_19);
121#
122#     // Return red if no error is detected.
123#     _GLF_color = vec4(_int_1, _int_0, _int_0, _int_1);
124#
125#     for(int i = _int_0; i < _int_10; i ++)
126#     {
127#         // Unexpected value. Change the color to black.
128#         if(arr0[i] != ref0[i] || arr1[i] != ref1[i])
129#         {
130#             _GLF_color = vec4(_int_0);
131#         }
132#     }
133# }
134SHADER fragment variant_fragment_shader SPIRV-ASM TARGET_ENV spv1.0
135; SPIR-V
136; Version: 1.0
137; Generator: Khronos Glslang Reference Front End; 10
138; Bound: 289
139; Schema: 0
140               OpCapability Shader
141          %1 = OpExtInstImport "GLSL.std.450"
142               OpMemoryModel Logical GLSL450
143               OpEntryPoint Fragment %4 "main" %234
144               OpExecutionMode %4 OriginUpperLeft
145               OpSource ESSL 320
146               OpName %4 "main"
147               OpName %11 "arr0"
148               OpName %14 "buf0"
149               OpMemberName %14 0 "_GLF_uniform_int_values"
150               OpName %16 ""
151               OpName %49 "arr1"
152               OpName %82 "a"
153               OpName %95 "limiter0"
154               OpName %109 "limiter1"
155               OpName %112 "b"
156               OpName %140 "limiter2"
157               OpName %157 "limiter3"
158               OpName %158 "d"
159               OpName %187 "ref0"
160               OpName %209 "ref1"
161               OpName %234 "_GLF_color"
162               OpName %248 "i"
163               OpName %286 "buf1"
164               OpMemberName %286 0 "one"
165               OpName %288 ""
166               OpDecorate %13 ArrayStride 16
167               OpMemberDecorate %14 0 Offset 0
168               OpDecorate %14 Block
169               OpDecorate %16 DescriptorSet 0
170               OpDecorate %16 Binding 0
171               OpDecorate %234 Location 0
172               OpMemberDecorate %286 0 Offset 0
173               OpDecorate %286 Block
174               OpDecorate %288 DescriptorSet 0
175               OpDecorate %288 Binding 1
176          %2 = OpTypeVoid
177          %3 = OpTypeFunction %2
178          %6 = OpTypeInt 32 1
179          %7 = OpTypeInt 32 0
180          %8 = OpConstant %7 10
181          %9 = OpTypeArray %6 %8
182         %10 = OpTypePointer Function %9
183         %12 = OpConstant %7 20
184         %13 = OpTypeArray %6 %12
185         %14 = OpTypeStruct %13
186         %15 = OpTypePointer Uniform %14
187         %16 = OpVariable %15 Uniform
188         %17 = OpConstant %6 0
189         %18 = OpConstant %6 3
190         %19 = OpTypePointer Uniform %6
191         %22 = OpConstant %6 2
192         %25 = OpConstant %6 4
193         %28 = OpConstant %6 5
194         %31 = OpConstant %6 6
195         %34 = OpConstant %6 7
196         %37 = OpConstant %6 8
197         %40 = OpConstant %6 9
198         %45 = OpConstant %6 10
199         %50 = OpConstant %6 1
200         %53 = OpConstant %6 12
201         %56 = OpConstant %6 15
202         %59 = OpConstant %6 16
203         %62 = OpConstant %6 17
204         %65 = OpConstant %6 13
205         %68 = OpConstant %6 14
206         %71 = OpConstant %6 11
207         %74 = OpConstant %6 18
208         %77 = OpConstant %6 19
209         %81 = OpTypePointer Function %6
210         %93 = OpTypeBool
211        %231 = OpTypeFloat 32
212        %232 = OpTypeVector %231 4
213        %233 = OpTypePointer Output %232
214        %234 = OpVariable %233 Output
215        %286 = OpTypeStruct %6
216        %287 = OpTypePointer Uniform %286
217        %288 = OpVariable %287 Uniform
218          %4 = OpFunction %2 None %3
219          %5 = OpLabel
220         %11 = OpVariable %10 Function
221         %49 = OpVariable %10 Function
222         %82 = OpVariable %81 Function
223         %95 = OpVariable %81 Function
224        %109 = OpVariable %81 Function
225        %112 = OpVariable %81 Function
226        %140 = OpVariable %81 Function
227        %157 = OpVariable %81 Function
228        %158 = OpVariable %81 Function
229        %187 = OpVariable %10 Function
230        %209 = OpVariable %10 Function
231        %248 = OpVariable %81 Function
232         %20 = OpAccessChain %19 %16 %17 %18
233         %21 = OpLoad %6 %20
234         %23 = OpAccessChain %19 %16 %17 %22
235         %24 = OpLoad %6 %23
236         %26 = OpAccessChain %19 %16 %17 %25
237         %27 = OpLoad %6 %26
238         %29 = OpAccessChain %19 %16 %17 %28
239         %30 = OpLoad %6 %29
240         %32 = OpAccessChain %19 %16 %17 %31
241         %33 = OpLoad %6 %32
242         %35 = OpAccessChain %19 %16 %17 %34
243         %36 = OpLoad %6 %35
244         %38 = OpAccessChain %19 %16 %17 %37
245         %39 = OpLoad %6 %38
246         %41 = OpAccessChain %19 %16 %17 %40
247         %42 = OpLoad %6 %41
248         %43 = OpAccessChain %19 %16 %17 %17
249         %44 = OpLoad %6 %43
250         %46 = OpAccessChain %19 %16 %17 %45
251         %47 = OpLoad %6 %46
252         %48 = OpCompositeConstruct %9 %21 %24 %27 %30 %33 %36 %39 %42 %44 %47
253               OpStore %11 %48
254         %51 = OpAccessChain %19 %16 %17 %50
255         %52 = OpLoad %6 %51
256         %54 = OpAccessChain %19 %16 %17 %53
257         %55 = OpLoad %6 %54
258         %57 = OpAccessChain %19 %16 %17 %56
259         %58 = OpLoad %6 %57
260         %60 = OpAccessChain %19 %16 %17 %59
261         %61 = OpLoad %6 %60
262         %63 = OpAccessChain %19 %16 %17 %62
263         %64 = OpLoad %6 %63
264         %66 = OpAccessChain %19 %16 %17 %65
265         %67 = OpLoad %6 %66
266         %69 = OpAccessChain %19 %16 %17 %68
267         %70 = OpLoad %6 %69
268         %72 = OpAccessChain %19 %16 %17 %71
269         %73 = OpLoad %6 %72
270         %75 = OpAccessChain %19 %16 %17 %74
271         %76 = OpLoad %6 %75
272         %78 = OpAccessChain %19 %16 %17 %77
273         %79 = OpLoad %6 %78
274         %80 = OpCompositeConstruct %9 %52 %55 %58 %61 %64 %67 %70 %73 %76 %79
275               OpStore %49 %80
276         %83 = OpAccessChain %19 %16 %17 %37
277         %84 = OpLoad %6 %83
278               OpStore %82 %84
279               OpBranch %85
280         %85 = OpLabel
281               OpLoopMerge %87 %88 None
282               OpBranch %89
283         %89 = OpLabel
284         %90 = OpLoad %6 %82
285         %91 = OpAccessChain %19 %16 %17 %17
286         %92 = OpLoad %6 %91
287         %94 = OpSLessThan %93 %90 %92
288               OpBranchConditional %94 %86 %87
289         %86 = OpLabel
290         %96 = OpAccessChain %19 %16 %17 %18
291         %97 = OpLoad %6 %96
292               OpStore %95 %97
293               OpBranch %98
294         %98 = OpLabel
295               OpLoopMerge %100 %101 None
296               OpBranch %102
297        %102 = OpLabel
298        %103 = OpLoad %6 %95
299        %104 = OpAccessChain %19 %16 %17 %25
300        %105 = OpLoad %6 %104
301        %106 = OpSLessThan %93 %103 %105
302               OpBranchConditional %106 %99 %100
303         %99 = OpLabel
304        %107 = OpLoad %6 %95
305        %108 = OpIAdd %6 %107 %50
306               OpStore %95 %108
307        %110 = OpAccessChain %19 %16 %17 %22
308        %111 = OpLoad %6 %110
309               OpStore %109 %111
310        %113 = OpAccessChain %19 %16 %17 %18
311        %114 = OpLoad %6 %113
312               OpStore %112 %114
313               OpBranch %115
314        %115 = OpLabel
315               OpLoopMerge %117 %118 None
316               OpBranch %119
317        %119 = OpLabel
318        %120 = OpLoad %6 %112
319        %121 = OpAccessChain %19 %16 %17 %50
320        %122 = OpLoad %6 %121
321        %123 = OpSLessThan %93 %120 %122
322               OpBranchConditional %123 %116 %117
323        %116 = OpLabel
324        %124 = OpLoad %6 %109
325        %125 = OpAccessChain %19 %16 %17 %28
326        %126 = OpLoad %6 %125
327        %127 = OpSGreaterThan %93 %124 %126
328               OpSelectionMerge %129 None
329               OpBranchConditional %127 %128 %129
330        %128 = OpLabel
331               OpBranch %117
332        %129 = OpLabel
333        %131 = OpLoad %6 %109
334        %132 = OpIAdd %6 %131 %50
335               OpStore %109 %132
336        %133 = OpLoad %6 %112
337        %134 = OpLoad %6 %82
338        %135 = OpAccessChain %81 %49 %134
339        %136 = OpLoad %6 %135
340        %137 = OpAccessChain %81 %11 %133
341               OpStore %137 %136
342               OpBranch %118
343        %118 = OpLabel
344        %138 = OpLoad %6 %112
345        %139 = OpIAdd %6 %138 %50
346               OpStore %112 %139
347               OpBranch %115
348        %117 = OpLabel
349               OpBranch %101
350        %101 = OpLabel
351               OpBranch %98
352        %100 = OpLabel
353               OpStore %140 %17
354               OpBranch %141
355        %141 = OpLabel
356               OpLoopMerge %143 %144 None
357               OpBranch %145
358        %145 = OpLabel
359        %146 = OpLoad %6 %140
360        %147 = OpSLessThan %93 %146 %28
361               OpBranchConditional %147 %142 %143
362        %142 = OpLabel
363        %148 = OpLoad %6 %140
364        %149 = OpIAdd %6 %148 %50
365               OpStore %140 %149
366        %150 = OpAccessChain %81 %49 %50
367        %151 = OpLoad %6 %150
368        %152 = OpAccessChain %81 %11 %50
369               OpStore %152 %151
370               OpBranch %144
371        %144 = OpLabel
372               OpBranch %141
373        %143 = OpLabel
374               OpBranch %153
375        %153 = OpLabel
376               OpLoopMerge %155 %156 None
377               OpBranch %154
378        %154 = OpLabel
379               OpStore %157 %17
380               OpStore %158 %17
381               OpBranch %159
382        %159 = OpLabel
383               OpLoopMerge %161 %162 None
384               OpBranch %163
385        %163 = OpLabel
386        %164 = OpLoad %6 %158
387        %165 = OpSLessThan %93 %164 %45
388               OpBranchConditional %165 %160 %161
389        %160 = OpLabel
390        %166 = OpLoad %6 %157
391        %167 = OpSGreaterThan %93 %166 %25
392               OpSelectionMerge %169 None
393               OpBranchConditional %167 %168 %169
394        %168 = OpLabel
395               OpBranch %161
396        %169 = OpLabel
397        %171 = OpLoad %6 %157
398        %172 = OpIAdd %6 %171 %50
399               OpStore %157 %172
400        %173 = OpLoad %6 %158
401        %174 = OpLoad %6 %158
402        %175 = OpAccessChain %81 %11 %174
403        %176 = OpLoad %6 %175
404        %177 = OpAccessChain %81 %49 %173
405               OpStore %177 %176
406               OpBranch %162
407        %162 = OpLabel
408        %178 = OpLoad %6 %158
409        %179 = OpIAdd %6 %178 %50
410               OpStore %158 %179
411               OpBranch %159
412        %161 = OpLabel
413               OpBranch %156
414        %156 = OpLabel
415        %180 = OpAccessChain %19 %16 %17 %22
416        %181 = OpLoad %6 %180
417        %182 = OpAccessChain %19 %16 %17 %18
418        %183 = OpLoad %6 %182
419        %184 = OpIEqual %93 %181 %183
420               OpBranchConditional %184 %153 %155
421        %155 = OpLabel
422               OpBranch %88
423         %88 = OpLabel
424        %185 = OpLoad %6 %82
425        %186 = OpIAdd %6 %185 %50
426               OpStore %82 %186
427               OpBranch %85
428         %87 = OpLabel
429        %188 = OpAccessChain %19 %16 %17 %71
430        %189 = OpLoad %6 %188
431        %190 = OpAccessChain %19 %16 %17 %53
432        %191 = OpLoad %6 %190
433        %192 = OpAccessChain %19 %16 %17 %71
434        %193 = OpLoad %6 %192
435        %194 = OpAccessChain %19 %16 %17 %28
436        %195 = OpLoad %6 %194
437        %196 = OpAccessChain %19 %16 %17 %31
438        %197 = OpLoad %6 %196
439        %198 = OpAccessChain %19 %16 %17 %34
440        %199 = OpLoad %6 %198
441        %200 = OpAccessChain %19 %16 %17 %37
442        %201 = OpLoad %6 %200
443        %202 = OpAccessChain %19 %16 %17 %40
444        %203 = OpLoad %6 %202
445        %204 = OpAccessChain %19 %16 %17 %17
446        %205 = OpLoad %6 %204
447        %206 = OpAccessChain %19 %16 %17 %45
448        %207 = OpLoad %6 %206
449        %208 = OpCompositeConstruct %9 %189 %191 %193 %195 %197 %199 %201 %203 %205 %207
450               OpStore %187 %208
451        %210 = OpAccessChain %19 %16 %17 %71
452        %211 = OpLoad %6 %210
453        %212 = OpAccessChain %19 %16 %17 %53
454        %213 = OpLoad %6 %212
455        %214 = OpAccessChain %19 %16 %17 %71
456        %215 = OpLoad %6 %214
457        %216 = OpAccessChain %19 %16 %17 %28
458        %217 = OpLoad %6 %216
459        %218 = OpAccessChain %19 %16 %17 %31
460        %219 = OpLoad %6 %218
461        %220 = OpAccessChain %19 %16 %17 %65
462        %221 = OpLoad %6 %220
463        %222 = OpAccessChain %19 %16 %17 %68
464        %223 = OpLoad %6 %222
465        %224 = OpAccessChain %19 %16 %17 %71
466        %225 = OpLoad %6 %224
467        %226 = OpAccessChain %19 %16 %17 %74
468        %227 = OpLoad %6 %226
469        %228 = OpAccessChain %19 %16 %17 %77
470        %229 = OpLoad %6 %228
471        %230 = OpCompositeConstruct %9 %211 %213 %215 %217 %219 %221 %223 %225 %227 %229
472               OpStore %209 %230
473        %235 = OpAccessChain %19 %16 %17 %22
474        %236 = OpLoad %6 %235
475        %237 = OpConvertSToF %231 %236
476        %238 = OpAccessChain %19 %16 %17 %18
477        %239 = OpLoad %6 %238
478        %240 = OpConvertSToF %231 %239
479        %241 = OpAccessChain %19 %16 %17 %18
480        %242 = OpLoad %6 %241
481        %243 = OpConvertSToF %231 %242
482        %244 = OpAccessChain %19 %16 %17 %22
483        %245 = OpLoad %6 %244
484        %246 = OpConvertSToF %231 %245
485        %247 = OpCompositeConstruct %232 %237 %240 %243 %246
486               OpStore %234 %247
487        %249 = OpAccessChain %19 %16 %17 %18
488        %250 = OpLoad %6 %249
489               OpStore %248 %250
490               OpBranch %251
491        %251 = OpLabel
492               OpLoopMerge %253 %254 None
493               OpBranch %255
494        %255 = OpLabel
495        %256 = OpLoad %6 %248
496        %257 = OpAccessChain %19 %16 %17 %50
497        %258 = OpLoad %6 %257
498        %259 = OpSLessThan %93 %256 %258
499               OpBranchConditional %259 %252 %253
500        %252 = OpLabel
501        %260 = OpLoad %6 %248
502        %261 = OpAccessChain %81 %11 %260
503        %262 = OpLoad %6 %261
504        %263 = OpLoad %6 %248
505        %264 = OpAccessChain %81 %187 %263
506        %265 = OpLoad %6 %264
507        %266 = OpINotEqual %93 %262 %265
508        %267 = OpLogicalNot %93 %266
509               OpSelectionMerge %269 None
510               OpBranchConditional %267 %268 %269
511        %268 = OpLabel
512        %270 = OpLoad %6 %248
513        %271 = OpAccessChain %81 %49 %270
514        %272 = OpLoad %6 %271
515        %273 = OpLoad %6 %248
516        %274 = OpAccessChain %81 %209 %273
517        %275 = OpLoad %6 %274
518        %276 = OpINotEqual %93 %272 %275
519               OpBranch %269
520        %269 = OpLabel
521        %277 = OpPhi %93 %266 %252 %276 %268
522               OpSelectionMerge %279 None
523               OpBranchConditional %277 %278 %279
524        %278 = OpLabel
525        %280 = OpAccessChain %19 %16 %17 %18
526        %281 = OpLoad %6 %280
527        %282 = OpConvertSToF %231 %281
528        %283 = OpCompositeConstruct %232 %282 %282 %282 %282
529               OpStore %234 %283
530               OpBranch %279
531        %279 = OpLabel
532               OpBranch %254
533        %254 = OpLabel
534        %284 = OpLoad %6 %248
535        %285 = OpIAdd %6 %284 %50
536               OpStore %248 %285
537               OpBranch %251
538        %253 = OpLabel
539               OpReturn
540               OpFunctionEnd
541END
542
543# uniforms for variant
544
545# one
546BUFFER variant_one DATA_TYPE int32 STD140 DATA
547 1
548END
549# _GLF_uniform_int_values
550BUFFER variant__GLF_uniform_int_values DATA_TYPE int32[] STD140 DATA
551 8 10 1 0 2 3 4 5 6 7 9 17 11 15 16 12 13 14 18 19
552END
553
554BUFFER variant_framebuffer FORMAT B8G8R8A8_UNORM
555
556PIPELINE graphics variant_pipeline
557  ATTACH variant_vertex_shader
558  ATTACH variant_fragment_shader
559  FRAMEBUFFER_SIZE 16 16
560  BIND BUFFER variant_framebuffer AS color LOCATION 0
561  BIND BUFFER variant_one AS uniform DESCRIPTOR_SET 0 BINDING 1
562  BIND BUFFER variant__GLF_uniform_int_values AS uniform DESCRIPTOR_SET 0 BINDING 0
563END
564CLEAR_COLOR variant_pipeline 0 0 0 255
565
566CLEAR variant_pipeline
567RUN variant_pipeline DRAW_RECT POS 0 0 SIZE 16 16
568
569EXPECT variant_framebuffer IDX 0 0 SIZE 16 16 EQ_RGBA 255 0 0 255
570