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 or vk::SpirvType.
Its not well documented what ext_reference actually turns into but from my experience it seems to be and OpTypePointer to the actual argument invoked.
This makes it problematic to write an intrinsic signature thats supposed to work both with T& and arbitrary vk::SpirvType, for example OpAtomicIAdd .
If you write
template<typename T>
[[vk::ext_instruction]]
T atomicIAdd([[vk::ext_reference]] T ptr, ...memory semantics... , T value);
then it will work on RWStructuredBuffer variables, but won't work on user-defined BDA pointers (or any pointers).
But if you write
template<typename T, typename P>
[[vk::ext_instruction]]
T atomicIAdd(P ptr, ...memory semantics... , T value);
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 like OpDecorate or OpMemberDecorate 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.
[[vk::ext_instruction(%opcode%)]]
%result_type% intrinsicHLSLName(arguments...);
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.
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] Torvk::SpirvType.Its not well documented what
ext_referenceactually turns into but from my experience it seems to be andOpTypePointerto 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::SpirvTypedefined 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
OpTypePointerfor a given variable (basically a hidden&/addrof)Also a way to obtain an
OpTyperesult id, because some instrinsics likeOpDecorateorOpMemberDecorateneed to be fed the type's%result_idas 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.