lavapipe: do not short-circuit AHB export alloc (non-import)

Per spec VUID-VkMemoryAllocateInfo-pNext-01874:

If the parameters do not define an import operation, and the pNext chain
includes a VkExportMemoryAllocateInfo structure with
VK_EXTERNAL_MEMORY_HANDLE_TYPE_ANDROID_HARDWARE_BUFFER_BIT_ANDROID
included in its handleTypes member, and the pNext chain includes a
VkMemoryDedicatedAllocateInfo structure with image not equal to
VK_NULL_HANDLE, then allocationSize must be 0

- before: total 116, skip 66, pass 36, fail 14
- after:  total 116, skip 66, pass 50, fail 0

Fixes: cebb2bf266 ("lavapipe: Add AHB extension")
Reviewed-by: Lucas Fryzek <lfryzek@igalia.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/36204>
This commit is contained in:
Yiwei Zhang 2025-07-17 22:46:58 -07:00 committed by Marge Bot
parent 91c8372c67
commit 209e402720

View file

@ -1967,12 +1967,7 @@ VKAPI_ATTR VkResult VKAPI_CALL lvp_AllocateMemory(
VkResult error = VK_ERROR_OUT_OF_DEVICE_MEMORY;
assert(pAllocateInfo->sType == VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO);
int priority = 0;
if (pAllocateInfo->allocationSize == 0) {
/* Apparently, this is allowed */
*pMem = VK_NULL_HANDLE;
return VK_SUCCESS;
}
bool is_ahb_export_alloc = false;
vk_foreach_struct_const(ext, pAllocateInfo->pNext) {
switch ((unsigned)ext->sType) {
@ -2007,6 +2002,20 @@ VKAPI_ATTR VkResult VKAPI_CALL lvp_AllocateMemory(
}
}
#if DETECT_OS_ANDROID
is_ahb_export_alloc = !ahb_import_info && export_info &&
export_info->handleTypes & VK_EXTERNAL_MEMORY_HANDLE_TYPE_ANDROID_HARDWARE_BUFFER_BIT_ANDROID;
#endif
/* Can early return with size 0 if not AHB export alloc. See
* VUID-VkMemoryAllocateInfo-pNext-01874 for details.
*/
if (pAllocateInfo->allocationSize == 0 && !is_ahb_export_alloc) {
/* Apparently, this is allowed */
*pMem = VK_NULL_HANDLE;
return VK_SUCCESS;
}
#ifdef PIPE_MEMORY_FD
if (import_info != NULL && import_info->fd < 0) {
return vk_error(device->instance, VK_ERROR_INVALID_EXTERNAL_HANDLE);
@ -2042,8 +2051,7 @@ VKAPI_ATTR VkResult VKAPI_CALL lvp_AllocateMemory(
error = lvp_import_ahb_memory(device, mem, ahb_import_info);
if (error != VK_SUCCESS)
goto fail;
} else if(export_info &&
(export_info->handleTypes & VK_EXTERNAL_MEMORY_HANDLE_TYPE_ANDROID_HARDWARE_BUFFER_BIT_ANDROID)) {
} else if (is_ahb_export_alloc) {
error = lvp_create_ahb_memory(device, mem, pAllocateInfo);
if (error != VK_SUCCESS)
goto fail;