ail: add is_level_compressed query

Signed-off-by: Alyssa Rosenzweig <alyssa@rosenzweig.io>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/26963>
This commit is contained in:
Alyssa Rosenzweig 2023-12-06 17:37:38 -04:00
parent 2728995f12
commit 67d92e0bb6

View file

@ -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,