pan/decode: Pretty print 22-bit pixel formats

Signed-off-by: Alyssa Rosenzweig <alyssa.rosenzweig@collabora.com>
Suggested-by: Icecream95 <ixn@disroot.org>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/9105>
This commit is contained in:
Alyssa Rosenzweig 2021-02-16 21:54:35 -05:00 committed by Marge Bot
parent 61584bb4e8
commit bc494b30b7
2 changed files with 28 additions and 7 deletions

View File

@ -166,6 +166,24 @@ __gen_unpack_padded(const uint8_t *restrict cl, uint32_t start, uint32_t end)
#define pan_section_print(fp, A, S, var, indent) \\
MALI_ ## A ## _SECTION_ ## S ## _print(fp, &(var), indent)
#define mali_pixel_format_print_v6(fp, format) \\
fprintf(fp, "%*sFormat (v6): %s%s%s %s%s%s%s\\n", indent, "", \\
mali_format_as_str((format >> 12) & 0xFF), \\
(format & (1 << 20)) ? " sRGB" : "", \\
(format & (1 << 21)) ? " big-endian" : "", \\
mali_channel_as_str(((format >> 0) & 0x7)), \\
mali_channel_as_str(((format >> 3) & 0x7)), \\
mali_channel_as_str(((format >> 6) & 0x7)), \\
mali_channel_as_str(((format >> 9) & 0x7)));
#define mali_pixel_format_print_v7(fp, format) \\
fprintf(fp, "%*sFormat (v7): %s%s %s%s\\n", indent, "", \\
mali_format_as_str((format >> 12) & 0xFF), \\
(format & (1 << 20)) ? " sRGB" : "", \\
mali_rgb_component_order_as_str((format & ((1 << 12) - 1))), \\
(format & (1 << 21)) ? " XXX BAD BIT" : "");
/* From presentations, 16x16 tiles externally. Use shift for fast computation
* of tile numbers. */
@ -332,7 +350,7 @@ class Field(object):
type = 'uint64_t'
elif self.type == 'int':
type = 'int32_t'
elif self.type in ['uint', 'padded']:
elif self.type in ['uint', 'padded', 'Pixel Format']:
type = 'uint32_t'
elif self.type in self.parser.structs:
type = 'struct ' + self.parser.gen_prefix(safe_name(self.type.upper()))
@ -487,7 +505,7 @@ class Group(object):
elif field.modifier[0] == "log2":
value = "util_logbase2({})".format(value)
if field.type == "uint" or field.type == "address":
if field.type in ["uint", "address", "Pixel Format"]:
s = "__gen_uint(%s, %d, %d)" % \
(value, start, end)
elif field.type == "padded":
@ -561,7 +579,7 @@ class Group(object):
args.append(str(fieldref.start))
args.append(str(fieldref.end))
if field.type in set(["uint", "address"]) | self.parser.enums:
if field.type in set(["uint", "address", "Pixel Format"]) | self.parser.enums:
convert = "__gen_unpack_uint"
elif field.type == "int":
convert = "__gen_unpack_sint"
@ -613,6 +631,9 @@ class Group(object):
print(' fprintf(fp, "%*s{}: %f\\n", indent, "", {});'.format(name, val))
elif field.type == "uint" and (field.end - field.start) >= 32:
print(' fprintf(fp, "%*s{}: 0x%" PRIx64 "\\n", indent, "", {});'.format(name, val))
elif field.type == "Pixel Format":
print(' mali_pixel_format_print_v6(fp, {});'.format(val))
print(' mali_pixel_format_print_v7(fp, {});'.format(val))
else:
print(' fprintf(fp, "%*s{}: %u\\n", indent, "", {});'.format(name, val))

View File

@ -462,7 +462,7 @@
<struct name="Attribute">
<field name="Buffer index" size="9" start="0" type="uint"/>
<field name="Offset enable" size="1" start="9" type="bool" default="true"/>
<field name="Format" size="22" start="10" type="uint"/>
<field name="Format" size="22" start="10" type="Pixel Format"/>
<field name="Offset" size="32" start="32" type="int"/>
</struct>
@ -563,7 +563,7 @@
</struct>
<struct name="Bifrost Internal Conversion" size="1">
<field name="Memory Format" size="22" start="0" type="uint"/>
<field name="Memory Format" size="22" start="0" type="Pixel Format"/>
<field name="Raw" size="1" start="22" type="bool"/>
<field name="Register Format" size="3" start="24" type="Bifrost Register File Format"/>
</struct>
@ -708,7 +708,7 @@
<field name="Depth" size="16" start="1:0" type="uint" modifier="minus(1)" default="1"/>
<field name="Sample count" size="16" start="1:0" type="uint" modifier="minus(1)" default="1"/>
<field name="Array size" size="16" start="1:16" type="uint" modifier="minus(1)"/>
<field name="Format" size="22" start="2:0" type="uint"/>
<field name="Format" size="22" start="2:0" type="Pixel Format"/>
<field name="Dimension" size="2" start="2:22" type="Texture Dimension"/>
<field name="Texel ordering" size="4" start="2:24" type="Texture Layout"/>
<field name="Surface pointer is 64b" size="1" start="2:28" type="bool" default="true"/>
@ -751,7 +751,7 @@
<field name="Dimension" size="2" start="0:4" type="Texture Dimension"/>
<field name="Sample corner position" size="1" start="0:8" type="bool" default="false"/>
<field name="Normalize coordinatess" size="1" start="0:9" type="bool" default="false"/>
<field name="Format" size="22" start="0:10" type="uint"/>
<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"/>