2 * © Copyright 2017-2098 The Panfrost Communiy
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 FROM,
20 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
24 #include "pan_pretty_print.h"
30 /* Some self-contained prettyprinting functions shared between panwrap and
33 #define DEFINE_CASE(name) case MALI_## name: return "MALI_" #name
34 char *panwrap_format_name(enum mali_format format
)
36 static char unk_format_str
[5];
39 DEFINE_CASE(RGB10_A2_UNORM
);
40 DEFINE_CASE(RGB10_A2_SNORM
);
41 DEFINE_CASE(RGB10_A2UI
);
42 DEFINE_CASE(RGB10_A2I
);
44 DEFINE_CASE(Z32_UNORM
);
45 DEFINE_CASE(R32_FIXED
);
46 DEFINE_CASE(RG32_FIXED
);
47 DEFINE_CASE(RGB32_FIXED
);
48 DEFINE_CASE(RGBA32_FIXED
);
49 DEFINE_CASE(R11F_G11F_B10F
);
50 DEFINE_CASE(VARYING_POS
);
51 DEFINE_CASE(VARYING_DISCARD
);
53 DEFINE_CASE(R8_SNORM
);
54 DEFINE_CASE(R16_SNORM
);
55 DEFINE_CASE(R32_SNORM
);
56 DEFINE_CASE(RG8_SNORM
);
57 DEFINE_CASE(RG16_SNORM
);
58 DEFINE_CASE(RG32_SNORM
);
59 DEFINE_CASE(RGB8_SNORM
);
60 DEFINE_CASE(RGB16_SNORM
);
61 DEFINE_CASE(RGB32_SNORM
);
62 DEFINE_CASE(RGBA8_SNORM
);
63 DEFINE_CASE(RGBA16_SNORM
);
64 DEFINE_CASE(RGBA32_SNORM
);
76 DEFINE_CASE(RGBA16UI
);
77 DEFINE_CASE(RGBA32UI
);
79 DEFINE_CASE(R8_UNORM
);
80 DEFINE_CASE(R16_UNORM
);
81 DEFINE_CASE(R32_UNORM
);
83 DEFINE_CASE(RG8_UNORM
);
84 DEFINE_CASE(RG16_UNORM
);
85 DEFINE_CASE(RG32_UNORM
);
87 DEFINE_CASE(RGB8_UNORM
);
88 DEFINE_CASE(RGB16_UNORM
);
89 DEFINE_CASE(RGB32_UNORM
);
91 DEFINE_CASE(RGBA8_UNORM
);
92 DEFINE_CASE(RGBA16_UNORM
);
93 DEFINE_CASE(RGBA32_UNORM
);
109 DEFINE_CASE(RGBA16I
);
110 DEFINE_CASE(RGBA32I
);
111 DEFINE_CASE(RGBA16F
);
114 DEFINE_CASE(RGBA8_2
);
115 DEFINE_CASE(RGB10_A2_2
);
117 snprintf(unk_format_str
, sizeof(unk_format_str
), "0x%02x", format
);
118 return unk_format_str
;
124 /* Helper to dump fixed-function blend part for debugging */
127 panfrost_factor_name(enum mali_dominant_factor factor
)
130 case MALI_DOMINANT_UNK0
:
133 case MALI_DOMINANT_ZERO
:
136 case MALI_DOMINANT_SRC_COLOR
:
137 return "source color";
139 case MALI_DOMINANT_DST_COLOR
:
142 case MALI_DOMINANT_UNK4
:
145 case MALI_DOMINANT_SRC_ALPHA
:
146 return "source alpha";
148 case MALI_DOMINANT_DST_ALPHA
:
151 case MALI_DOMINANT_CONSTANT
:
155 return "unreachable";
159 panfrost_modifier_name(enum mali_blend_modifier mod
)
162 case MALI_BLEND_MOD_UNK0
:
165 case MALI_BLEND_MOD_NORMAL
:
168 case MALI_BLEND_MOD_SOURCE_ONE
:
171 case MALI_BLEND_MOD_DEST_ONE
:
175 return "unreachable";
179 panfrost_print_fixed_part(const char *name
, unsigned u
)
181 struct mali_blend_mode part
;
182 memcpy(&part
, &u
, sizeof(part
));
184 printf("%s blend mode (%X):\n", name
, u
);
186 printf(" %s dominant:\n",
187 (part
.dominant
== MALI_BLEND_DOM_SOURCE
) ? "source" : "destination");
189 printf(" %s\n", panfrost_factor_name(part
.dominant_factor
));
191 if (part
.complement_dominant
)
192 printf(" complement\n");
195 printf(" nondominant %s\n",
196 (part
.nondominant_mode
== MALI_BLEND_NON_MIRROR
) ? "mirror" : "zero");
199 printf(" mode: %s\n", panfrost_modifier_name(part
.clip_modifier
));
201 if (part
.negate_source
) printf(" negate source\n");
203 if (part
.negate_dest
) printf(" negate dest\n");
205 assert(!(part
.unused_0
|| part
.unused_1
));
209 panfrost_print_blend_equation(struct mali_blend_equation eq
)
212 panfrost_print_fixed_part("RGB", eq
.rgb_mode
);
213 panfrost_print_fixed_part("Alpha", eq
.alpha_mode
);
217 printf("Mask: %s%s%s%s\n",
218 (eq
.color_mask
& MALI_MASK_R
) ? "R" : "",
219 (eq
.color_mask
& MALI_MASK_G
) ? "G" : "",
220 (eq
.color_mask
& MALI_MASK_B
) ? "B" : "",
221 (eq
.color_mask
& MALI_MASK_A
) ? "A" : "");
223 printf("Constant: %f\n", eq
.constant
);