ail: Assert that the mip level is in bounds

This preempts possible out-of-bounds accesses and later asserts when
trying to get the tile size.

Signed-off-by: Asahi Lina <lina@asahilina.net>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/20365>
This commit is contained in:
Asahi Lina 2022-12-09 20:15:42 +09:00 committed by Marge Bot
parent a8ec3135bb
commit 58d02e4f59

View file

@ -158,6 +158,7 @@ ail_detile(void *_tiled, void *_linear,
unsigned height_px = u_minify(tiled_layout->height_px, level);
unsigned blocksize_B = util_format_get_blocksize(tiled_layout->format);
assert(level < tiled_layout->levels && "Mip level out of bounds");
assert(tiled_layout->tiling == AIL_TILING_TWIDDLED && "Invalid usage");
assert((sx_px + swidth_px) <= width_px && "Invalid usage");
assert((sy_px + sheight_px) <= height_px && "Invalid usage");
@ -175,6 +176,7 @@ ail_tile(void *_tiled, void *_linear,
unsigned height_px = u_minify(tiled_layout->height_px, level);
unsigned blocksize_B = util_format_get_blocksize(tiled_layout->format);
assert(level < tiled_layout->levels && "Mip level out of bounds");
assert(tiled_layout->tiling == AIL_TILING_TWIDDLED && "Invalid usage");
assert((sx_px + swidth_px) <= width_px && "Invalid usage");
assert((sy_px + sheight_px) <= height_px && "Invalid usage");