From 6da4c818268ab5dd8152a59fa245779802fdebea Mon Sep 17 00:00:00 2001 From: Quaternions Date: Mon, 25 Sep 2023 19:31:44 -0700 Subject: [PATCH] rank device types and ignore user preference --- src/framework.rs | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/src/framework.rs b/src/framework.rs index 08b7738..b70479e 100644 --- a/src/framework.rs +++ b/src/framework.rs @@ -191,17 +191,23 @@ async fn setup(title: &str) -> Setup { let adapters = instance.enumerate_adapters(backends); let mut chosen_adapter = None; + let mut chosen_adapter_score=0; for adapter in adapters { if !adapter.is_surface_supported(&surface) { continue; } + let score=match adapter.get_info().device_type{ + wgpu::DeviceType::IntegratedGpu=>3, + wgpu::DeviceType::DiscreteGpu=>4, + wgpu::DeviceType::VirtualGpu=>2, + wgpu::DeviceType::Other|wgpu::DeviceType::Cpu=>1, + }; + let adapter_features = adapter.features(); - if adapter_features.contains(required_features) { - chosen_adapter = Some(adapter); - if adapter_features.contains(optional_features) { - break; - } + if chosen_adapter_score