Skip to content

Conversation

@Keenuts
Copy link
Collaborator

@Keenuts Keenuts commented Nov 6, 2025

Adds proposal to implement VK push constant support in Clang.

E2E implementation draft: llvm/llvm-project#166793

Adds proposal to implement VK push constant support in Clang.
@Keenuts Keenuts requested a review from s-perron November 6, 2025 16:20
- There can only be one ``[[vk::push_constant]]`` attribute in the shader.
- There can be no VLA in the struct type (or a nested struct type).

DXC allows any storage class to be attached to a push constant. I believe
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good call. Please list which storage classes are currently accepted by DXC, that will not be supported in Clang.
We should update DXC to match 202X?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Keywords DXC accepts are:

  • extern
  • static
  • groupshared
  • shared
  • uniform

Seems like [const] [extern] uniform is the good class, but [const] auto/none should be allowed as the attributes implies const extern uniform already.

Comment on lines +64 to +69
This being a Vulkan specific feature, the attribute is ignored when targeting
DXIL. This means the push constant global becomes part of the cbuffer when
building for DXIL.

The attribute being ignored, the variable belong to the cbuffer, meaning no
additional handling is required.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I still don't fully understand all of the requirements for HLSL attributes in SEMA. For the resource work @hekota mentioned that for the clang based tools like the rewriter, the attributes will have to be in the AST.

Can you be more explicit about where and how it will be ignored?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The AST will have the HLSLVkPushConstant attribute since parsing will see it. But in Sema, this attribute will be ignored, meaning we won't change the current behavior which is to put a global in the global cbuffer.

Comment on lines +77 to +78
Codegen will be left almost as-is as we simply load a variable in a different
address space.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you be more explicit about what the layout of the struct should be? I believe it is the same as a RWStructuredBuffer.

The DXC SPIR-V documentation does not mention it.

The rules in the Vulkan documentation give the same layout rules for push constant as storage buffers.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants