device-select: only try wayland/x11 if the required vars are set

don't try to infer connections, as this may deadlock compositors

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/31738>
This commit is contained in:
Mike Blumenkrantz 2024-10-18 09:42:04 -04:00 committed by Marge Bot
parent f4bb0e74fd
commit 45eb3bfd32

View file

@ -146,13 +146,16 @@ static VkResult device_select_CreateInstance(const VkInstanceCreateInfo *pCreate
info->xwayland = !strcmp(applicationName, "Xwayland");
info->xserver = !strcmp(applicationName, "Xorg") || !strcmp(applicationName, "Xephyr");
bool has_wayland = getenv("WAYLAND_DISPLAY") || getenv("WAYLAND_SOCKET");
bool has_xcb = !!getenv("DISPLAY");
for (unsigned i = 0; i < pCreateInfo->enabledExtensionCount; i++) {
#ifdef VK_USE_PLATFORM_WAYLAND_KHR
if (!strcmp(pCreateInfo->ppEnabledExtensionNames[i], VK_KHR_WAYLAND_SURFACE_EXTENSION_NAME))
if (!strcmp(pCreateInfo->ppEnabledExtensionNames[i], VK_KHR_WAYLAND_SURFACE_EXTENSION_NAME) && has_wayland)
info->has_wayland = true;
#endif
#ifdef VK_USE_PLATFORM_XCB_KHR
if (!strcmp(pCreateInfo->ppEnabledExtensionNames[i], VK_KHR_XCB_SURFACE_EXTENSION_NAME))
if (!strcmp(pCreateInfo->ppEnabledExtensionNames[i], VK_KHR_XCB_SURFACE_EXTENSION_NAME) && has_xcb)
info->has_xcb = !info->xserver || !info->zink;
#endif
}