From 1e80a426c28b5139a80d70792c997f7bcaeacc04 Mon Sep 17 00:00:00 2001 From: Yiwei Zhang Date: Wed, 31 Jan 2024 14:59:35 -0800 Subject: [PATCH] anv: extend implicit fencing support for case requiring implicit write This change extends the coverage to ANV being the producer while consumer is hardware encoder backed by iHD. So we'd apply implicit write to bos backing render target images, which is mostly aligned with i915_batch_submit tracking of the bos being writtern to. Signed-off-by: Yiwei Zhang Reviewed-by: Lionel Landwerlin Reviewed-by: Matt Turner Part-of: --- src/intel/vulkan/anv_device.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/intel/vulkan/anv_device.c b/src/intel/vulkan/anv_device.c index d49742e8313..4a3e536e213 100644 --- a/src/intel/vulkan/anv_device.c +++ b/src/intel/vulkan/anv_device.c @@ -4106,12 +4106,21 @@ VkResult anv_AllocateMemory( /* wsi has its own way of synchronizing with the compositor */ if (!wsi_info && dedicated_info && dedicated_info->image != VK_NULL_HANDLE) { + ANV_FROM_HANDLE(anv_image, image, dedicated_info->image); + /* 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; + + /* For color attachment, apply IMPLICIT_WRITE so a client on the + * consumer side relying on implicit fencing can have a fence to + * wait for render complete. + */ + if (image->vk.usage & VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT) + alloc_flags |= ANV_BO_ALLOC_IMPLICIT_WRITE; } }