improv(wgpu): adapter selection

This commit is contained in:
Ashley Wulber 2026-04-20 12:16:44 -04:00 committed by Ashley Wulber
parent 1444d5c43e
commit 347d91f7ea

View file

@ -76,18 +76,23 @@ impl Compositor {
.or_else(|| get_x11_device_ids(window))
});
#[cfg(all(
unix,
not(feature = "cctk"),
not(target_os = "macos"),
not(target_os = "redox")
))]
let ids = compatible_window
.as_ref()
.and_then(|window| get_x11_device_ids(window));
// HACK:
// 1. If we specifically didn't select an nvidia gpu
// 2. and the user didn't specifically request an nvidia gpu
// 3. and the user didn't set an adapter name,
// 4. and the user didn't request the high power pref
// => don't load the nvidia icd, as it might power on the gpu in hybrid setups causing severe delays
#[cfg(all(
unix,
feature = "cctk",
not(target_os = "macos"),
not(target_os = "redox")
))]
#[cfg(all(unix, not(target_os = "macos"), not(target_os = "redox")))]
if !matches!(ids, Some((0x10de, _)))
&& std::env::var_os("__NV_PRIME_RENDER_OFFLOAD")
.is_none_or(|var| var == "0")
@ -149,7 +154,6 @@ impl Compositor {
if std::env::var_os("WGPU_ADAPTER_NAME").is_none() {
#[cfg(all(
unix,
feature = "cctk",
not(target_os = "macos"),
not(target_os = "redox")
))]
@ -187,6 +191,8 @@ impl Compositor {
true
}
});
} else {
adapter = instance.request_adapter(&adapter_options).await.ok();
}
let adapter = match adapter {