Type

Enum Type 

Source
pub enum Type {
Show 22 variants Bool, AbstractInt, AbstractFloat, I32, U32, F32, F16, Struct(Box<StructType>), Array(Box<Type>, Option<usize>), Vec(u8, Box<Type>), Mat(u8, u8, Box<Type>), Atomic(Box<Type>), Ptr(AddressSpace, Box<Type>, AccessMode), Ref(AddressSpace, Box<Type>, AccessMode), Texture(TextureType), Sampler(SamplerType), I64, U64, F64, BindingArray(Box<Type>, Option<usize>), RayQuery(Option<AccelerationStructureFlags>), AccelerationStructure(Option<AccelerationStructureFlags>),
}
Expand description

WGSL type.

Variants§

§

Bool

§

AbstractInt

§

AbstractFloat

§

I32

§

U32

§

F32

§

F16

§

Struct(Box<StructType>)

§

Array(Box<Type>, Option<usize>)

§

Vec(u8, Box<Type>)

§

Mat(u8, u8, Box<Type>)

§

Atomic(Box<Type>)

§

Ptr(AddressSpace, Box<Type>, AccessMode)

§

Ref(AddressSpace, Box<Type>, AccessMode)

§

Texture(TextureType)

§

Sampler(SamplerType)

§

I64

Available on crate feature naga-ext only.
§

U64

Available on crate feature naga-ext only.
§

F64

Available on crate feature naga-ext only.
§

BindingArray(Box<Type>, Option<usize>)

Available on crate feature naga-ext only.
§

RayQuery(Option<AccelerationStructureFlags>)

Available on crate feature naga-ext only.
§

AccelerationStructure(Option<AccelerationStructureFlags>)

Available on crate feature naga-ext only.

Implementations§

Source§

impl Type

Source

pub fn size_of(&self) -> Option<u32>

Compute the size of the type.

Return None if the type is not host-shareable, or if it contains a runtime-sized array. See Type::min_size_of for runtime-sized arrays.

Reference: https://www.w3.org/TR/WGSL/#alignment-and-size

Source

pub fn min_size_of(&self) -> Option<u32>

Variant of Type::size_of, but for runtime-sized arrays, it returns the minimum size of the array, i.e. the size of an array with one element.

Source

pub fn align_of(&self) -> Option<u32>

Compute the alignment of the type.

Return None if the type is not host-shareable.

Reference: https://www.w3.org/TR/WGSL/#alignment-and-size

Source§

impl Type

Source

pub fn op_not(&self) -> Result<Self, Error>

Source

pub fn op_or(&self, rhs: &Type) -> Result<Self, Error>

Source

pub fn op_and(&self, rhs: &Type) -> Result<Self, Error>

Source§

impl Type

Source

pub fn op_neg(&self) -> Result<Self, Error>

Valid operands:

  • -S, S: scalar
Source

pub fn op_add(&self, rhs: &Type) -> Result<Self, Error>

Valid operands:

  • T + T, T: scalar or vec
  • S + V or V + S, S: scalar, V: vec<S>
  • M + M, M: mat
Source

pub fn op_sub(&self, rhs: &Type) -> Result<Self, Error>

Valid operands:

  • T - T, T: scalar or vec
  • S - V or V - S, S: scalar, V: vec<S>
  • M - M, M: mat
Source

pub fn op_mul(&self, rhs: &Type) -> Result<Self, Error>

Valid operands:

  • T * T, T: scalar or vec
  • S * V or V * S, S: scalar, V: vec<S>
  • S * M or M * S, S: float, M: mat<S>
  • V * M or M * V, S: float, V: vec<S>, M: mat<S>
  • M1 * M1, M1: matKxR, M2: matCxK
Source

pub fn op_div(&self, rhs: &Type) -> Result<Self, Error>

Valid operands:

  • T / T, T: scalar or vec
  • S / V or V / S, S: scalar, V: vec<S>
Source

pub fn op_rem(&self, rhs: &Type) -> Result<Self, Error>

Valid operands:

  • T % T, T: scalar or vec
  • S % V or V % S, S: scalar, V: vec<S>
Source§

impl Type

Source

pub fn op_eq(&self, rhs: &Type) -> Result<Type, Error>

Valid operands:

  • T == T, T: scalar or vec
Source

pub fn op_ne(&self, rhs: &Type) -> Result<Type, Error>

Valid operands:

  • T != T, T: scalar or vec
Source

pub fn op_lt(&self, rhs: &Type) -> Result<Type, Error>

Valid operands:

  • T < T, T: scalar or vec
Source

pub fn op_le(&self, rhs: &Type) -> Result<Type, Error>

Valid operands:

  • T <= T, T: scalar or vec
Source

pub fn op_gt(&self, rhs: &Type) -> Result<Type, Error>

