v3dv: implement wsi hook to decide if we can present directly on device

This will prevent the driver to take the prime blit path for presentation
in scenarios where it can avoid it, which can substantially improve
performance, particularly at high resolutions.

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 2021-04-26 08:13:53 +02:00 committed by Marge Bot
parent 0c0c1418ae
commit d636c5660c
1 changed files with 27 additions and 0 deletions

View File

@ -46,6 +46,31 @@ v3dv_wsi_proc_addr(VkPhysicalDevice physicalDevice, const char *pName)
return vk_device_dispatch_table_get(&vk_device_trampolines, pName);
}
static bool
v3dv_wsi_can_present_on_device(VkPhysicalDevice _pdevice, int fd)
{
V3DV_FROM_HANDLE(v3dv_physical_device, pdevice, _pdevice);
drmDevicePtr fd_devinfo, display_devinfo;
int ret;
ret = drmGetDevice2(fd, 0, &fd_devinfo);
if (ret)
return false;
ret = drmGetDevice2(pdevice->display_fd, 0, &display_devinfo);
if (ret) {
drmFreeDevice(&fd_devinfo);
return false;
}
bool result = drmDevicesEqual(fd_devinfo, display_devinfo);
drmFreeDevice(&fd_devinfo);
drmFreeDevice(&display_devinfo);
return result;
}
VkResult
v3dv_wsi_init(struct v3dv_physical_device *physical_device)
{
@ -61,6 +86,8 @@ v3dv_wsi_init(struct v3dv_physical_device *physical_device)
return result;
physical_device->wsi_device.supports_modifiers = true;
physical_device->wsi_device.can_present_on_device =
v3dv_wsi_can_present_on_device;
return VK_SUCCESS;
}