Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions graphics/src/settings.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,20 @@ pub struct Settings {
///
/// By default, it is `true`.
pub vsync: bool,

/// The maximum number of bind groups that can be used simultaneously
/// in a shader pipeline.
///
/// The [WebGPU specification] guarantees a minimum of `4`, which is also
/// the default value used by `wgpu`. Applications embedding custom render
/// pipelines (e.g. via [`Shader`] primitives) may need more bind groups
/// than iced's own pipelines require.
///
/// By default, it is set to `4`.
///
/// [WebGPU specification]: https://www.w3.org/TR/webgpu/#limits
/// [`Shader`]: https://docs.rs/iced/latest/iced/widget/shader/index.html
pub max_bind_groups: u32,
}

impl Default for Settings {
Expand All @@ -30,6 +44,7 @@ impl Default for Settings {
default_text_size: Pixels(16.0),
antialiasing: None,
vsync: true,
max_bind_groups: 4,
}
}
}
Expand All @@ -47,6 +62,7 @@ impl From<core::Settings> for Settings {
default_text_size: settings.default_text_size,
antialiasing: settings.antialiasing.then_some(Antialiasing::MSAAx4),
vsync: settings.vsync,
max_bind_groups: 4,
}
}
}
8 changes: 8 additions & 0 deletions wgpu/src/settings.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,12 @@ pub struct Settings {
///
/// By default, it is `None`.
pub antialiasing: Option<Antialiasing>,

/// The maximum number of bind groups that can be used simultaneously
/// in a shader pipeline.
///
/// By default, it is set to `4`.
pub max_bind_groups: u32,
}

impl Default for Settings {
Expand All @@ -37,6 +43,7 @@ impl Default for Settings {
default_font: Font::default(),
default_text_size: Pixels(16.0),
antialiasing: None,
max_bind_groups: 4,
}
}
}
Expand All @@ -52,6 +59,7 @@ impl From<graphics::Settings> for Settings {
default_font: settings.default_font,
default_text_size: settings.default_text_size,
antialiasing: settings.antialiasing,
max_bind_groups: settings.max_bind_groups,
..Settings::default()
}
}
Expand Down
2 changes: 1 addition & 1 deletion wgpu/src/window/compositor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ impl Compositor {
let limits = [wgpu::Limits::default(), wgpu::Limits::downlevel_defaults()];

let limits = limits.into_iter().map(|limits| wgpu::Limits {
max_bind_groups: 2,
max_bind_groups: settings.max_bind_groups,
max_non_sampler_bindings: 2048,
..limits
});
Expand Down