enum AccessTypeAdjustment {
None,
IntroducePointer(StorageClass),
UseStd140CompatType,
}Expand description
How to derive the type of OpAccessChain instructions from Naga IR.
Most of the time, we compile Naga IR to SPIR-V instructions whose result types are simply the direct SPIR-V analog of the Naga IR’s. But in some cases, the Naga IR and SPIR-V types need to diverge.
This enum specifies how BlockContext::write_access_chain should
choose a SPIR-V result type for the OpAccessChain it generates, based on
the type of the given Naga IR Expression it’s generating code for.
Variants§
None
No adjustment needed: the SPIR-V type should be the direct analog of the Naga IR expression type.
For most access chains, this is the right thing: the Naga IR access
expression produces a Pointer to the element / component, and the
SPIR-V OpAccessChain instruction does the same.
IntroducePointer(StorageClass)
The SPIR-V type should be an OpPointer to the direct analog of the
Naga IR expression’s type.
This is necessary for indexing binding arrays in the Handle address
space:
-
In Naga IR, referencing a binding array
GlobalVariablein theHandleaddress space produces a value of typeBindingArray, not a pointer to such. AndAccessandAccessIndexexpressions operate on handle binding arrays by value, and produce handle values, not pointers. -
In SPIR-V, a binding array
OpVariableproduces a pointer to an array, andOpAccessChaininstructions operate on pointers, regardless of whether the elements are opaque types or not.
See also the documentation for BindingArray.
UseStd140CompatType
The SPIR-V type should be an OpPointer to the std140 layout
compatible variant of the Naga IR expression’s base type.
This is used when accessing a type through an AddressSpace::Uniform
pointer in cases where the original type is incompatible with std140
layout requirements and we have therefore declared the uniform to be of
an alternative std140 compliant type.
Trait Implementations§
Source§impl Clone for AccessTypeAdjustment
impl Clone for AccessTypeAdjustment
Source§fn clone(&self) -> AccessTypeAdjustment
fn clone(&self) -> AccessTypeAdjustment
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more