From a1e80c43def9c9e811e944e5da5289af3cf907f4 Mon Sep 17 00:00:00 2001 From: Greg V Date: Fri, 9 Oct 2020 21:45:59 +0300 Subject: [PATCH] Never prefer CPU devices over GPUs --- wgpu-core/src/instance.rs | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/wgpu-core/src/instance.rs b/wgpu-core/src/instance.rs index 700b9c930..55483dc8f 100644 --- a/wgpu-core/src/instance.rs +++ b/wgpu-core/src/instance.rs @@ -480,7 +480,8 @@ impl Global { return Err(RequestAdapterError::NotFound); } - let (mut integrated, mut discrete, mut virt, mut other) = (None, None, None, None); + let (mut integrated, mut discrete, mut virt, mut cpu, mut other) = + (None, None, None, None, None); for (i, ty) in device_types.into_iter().enumerate() { match ty { @@ -493,7 +494,10 @@ impl Global { hal::adapter::DeviceType::VirtualGpu => { virt = virt.or(Some(i)); } - _ => { + hal::adapter::DeviceType::Cpu => { + cpu = cpu.or(Some(i)); + } + hal::adapter::DeviceType::Other => { other = other.or(Some(i)); } } @@ -501,9 +505,9 @@ impl Global { let preferred_gpu = match desc.power_preference { PowerPreference::Default | PowerPreference::LowPower => { - integrated.or(other).or(discrete).or(virt) + integrated.or(other).or(discrete).or(virt).or(cpu) } - PowerPreference::HighPerformance => discrete.or(other).or(integrated).or(virt), + PowerPreference::HighPerformance => discrete.or(other).or(integrated).or(virt).or(cpu), }; let mut selected = preferred_gpu.unwrap_or(0);