Enum naga::back::spv::LocalType

source ·
enum LocalType {
    Numeric(NumericType),
    LocalPointer {
        base: NumericType,
        class: StorageClass,
    },
    Pointer {
        base: Handle<Type>,
        class: StorageClass,
    },
    Image(LocalImageType),
    SampledImage {
        image_type_id: Word,
    },
    Sampler,
    PointerToBindingArray {
        base: Handle<Type>,
        size: u32,
        space: AddressSpace,
    },
    BindingArray {
        base: Handle<Type>,
        size: u32,
    },
    AccelerationStructure,
    RayQuery,
}
Expand description

A SPIR-V type constructed during code generation.

This is the variant of LookupType used to represent types that might not be available in the arena. Variants are present here for one of two reasons:

  • They represent types synthesized during code generation, as explained in the documentation for LookupType.

  • They represent types for which SPIR-V forbids duplicate OpType... instructions, requiring deduplication.

This is not a complete copy of TypeInner: for example, SPIR-V generation never synthesizes new struct types, so LocalType has nothing for that.

Each LocalType variant should be handled identically to its analogous TypeInner variant. You can use the LocalType::from_inner function to help with this, by converting everything possible to a LocalType before inspecting it.

§LocalType equality and SPIR-V OpType uniqueness

The definition of Eq on LocalType is carefully chosen to help us follow certain SPIR-V rules. SPIR-V §2.8 requires some classes of OpType... instructions to be unique; for example, you can’t have two OpTypeInt 32 1 instructions in the same module. All 32-bit signed integers must use the same type id.

All SPIR-V types that must be unique can be represented as a LocalType, and two LocalTypes are always Eq if SPIR-V would require them to use the same OpType... instruction. This lets us avoid duplicates by recording the ids of the type instructions we’ve already generated in a hash table, Writer::lookup_type, keyed by LocalType.

As another example, LocalImageType, stored in the LocalType::Image variant, is designed to help us deduplicate OpTypeImage instructions. See its documentation for details.

LocalType also includes variants like Pointer that do not need to be unique - but it is harmless to avoid the duplication.

As it always must, the Hash implementation respects the Eq relation.

Variants§

§

Numeric(NumericType)

A numeric type.

§

LocalPointer

Fields

§

Pointer

Fields

§base: Handle<Type>
§

Image(LocalImageType)

§

SampledImage

Fields

§image_type_id: Word
§

Sampler

§

PointerToBindingArray

Equivalent to a LocalType::Pointer whose base is a Naga IR BindingArray. SPIR-V permits duplicated OpTypePointer ids, so it’s fine to have two different LocalType representations for pointer types.

Fields

§base: Handle<Type>
§size: u32
§

BindingArray

Fields

§base: Handle<Type>
§size: u32
§

AccelerationStructure

§

RayQuery

Implementations§

Trait Implementations§

source§

impl Clone for LocalType

source§

fn clone(&self) -> LocalType

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

impl Debug for LocalType

source§

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

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

impl From<LocalType> for LookupType

source§

fn from(local: LocalType) -> Self

Converts to this type from the input type.
source§

impl Hash for LocalType

source§

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

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

impl PartialEq for LocalType

source§

fn eq(&self, other: &LocalType) -> 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 Copy for LocalType

source§

impl Eq for LocalType

source§

impl StructuralPartialEq for LocalType

Auto Trait Implementations§

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, dst: *mut T)

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

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

source§

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

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

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

source§

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