From ce96730c042970b018baa3947dd7e888b4b0619e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?vin=C3=ADcius=20x?= Date: Mon, 26 Jan 2026 22:26:28 -0300 Subject: [PATCH] fix dual-src validation of struct members --- naga/src/valid/interface.rs | 24 +++++++++++++++++------- 1 file changed, 17 insertions(+), 7 deletions(-) diff --git a/naga/src/valid/interface.rs b/naga/src/valid/interface.rs index 51b5f83571c..e30ab30861e 100644 --- a/naga/src/valid/interface.rs +++ b/naga/src/valid/interface.rs @@ -645,18 +645,28 @@ impl VaryingContext<'_> { if !self.blend_src_mask.is_empty() { let span_context = self.types.get_span_context(ty); - - // If there's any blend_src usage, it must apply to all members of which there must be exactly 2. - if members.len() != 2 || self.blend_src_mask.len() != 2 { + let location_members = members + .as_slice() + .iter() + .filter(|m| { + m.binding + .as_ref() + .is_some_and(|b| matches!(b, crate::Binding::Location { .. })) + }) + .collect::>(); + + // If there's any blend_src usage, it must apply to all members with a `location` attribute, of which there must be exactly 2. + if location_members.len() != 2 || self.blend_src_mask.len() != 2 { return Err( VaryingError::IncompleteBlendSrcUsage.with_span_context(span_context) ); } - // Also, all members must have the same type. - if members[0].ty != members[1].ty { + + // Also, all of them must have the same type. + if location_members[0].ty != location_members[1].ty { return Err(VaryingError::BlendSrcOutputTypeMismatch { - blend_src_0_type: members[0].ty, - blend_src_1_type: members[1].ty, + blend_src_0_type: location_members[0].ty, + blend_src_1_type: location_members[1].ty, } .with_span_context(span_context)); }