Introduce qptr
("quasi-pointer") type and associated lower->analyze->lift passes.
#24
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
qptr
is the first major SPIR-T feature/departure from SPIR-V, and represents a vision for memory/pointers:q
uasi-p
oint
er
" (alternatively, "q
uantum"), in the sense of "not quite (a pointer)"ptr
s)ptr
sGeneric
physical pointers (but more flexible and without runtime behavior)qptr
can replace Rust-GPU's "Storage Class" inference pass)VariablePointers
)VariablePointers
) can't be stored to memory, returned from functions or passed throughOpPhi
s, each "logical pointer" is strictly a static alias of some variable, with a maybe-dynamic offsetqptr.offset
nodes, andqptr.load
/qptr.store
leaves), and all such "trees" are disjoint between pointer definitions - such a "tree"-like structure can be seen reified in theqptr.usage
attribute (produced byqptr::analyze
)T addrspace(AS)*
pointer types (via OpenCL SPIR)int2ptr
casts, loads of physical pointers etc. - not implemented yet)QPtrOp
- shown asqptr.*
below)qptr::lower
: SPIR-VOpTypePointer
types/instructions are lowered toqptr
andqptr.*
opsOpAccessChain
s on composite types become pointer arithmetic (erasing those types)qptr
operations directly)qptr::analyze
:qptr
uses are analyzed to generateqptr.usage
attributesunion
-like uses that were illegal in the SPIR-V input ofqptr::lower
- Rust-GPU could use this to support many more shapes ofenum
s)qptr::lift
:qptr.*
ops are lifted back to SPIR-VOpTypePointer
types/instructionsqptr.usage
attributes are used to generate pointee types that support all (transitive) usesqptr::lower
- Rust-GPU could use this to replace its "Storage Class" inference pass)qptr
s can point to either:qptr.handle_array_index
to select a single handle (i.e. "descriptor indexing")qptr.buffer_data
to obtain aqptr
to the memory contentsOpImageTexelPointer
in SPIR-V, on a pointer to anOpTypeImage
)qptr.buffer_dyn_len
can query the size of dynamically-sized buffers (replacingOpArrayLength
)Block
-decoratedOpTypeStruct
s in specific "Storage Class"es (Uniform
,StorageBuffer
,ShaderRecordBufferKHR
) to encode buffers "syntactically" (i.e. mimicking their GLSL declaration syntax)qptr.offset
andqptr.dyn_offset
OpAccessChain
)qptr.dyn_offset
includes an immediate stride (in the extreme this could be generalized to a kind of "integer dot product", if N-dimensional arrays ever require it)qptr.load
/qptr.store
Example (
qptr
passes onkajiya
'sassets/shaders/wrc/wrc_see_through.rgen.hlsl
):(type information like
OpMemberName
can be seen to be erased, and only used offsets are recreated)(
qptr.*
ops can be seen as blue against the backdrop of orangespv.*
ops, thanks to #21)FIXME(@eddyb): move/copy some of this description into the library documentation (maybe a design document?)