Shaders: a vertex input whose channels run past v255 is refused, not wrapped onto v0 #278

Open
sharan104 wants to merge 1 commit from upstream-pr/278 into main
sharan104 commented 2026-11-26 14:14:30 +00:00 (Migrated from github.com)

Imported from avatarmanz/VIctory-7900XTX. Originally posted by sharan104 on 2026-11-26T14:14:30Z.


io::raise mapped each enabled channel of a vertex input to Reg::V(i.vgpr + channel), adding in u8. Here vgpr is a raw byte of the stage data (native.rs vs_io). For an input at v253 or above with a higher channel enabled:

  • Debug builds panic: "attempt to add with overflow".
  • Release builds wrap onto v0 and up, so v1 (say) gets taken for a vertex attribute, and the translated shader quietly reads the wrong register.

Fix: checked_add, refusing the stage data with ShaderError::Malformed("vertex input past the last VGPR"), as the module already does for other bad stage data.

Test: io::tests::vertex_inputs_past_the_last_vgpr_are_refused. v252 with all four channels is accepted. v253 with four channels, and v255 with channel 1, are refused. v255 with only channel 0 is still accepted, since only enabled channels count. Before the fix the test panicked with the overflow; after it, it passed 10 runs out of 10.

Results:

  • cargo test -p victory-shader --locked: 303 passed, 0 failed, 4 ignored.
  • Clippy -D warnings is clean, with and without --all-features.

This doesn't overlap #229, which fixes other malformed-input paths (signatures, thread groups, user SGPRs).

🤖 Generated with Claude Code

<!-- greyfinch-sync:avatarmanz/VIctory-7900XTX:issue:6628526193 --> Imported from [avatarmanz/VIctory-7900XTX](https://github.com/avatarmanz/VIctory-7900XTX/pull/278). Originally posted by [sharan104](https://github.com/sharan104) on 2026-11-26T14:14:30Z. --- `io::raise` mapped each enabled channel of a vertex input to `Reg::V(i.vgpr + channel)`, adding in `u8`. Here `vgpr` is a raw byte of the stage data (`native.rs` `vs_io`). For an input at v253 or above with a higher channel enabled: - **Debug builds** panic: "attempt to add with overflow". - **Release builds** wrap onto v0 and up, so v1 (say) gets taken for a vertex attribute, and the translated shader quietly reads the wrong register. **Fix:** `checked_add`, refusing the stage data with `ShaderError::Malformed("vertex input past the last VGPR")`, as the module already does for other bad stage data. **Test:** `io::tests::vertex_inputs_past_the_last_vgpr_are_refused`. v252 with all four channels is accepted. v253 with four channels, and v255 with channel 1, are refused. v255 with only channel 0 is still accepted, since only enabled channels count. Before the fix the test panicked with the overflow; after it, it passed 10 runs out of 10. **Results:** - `cargo test -p victory-shader --locked`: 303 passed, 0 failed, 4 ignored. - Clippy `-D warnings` is clean, with and without `--all-features`. This doesn't overlap #229, which fixes other malformed-input paths (signatures, thread groups, user SGPRs). 🤖 Generated with [Claude Code](https://claude.com/claude-code)
This pull request cannot be merged automatically due to conflicts.
Merge manually to resolve the conflicts.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin 'upstream-pr/278:upstream-pr/278'
git switch 'upstream-pr/278'

Merge

Merge the changes and update on Forgejo.

Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.

git switch 'main'
git merge --no-ff 'upstream-pr/278'
git switch 'upstream-pr/278'
git rebase 'main'
git switch 'main'
git merge --ff-only 'upstream-pr/278'
git switch 'upstream-pr/278'
git rebase 'main'
git switch 'main'
git merge --no-ff 'upstream-pr/278'
git switch 'main'
git merge --squash 'upstream-pr/278'
git switch 'main'
git merge --ff-only 'upstream-pr/278'
git switch 'main'
git merge 'upstream-pr/278'
git push origin 'main'
Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
avatarmanz/VIctory-7900XTX!278
No description provided.