Skip to content

Rewriter generate consistent bindings #7643

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

Nielsbishere
Copy link
Contributor

@Nielsbishere Nielsbishere commented Jul 16, 2025

This adds functionality to dxr.exe to use -consistent-bindings, which will generate bindings for registers and constant buffers without registers assigned. This is step 1/2 to fix #5105.

The problem is if for example you have 10 textures in an include without a binding but with a space (this is how I implement bindless); it won't actually work, because all shaders respond to it differently because register bindings are generated when the optimized IR is generated (from what I understand). This is solved with the consistent bindings, because this space will have those bindings generated before going through to DXIL.

Example: dxr -consistent-bindings myFile.hlsl:

Texture2D a;
Texture2D b;
RWTexture2D<float4> c;

[numthreads(1,1,1)]
void main() {
   c[0.xx] = b[0.xx];
}

[numthreads(1,1,1)]
void main2() {
   c[0.xx] = a[0.xx];
}

Would generate:

Texture2D a : register(t0);
Texture2D b : register(t1);
RWTexture2D<float4> c : register(u0);

[numthreads(1,1,1)]
void main() {
   c[0.xx] = b[0.xx];
}

[numthreads(1,1,1)]
void main2() {
   c[0.xx] = a[0.xx];
}

So if it's compiled as lib (with [shader] annotations) or if main2 and main are compiled as compute, they'll all provide identical bindings.

Currently this is done by our own preprocessor, but I want to move that behavior into the rewriter to generate more consistent results (and to avoid having to parse HLSL manually).

…he IDxcRewriter, this will allow generating register ids for registers that don't fully define them.
…allow passing different rewriter flags. Also added support for cbuffer auto bindings.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: New
Development

Successfully merging this pull request may close these issues.

Allow unused registers to be output to reflection
1 participant