freedreno/fdl: Separate the list of a6xx testcases from the the test code.
[mesa.git] / src / freedreno / fdl / fd6_layout_test.c
1 /*
2 * Copyright © 2020 Google LLC
3 *
4 * Permission is hereby granted, free of charge, to any person obtaining a
5 * copy of this software and associated documentation files (the "Software"),
6 * to deal in the Software without restriction, including without limitation
7 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 * and/or sell copies of the Software, and to permit persons to whom the
9 * Software is furnished to do so, subject to the following conditions:
10 *
11 * The above copyright notice and this permission notice (including the next
12 * paragraph) shall be included in all copies or substantial portions of the
13 * Software.
14 *
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
18 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
20 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
21 * IN THE SOFTWARE.
22 */
23
24 #include "freedreno_layout.h"
25 #include "fd_layout_test.h"
26 #include "adreno_common.xml.h"
27 #include "a6xx.xml.h"
28
29 #include <stdio.h>
30
31 static const struct testcase testcases[] = {
32 /* A straightforward first testcase, linear, with an obvious format. */
33 {
34 .format = PIPE_FORMAT_R8G8B8A8_UNORM,
35 .layout = {
36 .width0 = 32, .height0 = 32,
37 .slices = {
38 { .offset = 0, .pitch = 256 },
39 { .offset = 8192, .pitch = 256 },
40 { .offset = 12288, .pitch = 256 },
41 { .offset = 14336, .pitch = 256 },
42 { .offset = 15360, .pitch = 256 },
43 { .offset = 15872, .pitch = 256 },
44 },
45 },
46 },
47
48 /* A tiled/ubwc layout from the blob driver, at a size where the a630 blob
49 * driver does something interesting for linear.
50 */
51 {
52 .format = PIPE_FORMAT_R8G8B8A8_UNORM,
53 .layout = {
54 .tile_mode = TILE6_3,
55 .ubwc = true,
56 .width0 = 1024, .height0 = 1,
57 .slices = {
58 { .offset = 0, .pitch = 4096 },
59 { .offset = 65536, .pitch = 2048 },
60 { .offset = 98304, .pitch = 1024 },
61 { .offset = 114688, .pitch = 512 },
62 { .offset = 122880, .pitch = 256 },
63 { .offset = 126976, .pitch = 256 },
64 { .offset = 131072, .pitch = 256 },
65 { .offset = 135168, .pitch = 256 },
66 { .offset = 139264, .pitch = 256 },
67 { .offset = 143360, .pitch = 256 },
68 { .offset = 147456, .pitch = 256 },
69 },
70 .ubwc_slices = {
71 { .offset = 0, .pitch = 64 },
72 { .offset = 4096, .pitch = 64 },
73 { .offset = 8192, .pitch = 64 },
74 { .offset = 12288, .pitch = 64 },
75 { .offset = 16384, .pitch = 64 },
76 { .offset = 20480, .pitch = 64 },
77 { .offset = 24576, .pitch = 64 },
78 { .offset = 28672, .pitch = 64 },
79 { .offset = 32768, .pitch = 64 },
80 { .offset = 36864, .pitch = 64 },
81 { .offset = 40960, .pitch = 64 },
82 },
83 },
84 },
85
86 /* An interesting layout from the blob driver on a630, showing that
87 * per-level pitch must be derived from level 0's pitch, not width0. We
88 * don't do this level 0 pitch disalignment (we pick 4096), so disabled
89 * this test for now.
90 */
91 #if 0
92 {
93 .format = PIPE_FORMAT_R8G8B8A8_UNORM,
94 .layout = {
95 .width0 = 1024, .height0 = 1,
96 .slices = {
97 { .offset = 0, .pitch = 5120 },
98 { .offset = 5120, .pitch = 2560 },
99 { .offset = 7680, .pitch = 1280 },
100 { .offset = 8960, .pitch = 768 },
101 { .offset = 9728, .pitch = 512 },
102 { .offset = 10240, .pitch = 256 },
103 { .offset = 10496, .pitch = 256 },
104 { .offset = 10752, .pitch = 256 },
105 { .offset = 11008, .pitch = 256 },
106 { .offset = 11264, .pitch = 256 },
107 { .offset = 11520, .pitch = 256 },
108 },
109 },
110 },
111 #endif
112
113 /* A layout that we failed on (129 wide has a surprise level 1 pitch
114 * increase), and the sizes bracketing it.
115 */
116 {
117 .format = PIPE_FORMAT_R8G8B8A8_UNORM,
118 .layout = {
119 .width0 = 128, .height0 = 1,
120 .slices = {
121 { .offset = 0, .pitch = 512 },
122 { .offset = 512, .pitch = 256 },
123 { .offset = 768, .pitch = 256 },
124 { .offset = 1024, .pitch = 256 },
125 { .offset = 1280, .pitch = 256 },
126 { .offset = 1536, .pitch = 256 },
127 { .offset = 1792, .pitch = 256 },
128 { .offset = 2048, .pitch = 256 },
129 },
130 },
131 },
132 {
133 .format = PIPE_FORMAT_R8G8B8A8_UNORM,
134 .layout = {
135 .width0 = 129, .height0 = 1,
136 .slices = {
137 { .offset = 0, .pitch = 768 },
138 { .offset = 768, .pitch = 512 },
139 { .offset = 1280, .pitch = 256 },
140 { .offset = 1536, .pitch = 256 },
141 { .offset = 1792, .pitch = 256 },
142 { .offset = 2048, .pitch = 256 },
143 { .offset = 2304, .pitch = 256 },
144 { .offset = 2560, .pitch = 256 },
145 },
146 },
147 },
148 {
149 .format = PIPE_FORMAT_R8G8B8A8_UNORM,
150 .layout = {
151 .width0 = 130, .height0 = 1,
152 .slices = {
153 { .offset = 0, .pitch = 768 },
154 { .offset = 768, .pitch = 512 },
155 { .offset = 1280, .pitch = 256 },
156 { .offset = 1536, .pitch = 256 },
157 { .offset = 1792, .pitch = 256 },
158 { .offset = 2048, .pitch = 256 },
159 { .offset = 2304, .pitch = 256 },
160 { .offset = 2560, .pitch = 256 },
161 },
162 },
163 },
164
165 /* The 129 failure seems to be across formats, let's test some cpps */
166 {
167 .format = PIPE_FORMAT_R8_UNORM,
168 .layout = {
169 .width0 = 129, .height0 = 1,
170 .slices = {
171 { .offset = 0, .pitch = 192 },
172 { .offset = 192, .pitch = 128 },
173 { .offset = 320, .pitch = 64 },
174 { .offset = 384, .pitch = 64 },
175 { .offset = 448, .pitch = 64 },
176 { .offset = 512, .pitch = 64 },
177 { .offset = 576, .pitch = 64 },
178 { .offset = 640, .pitch = 64 },
179 },
180 },
181 },
182 {
183 .format = PIPE_FORMAT_R16_UINT,
184 .layout = {
185 .width0 = 129, .height0 = 1,
186 .slices = {
187 { .offset = 0, .pitch = 384 },
188 { .offset = 384, .pitch = 256 },
189 { .offset = 640, .pitch = 128 },
190 { .offset = 768, .pitch = 128 },
191 { .offset = 896, .pitch = 128 },
192 { .offset = 1024, .pitch = 128 },
193 { .offset = 1152, .pitch = 128 },
194 { .offset = 1280, .pitch = 128 },
195 },
196 },
197 },
198 {
199 .format = PIPE_FORMAT_R32G32B32A32_FLOAT,
200 .layout = {
201 .width0 = 129, .height0 = 1,
202 .slices = {
203 { .offset = 0, .pitch = 3072 },
204 { .offset = 3072, .pitch = 2048 },
205 { .offset = 5120, .pitch = 1024 },
206 { .offset = 6144, .pitch = 1024 },
207 { .offset = 7168, .pitch = 1024 },
208 { .offset = 8192, .pitch = 1024 },
209 { .offset = 9216, .pitch = 1024 },
210 { .offset = 10240, .pitch = 1024 },
211 },
212 },
213 },
214
215 /* The 129 failure replicated at every +256 pixels wide. Pick one of
216 * them, and this time increase the height as a new variable as well.
217 */
218 {
219 .format = PIPE_FORMAT_R8G8B8A8_UNORM,
220 .layout = {
221 .width0 = 385, .height0 = 128,
222 .slices = {
223 { .offset = 0, .pitch = 1792 },
224 { .offset = 229376, .pitch = 1024 },
225 { .offset = 294912, .pitch = 512 },
226 { .offset = 311296, .pitch = 256 },
227 { .offset = 315392, .pitch = 256 },
228 { .offset = 317440, .pitch = 256 },
229 { .offset = 318464, .pitch = 256 },
230 { .offset = 318976, .pitch = 256 },
231 { .offset = 319232, .pitch = 256 },
232 },
233 },
234 },
235
236 /* At 257-259 (and replicated every +256 pixels) we had another failure. */
237 {
238 .format = PIPE_FORMAT_R8G8B8A8_UNORM,
239 .layout = {
240 .width0 = 257, .height0 = 1,
241 .slices = {
242 { .offset = 0, .pitch = 1280 },
243 { .offset = 1280, .pitch = 768 },
244 { .offset = 2048, .pitch = 512 },
245 { .offset = 2560, .pitch = 256 },
246 { .offset = 2816, .pitch = 256 },
247 { .offset = 3072, .pitch = 256 },
248 { .offset = 3328, .pitch = 256 },
249 { .offset = 3584, .pitch = 256 },
250 { .offset = 3840, .pitch = 256 },
251 },
252 },
253 },
254 {
255 .format = PIPE_FORMAT_R8G8B8A8_UNORM,
256 .layout = {
257 .width0 = 258, .height0 = 1,
258 .slices = {
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 .width0 = 259, .height0 = 1,
275 .slices = {
276 { .offset = 0, .pitch = 1280 },
277 { .offset = 1280, .pitch = 768 },
278 { .offset = 2048, .pitch = 512 },
279 { .offset = 2560, .pitch = 256 },
280 { .offset = 2816, .pitch = 256 },
281 { .offset = 3072, .pitch = 256 },
282 { .offset = 3328, .pitch = 256 },
283 { .offset = 3584, .pitch = 256 },
284 { .offset = 3840, .pitch = 256 },
285 },
286 },
287 },
288 {
289 .format = PIPE_FORMAT_R8G8B8A8_UNORM,
290 .layout = {
291 .width0 = 260, .height0 = 1,
292 .slices = {
293 { .offset = 0, .pitch = 1280 },
294 { .offset = 1280, .pitch = 768 },
295 { .offset = 2048, .pitch = 512 },
296 { .offset = 2560, .pitch = 256 },
297 { .offset = 2816, .pitch = 256 },
298 { .offset = 3072, .pitch = 256 },
299 { .offset = 3328, .pitch = 256 },
300 { .offset = 3584, .pitch = 256 },
301 { .offset = 3840, .pitch = 256 },
302 },
303 },
304 },
305
306 /* And, again for the 257-9 failure, test a replica with a larger size*/
307 {
308 .format = PIPE_FORMAT_R8G8B8A8_UNORM,
309 .layout = {
310 .width0 = 513, .height0 = 32,
311 .slices = {
312 { .offset = 0, .pitch = 2304 },
313 { .offset = 73728, .pitch = 1280 },
314 { .offset = 94208, .pitch = 768 },
315 { .offset = 100352, .pitch = 512 },
316 { .offset = 102400, .pitch = 256 },
317 { .offset = 102912, .pitch = 256 },
318 { .offset = 103168, .pitch = 256 },
319 { .offset = 103424, .pitch = 256 },
320 { .offset = 103680, .pitch = 256 },
321 { .offset = 103936, .pitch = 256 },
322 },
323 },
324 },
325
326 /* Oh, look. The 513-517 failure extends up to 518 at the next texture
327 * level!
328 */
329 {
330 .format = PIPE_FORMAT_R8G8B8A8_UNORM,
331 .layout = {
332 .width0 = 518, .height0 = 1,
333 .slices = {
334 { .offset = 0, .pitch = 2304 },
335 { .offset = 2304, .pitch = 1280 },
336 { .offset = 3584, .pitch = 768 },
337 { .offset = 4352, .pitch = 512 },
338 { .offset = 4864, .pitch = 256 },
339 { .offset = 5120, .pitch = 256 },
340 { .offset = 5376, .pitch = 256 },
341 { .offset = 5632, .pitch = 256 },
342 { .offset = 5888, .pitch = 256 },
343 { .offset = 6144, .pitch = 256 },
344 },
345 },
346 },
347
348 /* Tiled mode testing of the unusual 1/2-bytes-per-pixel pitch alignment */
349 {
350 .format = PIPE_FORMAT_R8_UNORM,
351 .layout = {
352 .tile_mode = TILE6_3,
353 .width0 = 129, .height0 = 1,
354 .slices = {
355 { .offset = 0, .pitch = 256 },
356 { .offset = 8192, .pitch = 128 },
357 { .offset = 12288, .pitch = 128 },
358 { .offset = 16384, .pitch = 128 },
359 { .offset = 20480, .pitch = 64 },
360 { .offset = 20544, .pitch = 64 },
361 { .offset = 20608, .pitch = 64 },
362 { .offset = 20672, .pitch = 64 },
363 },
364 },
365 },
366
367 /* Single-level RGBA8888 UBWC following UBWC alignment rules laid out in
368 * msm_media_info.h to verify that we don't break buffer sharing.
369 */
370 {
371 .format = PIPE_FORMAT_R8G8B8A8_UNORM,
372 .layout = {
373 .tile_mode = TILE6_3,
374 .ubwc = true,
375 .width0 = 16384, .height0 = 129,
376 .slices = {
377 { .offset = 1024 * 48, .pitch = 16384 * 4 },
378 },
379 .ubwc_slices = {
380 { .offset = 0, .pitch = 1024 },
381 },
382 },
383 },
384
385 /* UBWC: Pitch comes from POT-aligned level 0. */
386 /* Pitch fixed in this commit, but offsets broken. Will be fixed in
387 * following commits.
388 */
389 {
390 .format = PIPE_FORMAT_R8G8B8A8_UNORM,
391 .layout = {
392 .tile_mode = TILE6_3,
393 .ubwc = true,
394 .width0 = 2049, .height0 = 128,
395 .slices = {
396 { .offset = 0, .pitch = 8448 },
397 { .offset = 1081344, .pitch = 4352 },
398 { .offset = 1359872, .pitch = 2304 },
399 { .offset = 1433600, .pitch = 1280 },
400 { .offset = 1454080, .pitch = 768 },
401 { .offset = 1466368, .pitch = 512 },
402 { .offset = 1474560, .pitch = 256 },
403 { .offset = 1478656, .pitch = 256 },
404 { .offset = 1482752, .pitch = 256 },
405 { .offset = 1486848, .pitch = 256 },
406 { .offset = 1490944, .pitch = 256 },
407 { .offset = 1495040, .pitch = 256 },
408 },
409 .ubwc_slices = {
410 { .offset = 0, .pitch = 256 },
411 { .offset = 16384, .pitch = 128 },
412 { .offset = 24576, .pitch = 64 },
413 { .offset = 28672, .pitch = 64 },
414 { .offset = 32768, .pitch = 64 },
415 { .offset = 36864, .pitch = 64 },
416 { .offset = 40960, .pitch = 64 },
417 { .offset = 45056, .pitch = 64 },
418 { .offset = 49152, .pitch = 64 },
419 { .offset = 53248, .pitch = 64 },
420 { .offset = 57344, .pitch = 64 },
421 { .offset = 61440, .pitch = 64 },
422 },
423 },
424 },
425 /* UBWC: Height comes from POT-aligned level 0. */
426 {
427 .format = PIPE_FORMAT_R8G8B8A8_UNORM,
428 .layout = {
429 .tile_mode = TILE6_3,
430 .ubwc = true,
431 .width0 = 1024, .height0 = 1025,
432 .slices = {
433 { .offset = 0, .pitch = 4096 },
434 { .offset = 4259840, .pitch = 2048 },
435 { .offset = 5308416, .pitch = 1024 },
436 { .offset = 5570560, .pitch = 512 },
437 { .offset = 5636096, .pitch = 256 },
438 { .offset = 5652480, .pitch = 256 },
439 { .offset = 5660672, .pitch = 256 },
440 { .offset = 5664768, .pitch = 256 },
441 { .offset = 5668864, .pitch = 256 },
442 { .offset = 5672960, .pitch = 256 },
443 { .offset = 5677056, .pitch = 256 },
444 },
445 .ubwc_slices = {
446 { .offset = 0, .pitch = 64 },
447 { .offset = 32768, .pitch = 64 },
448 { .offset = 49152, .pitch = 64 },
449 { .offset = 57344, .pitch = 64 },
450 { .offset = 61440, .pitch = 64 },
451 { .offset = 65536, .pitch = 64 },
452 { .offset = 69632, .pitch = 64 },
453 { .offset = 73728, .pitch = 64 },
454 { .offset = 77824, .pitch = 64 },
455 { .offset = 81920, .pitch = 64 },
456 { .offset = 86016, .pitch = 64 },
457 },
458 },
459 },
460
461 /* UBWC: Get at minimum height of a level across cpps */
462 {
463 .format = PIPE_FORMAT_R16_UINT,
464 .layout = {
465 .tile_mode = TILE6_3,
466 .ubwc = true,
467 .width0 = 16384, .height0 = 1,
468 .slices = {
469 { .offset = 0, .pitch = 32768 },
470 { .offset = 524288, .pitch = 16384 },
471 { .offset = 786432, .pitch = 8192 },
472 { .offset = 917504, .pitch = 4096 },
473 { .offset = 983040, .pitch = 2048 },
474 { .offset = 1015808, .pitch = 1024 },
475 { .offset = 1032192, .pitch = 512 },
476 { .offset = 1040384, .pitch = 256 },
477 { .offset = 1044480, .pitch = 256 },
478 { .offset = 1048576, .pitch = 256 },
479 { .offset = 1052672, .pitch = 256 },
480 { .offset = 1056768, .pitch = 256 },
481 { .offset = 1060864, .pitch = 256 },
482 { .offset = 1064960, .pitch = 256 },
483 { .offset = 1069056, .pitch = 256 },
484 },
485 .ubwc_slices = {
486 { .offset = 0, .pitch = 1024 },
487 { .offset = 65536, .pitch = 512 },
488 { .offset = 98304, .pitch = 256 },
489 { .offset = 114688, .pitch = 128 },
490 { .offset = 122880, .pitch = 64 },
491 { .offset = 126976, .pitch = 64 },
492 { .offset = 131072, .pitch = 64 },
493 { .offset = 135168, .pitch = 64 },
494 { .offset = 139264, .pitch = 64 },
495 { .offset = 143360, .pitch = 64 },
496 { .offset = 147456, .pitch = 64 },
497 { .offset = 151552, .pitch = 64 },
498 { .offset = 155648, .pitch = 64 },
499 { .offset = 159744, .pitch = 64 },
500 { .offset = 163840, .pitch = 64 },
501 },
502 },
503 },
504 {
505 .format = PIPE_FORMAT_R8G8B8A8_UNORM,
506 .layout = {
507 .tile_mode = TILE6_3,
508 .ubwc = true,
509 .width0 = 16384, .height0 = 1,
510 .slices = {
511 { .offset = 0, .pitch = 65536 },
512 { .offset = 1048576, .pitch = 32768 },
513 { .offset = 1572864, .pitch = 16384 },
514 { .offset = 1835008, .pitch = 8192 },
515 { .offset = 1966080, .pitch = 4096 },
516 { .offset = 2031616, .pitch = 2048 },
517 { .offset = 2064384, .pitch = 1024 },
518 { .offset = 2080768, .pitch = 512 },
519 { .offset = 2088960, .pitch = 256 },
520 { .offset = 2093056, .pitch = 256 },
521 { .offset = 2097152, .pitch = 256 },
522 { .offset = 2101248, .pitch = 256 },
523 { .offset = 2105344, .pitch = 256 },
524 { .offset = 2109440, .pitch = 256 },
525 { .offset = 2113536, .pitch = 256 },
526 },
527 .ubwc_slices = {
528 { .offset = 0, .pitch = 1024 },
529 { .offset = 65536, .pitch = 512 },
530 { .offset = 98304, .pitch = 256 },
531 { .offset = 114688, .pitch = 128 },
532 { .offset = 122880, .pitch = 64 },
533 { .offset = 126976, .pitch = 64 },
534 { .offset = 131072, .pitch = 64 },
535 { .offset = 135168, .pitch = 64 },
536 { .offset = 139264, .pitch = 64 },
537 { .offset = 143360, .pitch = 64 },
538 { .offset = 147456, .pitch = 64 },
539 { .offset = 151552, .pitch = 64 },
540 { .offset = 155648, .pitch = 64 },
541 { .offset = 159744, .pitch = 64 },
542 { .offset = 163840, .pitch = 64 },
543 },
544 },
545 },
546 {
547 .format = PIPE_FORMAT_R32G32B32A32_FLOAT,
548 .layout = {
549 .tile_mode = TILE6_3,
550 .ubwc = true,
551 .width0 = 16384, .height0 = 1,
552 .slices = {
553 { .offset = 0, .pitch = 262144 },
554 { .offset = 4194304, .pitch = 131072 },
555 { .offset = 6291456, .pitch = 65536 },
556 { .offset = 7340032, .pitch = 32768 },
557 { .offset = 7864320, .pitch = 16384 },
558 { .offset = 8126464, .pitch = 8192 },
559 { .offset = 8257536, .pitch = 4096 },
560 { .offset = 8323072, .pitch = 2048 },
561 { .offset = 8355840, .pitch = 1024 },
562 { .offset = 8372224, .pitch = 1024 },
563 { .offset = 8388608, .pitch = 1024 },
564 { .offset = 8404992, .pitch = 1024 },
565 { .offset = 8421376, .pitch = 1024 },
566 { .offset = 8437760, .pitch = 1024 },
567 { .offset = 8454144, .pitch = 1024 },
568 },
569 .ubwc_slices = {
570 { .offset = 0, .pitch = 4096 },
571 { .offset = 262144, .pitch = 2048 },
572 { .offset = 393216, .pitch = 1024 },
573 { .offset = 458752, .pitch = 512 },
574 { .offset = 491520, .pitch = 256 },
575 { .offset = 507904, .pitch = 128 },
576 { .offset = 516096, .pitch = 64 },
577 { .offset = 520192, .pitch = 64 },
578 { .offset = 524288, .pitch = 64 },
579 { .offset = 528384, .pitch = 64 },
580 { .offset = 532480, .pitch = 64 },
581 { .offset = 536576, .pitch = 64 },
582 { .offset = 540672, .pitch = 64 },
583 { .offset = 544768, .pitch = 64 },
584 { .offset = 548864, .pitch = 64 },
585 },
586 },
587 },
588 };
589
590 int
591 main(int argc, char **argv)
592 {
593 int ret = 0;
594
595 for (int i = 0; i < ARRAY_SIZE(testcases); i++) {
596 if (!fdl_test_layout(&testcases[i], 630))
597 ret = 1;
598 }
599
600 return ret;
601 }