forked from StrafesNET/strafe-project
replace enumerate_adapters with request_adapter
This commit is contained in:
parent
eb004cbb21
commit
2f422e97dd
@ -68,29 +68,11 @@ impl<'a> SetupContextPartial2<'a>{
|
||||
//let optional_features=optional_features();
|
||||
let required_features=required_features();
|
||||
|
||||
//no helper function smh gotta write it myself
|
||||
let adapters=self.instance.enumerate_adapters(self.backends);
|
||||
|
||||
let mut chosen_adapter=None;
|
||||
let mut chosen_adapter_score=0;
|
||||
for adapter in adapters {
|
||||
if !adapter.is_surface_supported(&self.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 chosen_adapter_score<score&&adapter_features.contains(required_features) {
|
||||
chosen_adapter_score=score;
|
||||
chosen_adapter=Some(adapter);
|
||||
}
|
||||
}
|
||||
let chosen_adapter=pollster::block_on(self.instance.request_adapter(&wgpu::RequestAdapterOptions{
|
||||
power_preference:wgpu::PowerPreference::HighPerformance,
|
||||
force_fallback_adapter:false,
|
||||
compatible_surface:Some(&self.surface),
|
||||
}));
|
||||
|
||||
if let Some(maybe_chosen_adapter)=chosen_adapter{
|
||||
adapter=maybe_chosen_adapter;
|
||||
|
Loading…
Reference in New Issue
Block a user