pub enum TypeInner {
Show 13 variants Scalar(Scalar), Vector { size: VectorSize, scalar: Scalar, }, Matrix { columns: VectorSize, rows: VectorSize, scalar: Scalar, }, Atomic(Scalar), Pointer { base: Handle<Type>, space: AddressSpace, }, ValuePointer { size: Option<VectorSize>, scalar: Scalar, space: AddressSpace, }, Array { base: Handle<Type>, size: ArraySize, stride: u32, }, Struct { members: Vec<StructMember>, span: u32, }, Image { dim: ImageDimension, arrayed: bool, class: ImageClass, }, Sampler { comparison: bool, }, AccelerationStructure, RayQuery, BindingArray { base: Handle<Type>, size: ArraySize, },
}
Available on crate feature wgpu only.
Expand description

Enum with additional information, depending on the kind of type.

Variants§

§

Scalar(Scalar)

Number of integral or floating-point kind.

§

Vector

Fields

§scalar: Scalar

Vector of numbers.

§

Matrix

Fields

§columns: VectorSize
§scalar: Scalar

Matrix of numbers.

§

Atomic(Scalar)

Atomic scalar.

§

Pointer

Fields

§base: Handle<Type>

Pointer to another type.

Pointers to scalars and vectors should be treated as equivalent to ValuePointer types. Use the TypeInner::equivalent method to compare types in a way that treats pointers correctly.

Pointers to non-SIZED types

The base type of a pointer may be a non-SIZED type like a dynamically-sized Array, or a Struct whose last member is a dynamically sized array. Such pointers occur as the types of GlobalVariable or AccessIndex expressions referring to dynamically-sized arrays.

However, among pointers to non-SIZED types, only pointers to Structs are DATA. Pointers to dynamically sized Arrays cannot be passed as arguments, stored in variables, or held in arrays or structures. Their only use is as the types of AccessIndex expressions.

§

ValuePointer

Fields

§scalar: Scalar

Pointer to a scalar or vector.

A ValuePointer type is equivalent to a Pointer whose base is a Scalar or Vector type. This is for use in TypeResolution::Value variants; see the documentation for TypeResolution for details.

Use the TypeInner::equivalent method to compare types that could be pointers, to ensure that Pointer and ValuePointer types are recognized as equivalent.

§

Array

Fields

§base: Handle<Type>
§stride: u32

Homogenous list of elements.

The base type must be a SIZED, DATA type.

Dynamically sized arrays

An Array is SIZED unless its size is Dynamic. Dynamically-sized arrays may only appear in a few situations:

  • They may appear as the type of a GlobalVariable, or as the last member of a Struct.

  • They may appear as the base type of a Pointer. An AccessIndex expression referring to a struct’s final unsized array member would have such a pointer type. However, such pointer types may only appear as the types of such intermediate expressions. They are not DATA, and cannot be stored in variables, held in arrays or structs, or passed as parameters.

§

Struct

Fields

§span: u32

User-defined structure.

There must always be at least one member.

A Struct type is DATA, and the types of its members must be DATA as well.

Member types must be SIZED, except for the final member of a struct, which may be a dynamically sized Array. The Struct type itself is SIZED when all its members are SIZED.

§

Image

Fields

§arrayed: bool

Possibly multidimensional array of texels.

§

Sampler

Fields

§comparison: bool

Can be used to sample values from images.

§

AccelerationStructure

Opaque object representing an acceleration structure of geometry.

§

RayQuery

Locally used handle for ray queries.

§

BindingArray

Fields

§base: Handle<Type>

Array of bindings.

A BindingArray represents an array where each element draws its value from a separate bound resource. The array’s element type base may be Image, Sampler, or any type that would be permitted for a global in the Uniform or Storage address spaces. Only global variables may be binding arrays; on the host side, their values are provided by TextureViewArray, SamplerArray, or BufferArray bindings.

Since each element comes from a distinct resource, a binding array of images could have images of varying sizes (but not varying dimensions; they must all have the same Image type). Or, a binding array of buffers could have elements that are dynamically sized arrays, each with a different length.

Binding arrays are in the same address spaces as their underlying type. As such, referring to an array of images produces an Image value directly (as opposed to a pointer). The only operation permitted on BindingArray values is indexing, which works transparently: indexing a binding array of samplers yields a Sampler, indexing a pointer to the binding array of storage buffers produces a pointer to the storage struct.

Unlike textures and samplers, binding arrays are not ARGUMENT, so they cannot be passed as arguments to functions.

