v3dv: allow headless device without display device
authorErico Nunes <nunes.erico@gmail.com>
Wed, 20 Sep 2023 20:06:39 +0000 (22:06 +0200)
committerMarge Bot <emma+marge@anholt.net>
Wed, 27 Sep 2023 18:46:31 +0000 (18:46 +0000)
When trying to create a headless Vulkan instance without a display
device available, device enumeration would fail.
Part of the physical device creation code already accounts for a missing
display device, allow device enumeration to continue in that case too so
headless instances can be created.

Signed-off-by: Erico Nunes <nunes.erico@gmail.com>
Reviewed-by: Iago Toral Quiroga <itoral@igalia.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/25313>

src/broadcom/vulkan/v3dv_device.c

index 108d100..e109b38 100644 (file)
@@ -1274,9 +1274,10 @@ enumerate_devices(struct vk_instance *vk_instance)
    }
 
 #if !using_v3d_simulator
-   if (v3d_idx != -1 && vc4_idx != -1) {
-      result =
-         create_physical_device(instance, devices[v3d_idx], devices[vc4_idx]);
+   if (v3d_idx != -1) {
+      drmDevicePtr v3d_device = devices[v3d_idx];
+      drmDevicePtr vc4_device = vc4_idx != -1 ? devices[vc4_idx] : NULL;
+      result = create_physical_device(instance, v3d_device, vc4_device);
    }
 #endif