diff --git a/Cargo.toml b/Cargo.toml index 6de4f4bf03..bee83d2ebe 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 @@ -148,7 +150,7 @@ cosmic-text = "0.12" dark-light = "1.0" futures = "0.3" glam = "0.25" -glyphon = { git = "https://github.com/hecrj/glyphon.git", rev = "feef9f5630c2adb3528937e55f7bfad2da561a65" } +glyphon = { git = "https://github.com/hecrj/glyphon.git", rev = "0d7ba1bba4dd71eb88d2cface5ce649db2413cb7" } guillotiere = "0.6" half = "2.2" image = { version = "0.24", default-features = false } @@ -181,7 +183,7 @@ wasm-bindgen-futures = "0.4" wasm-timer = "0.2" web-sys = "0.3.69" web-time = "1.1" -wgpu = "0.19" +wgpu = "22.0" winapi = "0.3" window_clipboard = "0.4.1" winit = { git = "https://github.com/iced-rs/winit.git", rev = "254d6b3420ce4e674f516f7a2bd440665e05484d" } diff --git a/benches/wgpu.rs b/benches/wgpu.rs index 0e40725305..0605294f23 100644 --- a/benches/wgpu.rs +++ b/benches/wgpu.rs @@ -66,6 +66,7 @@ fn benchmark<'a>( label: None, required_features: wgpu::Features::empty(), required_limits: wgpu::Limits::default(), + memory_hints: wgpu::MemoryHints::MemoryUsage, }, None, )) diff --git a/examples/custom_shader/src/scene/pipeline.rs b/examples/custom_shader/src/scene/pipeline.rs index 50b70a98b2..84a3e5e21a 100644 --- a/examples/custom_shader/src/scene/pipeline.rs +++ b/examples/custom_shader/src/scene/pipeline.rs @@ -243,6 +243,8 @@ impl Pipeline { module: &shader, entry_point: "vs_main", buffers: &[Vertex::desc(), cube::Raw::desc()], + compilation_options: + wgpu::PipelineCompilationOptions::default(), }, primitive: wgpu::PrimitiveState::default(), depth_stencil: Some(wgpu::DepthStencilState { @@ -276,8 +278,11 @@ impl Pipeline { }), write_mask: wgpu::ColorWrites::ALL, })], + compilation_options: + wgpu::PipelineCompilationOptions::default(), }), multiview: None, + cache: None, }); let depth_pipeline = DepthPipeline::new( @@ -490,6 +495,8 @@ impl DepthPipeline { module: &shader, entry_point: "vs_main", buffers: &[], + compilation_options: + wgpu::PipelineCompilationOptions::default(), }, primitive: wgpu::PrimitiveState::default(), depth_stencil: Some(wgpu::DepthStencilState { @@ -508,8 +515,11 @@ impl DepthPipeline { blend: Some(wgpu::BlendState::REPLACE), write_mask: wgpu::ColorWrites::ALL, })], + compilation_options: + wgpu::PipelineCompilationOptions::default(), }), multiview: None, + cache: None, }); Self { diff --git a/examples/integration/src/main.rs b/examples/integration/src/main.rs index 5b64cbd1f5..87a5b22b46 100644 --- a/examples/integration/src/main.rs +++ b/examples/integration/src/main.rs @@ -102,6 +102,8 @@ pub fn main() -> Result<(), winit::error::EventLoopError> { required_features: adapter_features & wgpu::Features::default(), required_limits: wgpu::Limits::default(), + memory_hints: + wgpu::MemoryHints::MemoryUsage, }, None, ) diff --git a/examples/integration/src/scene.rs b/examples/integration/src/scene.rs index e29558bfdb..15f97e0848 100644 --- a/examples/integration/src/scene.rs +++ b/examples/integration/src/scene.rs @@ -74,6 +74,7 @@ fn build_pipeline( module: &vs_module, entry_point: "main", buffers: &[], + compilation_options: wgpu::PipelineCompilationOptions::default(), }, fragment: Some(wgpu::FragmentState { module: &fs_module, @@ -86,6 +87,7 @@ fn build_pipeline( }), write_mask: wgpu::ColorWrites::ALL, })], + compilation_options: wgpu::PipelineCompilationOptions::default(), }), primitive: wgpu::PrimitiveState { topology: wgpu::PrimitiveTopology::TriangleList, @@ -99,5 +101,6 @@ fn build_pipeline( alpha_to_coverage_enabled: false, }, multiview: None, + cache: None, }) } diff --git a/renderer/Cargo.toml b/renderer/Cargo.toml index 458681dd5e..ac223f16e2 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 b13ecb3696..a8ebf3aa85 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/color.rs b/wgpu/src/color.rs index 9d593d9c40..effac8da83 100644 --- a/wgpu/src/color.rs +++ b/wgpu/src/color.rs @@ -110,6 +110,8 @@ pub fn convert( module: &shader, entry_point: "vs_main", buffers: &[], + compilation_options: wgpu::PipelineCompilationOptions::default( + ), }, fragment: Some(wgpu::FragmentState { module: &shader, @@ -130,6 +132,8 @@ pub fn convert( }), write_mask: wgpu::ColorWrites::ALL, })], + compilation_options: wgpu::PipelineCompilationOptions::default( + ), }), primitive: wgpu::PrimitiveState { topology: wgpu::PrimitiveTopology::TriangleList, @@ -139,6 +143,7 @@ pub fn convert( depth_stencil: None, multisample: wgpu::MultisampleState::default(), multiview: None, + cache: None, }); let texture = device.create_texture(&wgpu::TextureDescriptor { diff --git a/wgpu/src/image/mod.rs b/wgpu/src/image/mod.rs index 1b16022acd..cf83c3f203 100644 --- a/wgpu/src/image/mod.rs +++ b/wgpu/src/image/mod.rs @@ -153,6 +153,8 @@ impl Pipeline { 8 => Uint32, ), }], + compilation_options: + wgpu::PipelineCompilationOptions::default(), }, fragment: Some(wgpu::FragmentState { module: &shader, @@ -173,6 +175,8 @@ impl Pipeline { }), write_mask: wgpu::ColorWrites::ALL, })], + compilation_options: + wgpu::PipelineCompilationOptions::default(), }), primitive: wgpu::PrimitiveState { topology: wgpu::PrimitiveTopology::TriangleList, @@ -186,6 +190,7 @@ impl Pipeline { alpha_to_coverage_enabled: false, }, multiview: None, + cache: None, }); Pipeline { diff --git a/wgpu/src/quad/gradient.rs b/wgpu/src/quad/gradient.rs index 13dc10f837..207b0d73c8 100644 --- a/wgpu/src/quad/gradient.rs +++ b/wgpu/src/quad/gradient.rs @@ -152,11 +152,15 @@ impl Pipeline { 9 => Float32 ), }], + compilation_options: + wgpu::PipelineCompilationOptions::default(), }, fragment: Some(wgpu::FragmentState { module: &shader, entry_point: "gradient_fs_main", targets: &quad::color_target_state(format), + compilation_options: + wgpu::PipelineCompilationOptions::default(), }), primitive: wgpu::PrimitiveState { topology: wgpu::PrimitiveTopology::TriangleList, @@ -170,6 +174,7 @@ impl Pipeline { alpha_to_coverage_enabled: false, }, multiview: None, + cache: None, }, ); diff --git a/wgpu/src/quad/solid.rs b/wgpu/src/quad/solid.rs index 45039a2d0c..86f118d66f 100644 --- a/wgpu/src/quad/solid.rs +++ b/wgpu/src/quad/solid.rs @@ -114,11 +114,15 @@ impl Pipeline { 8 => Float32, ), }], + compilation_options: + wgpu::PipelineCompilationOptions::default(), }, fragment: Some(wgpu::FragmentState { module: &shader, entry_point: "solid_fs_main", targets: &quad::color_target_state(format), + compilation_options: + wgpu::PipelineCompilationOptions::default(), }), primitive: wgpu::PrimitiveState { topology: wgpu::PrimitiveTopology::TriangleList, @@ -132,6 +136,7 @@ impl Pipeline { alpha_to_coverage_enabled: false, }, multiview: None, + cache: None, }); Self { pipeline } diff --git a/wgpu/src/triangle.rs b/wgpu/src/triangle.rs index b0551f5596..3d0869e717 100644 --- a/wgpu/src/triangle.rs +++ b/wgpu/src/triangle.rs @@ -760,16 +760,21 @@ mod solid { 1 => Float32x4, ), }], + compilation_options: + wgpu::PipelineCompilationOptions::default(), }, fragment: Some(wgpu::FragmentState { module: &shader, entry_point: "solid_fs_main", targets: &[Some(triangle::fragment_target(format))], + compilation_options: + wgpu::PipelineCompilationOptions::default(), }), primitive: triangle::primitive_state(), depth_stencil: None, multisample: triangle::multisample_state(antialiasing), multiview: None, + cache: None, }, ); @@ -937,16 +942,21 @@ mod gradient { 6 => Float32x4 ), }], + compilation_options: + wgpu::PipelineCompilationOptions::default(), }, fragment: Some(wgpu::FragmentState { module: &shader, entry_point: "gradient_fs_main", targets: &[Some(triangle::fragment_target(format))], + compilation_options: + wgpu::PipelineCompilationOptions::default(), }), primitive: triangle::primitive_state(), depth_stencil: None, multisample: triangle::multisample_state(antialiasing), multiview: None, + cache: None, }, ); diff --git a/wgpu/src/triangle/msaa.rs b/wgpu/src/triangle/msaa.rs index 71c1692584..ec06e747ea 100644 --- a/wgpu/src/triangle/msaa.rs +++ b/wgpu/src/triangle/msaa.rs @@ -112,6 +112,8 @@ impl Blit { module: &shader, entry_point: "vs_main", buffers: &[], + compilation_options: + wgpu::PipelineCompilationOptions::default(), }, fragment: Some(wgpu::FragmentState { module: &shader, @@ -123,6 +125,8 @@ impl Blit { ), write_mask: wgpu::ColorWrites::ALL, })], + compilation_options: + wgpu::PipelineCompilationOptions::default(), }), primitive: wgpu::PrimitiveState { topology: wgpu::PrimitiveTopology::TriangleList, @@ -136,6 +140,7 @@ impl Blit { alpha_to_coverage_enabled: false, }, multiview: None, + cache: None, }); Blit { diff --git a/wgpu/src/window/compositor.rs b/wgpu/src/window/compositor.rs index 2e938c7719..56f33b5013 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() }); @@ -162,6 +167,7 @@ impl Compositor { ), required_features: wgpu::Features::empty(), required_limits: required_limits.clone(), + memory_hints: wgpu::MemoryHints::MemoryUsage, }, None, )