• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright © 2020 Google LLC
3  * SPDX-License-Identifier: MIT
4  */
5 
6 #include "freedreno_layout.h"
7 #include "fd_layout_test.h"
8 #include "adreno_common.xml.h"
9 #include "adreno_pm4.xml.h"
10 #include "a6xx.xml.h"
11 
12 #include <stdio.h>
13 
14 static const struct testcase
15    testcases_a630[] =
16       {
17          /* A straightforward first testcase, linear, with an obvious format. */
18          {
19             .format = PIPE_FORMAT_R8G8B8A8_UNORM,
20             .layout =
21                {
22                   .width0 = 32,
23                   .height0 = 32,
24                   .slices =
25                      {
26                         {.offset = 0, .pitch = 256},
27                         {.offset = 8192, .pitch = 256},
28                         {.offset = 12288, .pitch = 256},
29                         {.offset = 14336, .pitch = 256},
30                         {.offset = 15360, .pitch = 256},
31                         {.offset = 15872, .pitch = 256},
32                      },
33                },
34          },
35 
36          /* A tiled/ubwc layout from the blob driver, at a size where the a630
37           * blob driver does something interesting for linear.
38           */
39          {
40             .format = PIPE_FORMAT_R8G8B8A8_UNORM,
41             .layout =
42                {
43                   .tile_mode = TILE6_3,
44                   .ubwc = true,
45                   .width0 = 1024,
46                   .height0 = 1,
47                   .slices =
48                      {
49                         {.offset = 0, .pitch = 4096},
50                         {.offset = 65536, .pitch = 2048},
51                         {.offset = 98304, .pitch = 1024},
52                         {.offset = 114688, .pitch = 512},
53                         {.offset = 122880, .pitch = 256},
54                         {.offset = 126976, .pitch = 256},
55                         {.offset = 131072, .pitch = 256},
56                         {.offset = 135168, .pitch = 256},
57                         {.offset = 139264, .pitch = 256},
58                         {.offset = 143360, .pitch = 256},
59                         {.offset = 147456, .pitch = 256},
60                      },
61                   .ubwc_slices =
62                      {
63                         {.offset = 0, .pitch = 64},
64                         {.offset = 4096, .pitch = 64},
65                         {.offset = 8192, .pitch = 64},
66                         {.offset = 12288, .pitch = 64},
67                         {.offset = 16384, .pitch = 64},
68                         {.offset = 20480, .pitch = 64},
69                         {.offset = 24576, .pitch = 64},
70                         {.offset = 28672, .pitch = 64},
71                         {.offset = 32768, .pitch = 64},
72                         {.offset = 36864, .pitch = 64},
73                         {.offset = 40960, .pitch = 64},
74                      },
75                },
76          },
77 
78 /* An interesting layout from the blob driver on a630, showing that
79  * per-level pitch must be derived from level 0's pitch, not width0.  We
80  * don't do this level 0 pitch disalignment (we pick 4096), so disabled
81  * this test for now.
82  */
83 #if 0
84 	{
85 		.format = PIPE_FORMAT_R8G8B8A8_UNORM,
86 		.layout = {
87 			.width0 = 1024, .height0 = 1,
88 			.slices = {
89 				{ .offset = 0, .pitch = 5120 },
90 				{ .offset = 5120, .pitch = 2560 },
91 				{ .offset = 7680, .pitch = 1280 },
92 				{ .offset = 8960, .pitch = 768 },
93 				{ .offset = 9728, .pitch = 512 },
94 				{ .offset = 10240, .pitch = 256 },
95 				{ .offset = 10496, .pitch = 256 },
96 				{ .offset = 10752, .pitch = 256 },
97 				{ .offset = 11008, .pitch = 256 },
98 				{ .offset = 11264, .pitch = 256 },
99 				{ .offset = 11520, .pitch = 256 },
100 			},
101 		},
102 	},
103 #endif
104 
105          /* A layout that we failed on (129 wide has a surprise level 1 pitch
106           * increase), and the sizes bracketing it.
107           */
108          {
109             .format = PIPE_FORMAT_R8G8B8A8_UNORM,
110             .layout =
111                {
112                   .width0 = 128,
113                   .height0 = 1,
114                   .slices =
115                      {
116                         {.offset = 0, .pitch = 512},
117                         {.offset = 512, .pitch = 256},
118                         {.offset = 768, .pitch = 256},
119                         {.offset = 1024, .pitch = 256},
120                         {.offset = 1280, .pitch = 256},
121                         {.offset = 1536, .pitch = 256},
122                         {.offset = 1792, .pitch = 256},
123                         {.offset = 2048, .pitch = 256},
124                      },
125                },
126          },
127          {
128             .format = PIPE_FORMAT_R8G8B8A8_UNORM,
129             .layout =
130                {
131                   .width0 = 129,
132                   .height0 = 1,
133                   .slices =
134                      {
135                         {.offset = 0, .pitch = 768},
136                         {.offset = 768, .pitch = 512},
137                         {.offset = 1280, .pitch = 256},
138                         {.offset = 1536, .pitch = 256},
139                         {.offset = 1792, .pitch = 256},
140                         {.offset = 2048, .pitch = 256},
141                         {.offset = 2304, .pitch = 256},
142                         {.offset = 2560, .pitch = 256},
143                      },
144                },
145          },
146          {
147             .format = PIPE_FORMAT_R8G8B8A8_UNORM,
148             .layout =
149                {
150                   .width0 = 130,
151                   .height0 = 1,
152                   .slices =
153                      {
154                         {.offset = 0, .pitch = 768},
155                         {.offset = 768, .pitch = 512},
156                         {.offset = 1280, .pitch = 256},
157                         {.offset = 1536, .pitch = 256},
158                         {.offset = 1792, .pitch = 256},
159                         {.offset = 2048, .pitch = 256},
160                         {.offset = 2304, .pitch = 256},
161                         {.offset = 2560, .pitch = 256},
162                      },
163                },
164          },
165 
166          /* The 129 failure seems to be across formats, let's test some cpps */
167          {
168             .format = PIPE_FORMAT_R8_UNORM,
169             .layout =
170                {
171                   .width0 = 129,
172                   .height0 = 1,
173                   .slices =
174                      {
175                         {.offset = 0, .pitch = 192},
176                         {.offset = 192, .pitch = 128},
177                         {.offset = 320, .pitch = 64},
178                         {.offset = 384, .pitch = 64},
179                         {.offset = 448, .pitch = 64},
180                         {.offset = 512, .pitch = 64},
181                         {.offset = 576, .pitch = 64},
182                         {.offset = 640, .pitch = 64},
183                      },
184                },
185          },
186          {
187             .format = PIPE_FORMAT_R16_UINT,
188             .layout =
189                {
190                   .width0 = 129,
191                   .height0 = 1,
192                   .slices =
193                      {
194                         {.offset = 0, .pitch = 384},
195                         {.offset = 384, .pitch = 256},
196                         {.offset = 640, .pitch = 128},
197                         {.offset = 768, .pitch = 128},
198                         {.offset = 896, .pitch = 128},
199                         {.offset = 1024, .pitch = 128},
200                         {.offset = 1152, .pitch = 128},
201                         {.offset = 1280, .pitch = 128},
202                      },
203                },
204          },
205          {
206             .format = PIPE_FORMAT_R32G32B32A32_FLOAT,
207             .layout =
208                {
209                   .width0 = 129,
210                   .height0 = 1,
211                   .slices =
212                      {
213                         {.offset = 0, .pitch = 3072},
214                         {.offset = 3072, .pitch = 2048},
215                         {.offset = 5120, .pitch = 1024},
216                         {.offset = 6144, .pitch = 1024},
217                         {.offset = 7168, .pitch = 1024},
218                         {.offset = 8192, .pitch = 1024},
219                         {.offset = 9216, .pitch = 1024},
220                         {.offset = 10240, .pitch = 1024},
221                      },
222                },
223          },
224 
225          /* The 129 failure replicated at every +256 pixels wide.  Pick one of
226           * them, and this time increase the height as a new variable as well.
227           */
228          {
229             .format = PIPE_FORMAT_R8G8B8A8_UNORM,
230             .layout =
231                {
232                   .width0 = 385,
233                   .height0 = 128,
234                   .slices =
235                      {
236                         {.offset = 0, .pitch = 1792},
237                         {.offset = 229376, .pitch = 1024},
238                         {.offset = 294912, .pitch = 512},
239                         {.offset = 311296, .pitch = 256},
240                         {.offset = 315392, .pitch = 256},
241                         {.offset = 317440, .pitch = 256},
242                         {.offset = 318464, .pitch = 256},
243                         {.offset = 318976, .pitch = 256},
244                         {.offset = 319232, .pitch = 256},
245                      },
246                },
247          },
248 
249          /* At 257-259 (and replicated every +256 pixels) we had another
250             failure. */
251          {
252             .format = PIPE_FORMAT_R8G8B8A8_UNORM,
253             .layout =
254                {
255                   .width0 = 257,
256                   .height0 = 1,
257                   .slices =
258                      {
259                         {.offset = 0, .pitch = 1280},
260                         {.offset = 1280, .pitch = 768},
261                         {.offset = 2048, .pitch = 512},
262                         {.offset = 2560, .pitch = 256},
263                         {.offset = 2816, .pitch = 256},
264                         {.offset = 3072, .pitch = 256},
265                         {.offset = 3328, .pitch = 256},
266                         {.offset = 3584, .pitch = 256},
267                         {.offset = 3840, .pitch = 256},
268                      },
269                },
270          },
271          {
272             .format = PIPE_FORMAT_R8G8B8A8_UNORM,
273             .layout =
274                {
275                   .width0 = 258,
276                   .height0 = 1,
277                   .slices =
278                      {
279                         {.offset = 0, .pitch = 1280},
280                         {.offset = 1280, .pitch = 768},
281                         {.offset = 2048, .pitch = 512},
282                         {.offset = 2560, .pitch = 256},
283                         {.offset = 2816, .pitch = 256},
284                         {.offset = 3072, .pitch = 256},
285                         {.offset = 3328, .pitch = 256},
286                         {.offset = 3584, .pitch = 256},
287                         {.offset = 3840, .pitch = 256},
288                      },
289                },
290          },
291          {
292             .format = PIPE_FORMAT_R8G8B8A8_UNORM,
293             .layout =
294                {
295                   .width0 = 259,
296                   .height0 = 1,
297                   .slices =
298                      {
299                         {.offset = 0, .pitch = 1280},
300                         {.offset = 1280, .pitch = 768},
301                         {.offset = 2048, .pitch = 512},
302                         {.offset = 2560, .pitch = 256},
303                         {.offset = 2816, .pitch = 256},
304                         {.offset = 3072, .pitch = 256},
305                         {.offset = 3328, .pitch = 256},
306                         {.offset = 3584, .pitch = 256},
307                         {.offset = 3840, .pitch = 256},
308                      },
309                },
310          },
311          {
312             .format = PIPE_FORMAT_R8G8B8A8_UNORM,
313             .layout =
314                {
315                   .width0 = 260,
316                   .height0 = 1,
317                   .slices =
318                      {
319                         {.offset = 0, .pitch = 1280},
320                         {.offset = 1280, .pitch = 768},
321                         {.offset = 2048, .pitch = 512},
322                         {.offset = 2560, .pitch = 256},
323                         {.offset = 2816, .pitch = 256},
324                         {.offset = 3072, .pitch = 256},
325                         {.offset = 3328, .pitch = 256},
326                         {.offset = 3584, .pitch = 256},
327                         {.offset = 3840, .pitch = 256},
328                      },
329                },
330          },
331 
332          /* And, again for the 257-9 failure, test a replica with a larger size*/
333          {
334             .format = PIPE_FORMAT_R8G8B8A8_UNORM,
335             .layout =
336                {
337                   .width0 = 513,
338                   .height0 = 32,
339                   .slices =
340                      {
341                         {.offset = 0, .pitch = 2304},
342                         {.offset = 73728, .pitch = 1280},
343                         {.offset = 94208, .pitch = 768},
344                         {.offset = 100352, .pitch = 512},
345                         {.offset = 102400, .pitch = 256},
346                         {.offset = 102912, .pitch = 256},
347                         {.offset = 103168, .pitch = 256},
348                         {.offset = 103424, .pitch = 256},
349                         {.offset = 103680, .pitch = 256},
350                         {.offset = 103936, .pitch = 256},
351                      },
352                },
353          },
354 
355          /* Oh, look.  The 513-517 failure extends up to 518 at the next texture
356           * level!
357           */
358          {
359             .format = PIPE_FORMAT_R8G8B8A8_UNORM,
360             .layout =
361                {
362                   .width0 = 518,
363                   .height0 = 1,
364                   .slices =
365                      {
366                         {.offset = 0, .pitch = 2304},
367                         {.offset = 2304, .pitch = 1280},
368                         {.offset = 3584, .pitch = 768},
369                         {.offset = 4352, .pitch = 512},
370                         {.offset = 4864, .pitch = 256},
371                         {.offset = 5120, .pitch = 256},
372                         {.offset = 5376, .pitch = 256},
373                         {.offset = 5632, .pitch = 256},
374                         {.offset = 5888, .pitch = 256},
375                         {.offset = 6144, .pitch = 256},
376                      },
377                },
378          },
379 
380          /* Tiled mode testing of the unusual 1/2-bytes-per-pixel pitch
381             alignment */
382          {
383             .format = PIPE_FORMAT_R8_UNORM,
384             .layout =
385                {
386                   .tile_mode = TILE6_3,
387                   .width0 = 129,
388                   .height0 = 1,
389                   .slices =
390                      {
391                         {.offset = 0, .pitch = 256},
392                         {.offset = 8192, .pitch = 128},
393                         {.offset = 12288, .pitch = 128},
394                         {.offset = 16384, .pitch = 128},
395                         {.offset = 20480, .pitch = 128},
396                         {.offset = 20608, .pitch = 128},
397                         {.offset = 20736, .pitch = 128},
398                         {.offset = 20864, .pitch = 128},
399                      },
400                },
401          },
402 
403          /* Single-level RGBA8888 UBWC following UBWC alignment rules laid out
404           * in msm_media_info.h to verify that we don't break buffer sharing.
405           */
406          {
407             .format = PIPE_FORMAT_R8G8B8A8_UNORM,
408             .layout =
409                {
410                   .tile_mode = TILE6_3,
411                   .ubwc = true,
412                   .width0 = 16384,
413                   .height0 = 129,
414                   .slices =
415                      {
416                         {.offset = 1024 * 48, .pitch = 16384 * 4},
417                      },
418                   .ubwc_slices =
419                      {
420                         {.offset = 0, .pitch = 1024},
421                      },
422                },
423          },
424 
425          /* UBWC: Pitch comes from POT-aligned level 0. */
426          /* Pitch fixed in this commit, but offsets broken.  Will be fixed in
427           * following commits.
428           */
429          {
430             .format = PIPE_FORMAT_R8G8B8A8_UNORM,
431             .layout =
432                {
433                   .tile_mode = TILE6_3,
434                   .ubwc = true,
435                   .width0 = 2049,
436                   .height0 = 128,
437                   .slices =
438                      {
439                         {.offset = 0, .pitch = 8448},
440                         {.offset = 1081344, .pitch = 4352},
441                         {.offset = 1359872, .pitch = 2304},
442                         {.offset = 1433600, .pitch = 1280},
443                         {.offset = 1454080, .pitch = 768},
444                         {.offset = 1466368, .pitch = 512},
445                         {.offset = 1474560, .pitch = 256},
446                         {.offset = 1478656, .pitch = 256},
447                         {.offset = 1482752, .pitch = 256},
448                         {.offset = 1486848, .pitch = 256},
449                         {.offset = 1490944, .pitch = 256},
450                         {.offset = 1495040, .pitch = 256},
451                      },
452                   .ubwc_slices =
453                      {
454                         {.offset = 0, .pitch = 256},
455                         {.offset = 16384, .pitch = 128},
456                         {.offset = 24576, .pitch = 64},
457                         {.offset = 28672, .pitch = 64},
458                         {.offset = 32768, .pitch = 64},
459                         {.offset = 36864, .pitch = 64},
460                         {.offset = 40960, .pitch = 64},
461                         {.offset = 45056, .pitch = 64},
462                         {.offset = 49152, .pitch = 64},
463                         {.offset = 53248, .pitch = 64},
464                         {.offset = 57344, .pitch = 64},
465                         {.offset = 61440, .pitch = 64},
466                      },
467                },
468          },
469          /* UBWC: Height comes from POT-aligned level 0. */
470          {
471             .format = PIPE_FORMAT_R8G8B8A8_UNORM,
472             .layout =
473                {
474                   .tile_mode = TILE6_3,
475                   .ubwc = true,
476                   .width0 = 1024,
477                   .height0 = 1025,
478                   .slices =
479                      {
480                         {.offset = 0, .pitch = 4096},
481                         {.offset = 4259840, .pitch = 2048},
482                         {.offset = 5308416, .pitch = 1024},
483                         {.offset = 5570560, .pitch = 512},
484                         {.offset = 5636096, .pitch = 256},
485                         {.offset = 5652480, .pitch = 256},
486                         {.offset = 5660672, .pitch = 256},
487                         {.offset = 5664768, .pitch = 256},
488                         {.offset = 5668864, .pitch = 256},
489                         {.offset = 5672960, .pitch = 256},
490                         {.offset = 5677056, .pitch = 256},
491                      },
492                   .ubwc_slices =
493                      {
494                         {.offset = 0, .pitch = 64},
495                         {.offset = 32768, .pitch = 64},
496                         {.offset = 49152, .pitch = 64},
497                         {.offset = 57344, .pitch = 64},
498                         {.offset = 61440, .pitch = 64},
499                         {.offset = 65536, .pitch = 64},
500                         {.offset = 69632, .pitch = 64},
501                         {.offset = 73728, .pitch = 64},
502                         {.offset = 77824, .pitch = 64},
503                         {.offset = 81920, .pitch = 64},
504                         {.offset = 86016, .pitch = 64},
505                      },
506                },
507          },
508 
509          /* UBWC: Get at minimum height of a level across cpps */
510          {
511             .format = PIPE_FORMAT_R16_UINT,
512             .layout =
513                {
514                   .tile_mode = TILE6_3,
515                   .ubwc = true,
516                   .width0 = 16384,
517                   .height0 = 1,
518                   .slices =
519                      {
520                         {.offset = 0, .pitch = 32768},
521                         {.offset = 524288, .pitch = 16384},
522                         {.offset = 786432, .pitch = 8192},
523                         {.offset = 917504, .pitch = 4096},
524                         {.offset = 983040, .pitch = 2048},
525                         {.offset = 1015808, .pitch = 1024},
526                         {.offset = 1032192, .pitch = 512},
527                         {.offset = 1040384, .pitch = 256},
528                         {.offset = 1044480, .pitch = 256},
529                         {.offset = 1048576, .pitch = 256},
530                         {.offset = 1052672, .pitch = 256},
531                         {.offset = 1056768, .pitch = 256},
532                         {.offset = 1060864, .pitch = 256},
533                         {.offset = 1064960, .pitch = 256},
534                         {.offset = 1069056, .pitch = 256},
535                      },
536                   .ubwc_slices =
537                      {
538                         {.offset = 0, .pitch = 1024},
539                         {.offset = 65536, .pitch = 512},
540                         {.offset = 98304, .pitch = 256},
541                         {.offset = 114688, .pitch = 128},
542                         {.offset = 122880, .pitch = 64},
543                         {.offset = 126976, .pitch = 64},
544                         {.offset = 131072, .pitch = 64},
545                         {.offset = 135168, .pitch = 64},
546                         {.offset = 139264, .pitch = 64},
547                         {.offset = 143360, .pitch = 64},
548                         {.offset = 147456, .pitch = 64},
549                         {.offset = 151552, .pitch = 64},
550                         {.offset = 155648, .pitch = 64},
551                         {.offset = 159744, .pitch = 64},
552                         {.offset = 163840, .pitch = 64},
553                      },
554                },
555          },
556          {
557             .format = PIPE_FORMAT_R8G8B8A8_UNORM,
558             .layout =
559                {
560                   .tile_mode = TILE6_3,
561                   .ubwc = true,
562                   .width0 = 16384,
563                   .height0 = 1,
564                   .slices =
565                      {
566                         {.offset = 0, .pitch = 65536},
567                         {.offset = 1048576, .pitch = 32768},
568                         {.offset = 1572864, .pitch = 16384},
569                         {.offset = 1835008, .pitch = 8192},
570                         {.offset = 1966080, .pitch = 4096},
571                         {.offset = 2031616, .pitch = 2048},
572                         {.offset = 2064384, .pitch = 1024},
573                         {.offset = 2080768, .pitch = 512},
574                         {.offset = 2088960, .pitch = 256},
575                         {.offset = 2093056, .pitch = 256},
576                         {.offset = 2097152, .pitch = 256},
577                         {.offset = 2101248, .pitch = 256},
578                         {.offset = 2105344, .pitch = 256},
579                         {.offset = 2109440, .pitch = 256},
580                         {.offset = 2113536, .pitch = 256},
581                      },
582                   .ubwc_slices =
583                      {
584                         {.offset = 0, .pitch = 1024},
585                         {.offset = 65536, .pitch = 512},
586                         {.offset = 98304, .pitch = 256},
587                         {.offset = 114688, .pitch = 128},
588                         {.offset = 122880, .pitch = 64},
589                         {.offset = 126976, .pitch = 64},
590                         {.offset = 131072, .pitch = 64},
591                         {.offset = 135168, .pitch = 64},
592                         {.offset = 139264, .pitch = 64},
593                         {.offset = 143360, .pitch = 64},
594                         {.offset = 147456, .pitch = 64},
595                         {.offset = 151552, .pitch = 64},
596                         {.offset = 155648, .pitch = 64},
597                         {.offset = 159744, .pitch = 64},
598                         {.offset = 163840, .pitch = 64},
599                      },
600                },
601          },
602          {
603             .format = PIPE_FORMAT_R32G32B32A32_FLOAT,
604             .layout =
605                {
606                   .tile_mode = TILE6_3,
607                   .ubwc = true,
608                   .width0 = 16384,
609                   .height0 = 1,
610                   .slices =
611                      {
612                         {.offset = 0, .pitch = 262144},
613                         {.offset = 4194304, .pitch = 131072},
614                         {.offset = 6291456, .pitch = 65536},
615                         {.offset = 7340032, .pitch = 32768},
616                         {.offset = 7864320, .pitch = 16384},
617                         {.offset = 8126464, .pitch = 8192},
618                         {.offset = 8257536, .pitch = 4096},
619                         {.offset = 8323072, .pitch = 2048},
620                         {.offset = 8355840, .pitch = 1024},
621                         {.offset = 8372224, .pitch = 1024},
622                         {.offset = 8388608, .pitch = 1024},
623                         {.offset = 8404992, .pitch = 1024},
624                         {.offset = 8421376, .pitch = 1024},
625                         {.offset = 8437760, .pitch = 1024},
626                         {.offset = 8454144, .pitch = 1024},
627                      },
628                   .ubwc_slices =
629                      {
630                         {.offset = 0, .pitch = 4096},
631                         {.offset = 262144, .pitch = 2048},
632                         {.offset = 393216, .pitch = 1024},
633                         {.offset = 458752, .pitch = 512},
634                         {.offset = 491520, .pitch = 256},
635                         {.offset = 507904, .pitch = 128},
636                         {.offset = 516096, .pitch = 64},
637                         {.offset = 520192, .pitch = 64},
638                         {.offset = 524288, .pitch = 64},
639                         {.offset = 528384, .pitch = 64},
640                         {.offset = 532480, .pitch = 64},
641                         {.offset = 536576, .pitch = 64},
642                         {.offset = 540672, .pitch = 64},
643                         {.offset = 544768, .pitch = 64},
644                         {.offset = 548864, .pitch = 64},
645                      },
646                },
647          },
648 
649          {
650             .format = PIPE_FORMAT_R8G8B8A8_UNORM,
651             .layout =
652                {
653                   .tile_mode = TILE6_3,
654                   .ubwc = true,
655                   .nr_samples = 4,
656                   .width0 = 412,
657                   .height0 = 732,
658                   .slices =
659                      {
660                         {.offset = 0, .pitch = 7168},
661                      },
662                   .ubwc_slices =
663                      {
664                         {.offset = 0, .pitch = 128},
665                      },
666                },
667          },
668 
669          /* Easy 32x32x32 3d case */
670          {
671             .format = PIPE_FORMAT_R9G9B9E5_FLOAT,
672             .is_3d = true,
673             .layout =
674                {
675                   .tile_mode = TILE6_3,
676                   .ubwc = false,
677                   .width0 = 32,
678                   .height0 = 32,
679                   .depth0 = 32,
680                   .slices =
681                      {
682                         {.offset = 0, .pitch = 256, .size0 = 8192},
683                         {.offset = 262144, .pitch = 256, .size0 = 4096},
684                         {.offset = 327680, .pitch = 256, .size0 = 4096},
685                         {.offset = 360448, .pitch = 256, .size0 = 4096},
686                         {.offset = 376832, .pitch = 256, .size0 = 4096},
687                         {.offset = 385024, .pitch = 256},
688                      },
689                },
690          },
691 
692          /* Scale up a bit to 128x128x32 3d */
693          {
694             .format = PIPE_FORMAT_R9G9B9E5_FLOAT,
695             .is_3d = true,
696             .layout =
697                {
698                   .tile_mode = TILE6_3,
699                   .ubwc = false,
700                   .width0 = 128,
701                   .height0 = 128,
702                   .depth0 = 32,
703                   .slices =
704                      {
705                         {.offset = 0, .pitch = 512, .size0 = 65536},
706                         {.offset = 2097152, .pitch = 256, .size0 = 16384},
707                         {.offset = 2359296, .pitch = 256, .size0 = 8192},
708                         {.offset = 2424832, .pitch = 256, .size0 = 8192},
709                         {.offset = 2457600, .pitch = 256, .size0 = 8192},
710                         {.offset = 2473984, .pitch = 256},
711                         {.offset = 2482176, .pitch = 256},
712                         {.offset = 2490368, .pitch = 256},
713                      },
714                },
715          },
716 
717          /* Changing width to 1 changes where minimum layer size happens. */
718          {
719             .format = PIPE_FORMAT_R9G9B9E5_FLOAT,
720             .is_3d = true,
721             .layout =
722                {
723                   .tile_mode = TILE6_LINEAR,
724                   .ubwc = false,
725                   .width0 = 1,
726                   .height0 = 128,
727                   .depth0 = 32,
728                   .slices =
729                      {
730                         {.offset = 0, .pitch = 256, .size0 = 32768},
731                         {.offset = 1048576, .pitch = 256, .size0 = 16384},
732                         {.offset = 1310720, .pitch = 256, .size0 = 16384},
733                         {.offset = 1441792, .pitch = 256, .size0 = 16384},
734                         {.offset = 1507328, .pitch = 256, .size0 = 16384},
735                         {.offset = 1540096, .pitch = 256},
736                         {.offset = 1556480, .pitch = 256},
737                         {.offset = 1572864, .pitch = 256},
738                      },
739                },
740          },
741 
742          /* And increasing width makes it happen later. */
743          {
744             .format = PIPE_FORMAT_R9G9B9E5_FLOAT,
745             .is_3d = true,
746             .layout =
747                {
748                   .tile_mode = TILE6_3,
749                   .ubwc = false,
750                   .width0 = 1024,
751                   .height0 = 128,
752                   .depth0 = 32,
753                   .slices =
754                      {
755                         {.offset = 0, .pitch = 4096, .size0 = 524288},
756                         {.offset = 16777216, .pitch = 2048, .size0 = 131072},
757                         {.offset = 18874368, .pitch = 1024, .size0 = 32768},
758                         {.offset = 19136512, .pitch = 512, .size0 = 8192},
759                         {.offset = 19169280, .pitch = 256, .size0 = 4096},
760                         {.offset = 19177472, .pitch = 256},
761                         {.offset = 19181568, .pitch = 256},
762                         {.offset = 19185664, .pitch = 256},
763                         {.offset = 19189760, .pitch = 256},
764                         {.offset = 19193856, .pitch = 256},
765                         {.offset = 19197952, .pitch = 256},
766                      },
767                },
768          },
769 
770          /* NPOT height case that piglit was catching 3d texture failure in, we
771           * use a higher depth though to get more slice pitches detected from
772           * the blob.
773           */
774          {
775             .format = PIPE_FORMAT_R9G9B9E5_FLOAT,
776             .is_3d = true,
777             .layout =
778                {
779                   .tile_mode = TILE6_3,
780                   .ubwc = false,
781                   .width0 = 128,
782                   .height0 = 129,
783                   .depth0 = 16,
784                   .slices =
785                      {
786                         {.offset = 0, .pitch = 512, .size0 = 73728},
787                         {.offset = 1179648, .pitch = 256, .size0 = 20480},
788                         {.offset = 1343488, .pitch = 256, .size0 = 20480},
789                         {.offset = 1425408, .pitch = 256, .size0 = 20480},
790                         {.offset = 1466368, .pitch = 256},
791                         {.offset = 1486848, .pitch = 256},
792                         {.offset = 1507328, .pitch = 256},
793                         {.offset = 1527808, .pitch = 256},
794                      },
795                },
796          },
797 
798          /* NPOT height case that my first 3d layout ideas failed on. */
799          {
800             .format = PIPE_FORMAT_R9G9B9E5_FLOAT,
801             .is_3d = true,
802             .layout =
803                {
804                   .tile_mode = TILE6_3,
805                   .ubwc = false,
806                   .width0 = 128,
807                   .height0 = 132,
808                   .depth0 = 16,
809                   .slices =
810                      {
811                         {.offset = 0, .pitch = 512, .size0 = 73728},
812                         {.offset = 1179648, .pitch = 256, .size0 = 20480},
813                         {.offset = 1343488, .pitch = 256, .size0 = 20480},
814                         {.offset = 1425408, .pitch = 256, .size0 = 20480},
815                         {.offset = 1466368, .pitch = 256},
816                         {.offset = 1486848, .pitch = 256},
817                         {.offset = 1507328, .pitch = 256},
818                         {.offset = 1527808, .pitch = 256},
819                      },
820                },
821          },
822 
823          /* blob used MIN_LAYERSZ = 0x3000 here.
824           *
825           * This is an interesting case for 3d layout, since pitch stays NPOT for a while.
826           */
827          {
828             .format = PIPE_FORMAT_R9G9B9E5_FLOAT,
829             .is_3d = true,
830             .layout =
831                {
832                   .tile_mode = TILE6_3,
833                   .ubwc = false,
834                   .width0 = 768,
835                   .height0 = 32,
836                   .depth0 = 128,
837                   .slices =
838                      {
839                         {.offset = 0, .pitch = 3072, .size0 = 98304},
840                         {.offset = 12582912, .pitch = 1536, .size0 = 24576},
841                         {.offset = 14155776, .pitch = 768, .size0 = 12288},
842                         {.offset = 14548992, .pitch = 512, .size0 = 12288},
843                         {.offset = 14745600, .pitch = 256, .size0 = 12288},
844                         {.offset = 14843904, .pitch = 256, .size0 = 12288},
845                         {.offset = 14893056, .pitch = 256, .size0 = 12288},
846                         {.offset = 14917632, .pitch = 256},
847                         {.offset = 14929920, .pitch = 256},
848                         {.offset = 14942208, .pitch = 256},
849                      },
850                },
851          },
852 
853          /* dEQP-GLES31.functional.copy_image.mixed.viewclass_128_bits_mixed.rgba32f_rg11_eac.texture3d_to_texture2d */
854 #if 0 /* XXX: We disagree with the blob about level 0 size0, but the testcase passes. */
855          {
856             .format = PIPE_FORMAT_R32G32B32A32_FLOAT,
857             .is_3d = true,
858             .layout =
859                {
860                   .tile_mode = TILE6_3,
861                   .ubwc = false,
862                   .width0 = 129,
863                   .height0 = 129,
864                   .depth0 = 17,
865                   .slices =
866                      {
867                         {.offset = 0, .pitch = 3072, .size0 = 524288},
868                         {.offset = 8912896, .pitch = 2048, .size0 = 131072},
869                         {.offset = 9961472, .pitch = 1024, .size0 = 32768},
870                         {.offset = 10092544, .pitch = 1024, .size0 = 16384},
871                         {.offset = 10125312, .pitch = 1024},
872                         {.offset = 10141696, .pitch = 1024},
873                         {.offset = 10158080, .pitch = 1024},
874                         {.offset = 10174464, .pitch = 1024},
875                      },
876                },
877          },
878 #endif
879 
880          /* Size minification issue found while looking at the above test. */
881          {
882             .format = PIPE_FORMAT_R32G32B32A32_FLOAT,
883             .is_3d = true,
884             .layout =
885                {
886                   .tile_mode = TILE6_3,
887                   .ubwc = false,
888                   .width0 = 129,
889                   .height0 = 9,
890                   .depth0 = 8,
891                   .slices =
892                      {
893                         {.offset = 0, .pitch = 3072, .size0 = 49152},
894                         {.offset = 393216, .pitch = 2048, .size0 = 32768},
895                         {.offset = 524288, .pitch = 1024, .size0 = 32768},
896                         {.offset = 589824, .pitch = 1024},
897                         {.offset = 622592, .pitch = 1024},
898                         {.offset = 655360, .pitch = 1024},
899                         {.offset = 688128, .pitch = 1024},
900                         {.offset = 720896, .pitch = 1024},
901                      },
902                },
903          },
904          {
905             .format = PIPE_FORMAT_R16G16B16A16_UINT,
906             .is_3d = true,
907             .layout =
908                {
909                   .tile_mode = TILE6_3,
910                   .ubwc = true,
911                   .width0 = 56,
912                   .height0 = 32,
913                   .depth0 = 18,
914                   .slices =
915                      {
916                         {.offset = 0, .pitch = 512, .size0 = 16384},
917                      },
918                   .ubwc_slices =
919                      {
920                         {.offset = 0, .pitch = 64},
921                      },
922                },
923          },
924          {
925             .format = PIPE_FORMAT_R32_UINT,
926             .is_3d = true,
927             .layout =
928                {
929                   .tile_mode = TILE6_3,
930                   .ubwc = true,
931                   .width0 = 56,
932                   .height0 = 32,
933                   .depth0 = 16,
934                   .slices =
935                      {
936                         {.offset = 0, .pitch = 256, .size0 = 8192},
937                      },
938                   .ubwc_slices =
939                      {
940                         {.offset = 0, .pitch = 64},
941                      },
942                },
943          },
944          {
945             .format = PIPE_FORMAT_R8G8B8A8_UINT,
946             .is_3d = true,
947             .layout =
948                {
949                   .tile_mode = TILE6_3,
950                   .ubwc = true,
951                   .width0 = 56,
952                   .height0 = 32,
953                   .depth0 = 16,
954                   .slices =
955                      {
956                         {.offset = 0, .pitch = 256, .size0 = 8192},
957                      },
958                   .ubwc_slices =
959                      {
960                         {.offset = 0, .pitch = 64},
961                      },
962                },
963          },
964 
965          /* dEQP-VK.image.texel_view_compatible.graphic.extended.3d_image.texture_read.astc_8x8_unorm_block.r32g32b32a32_uint
966           *
967           * This is an interesting case where the size is 4K-aligned but the
968           * height becomes not aligned, and we have to use MINLAYERSZ to
969           * intervene.
970           *
971           * This test can only use tiled layouts on a750+, and the blob seems
972           * to make this one texture linear rather than deal with the
973           * alignment problem.
974           */
975          {
976             .format = PIPE_FORMAT_R32G32B32A32_FLOAT,
977             .is_3d = true,
978             .layout =
979                {
980                   .tile_mode = TILE6_3,
981                   .ubwc = false,
982                   .width0 = 76,
983                   .height0 = 76,
984                   .depth0 = 1,
985                   .slices =
986                      {
987                         {.offset = 0, .pitch = 2048, .size0 = 163840},
988                         {.offset = 163840, .pitch = 1024, .size0 = 49152},
989                         {.offset = 212992, .pitch = 1024, .size0 = 49152},
990                         {.offset = 262144, .pitch = 1024},
991                         {.offset = 311296, .pitch = 1024},
992                         {.offset = 360448, .pitch = 1024},
993                         {.offset = 409600, .pitch = 1024},
994                      },
995                },
996          },
997 
998 };
999 
1000 /* has_ubwc_linear_mipmap_fallback is supported started from A6XX gen4. */
1001 static const struct testcase
1002    testcases_a660[] =
1003       {
1004          {
1005             .format = PIPE_FORMAT_R8G8B8A8_UNORM,
1006             .layout =
1007                {
1008                   .tile_mode = TILE6_3,
1009                   .ubwc = true,
1010                   .width0 = 1024,
1011                   .height0 = 1,
1012                   .slices =
1013                      {
1014                         {.offset = 0, .pitch = 4096},
1015                         {.offset = 65536, .pitch = 2048},
1016                         {.offset = 98304, .pitch = 1024},
1017                         {.offset = 114688, .pitch = 512},
1018                         {.offset = 122880, .pitch = 256},
1019                         {.offset = 126976, .pitch = 256},
1020                         {.offset = 131072, .pitch = 256},
1021                         {.offset = 135168, .pitch = 256},
1022                         {.offset = 135424, .pitch = 256},
1023                         {.offset = 135680, .pitch = 256},
1024                         {.offset = 135936, .pitch = 256},
1025                      },
1026                   .ubwc_slices =
1027                      {
1028                         {.offset = 0, .pitch = 64},
1029                         {.offset = 4096, .pitch = 64},
1030                         {.offset = 8192, .pitch = 64},
1031                         {.offset = 12288, .pitch = 64},
1032                         {.offset = 16384, .pitch = 64},
1033                         {.offset = 20480, .pitch = 64},
1034                         {.offset = 24576, .pitch = 64},
1035                         {.offset = 0, .pitch = 64},
1036                         {.offset = 0, .pitch = 64},
1037                         {.offset = 0, .pitch = 64},
1038                         {.offset = 0, .pitch = 64},
1039                      },
1040                },
1041          },
1042          {
1043             .format = PIPE_FORMAT_R8G8B8A8_UNORM,
1044             .layout =
1045                {
1046                   .tile_mode = TILE6_3,
1047                   .ubwc = true,
1048                   .width0 = 2049,
1049                   .height0 = 128,
1050                   .slices =
1051                      {
1052                         {.offset = 0, .pitch = 8448},
1053                         {.offset = 1081344, .pitch = 4352},
1054                         {.offset = 1359872, .pitch = 2304},
1055                         {.offset = 1433600, .pitch = 1280},
1056                         {.offset = 1454080, .pitch = 768},
1057                         {.offset = 1466368, .pitch = 512},
1058                         {.offset = 1474560, .pitch = 256},
1059                         {.offset = 1478656, .pitch = 256},
1060                         {.offset = 1482752, .pitch = 256},
1061                         {.offset = 1483008, .pitch = 256},
1062                         {.offset = 1483264, .pitch = 256},
1063                         {.offset = 1483520, .pitch = 256},
1064                      },
1065                   .ubwc_slices =
1066                      {
1067                         {.offset = 0, .pitch = 256},
1068                         {.offset = 16384, .pitch = 128},
1069                         {.offset = 24576, .pitch = 64},
1070                         {.offset = 28672, .pitch = 64},
1071                         {.offset = 32768, .pitch = 64},
1072                         {.offset = 36864, .pitch = 64},
1073                         {.offset = 40960, .pitch = 64},
1074                         {.offset = 45056, .pitch = 64},
1075                         {.offset = 0, .pitch = 64},
1076                         {.offset = 0, .pitch = 64},
1077                         {.offset = 0, .pitch = 64},
1078                         {.offset = 0, .pitch = 64},
1079                      },
1080                },
1081          },
1082 
1083          /* UBWC: Height comes from POT-aligned level 0. */
1084          {
1085             .format = PIPE_FORMAT_R8G8B8A8_UNORM,
1086             .layout =
1087                {
1088                   .tile_mode = TILE6_3,
1089                   .ubwc = true,
1090                   .width0 = 1024,
1091                   .height0 = 1025,
1092                   .slices =
1093                      {
1094                         {.offset = 0, .pitch = 4096},
1095                         {.offset = 4259840, .pitch = 2048},
1096                         {.offset = 5308416, .pitch = 1024},
1097                         {.offset = 5570560, .pitch = 512},
1098                         {.offset = 5636096, .pitch = 256},
1099                         {.offset = 5652480, .pitch = 256},
1100                         {.offset = 5660672, .pitch = 256},
1101                         {.offset = 5664768, .pitch = 256},
1102                         {.offset = 5666816, .pitch = 256},
1103                         {.offset = 5667840, .pitch = 256},
1104                         {.offset = 5668352, .pitch = 256},
1105                      },
1106                   .ubwc_slices =
1107                      {
1108                         {.offset = 0, .pitch = 64},
1109                         {.offset = 32768, .pitch = 64},
1110                         {.offset = 49152, .pitch = 64},
1111                         {.offset = 57344, .pitch = 64},
1112                         {.offset = 61440, .pitch = 64},
1113                         {.offset = 65536, .pitch = 64},
1114                         {.offset = 69632, .pitch = 64},
1115                         {.offset = 0, .pitch = 64},
1116                         {.offset = 0, .pitch = 64},
1117                         {.offset = 0, .pitch = 64},
1118                         {.offset = 0, .pitch = 64},
1119                      },
1120                },
1121          },
1122 
1123          /* UBWC: Get at minimum height of a level across cpps */
1124          {
1125             .format = PIPE_FORMAT_R16_UINT,
1126             .layout =
1127                {
1128                   .tile_mode = TILE6_3,
1129                   .ubwc = true,
1130                   .width0 = 16384,
1131                   .height0 = 1,
1132                   .slices =
1133                      {
1134                         {.offset = 0, .pitch = 32768},
1135                         {.offset = 524288, .pitch = 16384},
1136                         {.offset = 786432, .pitch = 8192},
1137                         {.offset = 917504, .pitch = 4096},
1138                         {.offset = 983040, .pitch = 2048},
1139                         {.offset = 1015808, .pitch = 1024},
1140                         {.offset = 1032192, .pitch = 512},
1141                         {.offset = 1040384, .pitch = 256},
1142                         {.offset = 1044480, .pitch = 256},
1143                         {.offset = 1048576, .pitch = 256},
1144                         {.offset = 1052672, .pitch = 256},
1145                         {.offset = 1056768, .pitch = 256},
1146                         {.offset = 1057024, .pitch = 256},
1147                         {.offset = 1057280, .pitch = 256},
1148                         {.offset = 1057536, .pitch = 256},
1149                      },
1150                   .ubwc_slices =
1151                      {
1152                         {.offset = 0, .pitch = 1024},
1153                         {.offset = 65536, .pitch = 512},
1154                         {.offset = 98304, .pitch = 256},
1155                         {.offset = 114688, .pitch = 128},
1156                         {.offset = 122880, .pitch = 64},
1157                         {.offset = 126976, .pitch = 64},
1158                         {.offset = 131072, .pitch = 64},
1159                         {.offset = 135168, .pitch = 64},
1160                         {.offset = 139264, .pitch = 64},
1161                         {.offset = 143360, .pitch = 64},
1162                         {.offset = 147456, .pitch = 64},
1163                         {.offset = 0, .pitch = 64},
1164                         {.offset = 0, .pitch = 64},
1165                         {.offset = 0, .pitch = 64},
1166                         {.offset = 0, .pitch = 64},
1167                      },
1168                },
1169          },
1170          {
1171             .format = PIPE_FORMAT_R8G8B8A8_UNORM,
1172             .layout =
1173                {
1174                   .tile_mode = TILE6_3,
1175                   .ubwc = true,
1176                   .width0 = 16384,
1177                   .height0 = 1,
1178                   .slices =
1179                      {
1180                         {.offset = 0, .pitch = 65536},
1181                         {.offset = 1048576, .pitch = 32768},
1182                         {.offset = 1572864, .pitch = 16384},
1183                         {.offset = 1835008, .pitch = 8192},
1184                         {.offset = 1966080, .pitch = 4096},
1185                         {.offset = 2031616, .pitch = 2048},
1186                         {.offset = 2064384, .pitch = 1024},
1187                         {.offset = 2080768, .pitch = 512},
1188                         {.offset = 2088960, .pitch = 256},
1189                         {.offset = 2093056, .pitch = 256},
1190                         {.offset = 2097152, .pitch = 256},
1191                         {.offset = 2101248, .pitch = 256},
1192                         {.offset = 2101504, .pitch = 256},
1193                         {.offset = 2101760, .pitch = 256},
1194                         {.offset = 2102016, .pitch = 256},
1195                      },
1196                   .ubwc_slices =
1197                      {
1198                         {.offset = 0, .pitch = 1024},
1199                         {.offset = 65536, .pitch = 512},
1200                         {.offset = 98304, .pitch = 256},
1201                         {.offset = 114688, .pitch = 128},
1202                         {.offset = 122880, .pitch = 64},
1203                         {.offset = 126976, .pitch = 64},
1204                         {.offset = 131072, .pitch = 64},
1205                         {.offset = 135168, .pitch = 64},
1206                         {.offset = 139264, .pitch = 64},
1207                         {.offset = 143360, .pitch = 64},
1208                         {.offset = 147456, .pitch = 64},
1209                         {.offset = 0, .pitch = 64},
1210                         {.offset = 0, .pitch = 64},
1211                         {.offset = 0, .pitch = 64},
1212                         {.offset = 0, .pitch = 64},
1213                      },
1214                },
1215          },
1216          {
1217             .format = PIPE_FORMAT_R32G32B32A32_FLOAT,
1218             .layout =
1219                {
1220                   .tile_mode = TILE6_3,
1221                   .ubwc = true,
1222                   .width0 = 16384,
1223                   .height0 = 1,
1224                   .slices =
1225                      {
1226                         {.offset = 0, .pitch = 262144},
1227                         {.offset = 4194304, .pitch = 131072},
1228                         {.offset = 6291456, .pitch = 65536},
1229                         {.offset = 7340032, .pitch = 32768},
1230                         {.offset = 7864320, .pitch = 16384},
1231                         {.offset = 8126464, .pitch = 8192},
1232                         {.offset = 8257536, .pitch = 4096},
1233                         {.offset = 8323072, .pitch = 2048},
1234                         {.offset = 8355840, .pitch = 1024},
1235                         {.offset = 8372224, .pitch = 1024},
1236                         {.offset = 8388608, .pitch = 1024},
1237                         {.offset = 8404992, .pitch = 1024},
1238                         {.offset = 8406016, .pitch = 1024},
1239                         {.offset = 8407040, .pitch = 1024},
1240                         {.offset = 8408064, .pitch = 1024},
1241                      },
1242                   .ubwc_slices =
1243                      {
1244                         {.offset = 0, .pitch = 4096},
1245                         {.offset = 262144, .pitch = 2048},
1246                         {.offset = 393216, .pitch = 1024},
1247                         {.offset = 458752, .pitch = 512},
1248                         {.offset = 491520, .pitch = 256},
1249                         {.offset = 507904, .pitch = 128},
1250                         {.offset = 516096, .pitch = 64},
1251                         {.offset = 520192, .pitch = 64},
1252                         {.offset = 524288, .pitch = 64},
1253                         {.offset = 528384, .pitch = 64},
1254                         {.offset = 532480, .pitch = 64},
1255                         {.offset = 0, .pitch = 64},
1256                         {.offset = 0, .pitch = 64},
1257                         {.offset = 0, .pitch = 64},
1258                         {.offset = 0, .pitch = 64},
1259                      },
1260                },
1261          },
1262       };
1263 
1264 int
main(int argc,char ** argv)1265 main(int argc, char **argv)
1266 {
1267    int ret = 0;
1268 
1269    struct fd_dev_id a630_dev_id = {
1270       .gpu_id = 630,
1271    };
1272    for (int i = 0; i < ARRAY_SIZE(testcases_a630); i++) {
1273       if (!fdl_test_layout(&testcases_a630[i], &a630_dev_id))
1274          ret = 1;
1275    }
1276 
1277    struct fd_dev_id a660_dev_id = {
1278       .gpu_id = 660,
1279    };
1280    for (int i = 0; i < ARRAY_SIZE(testcases_a660); i++) {
1281       if (!fdl_test_layout(&testcases_a660[i], &a660_dev_id))
1282          ret = 1;
1283    }
1284 
1285    return ret;
1286 }
1287