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>
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);
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)