From 022e3cb66a028949a20909b76b342c4b8a902c56 Mon Sep 17 00:00:00 2001 From: Boris Brezillon Date: Wed, 7 May 2025 15:12:31 +0200 Subject: [PATCH] pan/format: Make pan_format::bind a 5-bit field This way, a pan_format instance fits into a single u32. This forces us to have an explicit translation in pipe_to_pan_bind_flags(), which is probably a good thing anyway. Signed-off-by: Boris Brezillon Reviewed-by: Eric R. Smith Reviewed-by: Mary Guillemard Acked-by: Daniel Stone Reviewed-by: Ryan Mckeever Reviewed-by: Olivia Lee Reviewed-by: Lars-Ivar Hesselberg Simonsen Reviewed-by: Erik Faye-Lund Part-of: --- src/gallium/drivers/panfrost/pan_screen.c | 17 +++++++++++------ src/panfrost/lib/pan_format.h | 12 ++++++------ 2 files changed, 17 insertions(+), 12 deletions(-) diff --git a/src/gallium/drivers/panfrost/pan_screen.c b/src/gallium/drivers/panfrost/pan_screen.c index 4d42465fc4b..f156974d43f 100644 --- a/src/gallium/drivers/panfrost/pan_screen.c +++ b/src/gallium/drivers/panfrost/pan_screen.c @@ -125,13 +125,18 @@ from_kmod_group_allow_priority_flags( static uint32_t pipe_to_pan_bind_flags(uint32_t pipe_bind_flags) { - static_assert(PIPE_BIND_DEPTH_STENCIL == PAN_BIND_DEPTH_STENCIL, ""); - static_assert(PIPE_BIND_RENDER_TARGET == PAN_BIND_RENDER_TARGET, ""); - static_assert(PIPE_BIND_SAMPLER_VIEW == PAN_BIND_SAMPLER_VIEW, ""); - static_assert(PIPE_BIND_VERTEX_BUFFER == PAN_BIND_VERTEX_BUFFER, ""); + uint32_t pan_bind_flags = 0; - return pipe_bind_flags & (PAN_BIND_DEPTH_STENCIL | PAN_BIND_RENDER_TARGET | - PAN_BIND_VERTEX_BUFFER | PAN_BIND_SAMPLER_VIEW); + if (pipe_bind_flags & PIPE_BIND_DEPTH_STENCIL) + pan_bind_flags |= PAN_BIND_DEPTH_STENCIL; + if (pipe_bind_flags & PIPE_BIND_RENDER_TARGET) + pan_bind_flags |= PAN_BIND_RENDER_TARGET; + if (pipe_bind_flags & PIPE_BIND_VERTEX_BUFFER) + pan_bind_flags |= PAN_BIND_VERTEX_BUFFER; + if (pipe_bind_flags & PIPE_BIND_SAMPLER_VIEW) + pan_bind_flags |= PAN_BIND_SAMPLER_VIEW; + + return pan_bind_flags; } /** diff --git a/src/panfrost/lib/pan_format.h b/src/panfrost/lib/pan_format.h index ca36b731315..b2441d42ad6 100644 --- a/src/panfrost/lib/pan_format.h +++ b/src/panfrost/lib/pan_format.h @@ -37,16 +37,16 @@ typedef uint32_t mali_pixel_format; /* pan bind flags */ -#define PAN_BIND_DEPTH_STENCIL (1 << 0) -#define PAN_BIND_RENDER_TARGET (1 << 1) -#define PAN_BIND_SAMPLER_VIEW (1 << 3) -#define PAN_BIND_VERTEX_BUFFER (1 << 4) -#define PAN_BIND_STORAGE_IMAGE (1 << 15) /* == PIPE_BIND_SHADER_IMAGE */ +#define PAN_BIND_DEPTH_STENCIL BITFIELD_BIT(0) +#define PAN_BIND_RENDER_TARGET BITFIELD_BIT(1) +#define PAN_BIND_SAMPLER_VIEW BITFIELD_BIT(2) +#define PAN_BIND_VERTEX_BUFFER BITFIELD_BIT(3) +#define PAN_BIND_STORAGE_IMAGE BITFIELD_BIT(4) struct panfrost_format { uint32_t hw : 22; uint32_t texfeat_bit : 5; - unsigned bind; + uint32_t bind : 5; }; struct pan_blendable_format {