Remove unwraps in webgpu checking function (#1382)
This commit is contained in:
parent
7c1198a1b4
commit
8f586949a0
|
|
@ -42,12 +42,15 @@ impl WasmApplicationIo {
|
||||||
pub async fn new() -> Self {
|
pub async fn new() -> Self {
|
||||||
#[cfg(all(feature = "wgpu", target_arch = "wasm32"))]
|
#[cfg(all(feature = "wgpu", target_arch = "wasm32"))]
|
||||||
let executor = if let Some(gpu) = web_sys::window().map(|w| w.navigator().gpu()) {
|
let executor = if let Some(gpu) = web_sys::window().map(|w| w.navigator().gpu()) {
|
||||||
let request_adapter = js_sys::Reflect::get(&gpu, &wasm_bindgen::JsValue::from_str("requestAdapter")).unwrap();
|
let request_adapter = || {
|
||||||
let function = js_sys::Function::try_from(&request_adapter).unwrap();
|
let request_adapter = js_sys::Reflect::get(&gpu, &wasm_bindgen::JsValue::from_str("requestAdapter")).ok()?;
|
||||||
let result = function.call0(&gpu);
|
let function = js_sys::Function::try_from(&request_adapter)?;
|
||||||
|
Some(function.call0(&gpu).ok())
|
||||||
|
};
|
||||||
|
let result = request_adapter();
|
||||||
match result {
|
match result {
|
||||||
Err(_) => None,
|
None => None,
|
||||||
Ok(_) => WgpuExecutor::new().await,
|
Some(_) => WgpuExecutor::new().await,
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
None
|
None
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue