-
Notifications
You must be signed in to change notification settings - Fork 694
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
[Feature Request] [SPIR-V] [Proposal 0011] vk::addrof(v)
to obtain an OpTypePointer
to a variable and deprecate [vk::ext_reference]
#6578
Comments
Here's what I tried in the meantime to return me a OpAccessChain with no Indices
OpBitcast with a
|
Requests for new HLSL language features (including Vulkan-specific attributes) now fall under the scope of the microsoft/hlsl-specs repository. Please consider submitting a proposal there instead. |
What are you planning to do about the fact that the apirv types don't deduplicate with the built-inones which makes it impossible to truly use prop 0011? |
I've been thinking about this more. Does something like this work for you: https://godbolt.org/z/xdEMd4bTo. Edit: updated link |
it seems to be on the right track, but I still can't construct my own access chains Edit 1: It also doesn't seem to work on composite structs https://godbolt.org/z/rahE3qvcG |
That happens if you remove -Vd for the scalar case as well. It is a missed optimization. In the inline spir-v is working as intended. If you add -Vd, there is the following dead code that is not removed:
|
Its a shame I need to disable validation to make it work, but thats ok for now. But I still can't construct my own access chains: |
@s-perron your intrinsic had the wrong signature, AtomicAdd returns a variable of type So this actually has some limited usage as a P.S. Still can't construct my own access chains |
@s-perron there's a problem with DXC's SPIR-V codegen, there's no leak analysis it seems and everything gets aggressively optimized with O1, O2 and O3. I cannot take references (SPIR-V pointers) to Example Note that this holds even if I start adding more funny things like conditionals. As long as the compiler wants/can optimize away any expression involving a variable I want to take a reference of, it will, same with loads. Basically the side-effects of assuming all references are restrict. Therefore a real Edit: I'm unsure how DXC works, does the SPIR-V backend always emit "as-if" for O0 and then gets SPIR-V Tools' Opt to do the O1,O2,O3 transforms, or does some of the pre-codegen change with different optimization options? Edit 2: Does SPIR-V assume C++-like strict aliasing that variables pointed to by different pointer types don't alias? I can see that there's obviously a Validation error with the |
P.S. wouldn't OpCopyLogical (opcode 400) codegen valid SPIR-V w.r.t. the rule that OpCopyObject has to copy between identical types? |
Scratch that, this works because I don't need to put a Spir-V type inside a Spir-V type (simple image type, nothing derived thankfully) |
Is your feature request related to a problem? Please describe.
When writing inline SPIR-V intrinsics in HLSL one needs to choose between making an input argument
T
,[vk::ext_reference] T
orvk::SpirvType
.Its not well documented what
ext_reference
actually turns into but from my experience it seems to be andOpTypePointer
to the actual argument invoked.This makes it problematic to write an intrinsic signature thats supposed to work both with
T&
and arbitraryvk::SpirvType
, for exampleOpAtomicIAdd
.If you write
then it will work on RWStructuredBuffer variables, but won't work on user-defined BDA pointers (or any pointers).
But if you write
then it will only work on
vk::SpirvType
defined pointers.Which wouldn't be too bad, except that you can't get a pointer/access-chain to any variable you like.
Describe the solution you'd like
A way to obtain an
OpTypePointer
for a given variable (basically a hidden&
/addrof
)Also a way to obtain an
OpType
result id, because some instrinsics likeOpDecorate
orOpMemberDecorate
need to be fed the type's%result_id
as an argument, its unclear to me how to achieve that with the current mapping of.Describe alternatives you've considered
Just generating an overload, but that makes the compiler confused with ambiguity.
Additional context
Trying to generate all Types and Operations from SPIR-V Headers.
Also implement Prop 0010.
The text was updated successfully, but these errors were encountered: