• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 "adreno_pm4.xml.h"
28 #include "a6xx.xml.h"
29 
30 #include <stdio.h>
31 
fdl_test_layout(const struct testcase * testcase,int gpu_id)32 bool fdl_test_layout(const struct testcase *testcase, int gpu_id)
33 {
34 	struct fdl_layout layout = {
35 		.ubwc = testcase->layout.ubwc,
36 		.tile_mode = testcase->layout.tile_mode,
37 	};
38 	bool ok = true;
39 
40 	int max_size = MAX2(testcase->layout.width0, testcase->layout.height0);
41 	int mip_levels = 1;
42 	while (max_size > 1 && testcase->layout.slices[mip_levels].pitch) {
43 		mip_levels++;
44 		max_size = u_minify(max_size, 1);
45 	}
46 
47 	if (gpu_id >= 600) {
48 		fdl6_layout(&layout,
49 				testcase->format,
50 				MAX2(testcase->layout.nr_samples, 1),
51 				testcase->layout.width0,
52 				MAX2(testcase->layout.height0, 1),
53 				MAX2(testcase->layout.depth0, 1),
54 				mip_levels,
55 				MAX2(testcase->array_size, 1),
56 				testcase->is_3d,
57 				NULL);
58 	} else {
59 		assert(gpu_id >= 500);
60 		fdl5_layout(&layout,
61 				testcase->format,
62 				MAX2(testcase->layout.nr_samples, 1),
63 				testcase->layout.width0,
64 				MAX2(testcase->layout.height0, 1),
65 				MAX2(testcase->layout.depth0, 1),
66 				mip_levels,
67 				MAX2(testcase->array_size, 1),
68 				testcase->is_3d);
69 	}
70 
71 	/* fdl lays out UBWC data before the color data, while all we have
72 	 * recorded in this testcase are the color offsets (other than the UBWC
73 	 * buffer sharing test).  Shift the fdl layout down so we can compare
74 	 * color offsets.
75 	 */
76 	if (layout.ubwc && !testcase->layout.slices[0].offset) {
77 		for (int l = 1; l < mip_levels; l++)
78 			layout.slices[l].offset -= layout.slices[0].offset;
79 		layout.slices[0].offset = 0;
80 	}
81 
82 	for (int l = 0; l < mip_levels; l++) {
83 		if (layout.slices[l].offset != testcase->layout.slices[l].offset) {
84 			fprintf(stderr, "%s %dx%dx%d@%dx lvl%d: offset 0x%x != 0x%x\n",
85 					util_format_short_name(testcase->format),
86 					layout.width0, layout.height0, layout.depth0,
87 					layout.nr_samples, l,
88 					layout.slices[l].offset,
89 					testcase->layout.slices[l].offset);
90 			ok = false;
91 		}
92 		if (fdl_pitch(&layout, l) != testcase->layout.slices[l].pitch) {
93 			fprintf(stderr, "%s %dx%dx%d@%dx lvl%d: pitch %d != %d\n",
94 					util_format_short_name(testcase->format),
95 					layout.width0, layout.height0, layout.depth0,
96 					layout.nr_samples, l,
97 					fdl_pitch(&layout, l),
98 					testcase->layout.slices[l].pitch);
99 			ok = false;
100 		}
101 
102 		if (layout.ubwc_slices[l].offset != testcase->layout.ubwc_slices[l].offset) {
103 			fprintf(stderr, "%s %dx%dx%d@%dx lvl%d: UBWC offset 0x%x != 0x%x\n",
104 					util_format_short_name(testcase->format),
105 					layout.width0, layout.height0, layout.depth0,
106 					layout.nr_samples, l,
107 					layout.ubwc_slices[l].offset,
108 					testcase->layout.ubwc_slices[l].offset);
109 			ok = false;
110 		}
111 		if (fdl_ubwc_pitch(&layout, l) != testcase->layout.ubwc_slices[l].pitch) {
112 			fprintf(stderr, "%s %dx%dx%d@%dx lvl%d: UBWC pitch %d != %d\n",
113 					util_format_short_name(testcase->format),
114 					layout.width0, layout.height0, layout.depth0,
115 					layout.nr_samples, l,
116 					fdl_ubwc_pitch(&layout, l),
117 					testcase->layout.ubwc_slices[l].pitch);
118 			ok = false;
119 		}
120 	}
121 
122 	if (!ok)
123 		fprintf(stderr, "\n");
124 
125 	return ok;
126 }
127