intel/isl: fix assert when surf->size_B is > UINT_MAX

I have some local tests for Sparse Resources that I wrote when I was
working on that for Anv. One of them tries to create a sparse buffer
with size 4294967296 (which doesn't fit in an uint32_t). Without this
patch, the right side of the assertion overflows and we get:

sparse: ../../src/intel/isl/isl.c:3787: isl_surf_from_mem: Assertion `surf->size_B == surf->row_pitch_B * extent.h * extent.a' failed

Fixes: fcdae4d4c0 ("intel: Add and use isl_surf_from_mem()")
Reviewed-by: Dylan Baker <dylan.c.baker@intel.com>
Signed-off-by: Paulo Zanoni <paulo.r.zanoni@intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/41253>
This commit is contained in:
Paulo Zanoni 2026-04-28 16:59:15 -07:00 committed by Marge Bot
parent 293b264b7d
commit c4b6df29bf

View file

@ -3784,7 +3784,7 @@ isl_surf_from_mem(const struct isl_device *isl_dev,
assert(ok);
if (extent.a > 1)
assert(surf->array_pitch_el_rows == extent.h);
assert(surf->size_B == surf->row_pitch_B * extent.h * extent.a);
assert(surf->size_B == (uint64_t)surf->row_pitch_B * extent.h * extent.a);
assert(surf->size_B <= max_tiles * tile_size_B);
}