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 LocalType
s 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
Pointer
Image(LocalImageType)
SampledImage
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.
BindingArray
AccelerationStructure
RayQuery
Implementations§
Trait Implementations§
source§impl From<LocalType> for LookupType
impl From<LocalType> for LookupType
impl Copy for LocalType
impl Eq for LocalType
impl StructuralPartialEq for LocalType
Auto Trait Implementations§
impl Freeze for LocalType
impl RefUnwindSafe for LocalType
impl Send for LocalType
impl Sync for LocalType
impl Unpin for LocalType
impl UnwindSafe for LocalType
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
source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key
and return true
if they are equal.