summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHein-Pieter van Braam <hp@tmm.cx>2019-02-14 15:25:37 +0000
committerHein-Pieter van Braam <hp@tmm.cx>2019-02-14 15:50:47 +0000
commit84627140d79ae88ba84d997010a23f6e000c8bf8 (patch)
treee2fd26116740ac7d1123fc72ef37c3e27e578d10
parent4a24ba6e77c7128e64dee31cf05f6960abdb8108 (diff)
Detect when primusrun/optirun is in use
It seems that bumblebee doesn't like us creating multiple GL contexts to avoid this we now detect whether we're running with this software and don't do anything.
-rw-r--r--platform/x11/os_x11.cpp33
1 files changed, 31 insertions, 2 deletions
diff --git a/platform/x11/os_x11.cpp b/platform/x11/os_x11.cpp
index ca4b02bb49..8098209474 100644
--- a/platform/x11/os_x11.cpp
+++ b/platform/x11/os_x11.cpp
@@ -243,8 +243,37 @@ Error OS_X11::initialize(const VideoMode &p_desired, int p_video_driver, int p_a
// maybe contextgl wants to be in charge of creating the window
#if defined(OPENGL_ENABLED)
if (getenv("DRI_PRIME") == NULL) {
- print_verbose("Detecting GPUs, set DRI_PRIME in the environment to override GPU detection logic.");
- int use_prime = detect_prime();
+ int use_prime = -1;
+
+ if (getenv("PRIMUS_DISPLAY") ||
+ getenv("PRIMUS_libGLd") ||
+ getenv("PRIMUS_libGLa") ||
+ getenv("PRIMUS_libGL") ||
+ getenv("PRIMUS_LOAD_GLOBAL") ||
+ getenv("BUMBLEBEE_SOCKET")) {
+
+ print_verbose("Optirun/primusrun detected. Skipping GPU detection");
+ use_prime = 0;
+ }
+
+ if (getenv("LD_LIBRARY_PATH")) {
+ String ld_library_path(getenv("LD_LIBRARY_PATH"));
+ Vector<String> libraries = ld_library_path.split(":");
+
+ for (int i = 0; i < libraries.size(); ++i) {
+ if (FileAccess::exists(libraries[i] + "/libGL.so.1") ||
+ FileAccess::exists(libraries[i] + "/libGL.so")) {
+
+ print_verbose("Custom libGL override detected. Skipping GPU detection");
+ use_prime = 0;
+ }
+ }
+ }
+
+ if (use_prime == -1) {
+ print_verbose("Detecting GPUs, set DRI_PRIME in the environment to override GPU detection logic.");
+ use_prime = detect_prime();
+ }
if (use_prime) {
print_line("Found discrete GPU, setting DRI_PRIME=1 to use it.");