Shaders/io+native: prioritize VS fetched attributes over hardware IDs, check VGPR overflow, and clamp thread_id_vgprs #677
No reviewers
Labels
No labels
accessibility
bug
documentation
duplicate
enhancement
good first issue
help wanted
invalid
question
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/fxceless--victory-fork!677
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-677"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
@AscilCH on GitHub · 2026-11-25 04:20 UTC · original
AscilCH:fix/shader-vs-input-shadowing-vgpr-overflow-and-tidig-clamp→main· +122 −7 · 2 files · 1 commits · openSummary
Fixes three I/O-raising and shader-metadata bugs in
crates/victory-shader:Silent VS attribute shadowing by hardware IDs (
crates/victory-shader/src/io.rs):VsInput.vgpr + channel, legitimately reusingv0..v3whenSV_VertexID/SV_InstanceIDare not needed afterwards.io::raisepreviously appended fetchedinputsafter(V(0), VertexId),(V(2), PrimitiveId),(V(3), InstanceId)while looking up with first-matchloaded.iter().find(...), silently lowering fetched attributes inv0/v3asSV_VertexID/SV_InstanceIDand aborting onv2(Input::PrimitiveId).inputsare now registered before the hardware fallback VGPRs.Unchecked
u8VGPR overflow on malformed FSSM (crates/victory-shader/src/io.rs):i.vgpr + channelcould panic in debug or wrap in release whenvgpr >= 253with upper mask bits set. Replaced withchecked_add, returningErr(ShaderError::Malformed("vertex input VGPR out of range")).Out-of-range 4th thread-ID dimension (
crates/victory-shader/src/native.rs):ComputeIo::thread_id_vgprs()returned4when 2-bitTIDIG_COMP_CNTwas3, emitting invalidInput::ThreadIdInGroup(3)(dx.op.threadIdInGroup(95, 3)). Clamped via((self.rsrc2 >> 11 & 3) as u8).min(2) + 1to match its1..=3contract.Verification
cargo test -p victory-shader --lib --locked -- io::tests native::tests— 18 passed, 0 failed (including newvs_fetched_attributes_in_v0_to_v3_override_hardware_ids_and_reject_vgpr_overflowandcompute_thread_id_vgprs_is_clamped_to_three_dimensions)cargo clippy -p victory-shader --all-targets --all-features --locked -- -D warnings— clean (0 warnings)cargo xtask policy— asset policy: 169 files ok(AI-assisted; synthetic unit tests only, no game data.)
Three fixes in `crates/victory-shader/src/{io.rs, native.rs}`: 1. `io::raise` (`StageIo::Vs`): `loaded` previously inserted `(V(0), VertexId)`, `(V(2), PrimitiveId)`, `(V(3), InstanceId)` *before* the fetch-shader `inputs`, and matched with first-match `loaded.iter().find(...)`. When the fetch shader overwrites `v0..v3` with fetched vertex attributes (because the VS does not need `SV_VertexID`/`SV_InstanceID` after vertex fetch), those attributes were silently shadowed as `VertexId`/`InstanceId` or aborted translation on `PrimitiveId`. Register fetched `inputs` before the hardware fallbacks. 2. `io::raise` (`StageIo::Vs` VGPR overflow): `VsInput.vgpr` is an arbitrary `u8` (`0..=255`) from the FSSM table, so `i.vgpr + channel` panicked in debug or wrapped to `v0..v2` in release for `vgpr >= 253` with upper channel bits set. Use `checked_add` and return `ShaderError::Malformed("vertex input VGPR out of range")`. 3. `ComputeIo::thread_id_vgprs` (`native.rs`): `(self.rsrc2 >> 11 & 3) as u8 + 1` returned `4` when the 2-bit `TIDIG_COMP_CNT` field was `3`, contradicting its `1..=3` contract and producing an invalid `Input::ThreadIdInGroup(3)` -> DXIL `threadIdInGroup(95, 3)`. Clamp with `.min(2) + 1`. Add `io::tests::vs_fetched_attributes_in_v0_to_v3_override_hardware_ids_and_reject_vgpr_overflow` and `native::tests::compute_thread_id_vgprs_is_clamped_to_three_dimensions`.@JRamos1993 on GitHub · 2026-11-25 05:27 UTC · original
Offline check on the retail shader pack: this changes no emitted shader of the title.
victory translate --validate --listover the title's full shader pack (26,084 programs, 14,247 vertex and pixel programs with I/O raised) on an RTX 5090,main310c6ebagainst this head merged onto it:So in this title no vertex program's fetched attributes land in
v0–v3where the order would matter. The batch tool raises I/O from each container's own data, so this covers the containers as shipped, not anything a pipeline adds at run time.AI use: Claude Code with Claude Opus 5.5 ran the pack and wrote this. Nothing from the title is in it.
View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.