Skip to content

Commit

Permalink
Fix web build
Browse files Browse the repository at this point in the history
  • Loading branch information
emilk committed Dec 1, 2023
1 parent 7660beb commit ab9479e
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions crates/egui-wgpu/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ impl RenderState {
) -> Result<Self, WgpuError> {
crate::profile_scope!("RenderState::create"); // async yield give bad names using `profile_function`

#[cfg(not(target_arch = "wasm32"))]
let adaptors: Vec<_> = instance.enumerate_adapters(wgpu::Backends::all()).collect();

let adapter = {
Expand All @@ -81,8 +82,7 @@ impl RenderState {
})
.await
.ok_or_else(|| {
let adaptors: Vec<_> =
instance.enumerate_adapters(wgpu::Backends::all()).collect();
#[cfg(not(target_arch = "wasm32"))]
if adaptors.is_empty() {
log::info!("No wgpu adaptors found");
} else if adaptors.len() == 1 {
Expand All @@ -102,6 +102,13 @@ impl RenderState {
})?
};

#[cfg(target_arch = "wasm32")]
log::debug!(
"Picked wgpu adaptor: {}",
adapter_info_summary(&adapter.get_info())
);

#[cfg(not(target_arch = "wasm32"))]
if adaptors.len() == 1 {
log::debug!(
"Picked the only available wgpu adaptor: {}",
Expand Down Expand Up @@ -144,6 +151,7 @@ impl RenderState {
}
}

#[cfg(not(target_arch = "wasm32"))]
fn describe_adaptors(adaptors: &[wgpu::Adapter]) -> String {
if adaptors.is_empty() {
"(none)".to_owned()
Expand Down

0 comments on commit ab9479e

Please sign in to comment.