Shaders: lower RDNA 2 ADDTID memory instructions to DXIL #1663

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

@⁠THE-PRO-GAME on GitHub · 2026-11-24 20:34 UTC · original
THE-PRO-GAME:review/rdna2-addtid → main · +510 −22 · 7 files · 1 commits · open

Base branch Marvisak/VIctory:main at ffe310eb2098e52169f4c44db5ffdabf43a72622.
Head review/rdna2-addtid at 20c6c269bf24179e4ad44ab484bebceb69a756e0.

Changes

Lower ds_read_addtid_b32, ds_write_addtid_b32 and global_load_dword_addtid. All three use 4 * guest_lane as a byte offset. LDS adds M0[15:0] and the 16-bit immediate. GLOBAL adds the signed 12-bit immediate and tracks the scalar base through the existing resource binding path. LDS accesses respect the workgroup allocation and all three operations respect EXEC. AMD RDNA 2 ISA §9.1 · AMD RDNA 2 ISA §10.4.3 · LLVM GFX1030 syntax

The group-synchronized compute path derives the guest lane from the flattened group thread ID. When LDS ordering requires guest wave layout, the emitted shader retains the physical WaveSize requirement. Synthetic tests cover both guest widths, signed GLOBAL offsets, LDS limits and inactive-lane preservation.

Individual validation

  • cargo test --workspace --locked passed 347 tests. The --all-features run passed 351. Both had zero failures and six ignored tests.
  • Strict workspace Clippy with --all-targets --locked -- -D warnings passed with default and all features. All five targeted ADDTID tests passed.
  • Microsoft DXIL Validator (dxv v1.9.2609) accepted all 10 emitted containers. D3D12 WARP and an NVIDIA GeForce RTX 3060 each matched the CPU reference for 14 dispatches, seven per guest wave width. The LDS fallback that requires a matching physical wave size was checked through DXIL validation and metadata inspection.
  • To reproduce the synthetic tests on a Windows D3D12 SM 6.6 system, run cargo test -p victory-shader --locked addtid -- --nocapture. Set VICTORY_DXIL to the full path to Microsoft's dxil.dll to select the validator explicitly. Microsoft DXC release

Joint validation

A separate local integration check combined both commits and exercised all six instructions in one synthetic compute shader. The test chains GLOBAL ADDTID reads through the three SAD instructions into LDS ADDTID, then reads the resulting dwords back after a group barrier. Inactive lanes keep their original destination values. The mixed shader matched the CPU reference for two cases per guest wave width on each backend.

The local merge kept both decoder tests as separate functions after resolving an overlap at their insertion point. The mixed-shader fixture is local to the integration check.

The combined targeted run passed all 11 tests. Microsoft dxv v1.9.2609 accepted 28 containers. WARP and the RTX 3060 each matched the CPU reference for 82 dispatches, including four mixed-shader dispatches. The integrated workspace reported 353 passing tests with default features and 357 with all features, with zero failures and six ignored tests in each run. Strict Clippy passed for both configurations. The existing Xbox SDK differential tests returned early on this host.

PR #164 explicitly excludes ADDTID. PR #1606 covers LDS atomics and PR #1636 fixes immediate offsets in the FLAT encoding. The ADDTID global load uses the signed GLOBAL field. The recent upstream review found no proposal lowering the three selected operations. PR #164 · PR #1606 · PR #1636

Test scope and remaining validation

Execution verification used original synthetic compute shaders and a CPU reference derived from the public ISA. WARP and the RTX 3060 ran translated DXIL with traceable resource bases. Native RDNA 2 execution in Wave32 and Wave64 remains pending, including comparison of lane-addressed loads and stores and the wave-dependent LDS case. Graphics stages and retail shader coverage were outside the test scope. VIctory asset policy

