From be3af5acf6f3fc18a1381d1a85adac4bb92abfda Mon Sep 17 00:00:00 2001 From: Yiwei Zhang Date: Wed, 31 Jan 2024 11:50:00 -0800 Subject: [PATCH] anv: optimize the implicit fencing support of external memory Previously we apply implicit sync to all external memory, which is a bit redundant since we only need it for the dedicated image scenario (media image imported into Vulkan). This change optimizes just like that while also excluding wsi which has its own way of synchronizing with the compositor. Signed-off-by: Yiwei Zhang Reviewed-by: Lionel Landwerlin Reviewed-by: Matt Turner Part-of: --- src/intel/vulkan/anv_device.c | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/src/intel/vulkan/anv_device.c b/src/intel/vulkan/anv_device.c index e1579e02e7c..d49742e8313 100644 --- a/src/intel/vulkan/anv_device.c +++ b/src/intel/vulkan/anv_device.c @@ -4099,12 +4099,21 @@ VkResult anv_AllocateMemory( if (wsi_info) alloc_flags |= ANV_BO_ALLOC_SCANOUT; - /* Anything imported or exported is EXTERNAL. Apply implicit sync to be - * compatible with clients relying on implicit fencing. This matches the - * behavior in iris i915_batch_submit. An example client is VA-API. - */ - if (mem->vk.export_handle_types || mem->vk.import_handle_type) - alloc_flags |= (ANV_BO_ALLOC_EXTERNAL | ANV_BO_ALLOC_IMPLICIT_SYNC); + /* Anything imported or exported is EXTERNAL */ + if (mem->vk.export_handle_types || mem->vk.import_handle_type) { + alloc_flags |= ANV_BO_ALLOC_EXTERNAL; + + /* wsi has its own way of synchronizing with the compositor */ + if (!wsi_info && dedicated_info && + dedicated_info->image != VK_NULL_HANDLE) { + /* Apply implicit sync to be compatible with clients relying on + * implicit fencing. This matches the behavior in iris i915_batch + * submit. An example client is VA-API (iHD), so only dedicated + * image scenario has to be covered. + */ + alloc_flags |= ANV_BO_ALLOC_IMPLICIT_SYNC; + } + } if (mem->vk.ahardware_buffer) { result = anv_import_ahw_memory(_device, mem);