From 4dcf32c56e7b433de20f33b6457c7c91d48589bf Mon Sep 17 00:00:00 2001 From: Emma Anholt Date: Wed, 6 Aug 2025 10:07:43 -0700 Subject: [PATCH] wsi/drm: Don't request implicit sync if we're doing implicit sync ourselves. This will avoid kernel overhead on tu (implicit syncs every BO) and radv (implicit syncs the swapchain BOs) for doing implicit synchronization on non-explicit-sync WSI backends (old X11 and Wayland, KHR_display without !36591, and headless). Part-of: --- src/vulkan/wsi/wsi_common.c | 2 +- src/vulkan/wsi/wsi_common.h | 6 ++++++ src/vulkan/wsi/wsi_common_drm.c | 5 ++++- 3 files changed, 11 insertions(+), 2 deletions(-) diff --git a/src/vulkan/wsi/wsi_common.c b/src/vulkan/wsi/wsi_common.c index 498e8864f95..c2d360aa757 100644 --- a/src/vulkan/wsi/wsi_common.c +++ b/src/vulkan/wsi/wsi_common.c @@ -1803,7 +1803,7 @@ wsi_create_buffer_blit_context(const struct wsi_swapchain *chain, .sType = VK_STRUCTURE_TYPE_WSI_MEMORY_ALLOCATE_INFO_MESA, .pNext = NULL, .implicit_sync = info->image_type == WSI_IMAGE_TYPE_DRM && - !info->explicit_sync, + !info->explicit_sync && !chain->dma_buf_semaphore, }; VkMemoryDedicatedAllocateInfo buf_mem_dedicated_info = { .sType = VK_STRUCTURE_TYPE_MEMORY_DEDICATED_ALLOCATE_INFO, diff --git a/src/vulkan/wsi/wsi_common.h b/src/vulkan/wsi/wsi_common.h index e3764939292..5b6b4e8c4fd 100644 --- a/src/vulkan/wsi/wsi_common.h +++ b/src/vulkan/wsi/wsi_common.h @@ -71,6 +71,12 @@ struct wsi_image_create_info { struct wsi_memory_allocate_info { VkStructureType sType; const void *pNext; + /** + * If set, then the driver needs to do implicit synchronization on this BO. + * + * For DRM drivers, this flag will only get set before linux 6.0, at which + * point DMA_BUF_IOCTL_IMPORT_SYNC_FILE was added. + */ bool implicit_sync; }; diff --git a/src/vulkan/wsi/wsi_common_drm.c b/src/vulkan/wsi/wsi_common_drm.c index 0419e7d2ea8..b366169f17f 100644 --- a/src/vulkan/wsi/wsi_common_drm.c +++ b/src/vulkan/wsi/wsi_common_drm.c @@ -746,7 +746,10 @@ wsi_create_native_image_mem(const struct wsi_swapchain *chain, const struct wsi_memory_allocate_info memory_wsi_info = { .sType = VK_STRUCTURE_TYPE_WSI_MEMORY_ALLOCATE_INFO_MESA, .pNext = NULL, - .implicit_sync = !info->explicit_sync, + /* Ask for the driver to add implicit sync to the image if we're not + * handling implict sync ourselves. + */ + .implicit_sync = !info->explicit_sync && !chain->dma_buf_semaphore, }; const VkExportMemoryAllocateInfo memory_export_info = { .sType = VK_STRUCTURE_TYPE_EXPORT_MEMORY_ALLOCATE_INFO,