From 6dbb3c5e6124759e5b76d4545a48d11db0dc9fb6 Mon Sep 17 00:00:00 2001 From: Ludovico de Nittis <ludovico.denittis@collabora.com> Date: Thu, 12 Nov 2020 14:04:31 +0100 Subject: [PATCH] graphics: Add detection of Primus graphics driver We are now able to detect when the Primus graphics driver is in use. Signed-off-by: Ludovico de Nittis <ludovico.denittis@collabora.com> --- steam-runtime-tools/graphics.c | 21 +++++++++++++++++++-- steam-runtime-tools/graphics.h | 2 ++ 2 files changed, 21 insertions(+), 2 deletions(-) diff --git a/steam-runtime-tools/graphics.c b/steam-runtime-tools/graphics.c index e209abd49..eba2ca2a6 100644 --- a/steam-runtime-tools/graphics.c +++ b/steam-runtime-tools/graphics.c @@ -786,8 +786,8 @@ _argv_for_list_glx_icds_in_path (const char *helpers_path, * This function returns %SRT_GRAPHICS_DRIVER_VENDOR_GLVND. * * For older GLX and EGL graphics stacks, the entry-point library libGL.so.1 or libEGL.so.1 - * is part of a particular vendor's graphics library, usually Mesa or NVIDIA. This function - * attempts to determine which one. + * is part of a particular vendor's graphics library, usually Mesa, NVIDIA or Primus. This + * function attempts to determine which one. * * For Vulkan the entry-point library libvulkan.so.1 is always vendor-neutral * (similar to GLVND), so this function is not useful. It always returns @@ -808,6 +808,8 @@ _srt_check_library_vendor (gchar **envp, SrtLibrary *library = NULL; SrtLibraryIssues issues; const char * const *dependencies; + gboolean have_libstdc_deps = FALSE; + gboolean have_libxcb_deps = FALSE; g_return_val_if_fail (envp != NULL, SRT_GRAPHICS_LIBRARY_VENDOR_UNKNOWN); @@ -858,6 +860,21 @@ _srt_check_library_vendor (gchar **envp, library_vendor = SRT_GRAPHICS_LIBRARY_VENDOR_NVIDIA; break; } + if (strstr (dependencies[i], "/libstdc++.so.") != NULL) + { + have_libstdc_deps = TRUE; + } + if (strstr (dependencies[i], "/libxcb.so.") != NULL) + { + have_libxcb_deps = TRUE; + } + } + + if (library_vendor == SRT_GRAPHICS_LIBRARY_VENDOR_UNKNOWN_NON_GLVND && + have_libstdc_deps && + !have_libxcb_deps) + { + library_vendor = SRT_GRAPHICS_LIBRARY_VENDOR_PRIMUS; } out: diff --git a/steam-runtime-tools/graphics.h b/steam-runtime-tools/graphics.h index 275161560..f3fe4ddbb 100644 --- a/steam-runtime-tools/graphics.h +++ b/steam-runtime-tools/graphics.h @@ -86,6 +86,7 @@ typedef enum * but the exact vendor is unknown * @SRT_GRAPHICS_LIBRARY_VENDOR_MESA: The graphics driver is the mesa non-GLVND * @SRT_GRAPHICS_LIBRARY_VENDOR_NVIDIA: The graphics driver is the Nvidia non-GLVND + * @SRT_GRAPHICS_LIBRARY_VENDOR_PRIMUS: The graphics driver is the Primus non-GLVND */ typedef enum { @@ -94,6 +95,7 @@ typedef enum SRT_GRAPHICS_LIBRARY_VENDOR_UNKNOWN_NON_GLVND, SRT_GRAPHICS_LIBRARY_VENDOR_MESA, SRT_GRAPHICS_LIBRARY_VENDOR_NVIDIA, + SRT_GRAPHICS_LIBRARY_VENDOR_PRIMUS, } SrtGraphicsLibraryVendor; /** -- GitLab