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();