File tree Expand file tree Collapse file tree 1 file changed +16
-8
lines changed Expand file tree Collapse file tree 1 file changed +16
-8
lines changed Original file line number Diff line number Diff line change @@ -98,19 +98,27 @@ async fn init_wgpu_context() -> WgpuContext {
98
98
let adapter_index = if let Some ( index) = adapter_override
99
99
&& index < adapters. len ( )
100
100
{
101
- index
101
+ Some ( index)
102
102
} else if cfg ! ( target_os = "windows" ) {
103
- match adapters. iter ( ) . enumerate ( ) . find ( |( _, a) | a. get_info ( ) . backend == wgpu:: Backend :: Dx12 ) {
104
- Some ( ( index, _) ) => index,
105
- None => 0 ,
106
- }
103
+ adapters. iter ( ) . enumerate ( ) . find ( |( _, a) | a. get_info ( ) . backend == wgpu:: Backend :: Dx12 ) . map ( |( i, _) | i)
107
104
} else {
108
- 0 // Same behavior as requests adapter
105
+ None
109
106
} ;
110
107
111
- tracing:: info!( "Using WGPU adapter {adapter_index}" ) ;
108
+ let adapter = if let Some ( index) = adapter_index {
109
+ tracing:: info!( "Using WGPU adapter {index}" ) ;
110
+ adapters. remove ( index)
111
+ } else {
112
+ tracing:: info!( "Requesting HighPerformance adapter from wgpu" ) ;
113
+
114
+ let adapter_options = wgpu:: RequestAdapterOptions {
115
+ power_preference : wgpu:: PowerPreference :: HighPerformance ,
116
+ compatible_surface : None ,
117
+ force_fallback_adapter : false ,
118
+ } ;
112
119
113
- let adapter = adapters. remove ( adapter_index) ;
120
+ instance. request_adapter ( & adapter_options) . await . expect ( "Failed to request WGPU adapter" )
121
+ } ;
114
122
115
123
WgpuContext :: new_with_instance_and_adapter ( instance, adapter)
116
124
. await
You can’t perform that action at this time.
0 commit comments