Struct naga::back::spv::GlobalVariable
source · struct GlobalVariable {
var_id: Word,
handle_id: Word,
access_id: Word,
}
Expand description
The SPIR-V representation of a crate::GlobalVariable
.
In the Vulkan spec 1.3.296, the section Descriptor Set Interface says:
Variables identified with the
Uniform
storage class are used to access transparent buffer backed resources. Such variables must be:
typed as
OpTypeStruct
, or an array of this type,identified with a
Block
orBufferBlock
decoration, andlaid out explicitly using the
Offset
,ArrayStride
, andMatrixStride
decorations as specified in “Offset and Stride Assignment”.
This is followed by identical language for the StorageBuffer
,
except that a BufferBlock
decoration is not allowed.
When we encounter a global variable in the Storage
or Uniform
address spaces whose type is not already Struct
, this backend implicitly
wraps the global variable in a struct: we generate a SPIR-V global variable
holding an OpTypeStruct
with a single member, whose type is what the Naga
global’s type would suggest, decorated as required above.
The helpers::global_needs_wrapper
function determines whether a given
crate::GlobalVariable
needs to be wrapped.
Fields§
§var_id: Word
The SPIR-V id of the OpVariable
that declares the global.
If this global has been implicitly wrapped in an OpTypeStruct
, this id
refers to the wrapper, not the original Naga value it contains. If you
need the Naga value, use access_id
instead of this field.
If this global is not implicitly wrapped, this is the same as
access_id
.
This is used to compute the access_id
pointer in function prologues,
and used for ArrayLength
expressions, which need to pass the wrapper
struct.
handle_id: Word
The loaded value of a AddressSpace::Handle
global variable.
If the current function uses this global variable, this is the id of an
OpLoad
instruction in the function’s prologue that loads its value.
(This value is assigned as we write the prologue code of each function.)
It is then used for all operations on the global, such as OpImageSample
.
access_id: Word
The SPIR-V id of a pointer to this variable’s Naga IR value.
If the current function uses this global variable, and it has been
implicitly wrapped in an OpTypeStruct
, this is the id of an
OpAccessChain
instruction in the function’s prologue that refers to
the wrapped value inside the struct. (This value is assigned as we write
the prologue code of each function.) If you need the wrapper struct
itself, use var_id
instead of this field.
If this global is not implicitly wrapped, this is the same as
var_id
.
Implementations§
Trait Implementations§
source§impl Clone for GlobalVariable
impl Clone for GlobalVariable
source§fn clone(&self) -> GlobalVariable
fn clone(&self) -> GlobalVariable
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read more