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

Closed
github-bot wants to merge 1 commit from gh-pr/339/head into gh-pr/339/base
Owner

@⁠SkippySteve on GitHub · 2026-11-24 02:24 UTC · original
SkippySteve/shader-tidig-count → main · +15 −2 · 1 files · 1 commits · closed without merging

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.
**@⁠SkippySteve** on GitHub · 2026-11-24 02:24 UTC · [original](https://github.com/Marvisak/VIctory/pull/339) `SkippySteve/shader-tidig-count` → `main` · +15 −2 · 1 files · 1 commits · closed without merging ## 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.
COMPUTE_PGM_RSRC2.TIDIG_COMP_CNT is a 2-bit field, and
ComputeIo::thread_id_vgprs returned it plus one: 4 for a value of 3.
io::raise then labelled v3 as Input::ThreadIdInGroup(3), and lowering
asks DXIL's threadIdInGroup for component 3, which does not exist (the
console-lanes path quietly treats it as z instead).

A thread id has only x, y and z, so clamp the field to 2 before adding
one: v0-v2 are the thread id and v3 stays an ordinary VGPR. A unit test
covers the field at 3.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 03:59:51 +00:00
github-bot closed this pull request 2026-11-26 03:59:51 +00:00
Author
Owner

@⁠SkippySteve on GitHub · 2026-11-24 02:25 UTC · original

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

**@⁠SkippySteve** on GitHub · 2026-11-24 02:25 UTC · [original](https://github.com/Marvisak/VIctory/pull/339#issuecomment-7120128934) superseded by #333 (combined native.rs: SGPR bound + refusal tests + TIDIG_COMP_CNT clamp)

Pull request closed

This discussion has been locked. Commenting is limited to contributors.
No reviewers
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.

Dependencies

No dependencies set

Reference
github/Marvisak--VIctory!339
No description provided.