Module: Mesa Branch: main Commit: d28cf0dbd5f9681dd654342623bab503c289beb5 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=d28cf0dbd5f9681dd654342623bab503c289beb5
Author: Iago Toral Quiroga <[email protected]> Date: Tue Apr 4 10:16:48 2023 +0200 v3dv: always acquire display device before checking if we can present Usually, we postpone acquisition until a swapchain is created, but there are some cases with display extensions (at least with EXT_acquire_drm_display) where we need to acquire before a swapchain is ever created. Fixes various tests in: dEQP-VK.wsi.acquire_drm_display.* Reviewed-by: Alejandro PiƱeiro <[email protected]> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/22283> --- src/broadcom/vulkan/v3dv_device.c | 3 ++- src/broadcom/vulkan/v3dv_wsi.c | 12 ++++++++++++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/src/broadcom/vulkan/v3dv_device.c b/src/broadcom/vulkan/v3dv_device.c index fb82b54e9a9..d4d2eb7f914 100644 --- a/src/broadcom/vulkan/v3dv_device.c +++ b/src/broadcom/vulkan/v3dv_device.c @@ -840,7 +840,8 @@ create_physical_device(struct v3dv_instance *instance, device->device_id = drm_render_device->deviceinfo.pci->device_id; #endif - if (instance->vk.enabled_extensions.KHR_display) { + if (instance->vk.enabled_extensions.KHR_display || + instance->vk.enabled_extensions.EXT_acquire_drm_display) { #if !using_v3d_simulator /* Open the primary node on the vc4 display device */ assert(drm_primary_device); diff --git a/src/broadcom/vulkan/v3dv_wsi.c b/src/broadcom/vulkan/v3dv_wsi.c index d22f51f43b2..5efb1ea9530 100644 --- a/src/broadcom/vulkan/v3dv_wsi.c +++ b/src/broadcom/vulkan/v3dv_wsi.c @@ -42,6 +42,18 @@ v3dv_wsi_can_present_on_device(VkPhysicalDevice _pdevice, int fd) { V3DV_FROM_HANDLE(v3dv_physical_device, pdevice, _pdevice); + /* There are some instances with direct display extensions where this may be + * called before we have ever tried to create a swapchain, and therefore, + * before we have ever tried to acquire the display device, in which case we + * have to do it now. + */ + if (unlikely(pdevice->display_fd < 0 && pdevice->master_fd >= 0)) { + VkResult result = + v3dv_physical_device_acquire_display(pdevice, NULL); + if (result != VK_SUCCESS) + return false; + } + return wsi_common_drm_devices_equal(fd, pdevice->display_fd); }
