mirror of
https://github.com/gfx-rs/wgpu.git
synced 2025-02-22 20:03:11 +00:00
Add logic to pick highest performance GPU on DirectX 12
Always select the first GPU in Integrated-Low/Discrete-High category, except when querying `LowPower`, in which case the last Discrete GPU is used.
This commit is contained in:
parent
dbef9f397e
commit
0d555fb688
@ -201,10 +201,23 @@ pub fn instance_get_adapter(instance_id: InstanceId, desc: &AdapterDescriptor) -
|
||||
};
|
||||
|
||||
let (mut low, mut high, mut other) = (None, None, None);
|
||||
// On Windows > 1803, dx12 enumerate_adapters returns the adapters in order from highest to
|
||||
// lowest performance. Therefore, the first found adapter in each category is selected.
|
||||
//
|
||||
// TODO: move power/performance policy querying into gfx, which has more context into
|
||||
// performance policy than wgpu
|
||||
for adapter in adapters {
|
||||
match adapter.info.device_type {
|
||||
hal::adapter::DeviceType::IntegratedGpu => low = Some(adapter),
|
||||
hal::adapter::DeviceType::DiscreteGpu => high = Some(adapter),
|
||||
hal::adapter::DeviceType::IntegratedGpu => low = low.or(Some(adapter)),
|
||||
hal::adapter::DeviceType::DiscreteGpu => {
|
||||
high = match desc.power_preference {
|
||||
// If `LowPower`, prefer lowest power `DiscreteGPU`
|
||||
PowerPreference::LowPower => Some(adapter),
|
||||
PowerPreference::HighPerformance | PowerPreference::Default => {
|
||||
high.or(Some(adapter))
|
||||
}
|
||||
}
|
||||
}
|
||||
_ => other = Some(adapter),
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user