naga::common::wgsl::to_wgsl

Function address_space_str

Source
pub const fn address_space_str(
    space: AddressSpace,
) -> (Option<&'static str>, Option<&'static str>)
Expand description

Return the WGSL address space and access mode strings for space.

Why don’t we implement ToWgsl for AddressSpace?

In WGSL, the full form of a pointer type is ptr<AS, T, AM>, where:

  • AS is the address space,
  • T is the store type, and
  • AM is the access mode.

Since the type T intervenes between the address space and the access mode, there isn’t really any individual WGSL grammar production that corresponds to an AddressSpace, so ToWgsl is too simple-minded for this case.

Furthermore, we want to write var<AS[, AM]> for most address spaces, but we want to just write var foo: T for handle types.