Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix #22

Closed
Closed

Fix #22

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading