Kevin Reid 326ad03ce1 Move trace_dir/trace_path to a custom enum inside DeviceDescriptor.
This allows `wgpu` to not unconditionally depend on `std::path::Path`.
It’s also, in my opinion, more user-friendly, because the feature which
most users will not use (and is not currently functional) is now a
defaultable struct field instead of a required parameter.

The disadvantage is that `wgpu-types` now has to know about tracing.
2025-03-10 22:17:06 -04:00

29 lines
989 B
Rust

//! Tests of the [`wgpu`] library API that are not run against a particular GPU.
mod api;
mod noop;
/// Obtain a device using [`wgpu::Backend::Noop`].
/// This should never fail.
fn request_noop_device() -> (wgpu::Device, wgpu::Queue) {
request_noop_device_with_desc(&wgpu::DeviceDescriptor::default())
}
fn request_noop_device_with_desc(desc: &wgpu::DeviceDescriptor) -> (wgpu::Device, wgpu::Queue) {
let instance = wgpu::Instance::new(&wgpu::InstanceDescriptor {
backends: wgpu::Backends::NOOP,
backend_options: wgpu::BackendOptions {
noop: wgpu::NoopBackendOptions { enable: true },
..Default::default()
},
..Default::default()
});
let adapter =
pollster::block_on(instance.request_adapter(&wgpu::RequestAdapterOptions::default()))
.expect("adapter");
assert_eq!(adapter.get_info().backend, wgpu::Backend::Noop);
pollster::block_on(adapter.request_device(desc)).expect("device")
}