vulkan/wsi: give drivers the option to decide if they need to blit
authorIago Toral Quiroga <itoral@igalia.com>
Wed, 4 Nov 2020 08:36:02 +0000 (09:36 +0100)
committerMarge Bot <eric+marge@anholt.net>
Tue, 27 Apr 2021 06:37:43 +0000 (06:37 +0000)
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 <jason@jlekstrand.net>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/5917>

src/vulkan/wsi/wsi_common.h
src/vulkan/wsi/wsi_common_drm.c

index 7c69268..b0ab216 100644 (file)
@@ -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);
index 1f81a92..88483cf 100644 (file)
@@ -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)