microsoft / microsoft/DirectXShaderCompiler
[Feature Request] A way to obtain/symbolically substitute a Type with its SPIR-V OpType ResultID in Inline Intrinsics
Nobody has claimed this yet.
- Dominant language
- C++
- Stars
- 3.7k
- Forks
- 900
- Avg merge
- 2d 11h
- Merged PRs (30d)
- 44
Description
Is your feature request related to a problem? Please describe.
I'm trying to use VK_KHR_shader_untyped_pointers with HLSL's Inline SPIR-V, but I've hit a roadblock
template<uint32_t StorageClass>
//[[vk::ext_extension("SPV_KHR_untyped_pointers")]] https://github.com/microsoft/DirectXShaderCompiler/issues/6958
//[[vk::ext_capability(spv::CapabilityUntypedPointersKHR)]] https://github.com/microsoft/DirectXShaderCompiler/issues/6958
using pointer_t = vk::SpirvOpaqueType<spv::OpTypeUntypedPointerKHR,vk::Literal<vk::integral_constant<uint32_t,StorageClass> > >;
template<uint32_t StorageClass>
[[vk::ext_extension("SPV_KHR_untyped_pointers")]]
[[vk::ext_capability(spv::CapabilityUntypedPointersKHR)]]
[[vk::ext_instruction(spv::OpUntypedVariableKHR)]]
pointer_t<StorageClass> untypedVariable([[vk::ext_literal]] uint32_t __storageClass=StorageClass/*, can't do DataType because there's no TypeID for vk::SpirvType, can't do initialize cause it comes after*/);
The problem is that I need to use OpUntypedVariable to declare (alloca) a variable, but it has the following SPIR-V signature
While the Inline SPIR-V can deduce the type of the return variable, and substitute it as the second operand (first in disassembled SPIR-V), there's no way for me to even symbolically plug even the ResultID of a given vk::SpirvType into the intrinsic (yes I know a regular T will be ambiguous because of layouts, but my own declared SpirvTypes are unambiguous).
Describe the solution you'd like
Syntax, maybe like this
vk::Spirv[Opaque]Type<...>::type_id
to get something like a vk::type_info opaque struct which can symbolically represent my custom type.
Describe alternatives you've considered
Extra template parameters for the intrinsic, but then its unclear what argument is meant to be passed as an actual custom SPIR-V value and the ResultID of the type.
Additional context
I think I've filed an issue for this before with a different motication, but can't find anything with a quick search.
Godbolt with my experiment : https://godbolt.org/z/benq3PW36
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reproducing the Inline SPIR-V experiment in the linked Godbolt example, then read the existing vk::SpirvOpaqueType and vk::ext_instruction usage shown in the issue. The change should provide a syntax for obtaining a custom SPIR-V type's ResultID and passing it symbolically to the intrinsic while preserving the intended OpUntypedVariableKHR operands.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp
- Domain
- compilers
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 25/100