Shaders: a thread-id count field of 3 still means three components #339

Closed
SkippySteve wants to merge 1 commit from upstream-pr/339 into main
SkippySteve commented 2026-11-24 02:24:24 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by SkippySteve on 2026-11-24T02:24:24Z.


What

`ComputeIo::thread_id_vgprs` (crates/victory-shader/src/native.rs) read `COMPUTE_PGM_RSRC2.TIDIG_COMP_CNT` (bits 11-12) and added one, so a field value of 3 gave 4 thread-id VGPRs. `io::raise` then mapped v3 to `Input::ThreadIdInGroup(3)`, and `emit/lower.rs` passes that component straight to DXIL's `threadIdInGroup.i32` — a component that doesn't exist (only 0-2 are valid). On the console-lanes path, component 3 fell into the `_` arm and was silently computed as z.

Fix

A thread id has only x, y and z, so the field is clamped to 2 before adding one: 3 now means v0-v2 like 2 does, and v3 stays an ordinary VGPR. One line plus a doc comment.

Tests

  • New unit test `native::tests::thread_id_count_three_is_still_three_components` (synthetic `rsrc2`, no game data).
  • `cargo test -p victory-shader`: 57 passed, 0 failed (Linux).
  • `cargo clippy -p victory-shader -- -D warnings`: clean. (`--all-targets` hits the existing dead-code warning on `emit::mod::tests::constant_color` off Windows, which this PR doesn't touch.)
  • `cargo fmt --check`: clean.
<!-- greyfinch-sync:Marvisak/VIctory:issue:6573196101 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/339). Originally posted by [SkippySteve](https://github.com/SkippySteve) on 2026-11-24T02:24:24Z. --- ## What \`ComputeIo::thread_id_vgprs\` (crates/victory-shader/src/native.rs) read \`COMPUTE_PGM_RSRC2.TIDIG_COMP_CNT\` (bits 11-12) and added one, so a field value of 3 gave **4** thread-id VGPRs. \`io::raise\` then mapped v3 to \`Input::ThreadIdInGroup(3)\`, and \`emit/lower.rs\` passes that component straight to DXIL's \`threadIdInGroup.i32\` — a component that doesn't exist (only 0-2 are valid). On the console-lanes path, component 3 fell into the \`_\` arm and was silently computed as z. ## Fix A thread id has only x, y and z, so the field is clamped to 2 before adding one: 3 now means v0-v2 like 2 does, and v3 stays an ordinary VGPR. One line plus a doc comment. ## Tests - New unit test \`native::tests::thread_id_count_three_is_still_three_components\` (synthetic \`rsrc2\`, no game data). - \`cargo test -p victory-shader\`: 57 passed, 0 failed (Linux). - \`cargo clippy -p victory-shader -- -D warnings\`: clean. (\`--all-targets\` hits the existing dead-code warning on \`emit::mod::tests::constant_color\` off Windows, which this PR doesn't touch.) - \`cargo fmt --check\`: clean.
upstream-sync closed this pull request 2026-11-24 06:52:29 +00:00
SkippySteve commented 2026-11-24 06:55:10 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by SkippySteve on 2026-11-24T02:25:34Z.


superseded by #333 (combined native.rs: SGPR bound + refusal tests + TIDIG_COMP_CNT clamp)

<!-- greyfinch-sync:Marvisak/VIctory:comment:7120128934 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/339#issuecomment-7120128934). Originally posted by [SkippySteve](https://github.com/SkippySteve) on 2026-11-24T02:25:34Z. --- superseded by #333 (combined native.rs: SGPR bound + refusal tests + TIDIG_COMP_CNT clamp)

Pull request closed

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
Marvisak/VIctory!339
No description provided.