diff options
Diffstat (limited to 'wgpu')
| -rw-r--r-- | wgpu/src/backend.rs | 8 | ||||
| -rw-r--r-- | wgpu/src/image.rs | 8 | ||||
| -rw-r--r-- | wgpu/src/image/atlas.rs | 14 | ||||
| -rw-r--r-- | wgpu/src/window/compositor.rs | 8 | 
4 files changed, 30 insertions, 8 deletions
diff --git a/wgpu/src/backend.rs b/wgpu/src/backend.rs index 77b6fa83..09ddbe4d 100644 --- a/wgpu/src/backend.rs +++ b/wgpu/src/backend.rs @@ -27,7 +27,6 @@ pub struct Backend {      text_pipeline: text::Pipeline,      triangle_pipeline: triangle::Pipeline,      pipeline_storage: pipeline::Storage, -      #[cfg(any(feature = "image", feature = "svg"))]      image_pipeline: image::Pipeline,  } @@ -35,6 +34,7 @@ pub struct Backend {  impl Backend {      /// Creates a new [`Backend`].      pub fn new( +        _adapter: &wgpu::Adapter,          device: &wgpu::Device,          queue: &wgpu::Queue,          settings: Settings, @@ -46,7 +46,11 @@ impl Backend {              triangle::Pipeline::new(device, format, settings.antialiasing);          #[cfg(any(feature = "image", feature = "svg"))] -        let image_pipeline = image::Pipeline::new(device, format); +        let image_pipeline = { +            let backend = _adapter.get_info().backend; + +            image::Pipeline::new(device, format, backend) +        };          Self {              quad_pipeline, diff --git a/wgpu/src/image.rs b/wgpu/src/image.rs index 06c22870..c8e4a4c2 100644 --- a/wgpu/src/image.rs +++ b/wgpu/src/image.rs @@ -176,7 +176,11 @@ impl Data {  }  impl Pipeline { -    pub fn new(device: &wgpu::Device, format: wgpu::TextureFormat) -> Self { +    pub fn new( +        device: &wgpu::Device, +        format: wgpu::TextureFormat, +        backend: wgpu::Backend, +    ) -> Self {          let nearest_sampler = device.create_sampler(&wgpu::SamplerDescriptor {              address_mode_u: wgpu::AddressMode::ClampToEdge,              address_mode_v: wgpu::AddressMode::ClampToEdge, @@ -318,7 +322,7 @@ impl Pipeline {                  multiview: None,              }); -        let texture_atlas = Atlas::new(device); +        let texture_atlas = Atlas::new(device, backend);          let texture = device.create_bind_group(&wgpu::BindGroupDescriptor {              label: Some("iced_wgpu::image texture atlas bind group"), diff --git a/wgpu/src/image/atlas.rs b/wgpu/src/image/atlas.rs index 789e35b4..ea36e06d 100644 --- a/wgpu/src/image/atlas.rs +++ b/wgpu/src/image/atlas.rs @@ -23,11 +23,19 @@ pub struct Atlas {  }  impl Atlas { -    pub fn new(device: &wgpu::Device) -> Self { +    pub fn new(device: &wgpu::Device, backend: wgpu::Backend) -> Self { +        let layers = match backend { +            // On the GL backend we start with 2 layers, to help wgpu figure +            // out that this texture is `GL_TEXTURE_2D_ARRAY` rather than `GL_TEXTURE_2D` +            // https://github.com/gfx-rs/wgpu/blob/004e3efe84a320d9331371ed31fa50baa2414911/wgpu-hal/src/gles/mod.rs#L371 +            wgpu::Backend::Gl => vec![Layer::Empty, Layer::Empty], +            _ => vec![Layer::Empty], +        }; +          let extent = wgpu::Extent3d {              width: SIZE,              height: SIZE, -            depth_or_array_layers: 1, +            depth_or_array_layers: layers.len() as u32,          };          let texture = device.create_texture(&wgpu::TextureDescriptor { @@ -55,7 +63,7 @@ impl Atlas {          Atlas {              texture,              texture_view, -            layers: vec![Layer::Empty], +            layers,          }      } diff --git a/wgpu/src/window/compositor.rs b/wgpu/src/window/compositor.rs index f32ed3ac..7ac017d9 100644 --- a/wgpu/src/window/compositor.rs +++ b/wgpu/src/window/compositor.rs @@ -146,7 +146,13 @@ impl Compositor {      /// Creates a new rendering [`Backend`] for this [`Compositor`].      pub fn create_backend(&self) -> Backend { -        Backend::new(&self.device, &self.queue, self.settings, self.format) +        Backend::new( +            &self.adapter, +            &self.device, +            &self.queue, +            self.settings, +            self.format, +        )      }  }  | 
