mirror of
https://github.com/GraphiteEditor/Graphite.git
synced 2026-12-06 11:11:48 -10:00
24 lines
1.0 KiB
Rust
24 lines
1.0 KiB
Rust
use crate::wrapper::{WgpuContext, WgpuContextBuilder, WgpuFeatures};
|
|
|
|
pub(super) async fn create_wgpu_context() -> WgpuContext {
|
|
let mut wgpu_context_builder = WgpuContextBuilder::new()
|
|
.with_features(WgpuFeatures::IMMEDIATES)
|
|
.with_optional_features(WgpuFeatures::VULKAN_EXTERNAL_MEMORY_DMA_BUF);
|
|
|
|
// TODO: make this configurable via cli flags instead
|
|
if let Some(index) = std::env::var("GRAPHITE_WGPU_ADAPTER").ok().and_then(|s| s.parse().ok()) {
|
|
tracing::info!("Overriding WGPU adapter selection with adapter index {index}");
|
|
wgpu_context_builder = wgpu_context_builder.with_selection(index);
|
|
}
|
|
|
|
// 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);
|
|
|
|
let wgpu_context = wgpu_context_builder.build().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
|
|
}
|