mirror of
https://github.com/storytold/wgpu.git
synced 2026-11-22 15:31:03 +01:00
31 lines
890 B
Rust
31 lines
890 B
Rust
/// This example shows how to describe the adapter in use.
|
|
async fn run() {
|
|
let adapter = wgpu::Instance::new(wgpu::BackendBit::PRIMARY)
|
|
.request_adapter(
|
|
&wgpu::RequestAdapterOptions {
|
|
power_preference: wgpu::PowerPreference::Default,
|
|
compatible_surface: None,
|
|
},
|
|
unsafe { wgpu::UnsafeFeatures::allow() },
|
|
)
|
|
.await
|
|
.unwrap();
|
|
|
|
#[cfg(not(target_arch = "wasm32"))]
|
|
println!("{:?}", adapter.get_info())
|
|
}
|
|
|
|
fn main() {
|
|
#[cfg(not(target_arch = "wasm32"))]
|
|
{
|
|
env_logger::init();
|
|
futures::executor::block_on(run());
|
|
}
|
|
#[cfg(target_arch = "wasm32")]
|
|
{
|
|
std::panic::set_hook(Box::new(console_error_panic_hook::hook));
|
|
console_log::init().expect("could not initialize logger");
|
|
wasm_bindgen_futures::spawn_local(run());
|
|
}
|
|
}
|