asahi: Eliminate "Pixel Format" type from GenXML

This is leaky and hurts compatibility with upstream GenXML. Just use the
actual hardware fields.

Signed-off-by: Alyssa Rosenzweig <alyssa@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/18922>
This commit is contained in:
Alyssa Rosenzweig 2022-09-30 21:03:02 -04:00 committed by Alyssa Rosenzweig
parent f4b03ea6dc
commit 8eefda4ea9
5 changed files with 19 additions and 37 deletions

View file

@ -28,9 +28,10 @@
#define F false
#define AGX_FORMAT__ 0
#define AGX_FMT(pipe, channels, type, is_renderable, internal_fmt) \
#define AGX_FMT(pipe, channels_, type_, is_renderable, internal_fmt) \
[PIPE_FORMAT_ ## pipe] = { \
.hw = (AGX_CHANNELS_ ## channels) | ((AGX_TEXTURE_TYPE_ ## type) << 7), \
.channels = AGX_CHANNELS_ ## channels_, \
.type = AGX_TEXTURE_TYPE_ ## type_, \
.renderable = is_renderable, \
.internal = AGX_FORMAT_ ## internal_fmt,\
}

View file

@ -29,7 +29,8 @@
#include "asahi/compiler/agx_compile.h"
struct agx_pixel_format_entry {
uint16_t hw;
uint8_t channels;
uint8_t type;
bool renderable : 1;
enum agx_format internal : 4;
};
@ -44,7 +45,7 @@ static inline bool
agx_is_valid_pixel_format(enum pipe_format format)
{
struct agx_pixel_format_entry entry = agx_pixel_format[format];
return (entry.hw != 0) || entry.renderable;
return ((entry.channels | entry.type) != 0) || entry.renderable;
}
#endif

View file

@ -169,15 +169,11 @@
<field name="Base coefficient register" size="8" start="16" type="uint"/>
</struct>
<struct name="Format" size="2">
<field name="Channels" size="7" start="0" type="Channels"/>
<field name="Type" size="3" start="7" type="Texture Type"/>
</struct>
<struct name="Render Target" size="24">
<field name="Unknown" size="4" start="0" type="hex" default="0x2"/>
<field name="Layout" size="2" start="4" type="Layout"/>
<field name="Format" size="10" start="6" type="Pixel Format"/>
<field name="Channels" size="7" start="6" type="Channels"/>
<field name="Type" size="3" start="13" type="Texture Type"/>
<field name="Swizzle R" size="2" start="16" type="Channel"/>
<field name="Swizzle G" size="2" start="18" type="Channel"/>
<field name="Swizzle B" size="2" start="20" type="Channel"/>
@ -228,7 +224,8 @@
<struct name="Texture" size="24">
<field name="Dimension" size="4" start="0" type="Texture dimension" default="2D"/>
<field name="Layout" size="2" start="4" type="Layout"/>
<field name="Format" size="10" start="6" type="Pixel Format"/>
<field name="Channels" size="7" start="6" type="Channels"/>
<field name="Type" size="3" start="13" type="Texture Type"/>
<field name="Swizzle R" size="3" start="16" type="Channel" default="R"/>
<field name="Swizzle G" size="3" start="19" type="Channel" default="G"/>
<field name="Swizzle B" size="3" start="22" type="Channel" default="B"/>

View file

@ -106,24 +106,6 @@ __gen_unpack_sint(const uint8_t *restrict cl, uint32_t start, uint32_t end)
#define agx_print(fp, T, var, indent) \\
AGX_ ## T ## _print(fp, &(var), indent)
#define agx_pixel_format_print(fp, format) do {\\
fprintf(fp, "%*sFormat: ", indent, ""); \\
\\
if (agx_channels_as_str((enum agx_channels)(format & 0x7F))) \\
fputs(agx_channels_as_str((enum agx_channels)(format & 0x7F)), fp); \\
else \\
fprintf(fp, "unknown channels %02X", format & 0x7F); \\
\\
fputs(" ", fp); \\
\\
if (agx_texture_type_as_str((enum agx_texture_type)(format >> 7))) \\
fputs(agx_texture_type_as_str((enum agx_texture_type)(format >> 7)), fp); \\
else \\
fprintf(fp, "unknown type %02X", format >> 7); \\
\\
fputs("\\n", fp); \\
} while(0) \\
"""
def to_alphanum(name):
@ -247,7 +229,7 @@ class Field(object):
type = 'uint64_t'
elif self.type == 'int':
type = 'int32_t'
elif self.type in ['uint', 'uint/float', 'Pixel Format', 'hex']:
elif self.type in ['uint', 'uint/float', 'hex']:
type = 'uint32_t'
elif self.type in self.parser.structs:
type = 'struct ' + self.parser.gen_prefix(safe_name(self.type.upper()))
@ -403,7 +385,7 @@ class Group(object):
elif field.modifier[0] == "log2":
value = "util_logbase2({})".format(value)
if field.type in ["uint", "hex", "Pixel Format", "address"]:
if field.type in ["uint", "hex", "address"]:
s = "util_bitpack_uint(%s, %d, %d)" % \
(value, start, end)
elif field.type in self.parser.enums:
@ -477,7 +459,7 @@ class Group(object):
args.append(str(fieldref.start))
args.append(str(fieldref.end))
if field.type in set(["uint", "uint/float", "address", "Pixel Format", "hex"]) | self.parser.enums:
if field.type in set(["uint", "uint/float", "address", "hex"]) | self.parser.enums:
convert = "__gen_unpack_uint"
elif field.type == "int":
convert = "__gen_unpack_sint"
@ -537,8 +519,6 @@ class Group(object):
print(' fprintf(fp, "%*s{}: 0x%" PRIx64 "\\n", indent, "", {});'.format(name, val))
elif field.type == "hex":
print(' fprintf(fp, "%*s{}: 0x%" PRIx32 "\\n", indent, "", {});'.format(name, val))
elif field.type in "Pixel Format":
print(' agx_pixel_format_print(fp, {});'.format(val))
elif field.type == "uint/float":
print(' fprintf(fp, "%*s{}: 0x%X (%f)\\n", indent, "", {}, uif({}));'.format(name, val, val))
else:

View file

@ -472,7 +472,8 @@ agx_create_sampler_view(struct pipe_context *pctx,
agx_pack(&so->desc, TEXTURE, cfg) {
cfg.dimension = agx_translate_texture_dimension(state->target);
cfg.layout = agx_translate_layout(rsrc->modifier);
cfg.format = agx_pixel_format[state->format].hw;
cfg.channels = agx_pixel_format[state->format].channels;
cfg.type = agx_pixel_format[state->format].type;
cfg.swizzle_r = agx_channel_from_pipe(out_swizzle[0]);
cfg.swizzle_g = agx_channel_from_pipe(out_swizzle[1]);
cfg.swizzle_b = agx_channel_from_pipe(out_swizzle[2]);
@ -772,7 +773,8 @@ agx_set_framebuffer_state(struct pipe_context *pctx,
agx_pack(ctx->render_target[i], RENDER_TARGET, cfg) {
cfg.layout = agx_translate_layout(tex->modifier);
cfg.format = agx_pixel_format[surf->format].hw;
cfg.channels = agx_pixel_format[surf->format].channels;
cfg.type = agx_pixel_format[surf->format].type;
assert(desc->nr_channels >= 1 && desc->nr_channels <= 4);
cfg.swizzle_r = agx_channel_from_pipe(desc->swizzle[0]);
@ -1414,7 +1416,8 @@ agx_build_reload_pipeline(struct agx_context *ctx, uint32_t code, struct pipe_su
*/
cfg.dimension = AGX_TEXTURE_DIMENSION_2D;
cfg.layout = agx_translate_layout(rsrc->modifier);
cfg.format = agx_pixel_format[surf->format].hw;
cfg.channels = agx_pixel_format[surf->format].channels;
cfg.type = agx_pixel_format[surf->format].type;
cfg.swizzle_r = agx_channel_from_pipe(desc->swizzle[0]);
cfg.swizzle_g = agx_channel_from_pipe(desc->swizzle[1]);
cfg.swizzle_b = agx_channel_from_pipe(desc->swizzle[2]);