2 * Copyright © 2020 Google LLC
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:
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
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
24 #include "freedreno_layout.h"
25 #include "fd_layout_test.h"
26 #include "adreno_common.xml.h"
31 bool fdl_test_layout(const struct testcase
*testcase
, int gpu_id
)
33 struct fdl_layout layout
= {
34 .ubwc
= testcase
->layout
.ubwc
,
35 .tile_mode
= testcase
->layout
.tile_mode
,
39 int max_size
= MAX2(testcase
->layout
.width0
, testcase
->layout
.height0
);
41 while (max_size
> 1 && testcase
->layout
.slices
[mip_levels
].pitch
) {
43 max_size
= u_minify(max_size
, 1);
46 assert(gpu_id
>= 600);
49 MAX2(testcase
->layout
.nr_samples
, 1),
50 testcase
->layout
.width0
,
51 MAX2(testcase
->layout
.height0
, 1),
52 MAX2(testcase
->layout
.depth0
, 1),
54 MAX2(testcase
->array_size
, 1),
57 /* fdl lays out UBWC data before the color data, while all we have
58 * recorded in this testcase are the color offsets (other than the UBWC
59 * buffer sharing test). Shift the fdl layout down so we can compare
62 if (layout
.ubwc
&& !testcase
->layout
.slices
[0].offset
) {
63 for (int l
= 1; l
< mip_levels
; l
++)
64 layout
.slices
[l
].offset
-= layout
.slices
[0].offset
;
65 layout
.slices
[0].offset
= 0;
68 for (int l
= 0; l
< mip_levels
; l
++) {
69 if (layout
.slices
[l
].offset
!= testcase
->layout
.slices
[l
].offset
) {
70 fprintf(stderr
, "%s %dx%dx%d@%dx lvl%d: offset 0x%x != 0x%x\n",
71 util_format_short_name(testcase
->format
),
72 layout
.width0
, layout
.height0
, layout
.depth0
,
74 layout
.slices
[l
].offset
,
75 testcase
->layout
.slices
[l
].offset
);
78 if (layout
.slices
[l
].pitch
!= testcase
->layout
.slices
[l
].pitch
) {
79 fprintf(stderr
, "%s %dx%dx%d@%dx lvl%d: pitch %d != %d\n",
80 util_format_short_name(testcase
->format
),
81 layout
.width0
, layout
.height0
, layout
.depth0
,
83 layout
.slices
[l
].pitch
,
84 testcase
->layout
.slices
[l
].pitch
);
88 if (layout
.ubwc_slices
[l
].offset
!= testcase
->layout
.ubwc_slices
[l
].offset
) {
89 fprintf(stderr
, "%s %dx%dx%d@%dx lvl%d: UBWC offset 0x%x != 0x%x\n",
90 util_format_short_name(testcase
->format
),
91 layout
.width0
, layout
.height0
, layout
.depth0
,
93 layout
.ubwc_slices
[l
].offset
,
94 testcase
->layout
.ubwc_slices
[l
].offset
);
97 if (layout
.ubwc_slices
[l
].pitch
!= testcase
->layout
.ubwc_slices
[l
].pitch
) {
98 fprintf(stderr
, "%s %dx%dx%d@%dx lvl%d: UBWC pitch %d != %d\n",
99 util_format_short_name(testcase
->format
),
100 layout
.width0
, layout
.height0
, layout
.depth0
,
101 layout
.nr_samples
, l
,
102 layout
.ubwc_slices
[l
].pitch
,
103 testcase
->layout
.ubwc_slices
[l
].pitch
);
109 fprintf(stderr
, "\n");