Skip to content

Commit

Permalink
Remove adapter argument introduced to Backend in iced_wgpu
Browse files Browse the repository at this point in the history
  • Loading branch information
hecrj committed Feb 22, 2024
1 parent c1f41a4 commit 2da9fdc
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 29 deletions.
4 changes: 2 additions & 2 deletions examples/integration/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ pub fn main() -> Result<(), Box<dyn std::error::Error>> {
});
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,
Expand Down Expand Up @@ -157,7 +157,7 @@ pub fn main() -> Result<(), Box<dyn std::error::Error>> {
// 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),
);
Expand Down
7 changes: 1 addition & 6 deletions wgpu/src/backend.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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,
Expand Down
8 changes: 2 additions & 6 deletions wgpu/src/image.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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"),
Expand Down
13 changes: 5 additions & 8 deletions wgpu/src/image/atlas.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
8 changes: 1 addition & 7 deletions wgpu/src/window/compositor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
}

Expand Down

0 comments on commit 2da9fdc

Please sign in to comment.