mirror of
https://github.com/gfx-rs/wgpu.git
synced 2026-04-22 03:02:01 -04:00
Never prefer CPU devices over GPUs
This commit is contained in:
@@ -628,7 +628,8 @@ impl<G: GlobalIdentityHandlerFactory> Global<G> {
|
||||
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 {
|
||||
@@ -641,15 +642,18 @@ impl<G: GlobalIdentityHandlerFactory> Global<G> {
|
||||
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));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
let preferred_gpu = match desc.power_preference {
|
||||
PowerPreference::LowPower => integrated.or(other).or(discrete).or(virt),
|
||||
PowerPreference::HighPerformance => discrete.or(other).or(integrated).or(virt),
|
||||
PowerPreference::LowPower => integrated.or(other).or(discrete).or(virt).or(cpu),
|
||||
PowerPreference::HighPerformance => discrete.or(other).or(integrated).or(virt).or(cpu),
|
||||
};
|
||||
|
||||
let mut selected = preferred_gpu.unwrap_or(0);
|
||||
|
||||
Reference in New Issue
Block a user