Type Alias spirt::qptr::layout::HandleLayout
source · pub(super) type HandleLayout = Handle<Rc<MemTypeLayout>>;
Aliased Type§
enum HandleLayout {
Opaque(Type),
Buffer(AddrSpace, Rc<MemTypeLayout>),
}
Variants§
Opaque(Type)
Fully opaque resources (e.g. samplers, images).
Buffer(AddrSpace, Rc<MemTypeLayout>)
Buffer resources, describing ranges of (technically) untyped memory in
some address space (e.g. Uniform
, StorageBuffer
), but being limited
by SPIR-V logical addressing (unlike e.g. PhysicalStorageBuffer
).
SPIR-V makes this particularly painful, through a couple of design flaws:
- forcing a static type (for the buffer contents) and disallowing any
pointer casts, despite the fact that any plausible representation for
“logical pointer into a buffer” (e.g.
(BufferDescriptor, Offset)
) must be fundamentally untyped (as it must allow access to relatively large amounts of memory, and also support dynamic array indexing), even when not a “GPU memory address” (likePhysicalStorageBuffer
) - encoding the buffer type using a (GLSL-style) “interface block”, where
instead of a special type (or a pointer with the right storage class),
an
OpTypeStruct
(having the statically typed buffer contents as fields) with theBlock
decoration is used, and then this “interface block” type can be further nested inOpTypeArray
orOpTypeRuntimeArray
to allow descriptor indexing - which leads to constructs like a GLSLbuffer { uint data[]; } bufs[];
being encoded with two levels ofOpTypeRuntimeArray
, separated not by any explicit indirection, but only by theBlock
decoration on theOpTypeStruct
forbuffer {...}