fix: when using wgpu, default to low power GPU
Ensures that the integrated GPU is used by default on hybrid graphics systems; and resolves NVIDIA-related driver issues.
This commit is contained in:
parent
68c760e652
commit
6850e53855
1 changed files with 17 additions and 0 deletions
|
|
@ -135,11 +135,28 @@ pub(crate) fn iced_settings<App: Application>(
|
|||
///
|
||||
/// Returns error on application failure.
|
||||
pub fn run<App: Application>(settings: Settings, flags: App::Flags) -> iced::Result {
|
||||
#[cfg(feature = "wgpu")]
|
||||
wgpu_power_pref();
|
||||
|
||||
let settings = iced_settings::<App>(settings, flags);
|
||||
|
||||
cosmic::Cosmic::<App>::run(settings)
|
||||
}
|
||||
|
||||
/// Default to rendering the application with the low power GPU preference.
|
||||
#[cfg(feature = "wgpu")]
|
||||
fn wgpu_power_pref() {
|
||||
// Ignore if requested to run on NVIDIA GPU
|
||||
if std::env::var("__NV_PRIME_RENDER_OFFLOAD").ok().as_deref() == Some("1") {
|
||||
return;
|
||||
}
|
||||
|
||||
const VAR: &str = "WGPU_POWER_PREF";
|
||||
if std::env::var(VAR).is_err() {
|
||||
std::env::set_var(VAR, "low");
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(feature = "single-instance")]
|
||||
#[derive(Debug, Clone)]
|
||||
pub struct DbusActivationMessage<Action = String, Args = Vec<String>> {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue