enum AccessTypeAdjustment {
None,
IntroducePointer(StorageClass),
}
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_expression_pointer
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
GlobalVariable
in theHandle
address space produces a value of typeBindingArray
, not a pointer to such. AndAccess
andAccessIndex
expressions operate on handle binding arrays by value, and produce handle values, not pointers. -
In SPIR-V, a binding array
OpVariable
produces a pointer to an array, andOpAccessChain
instructions operate on pointers, regardless of whether the elements are opaque types or not.
See also the documentation for BindingArray
.