microsoft / microsoft/DirectXShaderCompiler
[Feature Request] [SPIR-V] Allow more than one push constant struct in Library shaders
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.
In SPIR-V, we actually are able to have more than one push constant struct in a shader with multiple entrypoints. See: https://godbolt.org/z/ovj17dKro.
This is currently not possible when compiling SPIR-V using DXC. We get the error error: cannot have more than one push constant block. See: https://godbolt.org/z/69GW8KdfW
Describe the solution you'd like
Ideally, to be able to include two push constant structs and have the unused stuff be optimized out later on. Like in the second godbolt sample.
[[vk::push_constant]] PC0 pc0;
[numthreads(1,1,1)]
[shader("compute")]
void main0()
{
// use only pc0 here
}
[[vk::push_constant]] PC1 pc1;
[numthreads(1,1,1)]
[shader("compute")]
void main1()
{
// use only pc1 here
}
Describe alternatives you've considered
Current workaround is to put the two push constant structs in one big one and update with push constant offsets.
However, that comes with its own limitations.
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 single-push-constant and multiple-push-constant cases in the two linked Godbolt samples, confirming the current DXC error. Trace how DXC handles [[vk::push_constant]] declarations across shader entrypoints. Done means separate push constant structs compile successfully and unused data can be optimized out as described.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp
- Domain
- compilers
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 48/100