From aebecb288661cf3dbeda468a25630ca2e8b09de5 Mon Sep 17 00:00:00 2001 From: Alyssa Rosenzweig Date: Thu, 9 Jan 2025 15:25:17 -0500 Subject: [PATCH] ail: move helpers to layout.h for sharing Signed-off-by: Alyssa Rosenzweig Part-of: --- src/asahi/layout/layout.h | 11 +++++++++++ src/asahi/layout/tiling.cc | 11 ----------- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/src/asahi/layout/layout.h b/src/asahi/layout/layout.h index 4b5a2acd6d3..63f5e2b46ae 100644 --- a/src/asahi/layout/layout.h +++ b/src/asahi/layout/layout.h @@ -246,6 +246,17 @@ ail_get_linear_pixel_B(const struct ail_layout *layout, ASSERTED unsigned level, (x_px * util_format_get_blocksize(layout->format)); } +static inline uint32_t +ail_space_bits(unsigned x) +{ + assert(x < 128 && "offset must be inside the tile"); + + return ((x & 1) << 0) | ((x & 2) << 1) | ((x & 4) << 2) | ((x & 8) << 3) | + ((x & 16) << 4) | ((x & 32) << 5) | ((x & 64) << 6); +} + +#define MOD_POT(x, y) (x) & ((y) - 1) + static inline unsigned ail_effective_width_sa(unsigned width_px, unsigned sample_count_sa) { diff --git a/src/asahi/layout/tiling.cc b/src/asahi/layout/tiling.cc index a11720b9f71..b840976c78b 100644 --- a/src/asahi/layout/tiling.cc +++ b/src/asahi/layout/tiling.cc @@ -37,22 +37,11 @@ * applying the two's complement identity, we are left with (X - mask) & mask */ -#define MOD_POT(x, y) (x) & ((y)-1) - typedef struct { uint64_t lo; uint64_t hi; } __attribute__((packed)) ail_uint128_t; -static uint32_t -ail_space_bits(unsigned x) -{ - assert(x < 128 && "offset must be inside the tile"); - - return ((x & 1) << 0) | ((x & 2) << 1) | ((x & 4) << 2) | ((x & 8) << 3) | - ((x & 16) << 4) | ((x & 32) << 5) | ((x & 64) << 6); -} - /* * Given a power-of-two block width/height, construct the mask of "X" bits. This * is found by restricting the full mask of alternating 0s and 1s to only cover