Skip to content

[Validator] Add validation for createHandleFromBinding - #8205

Merged
Damyan Pepper (damyanp) merged 17 commits into
microsoft:mainfrom
damyanp:copilot/fix-issue-7019-tests
Mar 16, 2026
Merged

Damyan Pepper (damyanp) merged 17 commits into
microsoft:mainfrom
damyanp:copilot/fix-issue-7019-tests

Conversation

@damyanp

@damyanp Damyan Pepper (damyanp) commented Feb 26, 2026 •

Copy link
Copy Markdown
Member

Previously, the validator didn't validate the parameters to createHandleFromBinding. This change adds validation that validates:

  • Bind parameter is constant — validates the bind struct parameter is a constant
  • Resource class is valid — validates resourceClass is one of CBuffer, Sampler, SRV, or UAV
  • Index range — validates constant indices fall within [rangeLowerBound, rangeUpperBound]

Fixes #7019

Copilot AI and others added 5 commits February 21, 2026 00:24
…osoft#7019)

Add validation in BuildResMap() to check that the index parameter of
createHandleFromBinding falls within the range [rangeLowerBound, rangeUpperBound]
from the ResBind parameter. This matches the existing validation done for
createHandle.

Add a LIT test that verifies the validator catches an out-of-range index
(index 0 with rangeLowerBound=1, rangeUpperBound=1).

Co-authored-by: damyanp <[email protected]>
…ation

Extend the test to cover both edge cases: index below rangeLowerBound (0 < 1)
and index above rangeUpperBound (4 > 3). Uses a range of [1,3] to ensure
both boundaries are tested independently.

Co-authored-by: damyanp <[email protected]>
@damyanp

Copy link
Copy Markdown
Member Author

There doesn't seem to be any validation at all for CreateHandleFromBinding. Maybe the right way to resolve this would be to get all the validation in place?

@damyanp
Damyan Pepper (damyanp) marked this pull request as ready for review February 26, 2026 22:28

@bob80905 Joshua Batista (bob80905) left a comment •

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

LGTM, though I agree it would be even better if moved nearby to where createhandle is validated.

Damyan Pepper (damyanp) and others added 5 commits March 9, 2026 17:32
Expand validation to check:
1. bind parameter is constant
2. resourceClass in the binding is valid (CBuffer/Sampler/SRV/UAV)
3. constant index is within [rangeLowerBound, rangeUpperBound] (existing)

Add test for invalid resourceClass (value 5, outside 0-3 range).

Co-authored-by: damyanp <[email protected]>
@damyanp Damyan Pepper (damyanp) changed the title [Validator] Detect obviously bad indices for createHandleFromBinding op [Validator] Add validation for createHandleFromBinding Mar 12, 2026
@damyanp
Damyan Pepper (damyanp) marked this pull request as draft March 12, 2026 02:37
Copilot AI and others added 3 commits March 12, 2026 02:51
Consolidate the three separate createHandleFromBinding test files into two
following the existing _passing/_failing convention:

- createHandleFromBinding_passing.ll: valid indices at lower and upper bounds
- createHandleFromBinding_failing.ll: index below/above range + invalid class

Removed the non-constant bind test since it's a defensive check that can't
be triggered without also triggering unrelated validation errors.

Co-authored-by: damyanp <[email protected]>
Re-add createHandleFromBinding_non_constant_bind.ll to maintain test
coverage for the bind parameter constness check.

Co-authored-by: damyanp <[email protected]>
Remove mention of "non-constant bind parameters" from the description
since that case is tested in the separate _non_constant_bind.ll file.

Co-authored-by: damyanp <[email protected]>
Damyan Pepper (damyanp) and others added 3 commits March 13, 2026 13:01
When the binding range has size 1 (rangeLowerBound == rangeUpperBound),
the resource is non-array and the index must be a constant. This mirrors
the existing CreateHandle validation which rejects non-constant indices
on non-array resources.

Co-authored-by: Copilot <[email protected]>
The rangeLowerBound == rangeUpperBound check cannot distinguish
non-array resources from 1-element arrays, so revert the non-constant
index rejection for now. Keep the passing test case that verifies
non-constant indices on array resources are accepted.

Co-authored-by: Copilot <[email protected]>
Rename local variables to UpperCamelCase: hdl->Hdl, bind->Bind,
cIndex->CIndex, index->Index.

Co-authored-by: Copilot <[email protected]>

@bob80905 Joshua Batista (bob80905) left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

LGTM

@damyanp
Damyan Pepper (damyanp) merged commit f62b9b4 into microsoft:main Mar 16, 2026
12 checks passed
@github-project-automation github-project-automation Bot moved this from New to Done in HLSL Roadmap Mar 16, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

DXIL Validator doesn't notice obviously bad indices in the createHandleFromBinding op

4 participants