panfrost: Debitfieldize mali_uniform_buffer_meta
[mesa.git] / src / panfrost / pandecode / pan_pretty_print.c
1 /*
2 * © Copyright 2017-2098 The Panfrost Communiy
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 FROM,
20 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 * SOFTWARE.
22 */
23
24 #include "pan_pretty_print.h"
25
26 #include <stdio.h>
27 #include <string.h>
28 #include <assert.h>
29
30 /* Some self-contained prettyprinting functions shared between pandecode and
31 * the main driver */
32
33 #define DEFINE_CASE(name) case MALI_## name: return "MALI_" #name
34 char *pandecode_format(enum mali_format format)
35 {
36 static char unk_format_str[10];
37
38 switch (format) {
39 DEFINE_CASE(ETC2_RGB8);
40 DEFINE_CASE(ETC2_R11_UNORM);
41 DEFINE_CASE(ETC2_RGBA8);
42 DEFINE_CASE(ETC2_RG11_UNORM);
43 DEFINE_CASE(ETC2_R11_SNORM);
44 DEFINE_CASE(ETC2_RG11_SNORM);
45 DEFINE_CASE(ETC2_RGB8A1);
46 DEFINE_CASE(ASTC_SRGB_SUPP);
47 DEFINE_CASE(ASTC_HDR_SUPP);
48 DEFINE_CASE(RGB565);
49 DEFINE_CASE(RGB5_A1_UNORM);
50 DEFINE_CASE(RGB10_A2_UNORM);
51 DEFINE_CASE(RGB10_A2_SNORM);
52 DEFINE_CASE(RGB10_A2UI);
53 DEFINE_CASE(RGB10_A2I);
54 DEFINE_CASE(NV12);
55 DEFINE_CASE(Z32_UNORM);
56 DEFINE_CASE(R32_FIXED);
57 DEFINE_CASE(RG32_FIXED);
58 DEFINE_CASE(RGB32_FIXED);
59 DEFINE_CASE(RGBA32_FIXED);
60 DEFINE_CASE(R11F_G11F_B10F);
61 DEFINE_CASE(R9F_G9F_B9F_E5F);
62 DEFINE_CASE(VARYING_POS);
63 DEFINE_CASE(VARYING_DISCARD);
64
65 DEFINE_CASE(R8_SNORM);
66 DEFINE_CASE(R16_SNORM);
67 DEFINE_CASE(R32_SNORM);
68 DEFINE_CASE(RG8_SNORM);
69 DEFINE_CASE(RG16_SNORM);
70 DEFINE_CASE(RG32_SNORM);
71 DEFINE_CASE(RGB8_SNORM);
72 DEFINE_CASE(RGB16_SNORM);
73 DEFINE_CASE(RGB32_SNORM);
74 DEFINE_CASE(RGBA8_SNORM);
75 DEFINE_CASE(RGBA16_SNORM);
76 DEFINE_CASE(RGBA32_SNORM);
77
78 DEFINE_CASE(R8UI);
79 DEFINE_CASE(R16UI);
80 DEFINE_CASE(R32UI);
81 DEFINE_CASE(RG8UI);
82 DEFINE_CASE(RG16UI);
83 DEFINE_CASE(RG32UI);
84 DEFINE_CASE(RGB8UI);
85 DEFINE_CASE(RGB16UI);
86 DEFINE_CASE(RGB32UI);
87 DEFINE_CASE(RGBA8UI);
88 DEFINE_CASE(RGBA16UI);
89 DEFINE_CASE(RGBA32UI);
90
91 DEFINE_CASE(R8_UNORM);
92 DEFINE_CASE(R16_UNORM);
93 DEFINE_CASE(R32_UNORM);
94 DEFINE_CASE(R32F);
95 DEFINE_CASE(RG8_UNORM);
96 DEFINE_CASE(RG16_UNORM);
97 DEFINE_CASE(RG32_UNORM);
98 DEFINE_CASE(RG32F);
99 DEFINE_CASE(RGB8_UNORM);
100 DEFINE_CASE(RGB16_UNORM);
101 DEFINE_CASE(RGB32_UNORM);
102 DEFINE_CASE(RGB32F);
103 DEFINE_CASE(RGBA4_UNORM);
104 DEFINE_CASE(RGBA8_UNORM);
105 DEFINE_CASE(RGBA16_UNORM);
106 DEFINE_CASE(RGBA32_UNORM);
107 DEFINE_CASE(RGBA32F);
108
109 DEFINE_CASE(R8I);
110 DEFINE_CASE(R16I);
111 DEFINE_CASE(R32I);
112 DEFINE_CASE(RG8I);
113 DEFINE_CASE(R16F);
114 DEFINE_CASE(RG16I);
115 DEFINE_CASE(RG32I);
116 DEFINE_CASE(RG16F);
117 DEFINE_CASE(RGB8I);
118 DEFINE_CASE(RGB16I);
119 DEFINE_CASE(RGB32I);
120 DEFINE_CASE(RGB16F);
121 DEFINE_CASE(RGBA8I);
122 DEFINE_CASE(RGBA16I);
123 DEFINE_CASE(RGBA32I);
124 DEFINE_CASE(RGBA16F);
125
126 DEFINE_CASE(RGBA4);
127 DEFINE_CASE(RGBA8_2);
128 DEFINE_CASE(RGB10_A2_2);
129 default:
130 snprintf(unk_format_str, sizeof(unk_format_str), "MALI_0x%02x", format);
131 return unk_format_str;
132 }
133 }
134
135 #undef DEFINE_CASE
136
137 /* Helper to dump fixed-function blend part for debugging */
138
139 static const char *
140 panfrost_factor_name(enum mali_dominant_factor factor)
141 {
142 switch (factor) {
143 case MALI_DOMINANT_UNK0:
144 return "unk0";
145
146 case MALI_DOMINANT_ZERO:
147 return "zero";
148
149 case MALI_DOMINANT_SRC_COLOR:
150 return "source color";
151
152 case MALI_DOMINANT_DST_COLOR:
153 return "dest color";
154
155 case MALI_DOMINANT_UNK4:
156 return "unk4";
157
158 case MALI_DOMINANT_SRC_ALPHA:
159 return "source alpha";
160
161 case MALI_DOMINANT_DST_ALPHA:
162 return "dest alpha";
163
164 case MALI_DOMINANT_CONSTANT:
165 return "constant";
166 }
167
168 return "unreachable";
169 }
170
171 static const char *
172 panfrost_modifier_name(enum mali_blend_modifier mod)
173 {
174 switch (mod) {
175 case MALI_BLEND_MOD_UNK0:
176 return "unk0";
177
178 case MALI_BLEND_MOD_NORMAL:
179 return "normal";
180
181 case MALI_BLEND_MOD_SOURCE_ONE:
182 return "source one";
183
184 case MALI_BLEND_MOD_DEST_ONE:
185 return "dest one";
186 }
187
188 return "unreachable";
189 }
190
191 static void
192 panfrost_print_fixed_part(const char *name, unsigned u)
193 {
194 struct mali_blend_mode part;
195 memcpy(&part, &u, sizeof(part));
196
197 printf("%s blend mode (%X):\n", name, u);
198
199 printf(" %s dominant:\n",
200 (part.dominant == MALI_BLEND_DOM_SOURCE) ? "source" : "destination");
201
202 printf(" %s\n", panfrost_factor_name(part.dominant_factor));
203
204 if (part.complement_dominant)
205 printf(" complement\n");
206
207
208 printf(" nondominant %s\n",
209 (part.nondominant_mode == MALI_BLEND_NON_MIRROR) ? "mirror" : "zero");
210
211
212 printf(" mode: %s\n", panfrost_modifier_name(part.clip_modifier));
213
214 if (part.negate_source) printf(" negate source\n");
215
216 if (part.negate_dest) printf(" negate dest\n");
217
218 assert(!(part.unused_0 || part.unused_1));
219 }
220
221 void
222 panfrost_print_blend_equation(struct mali_blend_equation eq)
223 {
224 printf("\n");
225 panfrost_print_fixed_part("RGB", eq.rgb_mode);
226 panfrost_print_fixed_part("Alpha", eq.alpha_mode);
227
228 assert(!eq.zero1);
229
230 printf("Mask: %s%s%s%s\n",
231 (eq.color_mask & MALI_MASK_R) ? "R" : "",
232 (eq.color_mask & MALI_MASK_G) ? "G" : "",
233 (eq.color_mask & MALI_MASK_B) ? "B" : "",
234 (eq.color_mask & MALI_MASK_A) ? "A" : "");
235 }