From 84b658dbef0b29c57f67e041a1496c699ce78615 Mon Sep 17 00:00:00 2001 From: Héctor Ramón Jiménez Date: Fri, 20 Sep 2024 00:39:21 +0200 Subject: Introduce `strict-assertions` feature flag For now, this feature flag only enables validation in `iced_wgpu`; which has become quite expensive since its `0.20` release. --- Cargo.toml | 2 ++ renderer/Cargo.toml | 1 + wgpu/Cargo.toml | 1 + wgpu/src/window/compositor.rs | 5 +++++ 4 files changed, 9 insertions(+) diff --git a/Cargo.toml b/Cargo.toml index 629b1c9d..bee83d2e 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -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 diff --git a/renderer/Cargo.toml b/renderer/Cargo.toml index 458681dd..ac223f16 100644 --- a/renderer/Cargo.toml +++ b/renderer/Cargo.toml @@ -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 diff --git a/wgpu/Cargo.toml b/wgpu/Cargo.toml index b13ecb36..a8ebf3aa 100644 --- a/wgpu/Cargo.toml +++ b/wgpu/Cargo.toml @@ -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 diff --git a/wgpu/src/window/compositor.rs b/wgpu/src/window/compositor.rs index 0cfd49b7..56f33b50 100644 --- a/wgpu/src/window/compositor.rs +++ b/wgpu/src/window/compositor.rs @@ -56,6 +56,11 @@ impl Compositor { ) -> Result { 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() }); -- cgit