46814b22f1e762b7a5fd2b8478e9c94274767660
[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 "adreno_common.xml.h"
26 #include "a6xx.xml.h"
27
28 #include <stdio.h>
29
30 struct testcase {
31 enum pipe_format format;
32
33 int array_size; /* Size for array textures, or 0 otherwise. */
34 bool is_3d;
35
36 /* Partially filled layout of input parameters and expected results. */
37 struct fdl_layout layout;
38 };
39
40 static const struct testcase testcases[] = {
41 /* A straightforward first testcase, linear, with an obvious format. */
42 {
43 .format = PIPE_FORMAT_R8G8B8A8_UNORM,
44 .layout = {
45 .width0 = 32, .height0 = 32,
46 .slices = {
47 { .offset = 0, .pitch = 256 },
48 { .offset = 8192, .pitch = 256 },
49 { .offset = 12288, .pitch = 256 },
50 { .offset = 14336, .pitch = 256 },
51 { .offset = 15360, .pitch = 256 },
52 { .offset = 15872, .pitch = 256 },
53 },
54 },
55 },
56
57 /* A tiled/ubwc layout from the blob driver, at a size where the a630 blob
58 * driver does something interesting for linear.
59 */
60 {
61 .format = PIPE_FORMAT_R8G8B8A8_UNORM,
62 .layout = {
63 .tile_mode = TILE6_3,
64 .ubwc = true,
65 .width0 = 1024, .height0 = 1,
66 .slices = {
67 { .offset = 0, .pitch = 4096 },
68 { .offset = 65536, .pitch = 2048 },
69 { .offset = 98304, .pitch = 1024 },
70 { .offset = 114688, .pitch = 512 },
71 { .offset = 122880, .pitch = 256 },
72 { .offset = 126976, .pitch = 256 },
73 { .offset = 131072, .pitch = 256 },
74 { .offset = 135168, .pitch = 256 },
75 { .offset = 139264, .pitch = 256 },
76 { .offset = 143360, .pitch = 256 },
77 { .offset = 147456, .pitch = 256 },
78 },
79 .ubwc_slices = {
80 { .offset = 0, .pitch = 64 },
81 { .offset = 4096, .pitch = 64 },
82 { .offset = 8192, .pitch = 64 },
83 { .offset = 12288, .pitch = 64 },
84 { .offset = 16384, .pitch = 64 },
85 { .offset = 20480, .pitch = 64 },
86 { .offset = 24576, .pitch = 64 },
87 { .offset = 28672, .pitch = 64 },
88 { .offset = 32768, .pitch = 64 },
89 { .offset = 36864, .pitch = 64 },
90 { .offset = 40960, .pitch = 64 },
91 },
92 },
93 },
94
95 /* An interesting layout from the blob driver on a630, showing that
96 * per-level pitch must be derived from level 0's pitch, not width0. We
97 * don't do this level 0 pitch disalignment (we pick 4096), so disabled
98 * this test for now.
99 */
100 #if 0
101 {
102 .format = PIPE_FORMAT_R8G8B8A8_UNORM,
103 .layout = {
104 .width0 = 1024, .height0 = 1,
105 .slices = {
106 { .offset = 0, .pitch = 5120 },
107 { .offset = 5120, .pitch = 2560 },
108 { .offset = 7680, .pitch = 1280 },
109 { .offset = 8960, .pitch = 768 },
110 { .offset = 9728, .pitch = 512 },
111 { .offset = 10240, .pitch = 256 },
112 { .offset = 10496, .pitch = 256 },
113 { .offset = 10752, .pitch = 256 },
114 { .offset = 11008, .pitch = 256 },
115 { .offset = 11264, .pitch = 256 },
116 { .offset = 11520, .pitch = 256 },
117 },
118 },
119 },
120 #endif
121
122 /* A layout that we failed on (129 wide has a surprise level 1 pitch
123 * increase), and the sizes bracketing it.
124 */
125 {
126 .format = PIPE_FORMAT_R8G8B8A8_UNORM,
127 .layout = {
128 .width0 = 128, .height0 = 1,
129 .slices = {
130 { .offset = 0, .pitch = 512 },
131 { .offset = 512, .pitch = 256 },
132 { .offset = 768, .pitch = 256 },
133 { .offset = 1024, .pitch = 256 },
134 { .offset = 1280, .pitch = 256 },
135 { .offset = 1536, .pitch = 256 },
136 { .offset = 1792, .pitch = 256 },
137 { .offset = 2048, .pitch = 256 },
138 },
139 },
140 },
141 {
142 .format = PIPE_FORMAT_R8G8B8A8_UNORM,
143 .layout = {
144 .width0 = 129, .height0 = 1,
145 .slices = {
146 { .offset = 0, .pitch = 768 },
147 { .offset = 768, .pitch = 512 },
148 { .offset = 1280, .pitch = 256 },
149 { .offset = 1536, .pitch = 256 },
150 { .offset = 1792, .pitch = 256 },
151 { .offset = 2048, .pitch = 256 },
152 { .offset = 2304, .pitch = 256 },
153 { .offset = 2560, .pitch = 256 },
154 },
155 },
156 },
157 {
158 .format = PIPE_FORMAT_R8G8B8A8_UNORM,
159 .layout = {
160 .width0 = 130, .height0 = 1,
161 .slices = {
162 { .offset = 0, .pitch = 768 },
163 { .offset = 768, .pitch = 512 },
164 { .offset = 1280, .pitch = 256 },
165 { .offset = 1536, .pitch = 256 },
166 { .offset = 1792, .pitch = 256 },
167 { .offset = 2048, .pitch = 256 },
168 { .offset = 2304, .pitch = 256 },
169 { .offset = 2560, .pitch = 256 },
170 },
171 },
172 },
173
174 /* The 129 failure seems to be across formats, let's test some cpps */
175 {
176 .format = PIPE_FORMAT_R8_UNORM,
177 .layout = {
178 .width0 = 129, .height0 = 1,
179 .slices = {
180 { .offset = 0, .pitch = 192 },
181 { .offset = 192, .pitch = 128 },
182 { .offset = 320, .pitch = 64 },
183 { .offset = 384, .pitch = 64 },
184 { .offset = 448, .pitch = 64 },
185 { .offset = 512, .pitch = 64 },
186 { .offset = 576, .pitch = 64 },
187 { .offset = 640, .pitch = 64 },
188 },
189 },
190 },
191 {
192 .format = PIPE_FORMAT_R16_UINT,
193 .layout = {
194 .width0 = 129, .height0 = 1,
195 .slices = {
196 { .offset = 0, .pitch = 384 },
197 { .offset = 384, .pitch = 256 },
198 { .offset = 640, .pitch = 128 },
199 { .offset = 768, .pitch = 128 },
200 { .offset = 896, .pitch = 128 },
201 { .offset = 1024, .pitch = 128 },
202 { .offset = 1152, .pitch = 128 },
203 { .offset = 1280, .pitch = 128 },
204 },
205 },
206 },
207 {
208 .format = PIPE_FORMAT_R32G32B32A32_FLOAT,
209 .layout = {
210 .width0 = 129, .height0 = 1,
211 .slices = {
212 { .offset = 0, .pitch = 3072 },
213 { .offset = 3072, .pitch = 2048 },
214 { .offset = 5120, .pitch = 1024 },
215 { .offset = 6144, .pitch = 1024 },
216 { .offset = 7168, .pitch = 1024 },
217 { .offset = 8192, .pitch = 1024 },
218 { .offset = 9216, .pitch = 1024 },
219 { .offset = 10240, .pitch = 1024 },
220 },
221 },
222 },
223
224 /* The 129 failure replicated at every +256 pixels wide. Pick one of
225 * them, and this time increase the height as a new variable as well.
226 */
227 {
228 .format = PIPE_FORMAT_R8G8B8A8_UNORM,
229 .layout = {
230 .width0 = 385, .height0 = 128,
231 .slices = {
232 { .offset = 0, .pitch = 1792 },
233 { .offset = 229376, .pitch = 1024 },
234 { .offset = 294912, .pitch = 512 },
235 { .offset = 311296, .pitch = 256 },
236 { .offset = 315392, .pitch = 256 },
237 { .offset = 317440, .pitch = 256 },
238 { .offset = 318464, .pitch = 256 },
239 { .offset = 318976, .pitch = 256 },
240 { .offset = 319232, .pitch = 256 },
241 },
242 },
243 },
244
245 /* At 257-259 (and replicated every +256 pixels) we had another failure. */
246 {
247 .format = PIPE_FORMAT_R8G8B8A8_UNORM,
248 .layout = {
249 .width0 = 257, .height0 = 1,
250 .slices = {
251 { .offset = 0, .pitch = 1280 },
252 { .offset = 1280, .pitch = 768 },
253 { .offset = 2048, .pitch = 512 },
254 { .offset = 2560, .pitch = 256 },
255 { .offset = 2816, .pitch = 256 },
256 { .offset = 3072, .pitch = 256 },
257 { .offset = 3328, .pitch = 256 },
258 { .offset = 3584, .pitch = 256 },
259 { .offset = 3840, .pitch = 256 },
260 },
261 },
262 },
263 {
264 .format = PIPE_FORMAT_R8G8B8A8_UNORM,
265 .layout = {
266 .width0 = 258, .height0 = 1,
267 .slices = {
268 { .offset = 0, .pitch = 1280 },
269 { .offset = 1280, .pitch = 768 },
270 { .offset = 2048, .pitch = 512 },
271 { .offset = 2560, .pitch = 256 },
272 { .offset = 2816, .pitch = 256 },
273 { .offset = 3072, .pitch = 256 },
274 { .offset = 3328, .pitch = 256 },
275 { .offset = 3584, .pitch = 256 },
276 { .offset = 3840, .pitch = 256 },
277 },
278 },
279 },
280 {
281 .format = PIPE_FORMAT_R8G8B8A8_UNORM,
282 .layout = {
283 .width0 = 259, .height0 = 1,
284 .slices = {
285 { .offset = 0, .pitch = 1280 },
286 { .offset = 1280, .pitch = 768 },
287 { .offset = 2048, .pitch = 512 },
288 { .offset = 2560, .pitch = 256 },
289 { .offset = 2816, .pitch = 256 },
290 { .offset = 3072, .pitch = 256 },
291 { .offset = 3328, .pitch = 256 },
292 { .offset = 3584, .pitch = 256 },
293 { .offset = 3840, .pitch = 256 },
294 },
295 },
296 },
297 {
298 .format = PIPE_FORMAT_R8G8B8A8_UNORM,
299 .layout = {
300 .width0 = 260, .height0 = 1,
301 .slices = {
302 { .offset = 0, .pitch = 1280 },
303 { .offset = 1280, .pitch = 768 },
304 { .offset = 2048, .pitch = 512 },
305 { .offset = 2560, .pitch = 256 },
306 { .offset = 2816, .pitch = 256 },
307 { .offset = 3072, .pitch = 256 },
308 { .offset = 3328, .pitch = 256 },
309 { .offset = 3584, .pitch = 256 },
310 { .offset = 3840, .pitch = 256 },
311 },
312 },
313 },
314
315 /* And, again for the 257-9 failure, test a replica with a larger size*/
316 {
317 .format = PIPE_FORMAT_R8G8B8A8_UNORM,
318 .layout = {
319 .width0 = 513, .height0 = 32,
320 .slices = {
321 { .offset = 0, .pitch = 2304 },
322 { .offset = 73728, .pitch = 1280 },
323 { .offset = 94208, .pitch = 768 },
324 { .offset = 100352, .pitch = 512 },
325 { .offset = 102400, .pitch = 256 },
326 { .offset = 102912, .pitch = 256 },
327 { .offset = 103168, .pitch = 256 },
328 { .offset = 103424, .pitch = 256 },
329 { .offset = 103680, .pitch = 256 },
330 { .offset = 103936, .pitch = 256 },
331 },
332 },
333 },
334
335 /* Oh, look. The 513-517 failure extends up to 518 at the next texture
336 * level!
337 */
338 {
339 .format = PIPE_FORMAT_R8G8B8A8_UNORM,
340 .layout = {
341 .width0 = 518, .height0 = 1,
342 .slices = {
343 { .offset = 0, .pitch = 2304 },
344 { .offset = 2304, .pitch = 1280 },
345 { .offset = 3584, .pitch = 768 },
346 { .offset = 4352, .pitch = 512 },
347 { .offset = 4864, .pitch = 256 },
348 { .offset = 5120, .pitch = 256 },
349 { .offset = 5376, .pitch = 256 },
350 { .offset = 5632, .pitch = 256 },
351 { .offset = 5888, .pitch = 256 },
352 { .offset = 6144, .pitch = 256 },
353 },
354 },
355 },
356
357 /* Tiled mode testing of the unusual 1/2-bytes-per-pixel pitch alignment */
358 {
359 .format = PIPE_FORMAT_R8_UNORM,
360 .layout = {
361 .tile_mode = TILE6_3,
362 .width0 = 129, .height0 = 1,
363 .slices = {
364 { .offset = 0, .pitch = 256 },
365 { .offset = 8192, .pitch = 128 },
366 { .offset = 12288, .pitch = 128 },
367 { .offset = 16384, .pitch = 128 },
368 { .offset = 20480, .pitch = 64 },
369 { .offset = 20544, .pitch = 64 },
370 { .offset = 20608, .pitch = 64 },
371 { .offset = 20672, .pitch = 64 },
372 },
373 },
374 },
375
376 /* Single-level RGBA8888 UBWC following UBWC alignment rules laid out in
377 * msm_media_info.h to verify that we don't break buffer sharing.
378 */
379 {
380 .format = PIPE_FORMAT_R8G8B8A8_UNORM,
381 .layout = {
382 .tile_mode = TILE6_3,
383 .ubwc = true,
384 .width0 = 16384, .height0 = 129,
385 .slices = {
386 { .offset = 1024 * 48, .pitch = 16384 * 4 },
387 },
388 .ubwc_slices = {
389 { .offset = 0, .pitch = 1024 },
390 },
391 },
392 },
393
394 /* UBWC: Pitch comes from POT-aligned level 0. */
395 /* Pitch fixed in this commit, but offsets broken. Will be fixed in
396 * following commits.
397 */
398 {
399 .format = PIPE_FORMAT_R8G8B8A8_UNORM,
400 .layout = {
401 .tile_mode = TILE6_3,
402 .ubwc = true,
403 .width0 = 2049, .height0 = 128,
404 .slices = {
405 { .offset = 0, .pitch = 8448 },
406 { .offset = 1081344, .pitch = 4352 },
407 { .offset = 1359872, .pitch = 2304 },
408 { .offset = 1433600, .pitch = 1280 },
409 { .offset = 1454080, .pitch = 768 },
410 { .offset = 1466368, .pitch = 512 },
411 { .offset = 1474560, .pitch = 256 },
412 { .offset = 1478656, .pitch = 256 },
413 { .offset = 1482752, .pitch = 256 },
414 { .offset = 1486848, .pitch = 256 },
415 { .offset = 1490944, .pitch = 256 },
416 { .offset = 1495040, .pitch = 256 },
417 },
418 .ubwc_slices = {
419 { .offset = 0, .pitch = 256 },
420 { .offset = 16384, .pitch = 128 },
421 { .offset = 24576, .pitch = 64 },
422 { .offset = 28672, .pitch = 64 },
423 { .offset = 32768, .pitch = 64 },
424 { .offset = 36864, .pitch = 64 },
425 { .offset = 40960, .pitch = 64 },
426 { .offset = 45056, .pitch = 64 },
427 { .offset = 49152, .pitch = 64 },
428 { .offset = 53248, .pitch = 64 },
429 { .offset = 57344, .pitch = 64 },
430 { .offset = 61440, .pitch = 64 },
431 },
432 },
433 },
434 /* UBWC: Height comes from POT-aligned level 0. */
435 {
436 .format = PIPE_FORMAT_R8G8B8A8_UNORM,
437 .layout = {
438 .tile_mode = TILE6_3,
439 .ubwc = true,
440 .width0 = 1024, .height0 = 1025,
441 .slices = {
442 { .offset = 0, .pitch = 4096 },
443 { .offset = 4259840, .pitch = 2048 },
444 { .offset = 5308416, .pitch = 1024 },
445 { .offset = 5570560, .pitch = 512 },
446 { .offset = 5636096, .pitch = 256 },
447 { .offset = 5652480, .pitch = 256 },
448 { .offset = 5660672, .pitch = 256 },
449 { .offset = 5664768, .pitch = 256 },
450 { .offset = 5668864, .pitch = 256 },
451 { .offset = 5672960, .pitch = 256 },
452 { .offset = 5677056, .pitch = 256 },
453 },
454 .ubwc_slices = {
455 { .offset = 0, .pitch = 64 },
456 { .offset = 32768, .pitch = 64 },
457 { .offset = 49152, .pitch = 64 },
458 { .offset = 57344, .pitch = 64 },
459 { .offset = 61440, .pitch = 64 },
460 { .offset = 65536, .pitch = 64 },
461 { .offset = 69632, .pitch = 64 },
462 { .offset = 73728, .pitch = 64 },
463 { .offset = 77824, .pitch = 64 },
464 { .offset = 81920, .pitch = 64 },
465 { .offset = 86016, .pitch = 64 },
466 },
467 },
468 },
469
470 /* UBWC: Get at minimum height of a level across cpps */
471 {
472 .format = PIPE_FORMAT_R16_UINT,
473 .layout = {
474 .tile_mode = TILE6_3,
475 .ubwc = true,
476 .width0 = 16384, .height0 = 1,
477 .slices = {
478 { .offset = 0, .pitch = 32768 },
479 { .offset = 524288, .pitch = 16384 },
480 { .offset = 786432, .pitch = 8192 },
481 { .offset = 917504, .pitch = 4096 },
482 { .offset = 983040, .pitch = 2048 },
483 { .offset = 1015808, .pitch = 1024 },
484 { .offset = 1032192, .pitch = 512 },
485 { .offset = 1040384, .pitch = 256 },
486 { .offset = 1044480, .pitch = 256 },
487 { .offset = 1048576, .pitch = 256 },
488 { .offset = 1052672, .pitch = 256 },
489 { .offset = 1056768, .pitch = 256 },
490 { .offset = 1060864, .pitch = 256 },
491 { .offset = 1064960, .pitch = 256 },
492 { .offset = 1069056, .pitch = 256 },
493 },
494 .ubwc_slices = {
495 { .offset = 0, .pitch = 1024 },
496 { .offset = 65536, .pitch = 512 },
497 { .offset = 98304, .pitch = 256 },
498 { .offset = 114688, .pitch = 128 },
499 { .offset = 122880, .pitch = 64 },
500 { .offset = 126976, .pitch = 64 },
501 { .offset = 131072, .pitch = 64 },
502 { .offset = 135168, .pitch = 64 },
503 { .offset = 139264, .pitch = 64 },
504 { .offset = 143360, .pitch = 64 },
505 { .offset = 147456, .pitch = 64 },
506 { .offset = 151552, .pitch = 64 },
507 { .offset = 155648, .pitch = 64 },
508 { .offset = 159744, .pitch = 64 },
509 { .offset = 163840, .pitch = 64 },
510 },
511 },
512 },
513 {
514 .format = PIPE_FORMAT_R8G8B8A8_UNORM,
515 .layout = {
516 .tile_mode = TILE6_3,
517 .ubwc = true,
518 .width0 = 16384, .height0 = 1,
519 .slices = {
520 { .offset = 0, .pitch = 65536 },
521 { .offset = 1048576, .pitch = 32768 },
522 { .offset = 1572864, .pitch = 16384 },
523 { .offset = 1835008, .pitch = 8192 },
524 { .offset = 1966080, .pitch = 4096 },
525 { .offset = 2031616, .pitch = 2048 },
526 { .offset = 2064384, .pitch = 1024 },
527 { .offset = 2080768, .pitch = 512 },
528 { .offset = 2088960, .pitch = 256 },
529 { .offset = 2093056, .pitch = 256 },
530 { .offset = 2097152, .pitch = 256 },
531 { .offset = 2101248, .pitch = 256 },
532 { .offset = 2105344, .pitch = 256 },
533 { .offset = 2109440, .pitch = 256 },
534 { .offset = 2113536, .pitch = 256 },
535 },
536 .ubwc_slices = {
537 { .offset = 0, .pitch = 1024 },
538 { .offset = 65536, .pitch = 512 },
539 { .offset = 98304, .pitch = 256 },
540 { .offset = 114688, .pitch = 128 },
541 { .offset = 122880, .pitch = 64 },
542 { .offset = 126976, .pitch = 64 },
543 { .offset = 131072, .pitch = 64 },
544 { .offset = 135168, .pitch = 64 },
545 { .offset = 139264, .pitch = 64 },
546 { .offset = 143360, .pitch = 64 },
547 { .offset = 147456, .pitch = 64 },
548 { .offset = 151552, .pitch = 64 },
549 { .offset = 155648, .pitch = 64 },
550 { .offset = 159744, .pitch = 64 },
551 { .offset = 163840, .pitch = 64 },
552 },
553 },
554 },
555 {
556 .format = PIPE_FORMAT_R32G32B32A32_FLOAT,
557 .layout = {
558 .tile_mode = TILE6_3,
559 .ubwc = true,
560 .width0 = 16384, .height0 = 1,
561 .slices = {
562 { .offset = 0, .pitch = 262144 },
563 { .offset = 4194304, .pitch = 131072 },
564 { .offset = 6291456, .pitch = 65536 },
565 { .offset = 7340032, .pitch = 32768 },
566 { .offset = 7864320, .pitch = 16384 },
567 { .offset = 8126464, .pitch = 8192 },
568 { .offset = 8257536, .pitch = 4096 },
569 { .offset = 8323072, .pitch = 2048 },
570 { .offset = 8355840, .pitch = 1024 },
571 { .offset = 8372224, .pitch = 1024 },
572 { .offset = 8388608, .pitch = 1024 },
573 { .offset = 8404992, .pitch = 1024 },
574 { .offset = 8421376, .pitch = 1024 },
575 { .offset = 8437760, .pitch = 1024 },
576 { .offset = 8454144, .pitch = 1024 },
577 },
578 .ubwc_slices = {
579 { .offset = 0, .pitch = 4096 },
580 { .offset = 262144, .pitch = 2048 },
581 { .offset = 393216, .pitch = 1024 },
582 { .offset = 458752, .pitch = 512 },
583 { .offset = 491520, .pitch = 256 },
584 { .offset = 507904, .pitch = 128 },
585 { .offset = 516096, .pitch = 64 },
586 { .offset = 520192, .pitch = 64 },
587 { .offset = 524288, .pitch = 64 },
588 { .offset = 528384, .pitch = 64 },
589 { .offset = 532480, .pitch = 64 },
590 { .offset = 536576, .pitch = 64 },
591 { .offset = 540672, .pitch = 64 },
592 { .offset = 544768, .pitch = 64 },
593 { .offset = 548864, .pitch = 64 },
594 },
595 },
596 },
597 };
598
599 static bool test_layout(const struct testcase *testcase)
600 {
601 struct fdl_layout layout = {
602 .ubwc = testcase->layout.ubwc,
603 .tile_mode = testcase->layout.tile_mode,
604 };
605 bool ok = true;
606
607 int max_size = MAX2(testcase->layout.width0, testcase->layout.height0);
608 int mip_levels = 1;
609 while (max_size > 1 && testcase->layout.slices[mip_levels].pitch) {
610 mip_levels++;
611 max_size = u_minify(max_size, 1);
612 }
613
614 fdl6_layout(&layout,
615 testcase->format,
616 MAX2(testcase->layout.nr_samples, 1),
617 testcase->layout.width0,
618 MAX2(testcase->layout.height0, 1),
619 MAX2(testcase->layout.depth0, 1),
620 mip_levels,
621 MAX2(testcase->array_size, 1),
622 testcase->is_3d);
623
624 /* fdl lays out UBWC data before the color data, while all we have
625 * recorded in this testcase are the color offsets (other than the UBWC
626 * buffer sharing test). Shift the fdl layout down so we can compare
627 * color offsets.
628 */
629 if (layout.ubwc && !testcase->layout.slices[0].offset) {
630 for (int l = 1; l < mip_levels; l++)
631 layout.slices[l].offset -= layout.slices[0].offset;
632 layout.slices[0].offset = 0;
633 }
634
635 for (int l = 0; l < mip_levels; l++) {
636 if (layout.slices[l].offset != testcase->layout.slices[l].offset) {
637 fprintf(stderr, "%s %dx%dx%d@%dx lvl%d: offset 0x%x != 0x%x\n",
638 util_format_short_name(testcase->format),
639 layout.width0, layout.height0, layout.depth0,
640 layout.nr_samples, l,
641 layout.slices[l].offset,
642 testcase->layout.slices[l].offset);
643 ok = false;
644 }
645 if (layout.slices[l].pitch != testcase->layout.slices[l].pitch) {
646 fprintf(stderr, "%s %dx%dx%d@%dx lvl%d: pitch %d != %d\n",
647 util_format_short_name(testcase->format),
648 layout.width0, layout.height0, layout.depth0,
649 layout.nr_samples, l,
650 layout.slices[l].pitch,
651 testcase->layout.slices[l].pitch);
652 ok = false;
653 }
654
655 if (layout.ubwc_slices[l].offset != testcase->layout.ubwc_slices[l].offset) {
656 fprintf(stderr, "%s %dx%dx%d@%dx lvl%d: UBWC offset 0x%x != 0x%x\n",
657 util_format_short_name(testcase->format),
658 layout.width0, layout.height0, layout.depth0,
659 layout.nr_samples, l,
660 layout.ubwc_slices[l].offset,
661 testcase->layout.ubwc_slices[l].offset);
662 ok = false;
663 }
664 if (layout.ubwc_slices[l].pitch != testcase->layout.ubwc_slices[l].pitch) {
665 fprintf(stderr, "%s %dx%dx%d@%dx lvl%d: UBWC pitch %d != %d\n",
666 util_format_short_name(testcase->format),
667 layout.width0, layout.height0, layout.depth0,
668 layout.nr_samples, l,
669 layout.ubwc_slices[l].pitch,
670 testcase->layout.ubwc_slices[l].pitch);
671 ok = false;
672 }
673 }
674
675 if (!ok)
676 fprintf(stderr, "\n");
677
678 return ok;
679 }
680
681 int
682 main(int argc, char **argv)
683 {
684 int ret = 0;
685
686 for (int i = 0; i < ARRAY_SIZE(testcases); i++) {
687 if (!test_layout(&testcases[i]))
688 ret = 1;
689 }
690
691 return ret;
692 }