#[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.
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,
pub fn set_0(&mut self, value: Scalar<T>)
Source§impl Scalar<f32>
impl Scalar<f32>
Sourcepub fn distance(self, rhs: Self) -> Scalar<f32>
pub fn distance(self, rhs: Self) -> Scalar<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().
Sourcepub fn smoothstep(self, edge0: Self, edge1: Self) -> Self
pub fn smoothstep(self, edge0: Self, edge1: Self) -> Self
As per WGSL smoothstep(),
but the third parameter called x is moved to be the self parameter.
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) -> Scalar<f64>
pub fn distance(self, rhs: Self) -> Scalar<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().
Sourcepub fn smoothstep(self, edge0: Self, edge1: Self) -> Self
pub fn smoothstep(self, edge0: Self, edge1: Self) -> Self
As per WGSL smoothstep(),
but the third parameter called x is moved to be the self parameter.
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 Scalar<bool>
impl Scalar<bool>
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>
Source§impl<T> Scalar<T>
impl<T> Scalar<T>
Sourcepub fn into_inner(self) -> T
pub fn into_inner(self) -> T
Currently equivalent to self.0 but can be used as a more strongly typed operation.