From 8eefda4ea907b13bd97e29bf8496b019f29e9b6f Mon Sep 17 00:00:00 2001 From: Alyssa Rosenzweig Date: Fri, 30 Sep 2022 21:03:02 -0400 Subject: [PATCH] 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 Part-of: --- src/asahi/lib/agx_formats.c | 5 +++-- src/asahi/lib/agx_formats.h | 5 +++-- src/asahi/lib/cmdbuf.xml | 11 ++++------- src/asahi/lib/gen_pack.py | 26 +++----------------------- src/gallium/drivers/asahi/agx_state.c | 9 ++++++--- 5 files changed, 19 insertions(+), 37 deletions(-) diff --git a/src/asahi/lib/agx_formats.c b/src/asahi/lib/agx_formats.c index a9433e52ca1..3b6db88215e 100644 --- a/src/asahi/lib/agx_formats.c +++ b/src/asahi/lib/agx_formats.c @@ -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,\ } diff --git a/src/asahi/lib/agx_formats.h b/src/asahi/lib/agx_formats.h index 506f1e08c5b..15c9d4b6778 100644 --- a/src/asahi/lib/agx_formats.h +++ b/src/asahi/lib/agx_formats.h @@ -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 diff --git a/src/asahi/lib/cmdbuf.xml b/src/asahi/lib/cmdbuf.xml index e3fcfd1773f..e0b28bcfa22 100644 --- a/src/asahi/lib/cmdbuf.xml +++ b/src/asahi/lib/cmdbuf.xml @@ -169,15 +169,11 @@ - - - - - - + + @@ -228,7 +224,8 @@ - + + diff --git a/src/asahi/lib/gen_pack.py b/src/asahi/lib/gen_pack.py index a8d839e0e2c..c0a4b25881e 100644 --- a/src/asahi/lib/gen_pack.py +++ b/src/asahi/lib/gen_pack.py @@ -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: diff --git a/src/gallium/drivers/asahi/agx_state.c b/src/gallium/drivers/asahi/agx_state.c index 462ec409a8d..c6922ffb4bf 100644 --- a/src/gallium/drivers/asahi/agx_state.c +++ b/src/gallium/drivers/asahi/agx_state.c @@ -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]);