mirror of
https://github.com/storytold/wgpu.git
synced 2026-11-19 22:11:01 +01:00
spv-in: more sign agnostic binary operations
This commit is contained in:
1 parent
03f0e5c437
commit
ec64092b12
2 files changed
+15
-15
No files matched your search
@@ -13,6 +13,7 @@ pub(super) fn map_binary_operator(word: spirv::Op) -> Result<crate::BinaryOperat
|
||||
Op::IMul | Op::FMul => Ok(BinaryOperator::Multiply),
|
||||
Op::UDiv | Op::SDiv | Op::FDiv => Ok(BinaryOperator::Divide),
|
||||
Op::UMod | Op::SMod | Op::FMod => Ok(BinaryOperator::Modulo),
|
||||
Op::SRem => Ok(BinaryOperator::Modulo),
|
||||
// Relational and Logical Instructions
|
||||
Op::IEqual | Op::FOrdEqual | Op::FUnordEqual | Op::LogicalEqual => {
|
||||
Ok(BinaryOperator::Equal)
|
||||
@@ -34,6 +35,9 @@ pub(super) fn map_binary_operator(word: spirv::Op) -> Result<crate::BinaryOperat
|
||||
| Op::SGreaterThanEqual
|
||||
| Op::FOrdGreaterThanEqual
|
||||
| Op::FUnordGreaterThanEqual => Ok(BinaryOperator::GreaterEqual),
|
||||
Op::BitwiseOr => Ok(BinaryOperator::InclusiveOr),
|
||||
Op::BitwiseXor => Ok(BinaryOperator::ExclusiveOr),
|
||||
Op::BitwiseAnd => Ok(BinaryOperator::And),
|
||||
_ => Err(Error::UnknownBinaryOperator(word)),
|
||||
}
|
||||
}
|
||||
|
||||
+11
-15
@@ -1891,7 +1891,15 @@ impl<I: Iterator<Item = u32>> Parser<I> {
|
||||
inst.expect(4)?;
|
||||
parse_expr_op!(crate::UnaryOperator::Negate, UNARY)?;
|
||||
}
|
||||
Op::IAdd | Op::ISub | Op::IMul => {
|
||||
Op::IAdd
|
||||
| Op::ISub
|
||||
| Op::IMul
|
||||
| Op::BitwiseOr
|
||||
| Op::BitwiseXor
|
||||
| Op::BitwiseAnd
|
||||
| Op::SDiv
|
||||
| Op::SMod
|
||||
| Op::SRem => {
|
||||
inst.expect(5)?;
|
||||
let operator = map_binary_operator(inst.op)?;
|
||||
self.parse_expr_binary_op_sign_adjusted(
|
||||
@@ -1929,11 +1937,11 @@ impl<I: Iterator<Item = u32>> Parser<I> {
|
||||
inst.expect(5)?;
|
||||
parse_expr_op!(crate::BinaryOperator::Multiply, BINARY)?;
|
||||
}
|
||||
Op::SDiv | Op::UDiv | Op::FDiv => {
|
||||
Op::UDiv | Op::FDiv => {
|
||||
inst.expect(5)?;
|
||||
parse_expr_op!(crate::BinaryOperator::Divide, BINARY)?;
|
||||
}
|
||||
Op::SMod | Op::UMod | Op::FMod | Op::SRem | Op::FRem => {
|
||||
Op::UMod | Op::FMod | Op::FRem => {
|
||||
inst.expect(5)?;
|
||||
parse_expr_op!(crate::BinaryOperator::Modulo, BINARY)?;
|
||||
}
|
||||
@@ -2170,18 +2178,6 @@ impl<I: Iterator<Item = u32>> Parser<I> {
|
||||
inst.expect(4)?;
|
||||
parse_expr_op!(crate::UnaryOperator::Not, UNARY)?;
|
||||
}
|
||||
Op::BitwiseOr => {
|
||||
inst.expect(5)?;
|
||||
parse_expr_op!(crate::BinaryOperator::InclusiveOr, BINARY)?;
|
||||
}
|
||||
Op::BitwiseXor => {
|
||||
inst.expect(5)?;
|
||||
parse_expr_op!(crate::BinaryOperator::ExclusiveOr, BINARY)?;
|
||||
}
|
||||
Op::BitwiseAnd => {
|
||||
inst.expect(5)?;
|
||||
parse_expr_op!(crate::BinaryOperator::And, BINARY)?;
|
||||
}
|
||||
Op::ShiftRightLogical => {
|
||||
inst.expect(5)?;
|
||||
//TODO: convert input and result to usigned
|
||||
|
||||
Reference in new issue
Block a user