Skip to content

Commit

Permalink
refactor(naga): split out cross handling to separate match arm
Browse files Browse the repository at this point in the history
  • Loading branch information
ErichDonGubler committed Aug 27, 2024
1 parent 5faa474 commit 144288e
Showing 1 changed file with 26 additions and 3 deletions.
29 changes: 26 additions & 3 deletions naga/src/valid/expression.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1161,7 +1161,7 @@ impl super::Validator {
));
}
}
Mf::Outer | Mf::Cross | Mf::Reflect => {
Mf::Outer | Mf::Reflect => {
let arg1_ty = match (arg1_ty, arg2_ty, arg3_ty) {
(Some(ty1), None, None) => ty1,
_ => return Err(ExpressionError::WrongArgumentCount(fun)),
Expand All @@ -1172,8 +1172,31 @@ impl super::Validator {
Sc {
kind: Sk::Float, ..
},
size: vector_size,
} if fun != Mf::Cross || vector_size == crate::VectorSize::Tri => {}
..
} => {}
_ => return Err(ExpressionError::InvalidArgumentType(fun, 0, arg)),
}
if arg1_ty != arg_ty {
return Err(ExpressionError::InvalidArgumentType(
fun,
1,
arg1.unwrap(),
));
}
}
Mf::Cross => {
let arg1_ty = match (arg1_ty, arg2_ty, arg3_ty) {
(Some(ty1), None, None) => ty1,
_ => return Err(ExpressionError::WrongArgumentCount(fun)),
};
match *arg_ty {
Ti::Vector {
scalar:
Sc {
kind: Sk::Float, ..
},
size: crate::VectorSize::Tri,
} => {}
_ => return Err(ExpressionError::InvalidArgumentType(fun, 0, arg)),
}
if arg1_ty != arg_ty {
Expand Down

0 comments on commit 144288e

Please sign in to comment.