From fc8bc2d307637df46b65e24eebd66ecbe7e5c4c6 Mon Sep 17 00:00:00 2001 From: Yiwei Zhang Date: Tue, 11 Jan 2022 22:01:22 +0000 Subject: [PATCH] venus: VkExternalImageFormatProperties is optional It's optional even if VkPhysicalDeviceExternalImageFormatInfo is there. Fixes: 108f386a612 ("venus: initial support for VkPhysicalDevice commands") Signed-off-by: Yiwei Zhang Reviewed-by: Chia-I Wu Part-of: (cherry picked from commit 17b753459ec0bfce490ee83e72d6dd6a29b4bf52) --- .pick_status.json | 2 +- src/virtio/vulkan/vn_physical_device.c | 30 +++++++++++++++----------- 2 files changed, 19 insertions(+), 13 deletions(-) diff --git a/.pick_status.json b/.pick_status.json index ab9465d837b..56b3e61cc99 100644 --- a/.pick_status.json +++ b/.pick_status.json @@ -4954,7 +4954,7 @@ "description": "venus: VkExternalImageFormatProperties is optional", "nominated": true, "nomination_type": 1, - "resolution": 0, + "resolution": 1, "main_sha": null, "because_sha": "108f386a612054e1617515af6e7ae7f87a9da5ba" }, diff --git a/src/virtio/vulkan/vn_physical_device.c b/src/virtio/vulkan/vn_physical_device.c index 01c5eb90767..8b7f9526ecb 100644 --- a/src/virtio/vulkan/vn_physical_device.c +++ b/src/virtio/vulkan/vn_physical_device.c @@ -2196,8 +2196,25 @@ vn_GetPhysicalDeviceImageFormatProperties2( if (result != VK_SUCCESS || !external_info) return vn_result(physical_dev->instance, result); + if (external_info->handleType == + VK_EXTERNAL_MEMORY_HANDLE_TYPE_ANDROID_HARDWARE_BUFFER_BIT_ANDROID) { + VkAndroidHardwareBufferUsageANDROID *ahb_usage = + vk_find_struct(pImageFormatProperties->pNext, + ANDROID_HARDWARE_BUFFER_USAGE_ANDROID); + if (ahb_usage) { + ahb_usage->androidHardwareBufferUsage = vn_android_get_ahb_usage( + pImageFormatInfo->usage, pImageFormatInfo->flags); + } + + /* AHBs with mipmap usage will ignore this property */ + pImageFormatProperties->imageFormatProperties.maxMipLevels = 1; + } + VkExternalImageFormatProperties *img_props = vk_find_struct( pImageFormatProperties->pNext, EXTERNAL_IMAGE_FORMAT_PROPERTIES); + if (!img_props) + return VK_SUCCESS; + VkExternalMemoryProperties *mem_props = &img_props->externalMemoryProperties; @@ -2217,17 +2234,6 @@ vn_GetPhysicalDeviceImageFormatProperties2( VK_EXTERNAL_MEMORY_HANDLE_TYPE_ANDROID_HARDWARE_BUFFER_BIT_ANDROID; mem_props->compatibleHandleTypes = VK_EXTERNAL_MEMORY_HANDLE_TYPE_ANDROID_HARDWARE_BUFFER_BIT_ANDROID; - - VkAndroidHardwareBufferUsageANDROID *ahb_usage = - vk_find_struct(pImageFormatProperties->pNext, - ANDROID_HARDWARE_BUFFER_USAGE_ANDROID); - if (ahb_usage) { - ahb_usage->androidHardwareBufferUsage = vn_android_get_ahb_usage( - pImageFormatInfo->usage, pImageFormatInfo->flags); - } - - /* AHBs with mipmap usage will ignore this property */ - pImageFormatProperties->imageFormatProperties.maxMipLevels = 1; } else { mem_props->compatibleHandleTypes = supported_handle_types; mem_props->exportFromImportedHandleTypes = @@ -2236,7 +2242,7 @@ vn_GetPhysicalDeviceImageFormatProperties2( : 0; } - return vn_result(physical_dev->instance, result); + return VK_SUCCESS; } void