microsoft / microsoft/DirectXShaderCompiler

[Feature Request] [SPIR-V] `vk::ext_decorate` on return types of Inline SPIR-V Intrinsics or functions In general

Open
#8,000 0 comments 0 reactions 1 assignee View on GitHub

@luciechoi is already working on this.

Since Apr 2, 2026.

enhancement
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.

In SPIR-V certain Result IDs (immediate SSA values) can be OpDecorated with very useful things like:

  • Uniform / UniformID , basically the reverse of nonUniformEXT
  • SPV_EXT_float_control2 decorations allow decorating expressions

Describe the solution you'd like

I'd like to do this https://godbolt.org/z/a1xnsnord

template<typename T>
[[vk::ext_instruction(/*spv::OpCopyObject*/83)]]
[[vk::ext_decorate(/*spv::DecorationUniform*/26)]]
T decorateExpression(T v);

which should be enough to decorate things like FMul and so on.

But this is not sufficient

template<typename T>
[[vk::ext_decorate(/*spv::DecorationUniform*/26)]]
T decorateExpression(T v)
{
    return v;
}

because certain decorations need to be applied directly to some SPIR-V instruction like mul,add.

Here's the SPIR-V I'd like to arrive at
https://godbolt.org/z/o6z9f6GYc

Describe alternatives you've considered

Ideally I'd love to be able to just decorate a statement.

However I know that even in latest trunk Clang statements cannot have attributes and thats a future C++ proposal
https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2024/p3093r0.html

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.