Rewriter generate consistent bindings #7643
Open
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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
:Would generate:
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).