From 6fdad684daa46e4191df8d4d4886513917df5f2a Mon Sep 17 00:00:00 2001 From: Alyssa Rosenzweig Date: Mon, 24 Feb 2025 18:05:19 -0500 Subject: [PATCH] ail: generalize ail_space_bits for full twiddling. Signed-off-by: Alyssa Rosenzweig Part-of: --- src/asahi/layout/layout.h | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/src/asahi/layout/layout.h b/src/asahi/layout/layout.h index d195fd048ea..ea35f390a63 100644 --- a/src/asahi/layout/layout.h +++ b/src/asahi/layout/layout.h @@ -247,10 +247,18 @@ ail_get_linear_pixel_B(const struct ail_layout *layout, ASSERTED unsigned level, static inline uint32_t ail_space_bits(unsigned x) { - assert(x < 128 && "offset must be inside the tile"); + uint32_t accum = 0; - return ((x & 1) << 0) | ((x & 2) << 1) | ((x & 4) << 2) | ((x & 8) << 3) | - ((x & 16) << 4) | ((x & 32) << 5) | ((x & 64) << 6); + /* With fully twiddled images, we can have up to 16384x16384 tiles, + * justifying stopping the loop at 14. + */ + assert(x < (1 << 14) && "offset must be inside the tile"); + + for (unsigned i = 0; i < 14; ++i) { + accum |= (x & (1 << i)) << i; + } + + return accum; } #define MOD_POT(x, y) (x) & ((y) - 1)