Skip to content

Commit 2e2d9b5

Browse files
refactor: check_stage: convert if to match for I/O checks
1 parent 3c0eeda commit 2e2d9b5

File tree

1 file changed

+32
-27
lines changed

1 file changed

+32
-27
lines changed

wgpu-core/src/validation.rs

Lines changed: 32 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1317,37 +1317,42 @@ impl Interface {
13171317
}
13181318
}
13191319

1320-
if shader_stage == naga::ShaderStage::Vertex {
1321-
for output in entry_point.outputs.iter() {
1322-
//TODO: count builtins towards the limit?
1323-
inter_stage_components += match *output {
1324-
Varying::Local { ref iv, .. } => iv.ty.dim.num_components(),
1325-
Varying::BuiltIn(_) => 0,
1326-
};
1327-
1328-
if let Some(
1329-
cmp @ wgt::CompareFunction::Equal | cmp @ wgt::CompareFunction::NotEqual,
1330-
) = compare_function
1331-
{
1332-
if let Varying::BuiltIn(naga::BuiltIn::Position { invariant: false }) = *output
1320+
#[expect(clippy::single_match)]
1321+
match shader_stage {
1322+
naga::ShaderStage::Vertex => {
1323+
for output in entry_point.outputs.iter() {
1324+
//TODO: count builtins towards the limit?
1325+
inter_stage_components += match *output {
1326+
Varying::Local { ref iv, .. } => iv.ty.dim.num_components(),
1327+
Varying::BuiltIn(_) => 0,
1328+
};
1329+
1330+
if let Some(
1331+
cmp @ wgt::CompareFunction::Equal | cmp @ wgt::CompareFunction::NotEqual,
1332+
) = compare_function
13331333
{
1334-
log::warn!(
1335-
concat!(
1336-
"Vertex shader with entry point {} outputs a ",
1337-
"@builtin(position) without the @invariant attribute and ",
1338-
"is used in a pipeline with {cmp:?}. On some machines, ",
1339-
"this can cause bad artifacting as {cmp:?} assumes the ",
1340-
"values output from the vertex shader exactly match the ",
1341-
"value in the depth buffer. The @invariant attribute on the ",
1342-
"@builtin(position) vertex output ensures that the exact ",
1343-
"same pixel depths are used every render."
1344-
),
1345-
entry_point_name,
1346-
cmp = cmp
1347-
);
1334+
if let Varying::BuiltIn(naga::BuiltIn::Position { invariant: false }) =
1335+
*output
1336+
{
1337+
log::warn!(
1338+
concat!(
1339+
"Vertex shader with entry point {} outputs a ",
1340+
"@builtin(position) without the @invariant attribute and ",
1341+
"is used in a pipeline with {cmp:?}. On some machines, ",
1342+
"this can cause bad artifacting as {cmp:?} assumes the ",
1343+
"values output from the vertex shader exactly match the ",
1344+
"value in the depth buffer. The @invariant attribute on the ",
1345+
"@builtin(position) vertex output ensures that the exact ",
1346+
"same pixel depths are used every render."
1347+
),
1348+
entry_point_name,
1349+
cmp = cmp
1350+
);
1351+
}
13481352
}
13491353
}
13501354
}
1355+
_ => (),
13511356
}
13521357

13531358
if inter_stage_components > self.limits.max_inter_stage_shader_components {

0 commit comments

Comments
 (0)