Skip to content

Commit

Permalink
Fix iced_wgpu device selection on Wasm
Browse files Browse the repository at this point in the history
  • Loading branch information
hecrj committed Sep 2, 2023
1 parent d518e7d commit 879277c
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 15 deletions.
2 changes: 1 addition & 1 deletion core/src/window/redraw_request.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ pub enum RedrawRequest {
#[cfg(test)]
mod tests {
use super::*;
use std::time::{Duration, Instant};
use crate::time::{Duration, Instant};

#[test]
fn ordering() {
Expand Down
33 changes: 19 additions & 14 deletions wgpu/src/window/compositor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@ use crate::graphics::compositor;
use crate::graphics::{Error, Viewport};
use crate::{Backend, Primitive, Renderer, Settings};

use futures::stream::{self, StreamExt};

use raw_window_handle::{HasRawDisplayHandle, HasRawWindowHandle};

use std::marker::PhantomData;
Expand Down Expand Up @@ -95,14 +93,17 @@ impl<Theme> Compositor<Theme> {
let limits =
[wgpu::Limits::default(), wgpu::Limits::downlevel_defaults()];

let limits = limits.into_iter().map(|limits| wgpu::Limits {
max_bind_groups: 2,
..limits
});
let mut limits = limits

Check failure on line 96 in wgpu/src/window/compositor.rs

View workflow job for this annotation

GitHub Actions / all

useless conversion to the same type: `std::iter::Map<std::array::IntoIter<wgpu::Limits, 2>, [closure@wgpu/src/window/compositor.rs:98:18: 98:26]>`
.into_iter()
.map(|limits| wgpu::Limits {
max_bind_groups: 2,
..limits
})
.into_iter();

let (device, queue) = stream::iter(limits)
.filter_map(|limits| async {
adapter.request_device(
let (device, queue) = loop {

Check failure on line 104 in wgpu/src/window/compositor.rs

View workflow job for this annotation

GitHub Actions / all

this loop never actually loops
if let Some(limits) = limits.next() {
let device = adapter.request_device(
&wgpu::DeviceDescriptor {
label: Some(
"iced_wgpu::window::compositor device descriptor",
Expand All @@ -111,11 +112,15 @@ impl<Theme> Compositor<Theme> {
limits,
},
None,
).await.ok()
})
.boxed()
.next()
.await?;
).await.ok();

if let Some(device) = device {
break Some(device);
}
}

break None;
}?;

Some(Compositor {
instance,
Expand Down

0 comments on commit 879277c

Please sign in to comment.