**@⁠THE-PRO-GAME** on GitHub · 2026-11-24 20:34 UTC · [original](https://github.com/Marvisak/VIctory/pull/1663) `THE-PRO-GAME:review/rdna2-addtid` → `main` · +510 −22 · 7 files · 1 commits · open Base branch `Marvisak/VIctory:main` at `ffe310eb2098e52169f4c44db5ffdabf43a72622`. Head `review/rdna2-addtid` at `20c6c269bf24179e4ad44ab484bebceb69a756e0`. ## Changes Lower `ds_read_addtid_b32`, `ds_write_addtid_b32` and `global_load_dword_addtid`. All three use `4 * guest_lane` as a byte offset. LDS adds `M0[15:0]` and the 16-bit immediate. GLOBAL adds the signed 12-bit immediate and tracks the scalar base through the existing resource binding path. LDS accesses respect the workgroup allocation and all three operations respect EXEC. [AMD RDNA 2 ISA §9.1](https://gpuopen.com/download/rdna2-shader-instruction-set-architecture.pdf#page=91) · [AMD RDNA 2 ISA §10.4.3](https://gpuopen.com/download/rdna2-shader-instruction-set-architecture.pdf#page=104) · [LLVM GFX1030 syntax](https://releases.llvm.org/18.1.6/docs/AMDGPU/AMDGPUAsmGFX1030.html) The group-synchronized compute path derives the guest lane from the flattened group thread ID. When LDS ordering requires guest wave layout, the emitted shader retains the physical `WaveSize` requirement. Synthetic tests cover both guest widths, signed GLOBAL offsets, LDS limits and inactive-lane preservation. ## Individual validation - `cargo test --workspace --locked` passed 347 tests. The `--all-features` run passed 351. Both had zero failures and six ignored tests. - Strict workspace Clippy with `--all-targets --locked -- -D warnings` passed with default and all features. All five targeted ADDTID tests passed. - Microsoft DXIL Validator (`dxv` v1.9.2609) accepted all 10 emitted containers. D3D12 WARP and an NVIDIA GeForce RTX 3060 each matched the CPU reference for 14 dispatches, seven per guest wave width. The LDS fallback that requires a matching physical wave size was checked through DXIL validation and metadata inspection. - To reproduce the synthetic tests on a Windows D3D12 SM 6.6 system, run `cargo test -p victory-shader --locked addtid -- --nocapture`. Set `VICTORY_DXIL` to the full path to Microsoft's `dxil.dll` to select the validator explicitly. [Microsoft DXC release](https://github.com/microsoft/DirectXShaderCompiler/releases/tag/v1.9.2609) ## Joint validation A separate local integration check combined both commits and exercised all six instructions in one synthetic compute shader. The test chains GLOBAL ADDTID reads through the three SAD instructions into LDS ADDTID, then reads the resulting dwords back after a group barrier. Inactive lanes keep their original destination values. The mixed shader matched the CPU reference for two cases per guest wave width on each backend. The local merge kept both decoder tests as separate functions after resolving an overlap at their insertion point. The mixed-shader fixture is local to the integration check. The combined targeted run passed all 11 tests. Microsoft `dxv` v1.9.2609 accepted 28 containers. WARP and the RTX 3060 each matched the CPU reference for 82 dispatches, including four mixed-shader dispatches. The integrated workspace reported 353 passing tests with default features and 357 with all features, with zero failures and six ignored tests in each run. Strict Clippy passed for both configurations. The existing Xbox SDK differential tests returned early on this host. ## Related work PR #164 explicitly excludes ADDTID. PR #1606 covers LDS atomics and PR #1636 fixes immediate offsets in the FLAT encoding. The ADDTID global load uses the signed GLOBAL field. The recent upstream review found no proposal lowering the three selected operations. [PR #164](https://git.gtahub.st/github/Marvisak--VIctory/pulls/164) · [PR #1606](https://git.gtahub.st/github/Marvisak--VIctory/pulls/1606) · [PR #1636](https://git.gtahub.st/github/Marvisak--VIctory/pulls/1636) ## Test scope and remaining validation Execution verification used original synthetic compute shaders and a CPU reference derived from the public ISA. WARP and the RTX 3060 ran translated DXIL with traceable resource bases. Native RDNA 2 execution in Wave32 and Wave64 remains pending, including comparison of lane-addressed loads and stores and the wave-dependent LDS case. Graphics stages and retail shader coverage were outside the test scope. [VIctory asset policy](https://github.com/Marvisak/VIctory/blob/main/docs/asset-policy.md)
Lower DS_READ_ADDTID_B32, DS_WRITE_ADDTID_B32 and
GLOBAL_LOAD_DWORD_ADDTID with explicit guest lane addresses and EXEC
guards. Keep wave-dependent LDS phases on the guest wave size.

Verify operand decoding and dispatch synthetic compute shaders through
D3D12 WARP and hardware with both guest wave sizes.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 04:40:38 +00:00
Author
Owner

@⁠Marvisak on GitHub · 2026-11-25 01:33 UTC · original

Automated triage for the maintainers.

Needs rebase. This pull request conflicts with main (conflicting: crates/victory-shader/src/emit/lower.rs, crates/victory-shader/src/emit/valu_tests.rs). It will be reviewed once it is rebased onto the current main.


Generated by Claude Code

**@⁠Marvisak** on GitHub · 2026-11-25 01:33 UTC · [original](https://github.com/Marvisak/VIctory/pull/1663#issuecomment-7149692052) <!-- victory-triage v1 head=20c6c269bf24179e4ad44ab484bebceb69a756e0 verdict=needs-rebase at=2026-11-25T01:33:52Z --> Automated triage for the maintainers. **Needs rebase.** This pull request conflicts with `main` (conflicting: `crates/victory-shader/src/emit/lower.rs`, `crates/victory-shader/src/emit/valu_tests.rs`). It will be reviewed once it is rebased onto the current `main`. --- _Generated by [Claude Code](https://claude.ai/code)_
Author
Owner

@⁠sinan-cmyk on GitHub · 2026-11-25 02:36 UTC · original

Offline measurement on a retail dump, and the shader tests on Ada

Result: no count change against main.

Offline. I merged head 20c6c26 onto main ffe310e (clean merge) and ran victory translate --validate --list on shaders.rpf (1.0.2.1), with dxil.dll 1.8.2502.11. I compared the result with main program by program (25,889 programs). Validated: 21,724 on main, 21,724 with this PR.

No program changes its failure reason either. That is the expected result for a fix whose instructions sit behind the earlier failures on main. The count shows that the change rejects nothing. It does not show whether the output is right.

Tests: with the same merge, cargo test --locked -p victory-shader --lib passed 125, failed 0. The bitcode benchmark is ignored, as on main, where 120 pass. The run was on an RTX 4070 SUPER (Ada, 32-lane waves, driver 32.0.16.1088), the default adapter, with VICTORY_WARP unset.

No shader names or data are included, per the asset policy. AI-assisted (Claude Code).

**@⁠sinan-cmyk** on GitHub · 2026-11-25 02:36 UTC · [original](https://github.com/Marvisak/VIctory/pull/1663#issuecomment-7150936050) ### Offline measurement on a retail dump, and the shader tests on Ada **Result: no count change against `main`.** **Offline.** I merged head 20c6c26 onto `main` ffe310e (clean merge) and ran `victory translate --validate --list` on `shaders.rpf` (1.0.2.1), with dxil.dll 1.8.2502.11. I compared the result with `main` program by program (25,889 programs). Validated: 21,724 on `main`, 21,724 with this PR. No program changes its failure reason either. That is the expected result for a fix whose instructions sit behind the earlier failures on `main`. The count shows that the change rejects nothing. It does not show whether the output is right. **Tests:** with the same merge, `cargo test --locked -p victory-shader --lib` passed 125, failed 0. The bitcode benchmark is ignored, as on `main`, where 120 pass. The run was on an RTX 4070 SUPER (Ada, 32-lane waves, driver 32.0.16.1088), the default adapter, with `VICTORY_WARP` unset. No shader names or data are included, per the asset policy. AI-assisted (Claude Code).
This pull request has changes conflicting with the target branch.
  • crates/victory-shader/src/emit/lower.rs
  • crates/victory-shader/src/emit/valu_tests.rs
View command line instructions

Manual merge helper

Use this merge commit message when completing the merge manually.

Checkout

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

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-1663'
git switch 'github-bot/gh-1663'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-1663'
git switch 'github-bot/gh-1663'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-1663'
git switch 'main'
git merge --squash 'github-bot/gh-1663'
git switch 'main'
git merge --ff-only 'github-bot/gh-1663'
git switch 'main'
git merge 'github-bot/gh-1663'
git push origin 'main'
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!1663
No description provided.