-
Notifications
You must be signed in to change notification settings - Fork 9
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Introduce qptr
("quasi-pointer") type and associated lower->analyze->lift passes.
#24
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
eddyb
force-pushed
the
qptr
branch
2 times, most recently
from
March 31, 2023 13:58
2661ecd
to
f30dd2e
Compare
This was referenced Apr 18, 2023
eddyb
added a commit
that referenced
this pull request
Apr 21, 2023
This is an easy way to annotate the IR (anything that supports attributes) with diagnostics that would otherwise have a hard time being reported in a way that correlates with the definition they relate to (without a full-on diagnostic system). Example from an WIP version of #24: ![image](https://user-images.githubusercontent.com/77424/233684908-283697c2-f367-4c84-b0be-be8b5fbf6016.png)
In the interest of releasing Rust-GPU 0.7 today, we'll try to get this merged as-is, and defer further polish. |
oisyn
previously approved these changes
Apr 21, 2023
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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?)