panfrost: print human readable versions of some swizzle fields

In traces produced with PAN_MESA_DEBUG, print swizzles in human readable
form (like BGRA) as well as the raw decimal format we were printing
before. This is purely a convenience feature for developers.

Reviewed-by: Boris Brezilllon <boris.brezillon@collabora.com>
Reviewed-by: Mary Guillemard <mary.guillemard@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/31242>
This commit is contained in:
Eric R. Smith
2024-09-18 20:52:34 -03:00
parent 1b4e100779
commit fd11bbbb90
5 changed files with 24 additions and 11 deletions
+16 -3
View File
@@ -173,6 +173,17 @@ static inline void pan_merge_helper(uint32_t *dst, const uint32_t *src, size_t b
#define pan_merge(packed1, packed2, type) \
pan_merge_helper((packed1).opaque, (packed2).opaque, pan_size(type))
static inline const char *mali_component_swizzle(unsigned val) {
static const char swiz_name[] = "RGBA01??";
static char out_str[5], *outp;
outp = out_str;
for (int i = 0; i < 12; i += 3) {
*outp++ = swiz_name[(val >> i) & 7];
}
*outp = 0;
return out_str;
}
/* From presentations, 16x16 tiles externally. Use shift for fast computation
* of tile numbers. */
@@ -354,7 +365,7 @@ class Field(object):
type = 'uint64_t'
elif self.type == 'int':
type = 'int32_t'
elif self.type in ['uint', 'hex', 'uint/float', 'padded', 'Pixel Format']:
elif self.type in ['uint', 'hex', 'uint/float', 'padded', 'Pixel Format', 'Component Swizzle']:
type = 'uint32_t'
elif self.type in self.parser.structs:
type = 'struct ' + self.parser.gen_prefix(safe_name(self.type.upper()))
@@ -505,7 +516,7 @@ class Group(object):
elif field.modifier[0] == "log2":
value = "util_logbase2({})".format(value)
if field.type in ["uint", "hex", "uint/float", "address", "Pixel Format"]:
if field.type in ["uint", "hex", "uint/float", "address", "Pixel Format", "Component Swizzle"]:
s = "util_bitpack_uint(%s, %d, %d)" % \
(value, start, end)
elif field.type == "padded":
@@ -587,7 +598,7 @@ class Group(object):
args.append(str(fieldref.start))
args.append(str(fieldref.end))
if field.type in set(["uint", "hex", "uint/float", "address", "Pixel Format"]):
if field.type in set(["uint", "hex", "uint/float", "address", "Pixel Format", "Component Swizzle"]):
convert = "__gen_unpack_uint"
elif field.type in self.parser.enums:
convert = "(enum %s)__gen_unpack_uint" % enum_name(field.type)
@@ -651,6 +662,8 @@ class Group(object):
print(' fprintf(fp, "%*s{}: 0x%X (%f)\\n", indent, "", {}, uif({}));'.format(name, val, val))
elif field.type == "Pixel Format":
print(' mali_pixel_format_print(fp, {});'.format(val))
elif field.type == "Component Swizzle":
print(' fprintf(fp, "%*s{}: %u (%s)\\n", indent, "", {}, mali_component_swizzle({}));'.format(name, val, val))
else:
print(' fprintf(fp, "%*s{}: %u\\n", indent, "", {});'.format(name, val))
+2 -2
View File
@@ -1282,7 +1282,7 @@
<field name="Format" size="22" start="0:10" type="Pixel Format"/>
<field name="Width" size="16" start="1:0" type="uint" modifier="minus(1)"/>
<field name="Height" size="16" start="1:16" type="uint" modifier="minus(1)"/>
<field name="Swizzle" size="12" start="2:0" type="uint"/>
<field name="Swizzle" size="12" start="2:0" type="Component Swizzle"/>
<field name="Texel interleave" size="1" start="2:12" type="bool"/>
<field name="Levels" size="5" start="2:16" type="uint" default="1" modifier="minus(1)"/>
<field name="Minimum level" size="5" start="2:24" type="uint"/>
@@ -1628,7 +1628,7 @@
<field name="Writeback MSAA" size="2" start="1:12" type="MSAA"/>
<field name="sRGB" size="1" start="1:14" type="bool"/>
<field name="Dithering Enable" size="1" start="1:15" type="bool"/>
<field name="Swizzle" size="12" start="1:16" type="uint"/>
<field name="Swizzle" size="12" start="1:16" type="Component Swizzle"/>
<field name="Clean Pixel Write Enable" size="1" start="1:31" type="bool"/>
<field name="RGB" size="128" start="8:0" type="RT Buffer"/>
<field name="Clear" size="128" start="12:0" type="RT Clear"/>
+2 -2
View File
@@ -664,7 +664,7 @@
<field name="Format" size="22" start="0:10" type="Pixel Format"/>
<field name="Width" size="16" start="1:0" type="uint" modifier="minus(1)"/>
<field name="Height" size="16" start="1:16" type="uint" modifier="minus(1)"/>
<field name="Swizzle" size="12" start="2:0" type="uint"/>
<field name="Swizzle" size="12" start="2:0" type="Component Swizzle"/>
<field name="Texel ordering" size="4" start="2:12" type="Texture Layout"/>
<field name="Levels" size="5" start="2:16" type="uint" default="1" modifier="minus(1)"/>
<field name="Minimum level" size="5" start="2:24" type="uint"/>
@@ -1080,7 +1080,7 @@
<field name="Writeback MSAA" size="2" start="1:12" type="MSAA"/>
<field name="sRGB" size="1" start="1:14" type="bool"/>
<field name="Dithering Enable" size="1" start="1:15" type="bool"/>
<field name="Swizzle" size="12" start="1:16" type="uint"/>
<field name="Swizzle" size="12" start="1:16" type="Component Swizzle"/>
<field name="Clean Pixel Write Enable" size="1" start="1:31" type="bool"/>
<field name="RGB" size="128" start="8:0" type="RT Buffer"/>
<field name="Clear" size="128" start="12:0" type="RT Clear"/>
+2 -2
View File
@@ -728,7 +728,7 @@
<field name="Format" size="22" start="0:10" type="Pixel Format"/>
<field name="Width" size="16" start="1:0" type="uint" modifier="minus(1)"/>
<field name="Height" size="16" start="1:16" type="uint" modifier="minus(1)"/>
<field name="Swizzle" size="12" start="2:0" type="uint"/>
<field name="Swizzle" size="12" start="2:0" type="Component Swizzle"/>
<field name="Texel ordering" size="4" start="2:12" type="Texture Layout"/>
<field name="Levels" size="5" start="2:16" type="uint" default="1" modifier="minus(1)"/>
<field name="Minimum level" size="5" start="2:24" type="uint"/>
@@ -1168,7 +1168,7 @@
<field name="Writeback MSAA" size="2" start="1:12" type="MSAA"/>
<field name="sRGB" size="1" start="1:14" type="bool"/>
<field name="Dithering Enable" size="1" start="1:15" type="bool"/>
<field name="Swizzle" size="12" start="1:16" type="uint"/>
<field name="Swizzle" size="12" start="1:16" type="Component Swizzle"/>
<field name="Clean Pixel Write Enable" size="1" start="1:31" type="bool"/>
<field name="RGB" size="128" start="8:0" type="RT Buffer"/>
<field name="Clear" size="128" start="12:0" type="RT Clear"/>
+2 -2
View File
@@ -819,7 +819,7 @@
<field name="Format" size="22" start="0:10" type="Pixel Format"/>
<field name="Width" size="16" start="1:0" type="uint" modifier="minus(1)"/>
<field name="Height" size="16" start="1:16" type="uint" modifier="minus(1)"/>
<field name="Swizzle" size="12" start="2:0" type="uint"/>
<field name="Swizzle" size="12" start="2:0" type="Component Swizzle"/>
<field name="Texel interleave" size="1" start="2:12" type="bool"/>
<field name="Levels" size="5" start="2:16" type="uint" default="1" modifier="minus(1)"/>
<field name="Minimum level" size="5" start="2:24" type="uint"/>
@@ -1157,7 +1157,7 @@
<field name="Writeback MSAA" size="2" start="1:12" type="MSAA"/>
<field name="sRGB" size="1" start="1:14" type="bool"/>
<field name="Dithering Enable" size="1" start="1:15" type="bool"/>
<field name="Swizzle" size="12" start="1:16" type="uint"/>
<field name="Swizzle" size="12" start="1:16" type="Component Swizzle"/>
<field name="Clean Pixel Write Enable" size="1" start="1:31" type="bool"/>
<field name="RGB" size="128" start="8:0" type="RT Buffer"/>
<field name="Clear" size="128" start="12:0" type="RT Clear"/>