diff options
author | Hein-Pieter van Braam <hp@tmm.cx> | 2019-01-03 23:35:47 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-01-03 23:35:47 +0100 |
commit | b1e3215f3a316cfaf518747f7dafba4cc0d8d291 (patch) | |
tree | 77264807b535f34d4d59271c9b2852531086b372 | |
parent | 65a86ae17c442163c424fe4b229a64d48da0fc89 (diff) | |
parent | bfade869f328e2a920acee326f8f70901744160e (diff) |
Merge pull request #24477 from lupoDharkael/nouveau
Don't enable DRI_PRIME if nouveau is loaded
-rw-r--r-- | platform/x11/os_x11.cpp | 21 |
1 files changed, 20 insertions, 1 deletions
diff --git a/platform/x11/os_x11.cpp b/platform/x11/os_x11.cpp index e5a7d988f9..0db79fa3e9 100644 --- a/platform/x11/os_x11.cpp +++ b/platform/x11/os_x11.cpp @@ -243,7 +243,26 @@ Error OS_X11::initialize(const VideoMode &p_desired, int p_video_driver, int p_a // Set DRI_PRIME if not set. This means that Godot should default to a higher-power GPU if it exists. // Note: Due to the final '0' parameter to setenv any existing DRI_PRIME environment variables will not // be overwritten. - setenv("DRI_PRIME", "1", 0); + bool enable_dri_prime = true; + // Check if Nouveau is loaded, we don't want to force dGPU usage with that driver. + if (FileAccess *f = FileAccess::open("/proc/modules", FileAccess::READ)) { + // Match driver name + space + String nouveau_str = "nouveau "; + + while (!f->eof_reached()) { + String line = f->get_line(); + + if (line.begins_with(nouveau_str)) { + enable_dri_prime = false; + break; + } + } + f->close(); + memdelete(f); + } + if (enable_dri_prime) { + setenv("DRI_PRIME", "1", 0); + } ContextGL_X11::ContextType opengl_api_type = ContextGL_X11::GLES_3_0_COMPATIBLE; |