From 1fa13ceb748752d597397bc17d7c10c01525a59f Mon Sep 17 00:00:00 2001 From: Mary Guillemard Date: Fri, 9 May 2025 11:15:10 +0200 Subject: [PATCH] pan/lib: Move pan_fixup_blend_type to pan_blend.c Also move bifrost_blend_type_from_nir to pan_blend.c, rename it and makes it not GENX. This part is related to blend so it makes more sense to have it there and this will allow us to make pan_shader.c not GENX. Signed-off-by: Mary Guillemard Acked-by: Boris Brezillon Reviewed-by: Olivia Lee Part-of: --- src/panfrost/lib/pan_blend.c | 38 +++++++++++++++++++++++++++++++ src/panfrost/lib/pan_blend.h | 6 +++++ src/panfrost/lib/pan_shader.c | 42 ++--------------------------------- src/panfrost/lib/pan_shader.h | 5 ----- 4 files changed, 46 insertions(+), 45 deletions(-) diff --git a/src/panfrost/lib/pan_blend.c b/src/panfrost/lib/pan_blend.c index b4fc947e646..c8e9cf620b5 100644 --- a/src/panfrost/lib/pan_blend.c +++ b/src/panfrost/lib/pan_blend.c @@ -466,6 +466,30 @@ pan_pack_blend(const struct pan_blend_equation equation) return out.opaque[0]; } +enum mali_register_file_format +pan_blend_type_from_nir(nir_alu_type nir_type) +{ + switch (nir_type) { + case 0: /* Render target not in use */ + return 0; + case nir_type_float16: + return MALI_REGISTER_FILE_FORMAT_F16; + case nir_type_float32: + return MALI_REGISTER_FILE_FORMAT_F32; + case nir_type_int32: + return MALI_REGISTER_FILE_FORMAT_I32; + case nir_type_uint32: + return MALI_REGISTER_FILE_FORMAT_U32; + case nir_type_int16: + return MALI_REGISTER_FILE_FORMAT_I16; + case nir_type_uint16: + return MALI_REGISTER_FILE_FORMAT_U16; + default: + unreachable("Unsupported blend shader type for NIR alu type"); + return 0; + } +} + #else /* ifndef PAN_ARCH */ static const char * @@ -757,6 +781,20 @@ GENX(pan_inline_rt_conversion)(nir_shader *s, enum pipe_format *formats) return nir_shader_intrinsics_pass(s, inline_rt_conversion, nir_metadata_control_flow, formats); } + +#if PAN_ARCH <= 7 +enum mali_register_file_format +GENX(pan_fixup_blend_type)(nir_alu_type T_size, enum pipe_format format) +{ + const struct util_format_description *desc = util_format_description(format); + unsigned size = nir_alu_type_get_type_size(T_size); + nir_alu_type T_format = pan_unpacked_type_for_format(desc); + nir_alu_type T = nir_alu_type_get_base_type(T_format) | size; + + return pan_blend_type_from_nir(T); +} +#endif + #endif #endif /* ifndef PAN_ARCH */ diff --git a/src/panfrost/lib/pan_blend.h b/src/panfrost/lib/pan_blend.h index 64a5f800c5d..3a97455ad8d 100644 --- a/src/panfrost/lib/pan_blend.h +++ b/src/panfrost/lib/pan_blend.h @@ -124,6 +124,7 @@ bool pan_blend_is_homogenous_constant(unsigned mask, const float *constants); void pan_blend_to_fixed_function_equation(const struct pan_blend_equation eq, struct MALI_BLEND_EQUATION *equation); +enum mali_register_file_format pan_blend_type_from_nir(nir_alu_type nir_type); uint32_t pan_pack_blend(const struct pan_blend_equation equation); #ifdef PAN_ARCH @@ -137,6 +138,11 @@ uint64_t GENX(pan_blend_get_internal_desc)(enum pipe_format fmt, unsigned rt, unsigned force_size, bool dithered); bool GENX(pan_inline_rt_conversion)(nir_shader *s, enum pipe_format *formats); + +#if PAN_ARCH <= 7 +enum mali_register_file_format + GENX(pan_fixup_blend_type)(nir_alu_type T_size, enum pipe_format format); +#endif #endif #endif diff --git a/src/panfrost/lib/pan_shader.c b/src/panfrost/lib/pan_shader.c index aa1e72c0c4f..52d4ceb5b65 100644 --- a/src/panfrost/lib/pan_shader.c +++ b/src/panfrost/lib/pan_shader.c @@ -24,6 +24,7 @@ #include "pan_shader.h" #include "panfrost/clc/panfrost_compile.h" +#include "pan_blend.h" #include "pan_format.h" #if PAN_ARCH <= 5 @@ -46,45 +47,6 @@ GENX(pan_shader_get_compiler_options)(void) #endif } -#if PAN_ARCH >= 6 -static enum mali_register_file_format -bifrost_blend_type_from_nir(nir_alu_type nir_type) -{ - switch (nir_type) { - case 0: /* Render target not in use */ - return 0; - case nir_type_float16: - return MALI_REGISTER_FILE_FORMAT_F16; - case nir_type_float32: - return MALI_REGISTER_FILE_FORMAT_F32; - case nir_type_int32: - return MALI_REGISTER_FILE_FORMAT_I32; - case nir_type_uint32: - return MALI_REGISTER_FILE_FORMAT_U32; - case nir_type_int16: - return MALI_REGISTER_FILE_FORMAT_I16; - case nir_type_uint16: - return MALI_REGISTER_FILE_FORMAT_U16; - default: - unreachable("Unsupported blend shader type for NIR alu type"); - return 0; - } -} - -#if PAN_ARCH <= 7 -enum mali_register_file_format -GENX(pan_fixup_blend_type)(nir_alu_type T_size, enum pipe_format format) -{ - const struct util_format_description *desc = util_format_description(format); - unsigned size = nir_alu_type_get_type_size(T_size); - nir_alu_type T_format = pan_unpacked_type_for_format(desc); - nir_alu_type T = nir_alu_type_get_base_type(T_format) | size; - - return bifrost_blend_type_from_nir(T); -} -#endif -#endif - /* This is only needed on Midgard. It's the same on both v4 and v5, so only * compile once to avoid the GenXML dependency for calls. */ @@ -241,7 +203,7 @@ GENX(pan_shader_compile)(nir_shader *s, struct panfrost_compile_inputs *inputs, /* This is "redundant" information, but is needed in a draw-time hot path */ for (unsigned i = 0; i < ARRAY_SIZE(info->bifrost.blend); ++i) { info->bifrost.blend[i].format = - bifrost_blend_type_from_nir(info->bifrost.blend[i].type); + pan_blend_type_from_nir(info->bifrost.blend[i].type); } #endif } diff --git a/src/panfrost/lib/pan_shader.h b/src/panfrost/lib/pan_shader.h index 436aa099be0..3864f2dfc6c 100644 --- a/src/panfrost/lib/pan_shader.h +++ b/src/panfrost/lib/pan_shader.h @@ -75,11 +75,6 @@ void GENX(pan_shader_compile)(nir_shader *nir, struct util_dynarray *binary, struct pan_shader_info *info); -#if PAN_ARCH >= 6 && PAN_ARCH <= 7 -enum mali_register_file_format - GENX(pan_fixup_blend_type)(nir_alu_type T_size, enum pipe_format format); -#endif - #if PAN_ARCH >= 9 static inline enum mali_shader_stage pan_shader_stage(const struct pan_shader_info *info)