2024-11-28 22:36:23 +09:00
|
|
|
use pollster::block_on;
|
|
|
|
|
|
|
|
|
|
pub struct State {
|
|
|
|
|
pub device: wgpu::Device,
|
|
|
|
|
pub queue: wgpu::Queue,
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
impl State {
|
|
|
|
|
pub fn new() -> Self {
|
2024-07-25 13:05:55 -05:00
|
|
|
let instance = wgpu::Instance::new(&wgpu::InstanceDescriptor::default());
|
2024-11-28 22:36:23 +09:00
|
|
|
|
|
|
|
|
let adapter = block_on(wgpu::util::initialize_adapter_from_env_or_default(
|
|
|
|
|
&instance, None,
|
|
|
|
|
))
|
|
|
|
|
.unwrap();
|
|
|
|
|
|
2025-10-31 14:03:21 +01:00
|
|
|
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,
|
|
|
|
|
..wgpu::DeviceDescriptor::default()
|
|
|
|
|
}))
|
2024-11-28 22:36:23 +09:00
|
|
|
.unwrap();
|
|
|
|
|
|
|
|
|
|
Self { device, queue }
|
|
|
|
|
}
|
|
|
|
|
}
|