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 optional_features=optional_features();
|
||||||
let required_features=required_features();
|
let required_features=required_features();
|
||||||
|
|
||||||
//no helper function smh gotta write it myself
|
let chosen_adapter=pollster::block_on(self.instance.request_adapter(&wgpu::RequestAdapterOptions{
|
||||||
let adapters=self.instance.enumerate_adapters(self.backends);
|
power_preference:wgpu::PowerPreference::HighPerformance,
|
||||||
|
force_fallback_adapter:false,
|
||||||
let mut chosen_adapter=None;
|
compatible_surface:Some(&self.surface),
|
||||||
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);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if let Some(maybe_chosen_adapter)=chosen_adapter{
|
if let Some(maybe_chosen_adapter)=chosen_adapter{
|
||||||
adapter=maybe_chosen_adapter;
|
adapter=maybe_chosen_adapter;
|
||||||
|
Loading…
Reference in New Issue
Block a user