mirror of
https://gitlab.com/veloren/veloren.git
synced 2024-08-30 18:12:32 +00:00
Add WGPU adapter selection using WGPU_ADAPTER
This commit is contained in:
parent
5e7e560c10
commit
a5ec81844f
@ -30,6 +30,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
||||
- Add server setting with PvE/PvP switch
|
||||
- Can now tilt glider while only wielding it
|
||||
- Experimental terrain persistence (see server documentation)
|
||||
- Add GPU filtering using WGPU_ADAPTER environment variable
|
||||
|
||||
### Changed
|
||||
|
||||
|
@ -224,12 +224,39 @@ impl Renderer {
|
||||
#[allow(unsafe_code)]
|
||||
let surface = unsafe { instance.create_surface(window) };
|
||||
|
||||
let adapter = runtime
|
||||
.block_on(instance.request_adapter(&wgpu::RequestAdapterOptionsBase {
|
||||
power_preference: wgpu::PowerPreference::HighPerformance,
|
||||
compatible_surface: Some(&surface),
|
||||
}))
|
||||
.ok_or(RenderError::CouldNotFindAdapter)?;
|
||||
let adapters = instance
|
||||
.enumerate_adapters(backend_bit)
|
||||
.enumerate()
|
||||
.collect::<Vec<_>>();
|
||||
|
||||
for (i, adapter) in adapters.iter() {
|
||||
let info = adapter.get_info();
|
||||
info!(
|
||||
?info.name,
|
||||
?info.vendor,
|
||||
?info.backend,
|
||||
?info.device,
|
||||
?info.device_type,
|
||||
"graphics device #{}", i,
|
||||
);
|
||||
}
|
||||
|
||||
let adapter = match std::env::var("WGPU_ADAPTER").ok() {
|
||||
Some(filter) if !filter.is_empty() => adapters.into_iter().find_map(|(i, adapter)| {
|
||||
let info = adapter.get_info();
|
||||
|
||||
let full_name = format!("#{} {} {:?}", i, info.name, info.device_type,);
|
||||
|
||||
full_name.contains(&filter).then(|| adapter)
|
||||
}),
|
||||
Some(_) | None => {
|
||||
runtime.block_on(instance.request_adapter(&wgpu::RequestAdapterOptionsBase {
|
||||
power_preference: wgpu::PowerPreference::HighPerformance,
|
||||
compatible_surface: Some(&surface),
|
||||
}))
|
||||
},
|
||||
}
|
||||
.ok_or(RenderError::CouldNotFindAdapter)?;
|
||||
|
||||
let info = adapter.get_info();
|
||||
info!(
|
||||
|
Loading…
Reference in New Issue
Block a user