diff --git a/CHANGELOG.md b/CHANGELOG.md index 5aeb9b12dd..b3379ab9f1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 diff --git a/voxygen/src/render/renderer.rs b/voxygen/src/render/renderer.rs index a77d86d368..820b1353d2 100644 --- a/voxygen/src/render/renderer.rs +++ b/voxygen/src/render/renderer.rs @@ -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::>(); + + 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!(