#[repr(transparent)]pub struct Scalar<T>(pub T);Expand description
This type wraps an underlying Rust-native scalar (or someday SIMD) type
to provide only methods and operators which are compatible with shader
function behaviors. That is, they act like Vec* even where T might not.
This allows the code generator to not worry as much about mismatches
between Rust and shader semantics.
TODO: This isn’t actually used yet.
Tuple Fields§
§0: TImplementations§
Source§impl<T> Scalar<T>
impl<T> Scalar<T>
pub fn splat(value: T) -> Selfwhere
T: Copy,
pub fn splat_from_scalar(value: Scalar<T>) -> Selfwhere
T: Copy,
Sourcepub const fn select(self, trues: Self, mask: Scalar<bool>) -> Selfwhere
T: Copy,
pub const fn select(self, trues: Self, mask: Scalar<bool>) -> Selfwhere
T: Copy,
Replaces the elements of self with the elements of trues wherever
mask contains true.
pub fn map<U, F>(self, f: F) -> Scalar<U>where
F: FnMut(T) -> U,
Source§impl Scalar<f32>
impl Scalar<f32>
Sourcepub fn distance(self, rhs: Self) -> f32
pub fn distance(self, rhs: Self) -> f32
As per WGSL distance().
Sourcepub fn face_forward(self, e2: Self, e3: Self) -> Self
pub fn face_forward(self, e2: Self, e3: Self) -> Self
As per WGSL faceForward().
Sourcepub fn normalize(self) -> Self
pub fn normalize(self) -> Self
As per WGSL normalize().
Sourcepub const fn saturate(self) -> Self
pub const fn saturate(self) -> Self
As per WGSL saturate().
pub const fn abs(self) -> Self
pub fn acos(self) -> Self
pub fn acosh(self) -> Self
pub fn asin(self) -> Self
pub fn asinh(self) -> Self
pub fn atan(self) -> Self
pub fn atanh(self) -> Self
pub fn ceil(self) -> Self
pub fn cos(self) -> Self
pub fn cosh(self) -> Self
pub fn exp(self) -> Self
pub fn exp2(self) -> Self
pub fn floor(self) -> Self
pub fn fract(self) -> Self
pub fn log2(self) -> Self
pub fn round(self) -> Self
pub fn sin(self) -> Self
pub fn sinh(self) -> Self
pub fn tan(self) -> Self
pub fn tanh(self) -> Self
pub fn trunc(self) -> Self
pub fn to_degrees(self) -> Self
pub fn to_radians(self) -> Self
pub fn atan2(self, rhs: Self) -> Self
pub fn max(self, rhs: Self) -> Self
pub fn min(self, rhs: Self) -> Self
pub fn powf(self, rhs: Self) -> Self
Source§impl Scalar<f64>
impl Scalar<f64>
Sourcepub fn distance(self, rhs: Self) -> f64
pub fn distance(self, rhs: Self) -> f64
As per WGSL distance().
Sourcepub fn face_forward(self, e2: Self, e3: Self) -> Self
pub fn face_forward(self, e2: Self, e3: Self) -> Self
As per WGSL faceForward().
Sourcepub fn normalize(self) -> Self
pub fn normalize(self) -> Self
As per WGSL normalize().
Sourcepub const fn saturate(self) -> Self
pub const fn saturate(self) -> Self
As per WGSL saturate().
pub const fn abs(self) -> Self
pub fn acos(self) -> Self
pub fn acosh(self) -> Self
pub fn asin(self) -> Self
pub fn asinh(self) -> Self
pub fn atan(self) -> Self
pub fn atanh(self) -> Self
pub fn ceil(self) -> Self
pub fn cos(self) -> Self
pub fn cosh(self) -> Self
pub fn exp(self) -> Self
pub fn exp2(self) -> Self
pub fn floor(self) -> Self
pub fn fract(self) -> Self
pub fn log2(self) -> Self
pub fn round(self) -> Self
pub fn sin(self) -> Self
pub fn sinh(self) -> Self
pub fn tan(self) -> Self
pub fn tanh(self) -> Self
pub fn trunc(self) -> Self
pub fn to_degrees(self) -> Self
pub fn to_radians(self) -> Self
pub fn atan2(self, rhs: Self) -> Self
pub fn max(self, rhs: Self) -> Self
pub fn min(self, rhs: Self) -> Self
pub fn powf(self, rhs: Self) -> Self
Source§impl Scalar<i32>
impl Scalar<i32>
pub fn cast_elem_as_u32(self) -> Scalar<u32>
pub fn cast_elem_as_i32(self) -> Scalar<i32>
pub fn cast_elem_as_f32(self) -> Scalar<f32>
pub fn cast_elem_as_f64(self) -> Scalar<f64>
Source§impl Scalar<u32>
impl Scalar<u32>
pub fn cast_elem_as_u32(self) -> Scalar<u32>
pub fn cast_elem_as_i32(self) -> Scalar<i32>
pub fn cast_elem_as_f32(self) -> Scalar<f32>
pub fn cast_elem_as_f64(self) -> Scalar<f64>
Source§impl Scalar<f32>
impl Scalar<f32>
pub fn cast_elem_as_u32(self) -> Scalar<u32>
pub fn cast_elem_as_i32(self) -> Scalar<i32>
pub fn cast_elem_as_f32(self) -> Scalar<f32>
pub fn cast_elem_as_f64(self) -> Scalar<f64>
Source§impl Scalar<f64>
impl Scalar<f64>
pub fn cast_elem_as_u32(self) -> Scalar<u32>
pub fn cast_elem_as_i32(self) -> Scalar<i32>
pub fn cast_elem_as_f32(self) -> Scalar<f32>
pub fn cast_elem_as_f64(self) -> Scalar<f64>
Source§impl<T: PartialOrd> Scalar<T>
impl<T: PartialOrd> Scalar<T>
pub fn elementwise_eq(self, rhs: Self) -> Scalar<bool>
pub fn elementwise_ne(self, rhs: Self) -> Scalar<bool>
pub fn elementwise_lt(self, rhs: Self) -> Scalar<bool>
pub fn elementwise_le(self, rhs: Self) -> Scalar<bool>
pub fn elementwise_gt(self, rhs: Self) -> Scalar<bool>
pub fn elementwise_ge(self, rhs: Self) -> Scalar<bool>
Trait Implementations§
Source§impl<T: PartialOrd> PartialOrd for Scalar<T>
impl<T: PartialOrd> PartialOrd for Scalar<T>
impl<T: Copy> Copy for Scalar<T>
impl<T: Eq> Eq for Scalar<T>
impl<T> StructuralPartialEq for Scalar<T>
Auto Trait Implementations§
impl<T> Freeze for Scalar<T>where
T: Freeze,
impl<T> RefUnwindSafe for Scalar<T>where
T: RefUnwindSafe,
impl<T> Send for Scalar<T>where
T: Send,
impl<T> Sync for Scalar<T>where
T: Sync,
impl<T> Unpin for Scalar<T>where
T: Unpin,
impl<T> UnwindSafe for Scalar<T>where
T: UnwindSafe,
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
Mutably borrows from an owned value. Read more