[Validator] Add validation for createHandleFromBinding#8205
[Validator] Add validation for createHandleFromBinding#8205damyanp wants to merge 17 commits intomicrosoft:mainfrom
Conversation
…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 <8118402+damyanp@users.noreply.github.com>
…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 <8118402+damyanp@users.noreply.github.com>
Co-authored-by: damyanp <8118402+damyanp@users.noreply.github.com>
Co-authored-by: damyanp <8118402+damyanp@users.noreply.github.com>
|
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? |
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 <8118402+damyanp@users.noreply.github.com>
Co-authored-by: damyanp <8118402+damyanp@users.noreply.github.com>
… into copilot/fix-issue-7019-tests # Conflicts: # docs/ReleaseNotes.md
Co-authored-by: damyanp <8118402+damyanp@users.noreply.github.com>
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 <8118402+damyanp@users.noreply.github.com>
Re-add createHandleFromBinding_non_constant_bind.ll to maintain test coverage for the bind parameter constness check. Co-authored-by: damyanp <8118402+damyanp@users.noreply.github.com>
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 <8118402+damyanp@users.noreply.github.com>
| } | ||
|
|
||
| // Validate constant index is within binding range. | ||
| ConstantInt *cIndex = dyn_cast<ConstantInt>(hdl.get_index()); |
There was a problem hiding this comment.
I don't fully understand what the DXIL::OpCode::CreateHandle version of this logic is doing where it handles a case for "index must be 0 for none array resource." (sic), so I'm not sure if it's relevant here, but do we need similar logic as well?
There was a problem hiding this comment.
Thanks - I think we might be missing checks for non-constant indexes entirely.
I just pushed a version that handles this, but as soon as I pushed it I realized that using lower==upper to decide if something is an array or not is probably not the right thing to do.
There was a problem hiding this comment.
It doesn't look like we can safely detect array resources without the extra information about the type that CreateHandle has. I think rejecting dynamic indexing on single element arrays would be undesireable.
There was a problem hiding this comment.
@bogner - latest iteration is what I think is the response to this. We don't have enough information to add a new validation rule for this, but I added some _passing tests around arrays to capture some of the thinking.
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 <223556219+Copilot@users.noreply.github.com>
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 <223556219+Copilot@users.noreply.github.com>
Rename local variables to UpperCamelCase: hdl->Hdl, bind->Bind, cIndex->CIndex, index->Index. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Previously, the validator didn't validate the parameters to createHandleFromBinding. This change adds validation that validates:
Fixes #7019