From e0fe9c369a1e68c4367e1a38d192594900c7dc1a Mon Sep 17 00:00:00 2001 From: Boris Brezillon Date: Tue, 5 Dec 2023 15:08:29 +0100 Subject: [PATCH] panfrost: Make panfrost_format_to_bifrost_blend() a per-gen helper Make panfrost_format_to_bifrost_blend() a per-gen helper so we don't have to pass a panfrost_device object around. While at it, pick a better name for this helper and move it to pan_format.h. Signed-off-by: Boris Brezillon Reviewed-by: Constantine Shablya Reviewed-by: Erik Faye-Lund Part-of: --- src/gallium/drivers/panfrost/pan_cmdstream.c | 5 ++--- src/panfrost/lib/pan_blend.c | 2 +- src/panfrost/lib/pan_blitter.c | 4 ++-- src/panfrost/lib/pan_format.h | 14 ++++++++++++++ src/panfrost/lib/pan_util.c | 13 ------------- src/panfrost/lib/pan_util.h | 5 ----- src/panfrost/vulkan/panvk_vX_cs.c | 3 +-- src/panfrost/vulkan/panvk_vX_meta_clear.c | 2 +- src/panfrost/vulkan/panvk_vX_meta_copy.c | 2 +- 9 files changed, 22 insertions(+), 28 deletions(-) diff --git a/src/gallium/drivers/panfrost/pan_cmdstream.c b/src/gallium/drivers/panfrost/pan_cmdstream.c index 12beb9b5753..6f29ca5d082 100644 --- a/src/gallium/drivers/panfrost/pan_cmdstream.c +++ b/src/gallium/drivers/panfrost/pan_cmdstream.c @@ -339,7 +339,6 @@ panfrost_emit_blend(struct panfrost_batch *batch, void *rts, } #if PAN_ARCH >= 6 - const struct panfrost_device *dev = pan_device(ctx->base.screen); struct panfrost_compiled_shader *fs = ctx->prog[PIPE_SHADER_FRAGMENT]; /* Words 2 and 3: Internal blend */ @@ -371,8 +370,8 @@ panfrost_emit_blend(struct panfrost_batch *batch, void *rts, * num_comps must be set to 4 */ cfg.fixed_function.num_comps = 4; - cfg.fixed_function.conversion.memory_format = - panfrost_format_to_bifrost_blend(dev, format, dithered); + cfg.fixed_function.conversion.memory_format = GENX( + panfrost_dithered_format_from_pipe_format)(format, dithered); cfg.fixed_function.rt = i; #if PAN_ARCH <= 7 diff --git a/src/panfrost/lib/pan_blend.c b/src/panfrost/lib/pan_blend.c index 3fb3c00663d..ce03044a56d 100644 --- a/src/panfrost/lib/pan_blend.c +++ b/src/panfrost/lib/pan_blend.c @@ -775,7 +775,7 @@ GENX(pan_blend_get_internal_desc)(const struct panfrost_device *dev, } cfg.fixed_function.conversion.memory_format = - panfrost_format_to_bifrost_blend(dev, fmt, dithered); + GENX(panfrost_dithered_format_from_pipe_format)(fmt, dithered); } return res; diff --git a/src/panfrost/lib/pan_blitter.c b/src/panfrost/lib/pan_blitter.c index 4c56d0b0cd4..9f4236f6da9 100644 --- a/src/panfrost/lib/pan_blitter.c +++ b/src/panfrost/lib/pan_blitter.c @@ -151,8 +151,8 @@ pan_blitter_emit_blend(const struct panfrost_device *dev, unsigned rt, nir_alu_type type = blit_shader->key.surfaces[rt].type; cfg.internal.fixed_function.num_comps = 4; - cfg.internal.fixed_function.conversion.memory_format = - panfrost_format_to_bifrost_blend(dev, iview->format, false); + cfg.internal.fixed_function.conversion.memory_format = GENX( + panfrost_dithered_format_from_pipe_format)(iview->format, false); cfg.internal.fixed_function.conversion.register_format = blit_type_to_reg_fmt(type); diff --git a/src/panfrost/lib/pan_format.h b/src/panfrost/lib/pan_format.h index 138555f3504..9a1d1a53a03 100644 --- a/src/panfrost/lib/pan_format.h +++ b/src/panfrost/lib/pan_format.h @@ -165,6 +165,20 @@ GENX(panfrost_blendable_format_from_pipe_format)(enum pipe_format f) { return &GENX(panfrost_blendable_formats)[f]; } + +#if PAN_ARCH >= 6 +static inline unsigned +GENX(panfrost_dithered_format_from_pipe_format)(enum pipe_format f, bool dithered) +{ + mali_pixel_format pixfmt = + GENX(panfrost_blendable_formats)[f].bifrost[dithered]; + + /* Formats requiring blend shaders are stored raw in the tilebuffer and will + * have 0 as their pixel format. Assumes dithering is set, I don't know of a + * case when it makes sense to turn off dithering. */ + return pixfmt ?: GENX(panfrost_format_from_pipe_format)(f)->hw; +} +#endif #endif #endif diff --git a/src/panfrost/lib/pan_util.c b/src/panfrost/lib/pan_util.c index baaee5f728f..d512d62e5b1 100644 --- a/src/panfrost/lib/pan_util.c +++ b/src/panfrost/lib/pan_util.c @@ -65,16 +65,3 @@ panfrost_invert_swizzle(const unsigned char *in, unsigned char *out) out[idx] = PIPE_SWIZZLE_X + c; } } - -/* Formats requiring blend shaders are stored raw in the tilebuffer and will - * have 0 as their pixel format. Assumes dithering is set, I don't know of a - * case when it makes sense to turn off dithering. */ - -unsigned -panfrost_format_to_bifrost_blend(const struct panfrost_device *dev, - enum pipe_format format, bool dithered) -{ - mali_pixel_format pixfmt = dev->blendable_formats[format].bifrost[dithered]; - - return pixfmt ?: dev->formats[format].hw; -} diff --git a/src/panfrost/lib/pan_util.h b/src/panfrost/lib/pan_util.h index 48cca9b879d..0b8b5140e79 100644 --- a/src/panfrost/lib/pan_util.h +++ b/src/panfrost/lib/pan_util.h @@ -55,17 +55,12 @@ #define PAN_DBG_YUV 0x20000 #define PAN_DBG_FORCE_PACK 0x40000 -struct panfrost_device; struct pan_blendable_format; unsigned panfrost_translate_swizzle_4(const unsigned char swizzle[4]); void panfrost_invert_swizzle(const unsigned char *in, unsigned char *out); -unsigned panfrost_format_to_bifrost_blend(const struct panfrost_device *dev, - enum pipe_format format, - bool dithered); - void pan_pack_color(const struct pan_blendable_format *blendable_formats, uint32_t *packed, const union pipe_color_union *color, enum pipe_format format, bool dithered); diff --git a/src/panfrost/vulkan/panvk_vX_cs.c b/src/panfrost/vulkan/panvk_vX_cs.c index addcbacea15..640b69a6e0d 100644 --- a/src/panfrost/vulkan/panvk_vX_cs.c +++ b/src/panfrost/vulkan/panvk_vX_cs.c @@ -627,7 +627,6 @@ panvk_per_arch(emit_blend)(const struct panvk_device *dev, cfg.load_destination = pan_blend_reads_dest(blend->rts[rt].equation); cfg.round_to_fb_precision = !dithered; - const struct panfrost_device *pdev = &dev->physical_device->pdev; const struct util_format_description *format_desc = util_format_description(rts->format); unsigned chan_size = 0; @@ -660,7 +659,7 @@ panvk_per_arch(emit_blend)(const struct panvk_device *dev, */ cfg.internal.fixed_function.num_comps = 4; cfg.internal.fixed_function.conversion.memory_format = - panfrost_format_to_bifrost_blend(pdev, rts->format, dithered); + GENX(panfrost_dithered_format_from_pipe_format)(rts->format, dithered); cfg.internal.fixed_function.conversion.register_format = bifrost_blend_type_from_nir(pipeline->fs.info.bifrost.blend[rt].type); cfg.internal.fixed_function.rt = rt; diff --git a/src/panfrost/vulkan/panvk_vX_meta_clear.c b/src/panfrost/vulkan/panvk_vX_meta_clear.c index 3e92ccb4823..edde83a0b98 100644 --- a/src/panfrost/vulkan/panvk_vX_meta_clear.c +++ b/src/panfrost/vulkan/panvk_vX_meta_clear.c @@ -111,7 +111,7 @@ panvk_meta_clear_color_attachment_emit_rsd(struct panfrost_device *pdev, cfg.internal.fixed_function.num_comps = 4; cfg.internal.fixed_function.rt = rt; cfg.internal.fixed_function.conversion.memory_format = - panfrost_format_to_bifrost_blend(pdev, format, false); + GENX(panfrost_dithered_format_from_pipe_format)(format, false); cfg.internal.fixed_function.conversion.register_format = shader_info->bifrost.blend[0].format; } diff --git a/src/panfrost/vulkan/panvk_vX_meta_copy.c b/src/panfrost/vulkan/panvk_vX_meta_copy.c index 23f84d6b1fe..9f55999844a 100644 --- a/src/panfrost/vulkan/panvk_vX_meta_copy.c +++ b/src/panfrost/vulkan/panvk_vX_meta_copy.c @@ -248,7 +248,7 @@ panvk_meta_copy_to_img_emit_rsd(struct panfrost_device *pdev, cfg.internal.fixed_function.num_comps = 4; if (!raw) { cfg.internal.fixed_function.conversion.memory_format = - panfrost_format_to_bifrost_blend(pdev, fmt, false); + GENX(panfrost_dithered_format_from_pipe_format)(fmt, false); cfg.internal.fixed_function.conversion.register_format = MALI_REGISTER_FILE_FORMAT_F32; } else {