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 "util/half_float.h"
28 #include "util/u_math.h"
29 #include "a5xx.xml.h"
30
31 #include <stdio.h>
32
33 /* Testcases generated from cffdump --script texturator-to-unit-test-5xx.lua
34 * on a Pixel 2
35 */
36 static const struct testcase testcases[] = {
37 /* Basic POT, non-UBWC layout test */
38 {
39 .format = PIPE_FORMAT_R9G9B9E5_FLOAT,
40 .layout =
41 {
42 .tile_mode = TILE5_3,
43 .width0 = 32,
44 .height0 = 32,
45 .slices =
46 {
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 /* Some 3D cases of sizes from the CTS, when I was suspicious of our 3D
58 * layout.
59 */
60 {
61 .format = PIPE_FORMAT_R9G9B9E5_FLOAT,
62 .is_3d = true,
63 .layout =
64 {
65 .tile_mode = TILE5_3,
66 .ubwc = false,
67 .width0 = 59,
68 .height0 = 37,
69 .depth0 = 11,
70 .slices =
71 {
72 {.offset = 0, .pitch = 256},
73 {.offset = 135168, .pitch = 256},
74 {.offset = 176128, .pitch = 256},
75 {.offset = 192512, .pitch = 256},
76 {.offset = 200704, .pitch = 256},
77 {.offset = 208896, .pitch = 256},
78 },
79 },
80 },
81 {
82 .format = PIPE_FORMAT_R32G32_FLOAT,
83 .is_3d = true,
84 .layout =
85 {
86 .tile_mode = TILE5_3,
87 .ubwc = false,
88 .width0 = 63,
89 .height0 = 29,
90 .depth0 = 11,
91 .slices =
92 {
93 {.offset = 0, .pitch = 512},
94 {.offset = 180224, .pitch = 512},
95 {.offset = 221184, .pitch = 512},
96 {.offset = 237568, .pitch = 512},
97 {.offset = 245760, .pitch = 512},
98 {.offset = 253952, .pitch = 512},
99 },
100 },
101 },
102 };
103
104 int
main(int argc,char ** argv)105 main(int argc, char **argv)
106 {
107 int ret = 0;
108
109 for (int i = 0; i < ARRAY_SIZE(testcases); i++) {
110 if (!fdl_test_layout(&testcases[i], 540))
111 ret = 1;
112 }
113
114 return ret;
115 }
116