anv: fix assert/crash in import of compressed local memory on xe2+
Some checks are pending
macOS-CI / macOS-CI (dri) (push) Waiting to run
macOS-CI / macOS-CI (xlib) (push) Waiting to run

There is no requirement that imported compressed memory is tied to an
image.

In practice it's unlikely to happen since unless drirc
anv_enable_buffer_comp is enabled we don't list the compressed memory
typed for anything but images. But you can build a case hitting the
assert without even creating an image.

Signed-off-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
Fixes: 5a05a39e56 ("anv: Limit the SCANOUT flag to color images")
Fixes: b7f7f1c74f ("anv: Treat imported compressed buffers as displayable (xe2)")
Closes: https://gitlab.freedesktop.org/mesa/mesa/-/work_items/15578
Reviewed-by: Tapani Pälli <tapani.palli@intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/42121>
This commit is contained in:
Lionel Landwerlin 2026-06-09 17:07:19 +03:00 committed by Marge Bot
parent 73017ea86a
commit 351c5d889c

View file

@ -1827,7 +1827,7 @@ VkResult anv_AllocateMemory(
VK_EXTERNAL_MEMORY_HANDLE_TYPE_OPAQUE_FD_BIT ||
fd_info->handleType ==
VK_EXTERNAL_MEMORY_HANDLE_TYPE_DMA_BUF_BIT_EXT);
if (alloc_flags & ANV_BO_ALLOC_COMPRESSED) {
if ((alloc_flags & ANV_BO_ALLOC_COMPRESSED) && image != NULL) {
/* First, when importing a compressed buffer on Xe2+, we are sure
* about that the buffer is from a resource created with modifiers
* supporting compression, even the info of modifier is not available
@ -1845,7 +1845,6 @@ VkResult anv_AllocateMemory(
* heap and then PAT entry in the later vm_bind stage.
*/
assert(device->info->ver >= 20);
assert(image);
if (vk_format_is_color(image->vk.format))
alloc_flags |= ANV_BO_ALLOC_SCANOUT;
}