Enum naga::BinaryOperator
source · pub enum BinaryOperator {
Show 18 variants
Add,
Subtract,
Multiply,
Divide,
Modulo,
Equal,
NotEqual,
Less,
LessEqual,
Greater,
GreaterEqual,
And,
ExclusiveOr,
InclusiveOr,
LogicalAnd,
LogicalOr,
ShiftLeft,
ShiftRight,
}Expand description
Operation that can be applied on two values.
Arithmetic type rules
The arithmetic operations Add, Subtract, Multiply, Divide, and
Modulo can all be applied to Scalar types other than Bool, or
Vectors thereof. Both operands must have the same type.
Add and Subtract can also be applied to Matrix values. Both operands
must have the same type.
Multiply supports additional cases:
-
A
MatrixorVectorcan be multiplied by a scalarFloat, either on the left or the right. -
A
Matrixon the left can be multiplied by aVectoron the right if the matrix has as many columns as the vector has components (`matCxR- VecC`).
-
A
Vectoron the left can be multiplied by aMatrixon the right if the matrix has as many rows as the vector has components (VecR * matCxR). -
Two matrices can be multiplied if the left operand has as many columns as the right operand has rows (
matNxR * matCxN).
In all the above Multiply cases, the byte widths of the underlying scalar
types of both operands must be the same.
Note that Multiply supports mixed vector and scalar operations directly,
whereas the other arithmetic operations require an explicit Splat for
mixed-type use.
Variants§
Add
Subtract
Multiply
Divide
Modulo
Equivalent of the WGSL’s % operator or SPIR-V’s OpFRem
Equal
NotEqual
Less
LessEqual
Greater
GreaterEqual
And
ExclusiveOr
InclusiveOr
LogicalAnd
LogicalOr
ShiftLeft
ShiftRight
Right shift carries the sign of signed integers only.
Trait Implementations§
source§impl Clone for BinaryOperator
impl Clone for BinaryOperator
source§fn clone(&self) -> BinaryOperator
fn clone(&self) -> BinaryOperator
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moresource§impl Debug for BinaryOperator
impl Debug for BinaryOperator
source§impl Hash for BinaryOperator
impl Hash for BinaryOperator
source§impl Ord for BinaryOperator
impl Ord for BinaryOperator
source§fn cmp(&self, other: &BinaryOperator) -> Ordering
fn cmp(&self, other: &BinaryOperator) -> Ordering
1.21.0 · source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
source§impl PartialEq for BinaryOperator
impl PartialEq for BinaryOperator
source§fn eq(&self, other: &BinaryOperator) -> bool
fn eq(&self, other: &BinaryOperator) -> bool
self and other values to be equal, and is used
by ==.source§impl PartialOrd for BinaryOperator
impl PartialOrd for BinaryOperator
source§fn partial_cmp(&self, other: &BinaryOperator) -> Option<Ordering>
fn partial_cmp(&self, other: &BinaryOperator) -> Option<Ordering>
1.0.0 · source§fn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
self and other) and is used by the <=
operator. Read moreimpl Copy for BinaryOperator
impl Eq for BinaryOperator
impl StructuralEq for BinaryOperator
impl StructuralPartialEq for BinaryOperator
Auto Trait Implementations§
impl RefUnwindSafe for BinaryOperator
impl Send for BinaryOperator
impl Sync for BinaryOperator
impl Unpin for BinaryOperator
impl UnwindSafe for BinaryOperator
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.