diff options
| author | 2023-09-03 01:01:33 +0200 | |
|---|---|---|
| committer | 2023-09-03 01:04:23 +0200 | |
| commit | 020fb3c37794fcfa2670c3c0ada949aee95855a0 (patch) | |
| tree | 7f0ac0402770d9382bb7321b8660112807881ca0 /wgpu/src | |
| parent | 52b3f69e35f267840be202b6cb4d08e0ca7a3b08 (diff) | |
| download | iced-020fb3c37794fcfa2670c3c0ada949aee95855a0.tar.gz iced-020fb3c37794fcfa2670c3c0ada949aee95855a0.tar.bz2 iced-020fb3c37794fcfa2670c3c0ada949aee95855a0.zip | |
Fix `iced_wgpu` device selection on Wasm
Diffstat (limited to '')
| -rw-r--r-- | wgpu/src/window/compositor.rs | 33 | 
1 files changed, 19 insertions, 14 deletions
| diff --git a/wgpu/src/window/compositor.rs b/wgpu/src/window/compositor.rs index cd5b20cc..5202c7ef 100644 --- a/wgpu/src/window/compositor.rs +++ b/wgpu/src/window/compositor.rs @@ -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; @@ -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 +            .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 { +            if let Some(limits) = limits.next() { +                let device = adapter.request_device(                      &wgpu::DeviceDescriptor {                          label: Some(                              "iced_wgpu::window::compositor device descriptor", @@ -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, | 
