Skip to content

Commit

Permalink
Fix
Browse files Browse the repository at this point in the history
  • Loading branch information
sigma-andex committed Jan 21, 2024
1 parent 50f7b5b commit 30118ba
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
1 change: 1 addition & 0 deletions crates/ratchet-core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ glam = "0.25.0"
pollster = "0.3.0"
futures-intrusive = "0.5.0"
anyhow = "1.0.79"
getrandom = { version = "0.2", features = ["js"] } # Needed for wasm support in `num` trait
num = "0.4.1"
rand_distr = { version = "0.4.3", optional = true }
rand = { version = "0.8.4", optional = true }
Expand Down
12 changes: 6 additions & 6 deletions crates/ratchet-core/src/gpu/device.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ impl PartialEq for WgpuDevice {
impl WgpuDevice {
pub async fn new() -> Result<Self, DeviceError> {
#[cfg(target_arch = "wasm32")]
let adapter = Self::select_adapter().await;
let adapter = Self::select_adapter().await?;
#[cfg(not(target_arch = "wasm32"))]
let adapter = Self::select_adapter()?;

Expand Down Expand Up @@ -106,7 +106,7 @@ impl WgpuDevice {
}

#[cfg(target_arch = "wasm32")]
async fn select_adapter() -> Adapter {
async fn select_adapter() -> Result<Adapter, DeviceError> {
let instance = wgpu::Instance::default();
let backends = wgpu::util::backend_bits_from_env().unwrap_or(wgpu::Backends::PRIMARY);
instance
Expand All @@ -116,10 +116,10 @@ impl WgpuDevice {
force_fallback_adapter: false,
})
.await
.map_err(|e| {
log::error!("Failed to create device: {:?}", e);
e
})?
.ok_or({
log::error!("Failed to request adapter.");
DeviceError::AdapterRequestFailed
})
}

#[cfg(not(target_arch = "wasm32"))]
Expand Down

0 comments on commit 30118ba

Please sign in to comment.