diff options
| author | 2026-04-04 23:11:39 +0800 | |
|---|---|---|
| committer | 2026-04-04 23:11:39 +0800 | |
| commit | 19f228a324e7462d3e3a6ec3921c30f0cb2a5415 (patch) | |
| tree | f3b575df1d6afe23ec6c5fee4852c71bccd0b7de /src-tauri/src | |
| parent | 96cad1ac999b7d6e288a681ce53a23044bc23127 (diff) | |
| download | DropOut-19f228a324e7462d3e3a6ec3921c30f0cb2a5415.tar.gz DropOut-19f228a324e7462d3e3a6ec3921c30f0cb2a5415.zip | |
Update src-tauri/src/main.rsfeat/linux-nvidia-prime-support
Co-authored-by: sourcery-ai[bot] <58596630+sourcery-ai[bot]@users.noreply.github.com>
Diffstat (limited to 'src-tauri/src')
| -rw-r--r-- | src-tauri/src/main.rs | 33 |
1 files changed, 24 insertions, 9 deletions
diff --git a/src-tauri/src/main.rs b/src-tauri/src/main.rs index 5109182..952d250 100644 --- a/src-tauri/src/main.rs +++ b/src-tauri/src/main.rs @@ -863,19 +863,34 @@ async fn start_game( } // On Linux, inject GPU environment variables for hybrid graphics support + // but do not override values that are already set in the environment. #[cfg(target_os = "linux")] { + let mut injected_any = false; + // NVIDIA Prime Render Offload - enables discrete NVIDIA GPU on hybrid systems - command.env("__NV_PRIME_RENDER_OFFLOAD", "1"); - command.env("__GLX_VENDOR_LIBRARY_NAME", "nvidia"); - + if std::env::var_os("__NV_PRIME_RENDER_OFFLOAD").is_none() { + command.env("__NV_PRIME_RENDER_OFFLOAD", "1"); + injected_any = true; + } + + if std::env::var_os("__GLX_VENDOR_LIBRARY_NAME").is_none() { + command.env("__GLX_VENDOR_LIBRARY_NAME", "nvidia"); + injected_any = true; + } + // AMD DRI_PRIME - enables discrete AMD GPU on hybrid systems - command.env("DRI_PRIME", "1"); - - emit_log!( - window, - "Injected GPU environment variables for Linux (NVIDIA Prime & AMD DRI_PRIME)".to_string() - ); + if std::env::var_os("DRI_PRIME").is_none() { + command.env("DRI_PRIME", "1"); + injected_any = true; + } + + if injected_any { + emit_log!( + window, + "Injected default GPU environment variables for Linux (NVIDIA Prime & AMD DRI_PRIME, only where unset)".to_string() + ); + } } // Spawn and handle output |