Skip to content

Commit

Permalink
Introduce strict-assertions feature flag
Browse files Browse the repository at this point in the history
For now, this feature flag only enables validation
in `iced_wgpu`; which has become quite expensive
since its `0.20` release.
  • Loading branch information
hecrj committed Sep 19, 2024
1 parent a5e69cf commit 84b658d
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 0 deletions.
2 changes: 2 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,8 @@ advanced = ["iced_core/advanced", "iced_widget/advanced"]
fira-sans = ["iced_renderer/fira-sans"]
# Enables auto-detecting light/dark mode for the built-in theme
auto-detect-theme = ["iced_core/auto-detect-theme"]
# Enables strict assertions for debugging purposes at the expense of performance
strict-assertions = ["iced_renderer/strict-assertions"]

[dependencies]
iced_core.workspace = true
Expand Down
1 change: 1 addition & 0 deletions renderer/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ geometry = ["iced_graphics/geometry", "iced_tiny_skia?/geometry", "iced_wgpu?/ge
web-colors = ["iced_wgpu?/web-colors"]
webgl = ["iced_wgpu?/webgl"]
fira-sans = ["iced_graphics/fira-sans"]
strict-assertions = ["iced_wgpu?/strict-assertions"]

[dependencies]
iced_graphics.workspace = true
Expand Down
1 change: 1 addition & 0 deletions wgpu/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ image = ["iced_graphics/image"]
svg = ["iced_graphics/svg", "resvg/text"]
web-colors = ["iced_graphics/web-colors"]
webgl = ["wgpu/webgl"]
strict-assertions = []

[dependencies]
iced_graphics.workspace = true
Expand Down
5 changes: 5 additions & 0 deletions wgpu/src/window/compositor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,11 @@ impl Compositor {
) -> Result<Self, Error> {
let instance = wgpu::Instance::new(wgpu::InstanceDescriptor {
backends: settings.backends,
flags: if cfg!(feature = "strict-assertions") {
wgpu::InstanceFlags::debugging()
} else {
wgpu::InstanceFlags::empty()
},
..Default::default()
});

Expand Down

0 comments on commit 84b658d

Please sign in to comment.