From e27d217fb16be3d72bc07822cd499ac78f8cc110 Mon Sep 17 00:00:00 2001 From: Lionel Landwerlin Date: Wed, 25 Jan 2023 20:16:23 +0200 Subject: [PATCH] vulkan/wsi/wayland: improve same gpu detection Some compositor like KWin do not return the render node. v2: Make sure we test if only drm_info.hasPrimary is true (Jason) Signed-off-by: Lionel Landwerlin Fixes: db42ed1e04 ("vulkan/wsi/wl: correctly find whether the compositor uses the same GPU") Closes: https://gitlab.freedesktop.org/mesa/mesa/-/issues/8139 Reviewed-by: Simon Ser Reviewed-by: Daniel Stone Reviewed-by: Jason Ekstrand Part-of: --- src/vulkan/wsi/wsi_common_wayland.c | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/src/vulkan/wsi/wsi_common_wayland.c b/src/vulkan/wsi/wsi_common_wayland.c index 6a337fc24e9..fdeebc5dd7a 100644 --- a/src/vulkan/wsi/wsi_common_wayland.c +++ b/src/vulkan/wsi/wsi_common_wayland.c @@ -843,10 +843,18 @@ wsi_wl_display_init(struct wsi_wayland *wsi_wl, /* Round-trip again to fetch dma-buf feedback */ wl_display_roundtrip_queue(display->wl_display, display->queue); - if (wsi_wl->wsi->drm_info.hasRender) { + if (wsi_wl->wsi->drm_info.hasRender || + wsi_wl->wsi->drm_info.hasPrimary) { + /* Apparently some wayland compositor do not send the render + * device node but the primary, so test against both. + */ display->same_gpu = - major(display->main_device) == wsi_wl->wsi->drm_info.renderMajor && - minor(display->main_device) == wsi_wl->wsi->drm_info.renderMinor; + (wsi_wl->wsi->drm_info.hasRender && + major(display->main_device) == wsi_wl->wsi->drm_info.renderMajor && + minor(display->main_device) == wsi_wl->wsi->drm_info.renderMinor) || + (wsi_wl->wsi->drm_info.hasPrimary && + major(display->main_device) == wsi_wl->wsi->drm_info.primaryMajor && + minor(display->main_device) == wsi_wl->wsi->drm_info.primaryMinor); } }