microsoft / microsoft/DirectXShaderCompiler

[Feature Request] [SPIR-V] Allow more than one push constant struct in Library shaders

Open
#8,019 6 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

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, 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

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.

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.