Skip to content

[Feature Request] [SPIR-V] [Proposal 0011] vk::addrof(v) to obtain an OpTypePointer to a variable and deprecate [vk::ext_reference] #6578

@devshgraphicsprogramming

Description

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementFeature suggestionspirvWork related to SPIR-V

    Type

    No type

    Projects

    Status

    Triaged

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions