From b8df0aac6e1f740d706fbb556d4e6d792a17cf27 Mon Sep 17 00:00:00 2001 From: Erich Gubler Date: Mon, 6 Oct 2025 16:16:12 -0400 Subject: [PATCH] refactor: `check_stage`: convert `if` to `match` for I/O checks --- wgpu-core/src/validation.rs | 57 ++++++++++++++++++++----------------- 1 file changed, 31 insertions(+), 26 deletions(-) diff --git a/wgpu-core/src/validation.rs b/wgpu-core/src/validation.rs index e29f088a9..13a3257f9 100644 --- a/wgpu-core/src/validation.rs +++ b/wgpu-core/src/validation.rs @@ -1317,37 +1317,42 @@ impl Interface { } } - if shader_stage == naga::ShaderStage::Vertex { - for output in entry_point.outputs.iter() { - //TODO: count builtins towards the limit? - inter_stage_components += match *output { - Varying::Local { ref iv, .. } => iv.ty.dim.num_components(), - Varying::BuiltIn(_) => 0, - }; + #[expect(clippy::single_match)] + match shader_stage { + naga::ShaderStage::Vertex => { + for output in entry_point.outputs.iter() { + //TODO: count builtins towards the limit? + inter_stage_components += match *output { + Varying::Local { ref iv, .. } => iv.ty.dim.num_components(), + Varying::BuiltIn(_) => 0, + }; - if let Some( - cmp @ wgt::CompareFunction::Equal | cmp @ wgt::CompareFunction::NotEqual, - ) = compare_function - { - if let Varying::BuiltIn(naga::BuiltIn::Position { invariant: false }) = *output + if let Some( + cmp @ wgt::CompareFunction::Equal | cmp @ wgt::CompareFunction::NotEqual, + ) = compare_function { - log::warn!( - concat!( - "Vertex shader with entry point {} outputs a ", - "@builtin(position) without the @invariant attribute and ", - "is used in a pipeline with {cmp:?}. On some machines, ", - "this can cause bad artifacting as {cmp:?} assumes the ", - "values output from the vertex shader exactly match the ", - "value in the depth buffer. The @invariant attribute on the ", - "@builtin(position) vertex output ensures that the exact ", - "same pixel depths are used every render." - ), - entry_point_name, - cmp = cmp - ); + if let Varying::BuiltIn(naga::BuiltIn::Position { invariant: false }) = + *output + { + log::warn!( + concat!( + "Vertex shader with entry point {} outputs a ", + "@builtin(position) without the @invariant attribute and ", + "is used in a pipeline with {cmp:?}. On some machines, ", + "this can cause bad artifacting as {cmp:?} assumes the ", + "values output from the vertex shader exactly match the ", + "value in the depth buffer. The @invariant attribute on the ", + "@builtin(position) vertex output ensures that the exact ", + "same pixel depths are used every render." + ), + entry_point_name, + cmp = cmp + ); + } } } } + _ => (), } if inter_stage_components > self.limits.max_inter_stage_shader_components {