From 25d185a501c561b0103cfb787d5cdc668c038ee4 Mon Sep 17 00:00:00 2001 From: Asahi Lina Date: Fri, 24 Nov 2023 16:19:08 +0900 Subject: [PATCH] ail: Fix tile size & strides for compressed textures Compressed textures have two additional quirks that affect the tiling code (but not the mip offsets): they get extra stride padding in some cases for the large miptree, and the tile size is based on the POT size and not the real size for the small miptree. Signed-off-by: Asahi Lina Part-of: --- src/asahi/layout/layout.c | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/src/asahi/layout/layout.c b/src/asahi/layout/layout.c index c99d492a667..f12d46061ed 100644 --- a/src/asahi/layout/layout.c +++ b/src/asahi/layout/layout.c @@ -124,6 +124,11 @@ ail_initialize_twiddled(struct ail_layout *layout) layout->stride_el[l] = util_format_get_nblocksx( layout->format, u_minify(layout->width_px, l)); + + /* Compressed textures pad the stride in this case */ + if (compressed && pad_left) + layout->stride_el[l]++; + layout->tilesize_el[l] = tilesize_el; } @@ -152,9 +157,12 @@ ail_initialize_twiddled(struct ail_layout *layout) offset_B = ALIGN_POT(offset_B + (blocksize_B * size_el), AIL_CACHELINE); /* The tilesize is based on the true mipmap level size, not the POT - * rounded size */ - unsigned tilesize_el = - util_next_power_of_two(u_minify(MIN2(w_el, h_el), l)); + * rounded size, except for compressed textures */ + unsigned tilesize_el; + if (compressed) + tilesize_el = util_next_power_of_two(MIN2(potw_el, poth_el)); + else + tilesize_el = util_next_power_of_two(u_minify(MIN2(w_el, h_el), l)); layout->tilesize_el[l] = (struct ail_tile){tilesize_el, tilesize_el}; layout->stride_el[l] = util_format_get_nblocksx( layout->format, u_minify(layout->width_px, l));