Naga’s WGSL front end supports binding arrays with the type syntax binding_array<T, N>.

Implementations§

§

impl TypeInner

pub fn to_wgsl(&self, gctx: &GlobalCtx<'_>) -> String

Formats the type as it is written in wgsl.

For example vec3<f32>.

Note: TypeInner::Struct doesn’t include the name of the struct type. Therefore this method will simply return “struct” for them.

§

impl TypeInner

pub fn indexable_length( &self, module: &Module ) -> Result<IndexableLength, IndexableLengthError>

Return the length of a subscriptable type.

The self parameter should be a handle to a vector, matrix, or array type, a pointer to one of those, or a value pointer. Arrays may be fixed-size, dynamically sized, or sized by a specializable constant. This function does not handle struct member references, as with AccessIndex.

The value returned is appropriate for bounds checks on subscripting.

Return an error if self does not describe a subscriptable type at all.

§

impl TypeInner

pub const fn scalar(&self) -> Option<Scalar>

Return the scalar type of self.

If inner is a scalar, vector, or matrix type, return its scalar type. Otherwise, return None.

pub fn scalar_kind(&self) -> Option<ScalarKind>

pub fn scalar_width(&self) -> Option<u8>

pub const fn pointer_space(&self) -> Option<AddressSpace>

pub fn is_atomic_pointer(&self, types: &UniqueArena<Type>) -> bool

pub fn size(&self, _gctx: GlobalCtx<'_>) -> u32

Get the size of this type.

pub fn canonical_form(&self, types: &UniqueArena<Type>) -> Option<TypeInner>

Return the canonical form of self, or None if it’s already in canonical form.

Certain types have multiple representations in TypeInner. This function converts all forms of equivalent types to a single representative of their class, so that simply applying Eq to the result indicates whether the types are equivalent, as far as Naga IR is concerned.

pub fn equivalent(&self, rhs: &TypeInner, types: &UniqueArena<Type>) -> bool

Compare self and rhs as types.

This is mostly the same as <TypeInner as Eq>::eq, but it treats ValuePointer and Pointer types as equivalent.

When you know that one side of the comparison is never a pointer, it’s fine to not bother with canonicalization, and just compare TypeInner values with ==.

pub fn is_dynamically_sized(&self, types: &UniqueArena<Type>) -> bool

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

pub fn component_type(&self, index: usize) -> Option<TypeResolution>

Trait Implementations§

§

impl Clone for TypeInner

§

fn clone(&self) -> TypeInner

Returns a copy of the value. Read more
1.0.0 · source§

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

Performs copy-assignment from source. Read more
§

impl Debug for TypeInner

§

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

Formats the value using the given formatter. Read more
§

impl Hash for TypeInner

§

fn hash<__H>(&self, state: &mut __H)
where __H: Hasher,

Feeds this value into the given Hasher. Read more
1.3.0 · source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
§

impl PartialEq for TypeInner

§

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

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

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

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

impl Eq for TypeInner

§

impl StructuralEq for TypeInner

§

impl StructuralPartialEq for TypeInner

Auto Trait Implementations§

Blanket Implementations§

source§

impl<S, D, Swp, Dwp, T> AdaptInto<D, Swp, Dwp, T> for S
where T: Real + Zero + Arithmetics + Clone, Swp: WhitePoint<T>, Dwp: WhitePoint<T>, D: AdaptFrom<S, Swp, Dwp, T>,

source§

fn adapt_into_using<M>(self, method: M) -> D
where M: TransformMatrix<T>,

Convert the source color to the destination color using the specified method.
source§

fn adapt_into(self) -> D

Convert the source color to the destination color using the bradford method by default.
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, C> ArraysFrom<C> for T
where C: IntoArrays<T>,

source§

fn arrays_from(colors: C) -> T

Cast a collection of colors into a collection of arrays.
source§

impl<T, C> ArraysInto<C> for T
where C: FromArrays<T>,

source§

fn arrays_into(self) -> C

Cast this collection of arrays into a collection of colors.
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
§

impl<T> CallHasher for T
where T: Hash + ?Sized,

§

default fn get_hash<H, B>(value: &H, build_hasher: &B) -> u64
where H: Hash + ?Sized, B: BuildHasher,

source§

impl<WpParam, T, U> Cam16IntoUnclamped<WpParam, T> for U
where T: FromCam16Unclamped<WpParam, U>,

§

type Scalar = <T as FromCam16Unclamped<WpParam, U>>::Scalar

The number type that’s used in parameters when converting.
source§

fn cam16_into_unclamped( self, parameters: BakedParameters<WpParam, <U as Cam16IntoUnclamped<WpParam, T>>::Scalar> ) -> T

Converts self into C, using the provided parameters.
source§

impl<T, C> ComponentsFrom<C> for T
where C: IntoComponents<T>,

source§

fn components_from(colors: C) -> T

Cast a collection of colors into a collection of color components.
§

impl<T> Downcast<T> for T

§

fn downcast(&self) -> &T

§

impl<T> Downcast for T
where T: Any,

§

fn into_any(self: Box<T>) -> Box<dyn Any>

Convert Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.
§

fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>

Convert Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be further downcast into Rc<ConcreteType> where ConcreteType implements Trait.
§

fn as_any(&self) -> &(dyn Any + 'static)

Convert &Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &Any’s vtable from &Trait’s.
§

fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)

Convert &mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &mut Any’s vtable from &mut Trait’s.
§

impl<T> DowncastSync for T
where T: Any + Send + Sync,

§

fn into_any_arc(self: Arc<T>) -> Arc<dyn Any + Send + Sync>

Convert Arc<Trait> (where Trait: Downcast) to Arc<Any>. Arc<Any> can then be further downcast into Arc<ConcreteType> where ConcreteType implements Trait.
§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T> FromAngle<T> for T

source§

fn from_angle(angle: T) -> T

Performs a conversion from angle.
source§

impl<T, U> FromStimulus<U> for T
where U: IntoStimulus<T>,

source§

fn from_stimulus(other: U) -> T

Converts other into Self, while performing the appropriate scaling, rounding and clamping.
§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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, U> IntoAngle<U> for T
where U: FromAngle<T>,

source§

fn into_angle(self) -> U

Performs a conversion into T.
source§

impl<WpParam, T, U> IntoCam16Unclamped<WpParam, T> for U
where T: Cam16FromUnclamped<WpParam, U>,

§

type Scalar = <T as Cam16FromUnclamped<WpParam, U>>::Scalar

The number type that’s used in parameters when converting.
source§

fn into_cam16_unclamped( self, parameters: BakedParameters<WpParam, <U as IntoCam16Unclamped<WpParam, T>>::Scalar> ) -> T

Converts self into C, using the provided parameters.
source§

impl<T, U> IntoColor<U> for T
where U: FromColor<T>,

source§

fn into_color(self) -> U

Convert into T with values clamped to the color defined bounds Read more
source§

impl<T, U> IntoColorUnclamped<U> for T
where U: FromColorUnclamped<T>,

source§

fn into_color_unclamped(self) -> U

Convert into T. The resulting color might be invalid in its color space Read more
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> IntoStimulus<T> for T

source§

fn into_stimulus(self) -> T

Converts self into T, while performing the appropriate scaling, rounding and clamping.
§

impl<T> Pointable for T

§

const ALIGN: usize = _

The alignment of pointer.
§

type Init = T

The type for initializers.
§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
source§

impl<T> Same for T

§

type Output = T

Should always be Self
source§

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

§

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, C> TryComponentsInto<C> for T
where C: TryFromComponents<T>,

§

type Error = <C as TryFromComponents<T>>::Error

The error for when try_into_colors fails to cast.
source§

fn try_components_into(self) -> Result<C, <T as TryComponentsInto<C>>::Error>

Try to cast this collection of color components into a collection of colors. Read more
source§

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

§

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>,

§

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.
source§

impl<T, U> TryIntoColor<U> for T
where U: TryFromColor<T>,

source§

fn try_into_color(self) -> Result<U, OutOfBounds<U>>

Convert into T, returning ok if the color is inside of its defined range, otherwise an OutOfBounds error is returned which contains the unclamped color. Read more
source§

impl<C, U> UintsFrom<C> for U
where C: IntoUints<U>,

source§

fn uints_from(colors: C) -> U

Cast a collection of colors into a collection of unsigned integers.
source§

impl<C, U> UintsInto<C> for U
where C: FromUints<U>,

source§

fn uints_into(self) -> C

Cast this collection of unsigned integers into a collection of colors.
§

impl<T> Upcast<T> for T

§

fn upcast(&self) -> Option<&T>

§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V

§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more
source§

impl<T> MaybeSend for T
where T: Send,

source§

impl<T> MaybeSync for T
where T: Sync,

§

impl<T> WasmNotSend for T
where T: Send,

§

impl<T> WasmNotSendSync for T

§

impl<T> WasmNotSync for T
where T: Sync,