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 or BufferBlock decoration, and

  • laid out explicitly using the Offset, ArrayStride, and MatrixStride 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§

source§

impl GlobalVariable

source

const fn dummy() -> Self

source

const fn new(id: Word) -> Self

source

fn reset_for_function(&mut self)

Prepare self for use within a single function.

Trait Implementations§

source§

impl Clone for GlobalVariable

source§

fn clone(&self) -> GlobalVariable

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

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