From 7adb9c42e016ed6a3a103952cb51f655e7910012 Mon Sep 17 00:00:00 2001 From: Yiwei Zhang Date: Thu, 20 May 2021 22:53:55 +0000 Subject: [PATCH] venus: advertise VK_ANDROID_external_memory_android_hardware_buffer Besides advertising AHB support, for Android, we do not advertise KHR_external_memory_fd, EXT_external_memory_dma_buf or EXT_image_drm_format_modifier so that AHB remains the sole channel for external resource sharing. Signed-off-by: Yiwei Zhang Reviewed-by: Chia-I Wu Part-of: --- src/virtio/vulkan/vn_device.c | 31 ++++++++++++++++++++----------- 1 file changed, 20 insertions(+), 11 deletions(-) diff --git a/src/virtio/vulkan/vn_device.c b/src/virtio/vulkan/vn_device.c index ab387769888..0eae4d7a1c7 100644 --- a/src/virtio/vulkan/vn_device.c +++ b/src/virtio/vulkan/vn_device.c @@ -1451,24 +1451,24 @@ vn_physical_device_get_native_extensions( /* see vn_physical_device_init_external_memory */ if (renderer_exts->EXT_external_memory_dma_buf && renderer_info->has_dmabuf_import) { +#ifdef ANDROID + if (renderer_exts->EXT_image_drm_format_modifier && + renderer_exts->EXT_queue_family_foreign) { + exts->ANDROID_external_memory_android_hardware_buffer = true; + exts->ANDROID_native_buffer = true; + } +#else exts->KHR_external_memory_fd = true; exts->EXT_external_memory_dma_buf = true; +#endif } - /* TODO join Android to do proper checks */ #ifdef VN_USE_WSI_PLATFORM exts->KHR_incremental_present = true; exts->KHR_swapchain = true; exts->KHR_swapchain_mutable_format = true; #endif -#ifdef ANDROID - if (renderer_exts->EXT_image_drm_format_modifier && - renderer_exts->EXT_queue_family_foreign && - exts->EXT_external_memory_dma_buf) { - exts->ANDROID_native_buffer = true; - } -#endif } static void @@ -1527,7 +1527,9 @@ vn_physical_device_get_passthrough_extensions( .EXT_shader_viewport_index_layer = true, /* EXT */ +#ifndef ANDROID .EXT_image_drm_format_modifier = true, +#endif .EXT_queue_family_foreign = true, .EXT_transform_feedback = true, }; @@ -3181,9 +3183,10 @@ vn_device_fix_create_info(const struct vn_device *dev, uint32_t extra_count = 0; uint32_t block_count = 0; - /* fix for WSI */ + /* fix for WSI (treat AHB as WSI extension for simplicity) */ const bool has_wsi = - app_exts->KHR_swapchain || app_exts->ANDROID_native_buffer; + app_exts->KHR_swapchain || app_exts->ANDROID_native_buffer || + app_exts->ANDROID_external_memory_android_hardware_buffer; if (has_wsi) { if (!app_exts->EXT_image_drm_format_modifier) { extra_exts[extra_count++] = @@ -3208,8 +3211,14 @@ vn_device_fix_create_info(const struct vn_device *dev, VK_KHR_SWAPCHAIN_MUTABLE_FORMAT_EXTENSION_NAME; block_exts[block_count++] = VK_KHR_INCREMENTAL_PRESENT_EXTENSION_NAME; - } else { + } + + if (app_exts->ANDROID_native_buffer) block_exts[block_count++] = VK_ANDROID_NATIVE_BUFFER_EXTENSION_NAME; + + if (app_exts->ANDROID_external_memory_android_hardware_buffer) { + block_exts[block_count++] = + VK_ANDROID_EXTERNAL_MEMORY_ANDROID_HARDWARE_BUFFER_EXTENSION_NAME; } }