From 2da9fdc549a380b2700baaa4f09b43d49c94e0bf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?H=C3=A9ctor=20Ram=C3=B3n=20Jim=C3=A9nez?= Date: Thu, 22 Feb 2024 09:52:12 +0100 Subject: [PATCH] Remove `adapter` argument introduced to `Backend` in `iced_wgpu` --- examples/integration/src/main.rs | 4 ++-- wgpu/src/backend.rs | 7 +------ wgpu/src/image.rs | 8 ++------ wgpu/src/image/atlas.rs | 13 +++++-------- wgpu/src/window/compositor.rs | 8 +------- 5 files changed, 11 insertions(+), 29 deletions(-) diff --git a/examples/integration/src/main.rs b/examples/integration/src/main.rs index 0e2e53acbb..afe342832d 100644 --- a/examples/integration/src/main.rs +++ b/examples/integration/src/main.rs @@ -87,7 +87,7 @@ pub fn main() -> Result<(), Box> { }); let surface = instance.create_surface(window.clone())?; - let (format, adapter, device, queue) = + let (format, _adapter, device, queue) = futures::futures::executor::block_on(async { let adapter = wgpu::util::initialize_adapter_from_env_or_default( &instance, @@ -157,7 +157,7 @@ pub fn main() -> Result<(), Box> { // Initialize iced let mut debug = Debug::new(); let mut renderer = Renderer::new( - Backend::new(&adapter, &device, &queue, Settings::default(), format), + Backend::new(&device, &queue, Settings::default(), format), Font::default(), Pixels(16.0), ); diff --git a/wgpu/src/backend.rs b/wgpu/src/backend.rs index 09ddbe4d8b..008378f4e3 100644 --- a/wgpu/src/backend.rs +++ b/wgpu/src/backend.rs @@ -34,7 +34,6 @@ pub struct Backend { impl Backend { /// Creates a new [`Backend`]. pub fn new( - _adapter: &wgpu::Adapter, device: &wgpu::Device, queue: &wgpu::Queue, settings: Settings, @@ -46,11 +45,7 @@ impl Backend { triangle::Pipeline::new(device, format, settings.antialiasing); #[cfg(any(feature = "image", feature = "svg"))] - let image_pipeline = { - let backend = _adapter.get_info().backend; - - image::Pipeline::new(device, format, backend) - }; + let image_pipeline = image::Pipeline::new(device, format); Self { quad_pipeline, diff --git a/wgpu/src/image.rs b/wgpu/src/image.rs index c8e4a4c282..06c22870bd 100644 --- a/wgpu/src/image.rs +++ b/wgpu/src/image.rs @@ -176,11 +176,7 @@ impl Data { } impl Pipeline { - pub fn new( - device: &wgpu::Device, - format: wgpu::TextureFormat, - backend: wgpu::Backend, - ) -> Self { + pub fn new(device: &wgpu::Device, format: wgpu::TextureFormat) -> Self { let nearest_sampler = device.create_sampler(&wgpu::SamplerDescriptor { address_mode_u: wgpu::AddressMode::ClampToEdge, address_mode_v: wgpu::AddressMode::ClampToEdge, @@ -322,7 +318,7 @@ impl Pipeline { multiview: None, }); - let texture_atlas = Atlas::new(device, backend); + let texture_atlas = Atlas::new(device); 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 ea36e06d32..ad99f6a4b9 100644 --- a/wgpu/src/image/atlas.rs +++ b/wgpu/src/image/atlas.rs @@ -23,14 +23,11 @@ pub struct Atlas { } impl Atlas { - 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], - }; + pub fn new(device: &wgpu::Device) -> Self { + // 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 + let layers = vec![Layer::Empty, Layer::Empty]; let extent = wgpu::Extent3d { width: SIZE, diff --git a/wgpu/src/window/compositor.rs b/wgpu/src/window/compositor.rs index 0a5d2c8f2d..b7b5723e55 100644 --- a/wgpu/src/window/compositor.rs +++ b/wgpu/src/window/compositor.rs @@ -146,13 +146,7 @@ impl Compositor { /// Creates a new rendering [`Backend`] for this [`Compositor`]. pub fn create_backend(&self) -> Backend { - Backend::new( - &self.adapter, - &self.device, - &self.queue, - self.settings, - self.format, - ) + Backend::new(&self.device, &self.queue, self.settings, self.format) } }