From 67d92e0bb633a485fff38a93c7022c6000ff5b30 Mon Sep 17 00:00:00 2001 From: Alyssa Rosenzweig Date: Wed, 6 Dec 2023 17:37:38 -0400 Subject: [PATCH] ail: add is_level_compressed query Signed-off-by: Alyssa Rosenzweig Part-of: --- src/asahi/layout/layout.h | 30 ++++++++++++++++++++++++------ 1 file changed, 24 insertions(+), 6 deletions(-) diff --git a/src/asahi/layout/layout.h b/src/asahi/layout/layout.h index 3bfce0a1a60..dd65953b344 100644 --- a/src/asahi/layout/layout.h +++ b/src/asahi/layout/layout.h @@ -202,12 +202,6 @@ ail_get_linear_pixel_B(struct ail_layout *layout, ASSERTED unsigned level, (x_px * util_format_get_blocksize(layout->format)); } -static inline bool -ail_is_compressed(struct ail_layout *layout) -{ - return layout->tiling == AIL_TILING_TWIDDLED_COMPRESSED; -} - static inline unsigned ail_effective_width_sa(unsigned width_px, unsigned sample_count_sa) { @@ -230,6 +224,30 @@ ail_can_compress(unsigned w_px, unsigned h_px, unsigned sample_count_sa) ail_effective_height_sa(h_px, sample_count_sa) >= 16; } +static inline bool +ail_is_compressed(struct ail_layout *layout) +{ + return layout->tiling == AIL_TILING_TWIDDLED_COMPRESSED; +} + +/* + * Even when the base mip level is compressed, high levels of the miptree + * (smaller than 16 pixels on either axis) are not compressed as it would be + * pointless. This queries this case. + */ +static inline bool +ail_is_level_compressed(struct ail_layout *layout, unsigned level) +{ + unsigned width_sa = ALIGN( + ail_effective_width_sa(layout->width_px, layout->sample_count_sa), 16); + + unsigned height_sa = ALIGN( + ail_effective_height_sa(layout->height_px, layout->sample_count_sa), 16); + + return ail_is_compressed(layout) && + u_minify(MAX2(width_sa, height_sa), level) >= 16; +} + void ail_make_miptree(struct ail_layout *layout); void ail_detile(void *_tiled, void *_linear, struct ail_layout *tiled_layout,