v3dv: always acquire display device before checking if we can present
authorIago Toral Quiroga <itoral@igalia.com>
Tue, 4 Apr 2023 08:16:48 +0000 (10:16 +0200)
committerMarge Bot <emma+marge@anholt.net>
Wed, 5 Apr 2023 06:21:26 +0000 (06:21 +0000)
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 <apinheiro@igalia.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/22283>

src/broadcom/vulkan/v3dv_device.c
src/broadcom/vulkan/v3dv_wsi.c

index fb82b54..d4d2eb7 100644 (file)
@@ -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);
index d22f51f..5efb1ea 100644 (file)
@@ -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);
 }