From 0c0c1418aeee7c733d743cfc386e957c2228789e Mon Sep 17 00:00:00 2001 From: Iago Toral Quiroga Date: Wed, 4 Nov 2020 09:36:02 +0100 Subject: [PATCH] vulkan/wsi: give drivers the option to decide if they need to blit Until now, the WSI code would rely on VK_EXT_pci_bus_info to check if the WSI device matched the DRM device used for display. If they matched, then it would allow direct presentation of the swapchain images, otherwise it would fallback to a blit path through a linear buffer. Unfortunately, this only works for PCI devices, so embedded GPUs would always fail the test and fallback to the prime blit path, incurring in a performance penalty due to the extra blit. With this change driver backends have the possibility to attach a callback to the WSI device to take control over that decision and have freedom to make that choice according to their own platform particularities. Reviewed-by: Jason Ekstrand Part-of: --- src/vulkan/wsi/wsi_common.h | 6 ++++++ src/vulkan/wsi/wsi_common_drm.c | 3 +++ 2 files changed, 9 insertions(+) diff --git a/src/vulkan/wsi/wsi_common.h b/src/vulkan/wsi/wsi_common.h index 7c69268..b0ab216 100644 --- a/src/vulkan/wsi/wsi_common.h +++ b/src/vulkan/wsi/wsi_common.h @@ -150,6 +150,12 @@ struct wsi_device { VkDeviceMemory memory, VkBool32 ownership); + /* + * If this is set, the WSI device will call it to let the driver backend + * decide if it can present images directly on the given device fd. + */ + bool (*can_present_on_device)(VkPhysicalDevice pdevice, int fd); + #define WSI_CB(cb) PFN_vk##cb cb WSI_CB(AllocateMemory); WSI_CB(AllocateCommandBuffers); diff --git a/src/vulkan/wsi/wsi_common_drm.c b/src/vulkan/wsi/wsi_common_drm.c index 1f81a92..88483cf 100644 --- a/src/vulkan/wsi/wsi_common_drm.c +++ b/src/vulkan/wsi/wsi_common_drm.c @@ -37,6 +37,9 @@ bool wsi_device_matches_drm_fd(const struct wsi_device *wsi, int drm_fd) { + if (wsi->can_present_on_device) + return wsi->can_present_on_device(wsi->pdevice, drm_fd); + drmDevicePtr fd_device; int ret = drmGetDevice2(drm_fd, 0, &fd_device); if (ret) -- 2.7.4