From 03dda90dddc3445dcd9168cbbf1ad7e2632ec793 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9mi=20Verschelde?= Date: Mon, 8 Mar 2021 16:03:24 +0100 Subject: [PATCH] Linux: Fix PRIME detection on Steam MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit To avoid trying to do PRIME detection on fake `libGL.so` as used by e.g. Renderdoc or Primus, we skip detection if there's a `libGL.so` in `LD_LIBRARY_PATH`... and our luck is that Steam defines it and includes system paths too, thus the actual system `libGL`... 🤦 So if we detect Steam, we skip this check. Co-authored-by: Hein-Pieter van Braam-Stewart (cherry picked from commit 562b1cd2cda2098e62c7501dae87393def99c23a) --- platform/x11/os_x11.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/platform/x11/os_x11.cpp b/platform/x11/os_x11.cpp index 72555815217..ae258338ba1 100644 --- a/platform/x11/os_x11.cpp +++ b/platform/x11/os_x11.cpp @@ -264,7 +264,10 @@ Error OS_X11::initialize(const VideoMode &p_desired, int p_video_driver, int p_a use_prime = 0; } - if (getenv("LD_LIBRARY_PATH")) { + // Some tools use fake libGL libraries and have them override the real one using + // LD_LIBRARY_PATH, so we skip them. *But* Steam also sets LD_LIBRARY_PATH for its + // runtime and includes system `/lib` and `/lib64`... so ignore Steam. + if (use_prime == -1 && getenv("LD_LIBRARY_PATH") && !getenv("STEAM_RUNTIME_LIBRARY_PATH")) { String ld_library_path(getenv("LD_LIBRARY_PATH")); Vector libraries = ld_library_path.split(":");