From c1cd05771f6d219fad153c3007fc61cdacf777fe Mon Sep 17 00:00:00 2001 From: Mary Guillemard Date: Wed, 11 Jun 2025 10:38:13 +0200 Subject: [PATCH] pan/lib: Refactor pan_padded_vertex_count We are going to move everything in pan_encode.h for CL usage. This inline the code used by pan_padded_vertex_count. Signed-off-by: Mary Guillemard Acked-by: Boris Brezillon Reviewed-by: Olivia Lee Part-of: --- src/panfrost/lib/pan_attributes.c | 29 +++++++---------------------- 1 file changed, 7 insertions(+), 22 deletions(-) diff --git a/src/panfrost/lib/pan_attributes.c b/src/panfrost/lib/pan_attributes.c index 8a1e5513273..1562d75971d 100644 --- a/src/panfrost/lib/pan_attributes.c +++ b/src/panfrost/lib/pan_attributes.c @@ -33,21 +33,15 @@ * exactly how the hardware calculates this (which is why the * algorithm is so weird) or else instancing will break. */ -/* Given an odd number (of the form 2k + 1), compute k */ -#define ODD(odd) ((odd - 1) >> 1) - -static unsigned -pan_small_padded_vertex_count(unsigned idx) +unsigned +pan_padded_vertex_count(unsigned vertex_count) { - if (idx < 10) - return idx; - else - return (idx + 1) & ~1; -} + if (vertex_count < 10) + return vertex_count; + + if (vertex_count < 20) + return (vertex_count + 1) & ~1; -static unsigned -pan_large_padded_vertex_count(uint32_t vertex_count) -{ /* First, we have to find the highest set one */ unsigned highest = 32 - __builtin_clz(vertex_count); @@ -78,15 +72,6 @@ pan_large_padded_vertex_count(uint32_t vertex_count) } } -unsigned -pan_padded_vertex_count(unsigned vertex_count) -{ - if (vertex_count < 20) - return pan_small_padded_vertex_count(vertex_count); - else - return pan_large_padded_vertex_count(vertex_count); -} - unsigned pan_compute_magic_divisor(unsigned hw_divisor, unsigned *divisor_r, unsigned *divisor_e)