Skip to content

Commit 5b04b25

Browse files
committed
wgpu: Fix explicit nvidia device selection
1 parent 1b46268 commit 5b04b25

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

wgpu/src/window/compositor.rs

+5-2
Original file line numberDiff line numberDiff line change
@@ -68,11 +68,14 @@ impl Compositor {
6868

6969
// HACK:
7070
// 1. If we specifically didn't select an nvidia gpu
71-
// 2. and nobody set an adapter name,
72-
// 3. and the user didn't request the high power pref
71+
// 2. and the user didn't specifically request an nvidia gpu
72+
// 3. and the user didn't set an adapter name,
73+
// 4. and the user didn't request the high power pref
7374
// => don't load the nvidia icd, as it might power on the gpu in hybrid setups causing severe delays
7475
#[cfg(all(unix, not(target_os = "macos"), not(target_os = "redox")))]
7576
if !matches!(ids, Some((0x10de, _)))
77+
&& std::env::var_os("__NV_PRIME_RENDER_OFFLOAD")
78+
.is_none_or(|var| var == "0")
7679
&& std::env::var_os("WGPU_ADAPTER_NAME").is_none()
7780
&& std::env::var("WGPU_POWER_PREF").as_deref() != Ok("high")
7881
{

0 commit comments

Comments
 (0)