From 008cfd1f8657c0e266a7a741920d7e9f7e187baa Mon Sep 17 00:00:00 2001 From: SoftFever Date: Wed, 4 Mar 2026 22:48:40 +0800 Subject: [PATCH] Linux: prefer discrete GPU on dual-GPU systems via PRIME environment variables (#12602) * Linux: prefer discrete GPU on dual-GPU systems via PRIME environment variables Set DRI_PRIME=1 for AMD/nouveau PRIME setups and __NV_PRIME_RENDER_OFFLOAD/__GLX_VENDOR_LIBRARY_NAME for NVIDIA proprietary driver, only when the NVIDIA kernel module is detected. Uses replace=false to respect user overrides. * Improves usability on Linux. No more double title bar (#12600) * Fix double title bar on Linux by removing WM decorations for GTK * wip * fix * finish * address review comment --- src/OrcaSlicer.cpp | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/OrcaSlicer.cpp b/src/OrcaSlicer.cpp index 397cd66d38..35736348a0 100644 --- a/src/OrcaSlicer.cpp +++ b/src/OrcaSlicer.cpp @@ -88,6 +88,7 @@ using namespace nlohmann; #ifdef __WXGTK__ #include +#include #endif #ifdef SLIC3R_GUI @@ -1191,6 +1192,17 @@ int CLI::run(int argc, char **argv) // mode forces software rendering, which works reliably on all backends. ::setenv("WEBKIT_DISABLE_COMPOSITING_MODE", "1", /* replace */ false); + // On Linux dual-GPU systems, request the high-performance discrete GPU. + // DRI_PRIME=1 handles AMD and nouveau (open-source NVIDIA) PRIME setups. + ::setenv("DRI_PRIME", "1", /* replace */ false); + + // For NVIDIA proprietary driver PRIME render offload, set additional variables. + // Only set if the NVIDIA kernel module is loaded to avoid breaking systems without NVIDIA. + if (::access("/proc/driver/nvidia/version", F_OK) == 0) { + ::setenv("__NV_PRIME_RENDER_OFFLOAD", "1", /* replace */ false); + ::setenv("__GLX_VENDOR_LIBRARY_NAME", "nvidia", /* replace */ false); + } + // Also on Linux, we need to tell Xlib that we will be using threads, // lest we crash when we fire up GStreamer. XInitThreads();