Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 17 additions & 7 deletions naga/src/valid/interface.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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::<Vec<_>>();

// 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,
Comment on lines +664 to +669
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The error message text uses the labels blend_src(0) and blend_src(1), but location_members could have them in the opposite order if they were declared that way in the source.

I think it would be possible to do one pass over the members and save the types of the blend_src members in an array [Option<Handle<Type>>; 2] along the way using the actual index values, so that they are identified correctly in the error message.

}
.with_span_context(span_context));
}
Expand Down
Loading