From 7afb012544ba5bd29374143b90408787183cf883 Mon Sep 17 00:00:00 2001 From: Lubosz Sarnecki Date: Thu, 2 Apr 2020 17:22:23 +0200 Subject: [PATCH] c/direct_mode: Check if NVIDIA path found any displays. This helps failing earlier with an NVIDIA Optimus setup, which currently is not supported. --- src/xrt/compositor/main/comp_window_direct_mode.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/xrt/compositor/main/comp_window_direct_mode.c b/src/xrt/compositor/main/comp_window_direct_mode.c index 624b2ae01..443211dfc 100644 --- a/src/xrt/compositor/main/comp_window_direct_mode.c +++ b/src/xrt/compositor/main/comp_window_direct_mode.c @@ -325,8 +325,7 @@ comp_window_direct_init_nvidia(struct comp_window *w) struct vk_bundle comp_vk = w->c->vk; // find our display using nvidia whitelist, enumerate its modes, and - // pick the best one - // get a list of attached displays + // pick the best one get a list of attached displays uint32_t display_count; if (comp_vk.vkGetPhysicalDeviceDisplayPropertiesKHR( comp_vk.physical_device, &display_count, NULL) != VK_SUCCESS) { @@ -334,6 +333,11 @@ comp_window_direct_init_nvidia(struct comp_window *w) return false; } + if (display_count == 0) { + COMP_ERROR(w->c, "NVIDIA: No Vulkan displays found."); + return false; + } + struct VkDisplayPropertiesKHR *display_props = U_TYPED_ARRAY_CALLOC(VkDisplayPropertiesKHR, display_count);