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 <jason@jlekstrand.net>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/5917>
This commit is contained in:
Iago Toral Quiroga 2020-11-04 09:36:02 +01:00 committed by Marge Bot
parent e1f3770a5c
commit 0c0c1418ae
2 changed files with 9 additions and 0 deletions

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

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