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

Open
github-bot wants to merge 1 commit from github-bot/gh-278 into main AGit
Owner

@⁠sharan104 on GitHub · 2026-11-26 14:14 UTC · original
sharan104:fix/gfx10-decode → main · +42 −1 · 1 files · 1 commits · open

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

**@⁠sharan104** on GitHub · 2026-11-26 14:14 UTC · [original](https://github.com/avatarmanz/VIctory-7900XTX/pull/278) `sharan104:fix/gfx10-decode` → `main` · +42 −1 · 1 files · 1 commits · open `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)
io::raise placed channel k of each fetched vertex attribute in VGPR
`vgpr + k`, a u8 sum with `vgpr` a raw byte of the stage data (vs_io). A
corrupt or unusual entry (v253 and up with a higher channel enabled)
overflowed it: a panic in a debug build, and in a release build the channel
wrapped onto v0 and up, so v1 was taken for a vertex attribute (v0, v2 and
v3 keep the system values, found first).

The sum is checked now, and such stage data is refused as Malformed, as
native.rs refuses other stage data that names nothing.

Test: io::tests::vertex_inputs_past_the_last_vgpr_are_refused (panicked
with "attempt to add with overflow" at io.rs:225 before the fix).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 14:22:20 +00:00
This pull request can be merged automatically.
This branch is out-of-date with the base branch
You are not authorized to merge this pull request.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin '+refs/pull/278/head:github-bot/gh-278'
git switch 'github-bot/gh-278'

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-278'
git switch 'github-bot/gh-278'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-278'
git switch 'github-bot/gh-278'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-278'
git switch 'main'
git merge --squash 'github-bot/gh-278'
git switch 'main'
git merge --ff-only 'github-bot/gh-278'
git switch 'main'
git merge 'github-bot/gh-278'
git push origin 'main'
This discussion has been locked. Commenting is limited to contributors.
No description provided.