Valid operands:

  • T > T, T: scalar or vec
Source

pub fn op_ge(&self, rhs: &Type) -> Result<Type, Error>

Valid operands:

  • T >= T, T: scalar or vec
Source§

impl Type

Source

pub fn op_bitnot(&self) -> Result<Type, Error>

Valid operands:

  • ~T, I: integer, T: I or vec<I>
Source

pub fn op_bitor(&self, rhs: &Type) -> Result<Type, Error>

Note: this is both the “bitwise OR” and “logical OR” operator.

Valid operands:

  • T | T, T: integer, or vec<integer> (bitwise OR)
  • V | V, V: vec<bool> (logical OR)
Source

pub fn op_bitand(&self, rhs: &Type) -> Result<Type, Error>

Note: this is both the “bitwise AND” and “logical AND” operator.

Valid operands:

  • T & T, T: integer or vec<integer> (bitwise AND)
  • V & V, V: vec<bool> (logical AND)
Source

pub fn op_bitxor(&self, rhs: &Type) -> Result<Type, Error>

Valid operands:

  • T ^ T, T: integer or vec<integer>
Source

pub fn op_shl(&self, rhs: &Type) -> Result<Type, Error>

Valid operands:

  • integer << u32
  • vec<integer> << vec<u32>
Source

pub fn op_shr(&self, rhs: &Type) -> Result<Type, Error>

Valid operands:

  • integer >> u32
  • vec<integer> >> vec<u32>
Source§

impl Type

Source

pub fn op_ref(&self) -> Result<Type, Error>

Source

pub fn op_deref(&self) -> Result<Type, Error>

Source§

impl Type

Source

pub fn is_convertible_to(&self, ty: &Type) -> bool

Source

pub fn concretize(&self) -> Self

Source

pub fn loaded(self) -> Self

Apply the load rule.

Reference: https://www.w3.org/TR/WGSL/#load-rule

Source§

impl Type

Source

pub fn is_scalar(&self) -> bool

Source

pub fn is_numeric(&self) -> bool

Source

pub fn is_integer(&self) -> bool

Source

pub fn is_float(&self) -> bool

Source

pub fn is_abstract(&self) -> bool

Source

pub fn is_concrete(&self) -> bool

Source

pub fn is_storable(&self) -> bool

Source

pub fn is_array(&self) -> bool

Source

pub fn is_vec(&self) -> bool

Source

pub fn is_i32(&self) -> bool

Source

pub fn is_u32(&self) -> bool

Source

pub fn is_f32(&self) -> bool

Source

pub fn is_i64(&self) -> bool

Available on crate feature naga-ext only.
Source

pub fn is_u64(&self) -> bool

Available on crate feature naga-ext only.
Source

pub fn is_f64(&self) -> bool

Available on crate feature naga-ext only.
Source

pub fn is_bool(&self) -> bool

Source

pub fn is_mat(&self) -> bool

Source

pub fn is_abstract_int(&self) -> bool

Source

pub fn unwrap_atomic(self) -> Box<Type>

Source

pub fn unwrap_struct(self) -> Box<StructType>

Source

pub fn unwrap_vec(self) -> (u8, Box<Type>)

Trait Implementations§

Source§

impl Clone for Type

Source§

fn clone(&self) -> Type

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Convert for Type

Source§

fn convert_to(&self, ty: &Type) -> Option<Self>

Convert an instance to another type, if a feasible conversion exists. Read more
Source§

fn convert_inner_to(&self, ty: &Type) -> Option<Self>

Convert an instance by changing its inner type to another. Read more
Source§

fn concretize(&self) -> Option<Self>

Convert an abstract instance to a concrete type. Read more
Source§

impl Debug for Type

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Display for Type

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl From<SampledType> for Type

Source§

fn from(value: SampledType) -> Self

Converts to this type from the input type.
Source§

impl From<StructType> for Type

Source§

fn from(value: StructType) -> Self

Converts to this type from the input type.
Source§

impl From<Type> for Instance

Source§

fn from(value: Type) -> Self

Converts to this type from the input type.
Source§

impl PartialEq for Type

Source§

fn eq(&self, other: &Type) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl TryFrom<&Type> for SampledType

Source§

type Error = Error

The type returned in the event of a conversion error.
Source§

fn try_from(value: &Type) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl Ty for Type

Source§

fn ty(&self) -> Type

get the type of an instance.
Source§

fn inner_ty(&self) -> Type

get the inner type of an instance (not recursive). Read more
Source§

impl Eq for Type

Source§

impl StructuralPartialEq for Type

Auto Trait Implementations§

§

impl Freeze for Type

§

impl RefUnwindSafe for Type

§

impl Send for Type

§

impl Sync for Type

§

impl Unpin for Type

§

impl UnwindSafe for Type

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.