mirror of
https://github.com/storytold/wgpu.git
synced 2026-11-19 22:11:01 +01:00
This PR removes all of the `futures` dependencies. `std::future` does not contain a lot of useful helpers available in futures. The obvious ones are `join_all`, `FutureExt::map`, and `block_on`. * `join_all` is replaced with a `Vec<T>` and async blocks. * `FuturesExt::map` in the web backend is replaced by rolling the `map` function into the `MakeSendFuture` type. * `block_on` is provided by `pollster`. The original code using `join_all` ignored the result type yielded by the Future from `map_async`. This code does the same, but makes dropping the result a little more obvious. These should not be troublesome. Figured I would call them out anyway. The last big change is replacing `futures-executor` in the examples with `async-executor`. A new concrete `Spawner` type is used in the example framework instead of an implementation of `futures_task::LocalSpawn`.
26 lines
790 B
Rust
26 lines
790 B
Rust
/// This example shows how to describe the adapter in use.
|
|
async fn run() {
|
|
#[cfg_attr(target_arch = "wasm32", allow(unused_variables))]
|
|
let adapter = wgpu::Instance::new(wgpu::BackendBit::PRIMARY)
|
|
.request_adapter(&wgpu::RequestAdapterOptions::default())
|
|
.await
|
|
.unwrap();
|
|
|
|
#[cfg(not(target_arch = "wasm32"))]
|
|
println!("{:?}", adapter.get_info())
|
|
}
|
|
|
|
fn main() {
|
|
#[cfg(not(target_arch = "wasm32"))]
|
|
{
|
|
wgpu_subscriber::initialize_default_subscriber(None);
|
|
pollster::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());
|
|
}
|
|
}
|