mirror of
https://github.com/GraphiteEditor/Graphite.git
synced 2026-09-21 13:38:12 +08:00
Desktop: Add rudimentary support for custom WGPU adapter selection (#3201)
* rudimentary custom wgpu adapter selection * WgpuContextBuilder * wasm fix * fix wasm warnings * Clean up * Review suggestions * fix
This commit is contained in:
@@ -0,0 +1,23 @@
|
||||
use graphite_desktop_wrapper::{WgpuContext, WgpuContextBuilder, WgpuFeatures};
|
||||
|
||||
pub(super) async fn create_wgpu_context() -> WgpuContext {
|
||||
let wgpu_context_builder = WgpuContextBuilder::new().with_features(WgpuFeatures::PUSH_CONSTANTS);
|
||||
|
||||
// TODO: add a cli flag to list adapters and exit instead of always printing
|
||||
println!("\nAvailable WGPU adapters:\n{}", wgpu_context_builder.available_adapters_fmt().await);
|
||||
|
||||
// TODO: make this configurable via cli flags instead
|
||||
let wgpu_context = match std::env::var("GRAPHITE_WGPU_ADAPTER").ok().and_then(|s| s.parse().ok()) {
|
||||
None => wgpu_context_builder.build().await,
|
||||
Some(adapter_index) => {
|
||||
tracing::info!("Overriding WGPU adapter selection with adapter index {adapter_index}");
|
||||
wgpu_context_builder.build_with_adapter_selection(|_| Some(adapter_index)).await
|
||||
}
|
||||
}
|
||||
.expect("Failed to create WGPU context");
|
||||
|
||||
// TODO: add a cli flag to list adapters and exit instead of always printing
|
||||
println!("Using WGPU adapter: {:?}", wgpu_context.adapter.get_info());
|
||||
|
||||
wgpu_context
|
||||
}
|
||||
Reference in New Issue
Block a user