glyphon/benches/state.rs

44 lines
1.2 KiB
Rust
Raw Permalink Normal View History

2025-01-18 20:59:56 -05:00
use wgpu::{BackendOptions, Dx12BackendOptions};
use pollster::block_on;
pub struct State {
pub device: wgpu::Device,
pub queue: wgpu::Queue,
}
impl State {
pub fn new() -> Self {
2025-01-18 20:59:56 -05:00
let instance = wgpu::Instance::new(&wgpu::InstanceDescriptor {
backends: wgpu::Backends::all(),
flags: wgpu::InstanceFlags::empty(),
2025-01-18 20:59:56 -05:00
backend_options: BackendOptions {
gl: wgpu::GlBackendOptions {
gles_minor_version: wgpu::Gles3MinorVersion::Automatic
},
dx12: Dx12BackendOptions {
shader_compiler: wgpu::Dx12Compiler::Fxc
},
}
});
let adapter = block_on(wgpu::util::initialize_adapter_from_env_or_default(
&instance, None,
))
.unwrap();
let (device, queue) = block_on(adapter.request_device(
&wgpu::DeviceDescriptor {
label: Some("Benchmark Device"),
required_features: adapter.features(),
required_limits: adapter.limits(),
memory_hints: wgpu::MemoryHints::Performance,
},
None,
))
.unwrap();
Self { device, queue }
}
}