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 <lina@asahilina.net>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/26614>
This commit is contained in:
Asahi Lina
2023-11-24 16:19:08 +09:00
committed by Alyssa Rosenzweig
parent be3890a898
commit 25d185a501
+11 -3
View File
@@ -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));