Shaders: lower ds_wrxchg2_rtn_b32 and ds_wrxchg2st64_rtn_b32 in pure 32-bit DXIL #2119

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

@⁠geiyiliyabumo on GitHub · 2026-11-25 05:25 UTC · original
geiyiliyabumo:feat/shader-ds-wrxchg2 → main · +154 −2 · 2 files · 1 commits · open

Summary

  • Lowers GFX10 LDS two-address atomic exchange instructions ds_wrxchg2_rtn_b32 (0x02e) and ds_wrxchg2st64_rtn_b32 (0x02f) in crates/victory-shader/src/emit/lower.rs (fn ds) to two ordered, EXEC-guarded pure 32-bit Rmw::Xchg atomics without enabling Int64 / WIDE_OPS.
  • Uses 4-byte (ds_wrxchg2_rtn_b32) and 256-byte (ds_wrxchg2st64_rtn_b32) offset scaling, reads all source VGPRs before writing vdst[0:1] (handling source/destination overlap safely), and preserves both vdst[0] and vdst[1] on inactive EXEC lanes.
  • Adds synthetic DXIL-validation and GPU execution tests in crates/victory-shader/src/emit/semantics_tests.rs covering distinct offsets, equal offsets (offset0 == offset1), 256-byte st64 stride, source/destination VGPR overlap, inactive EXEC lane preservation, and asserting Int64 is not set.

Verification

  • cargo xtask policy: passed
  • cargo clippy -p victory-shader --tests -- -D warnings: passed
  • cargo test -p victory-shader --lib lds_exchange_pair -- --test-threads=1 with Microsoft dxil.dll: passed on AMD Radeon RX 9060 XT (RDNA4) and Microsoft Basic Render Driver (WARP) (192 lane results, 0 hardware/WARP mismatches)
  • Zero game files or game-derived data used (synthetic tests only).
**@⁠geiyiliyabumo** on GitHub · 2026-11-25 05:25 UTC · [original](https://github.com/Marvisak/VIctory/pull/2119) `geiyiliyabumo:feat/shader-ds-wrxchg2` → `main` · +154 −2 · 2 files · 1 commits · open ## Summary - Lowers GFX10 LDS two-address atomic exchange instructions `ds_wrxchg2_rtn_b32` (`0x02e`) and `ds_wrxchg2st64_rtn_b32` (`0x02f`) in `crates/victory-shader/src/emit/lower.rs` (`fn ds`) to two ordered, `EXEC`-guarded pure 32-bit `Rmw::Xchg` atomics without enabling `Int64` / `WIDE_OPS`. - Uses 4-byte (`ds_wrxchg2_rtn_b32`) and 256-byte (`ds_wrxchg2st64_rtn_b32`) offset scaling, reads all source VGPRs before writing `vdst[0:1]` (handling source/destination overlap safely), and preserves both `vdst[0]` and `vdst[1]` on inactive `EXEC` lanes. - Adds synthetic DXIL-validation and GPU execution tests in `crates/victory-shader/src/emit/semantics_tests.rs` covering distinct offsets, equal offsets (`offset0 == offset1`), 256-byte `st64` stride, source/destination VGPR overlap, inactive `EXEC` lane preservation, and asserting `Int64` is not set. ## Verification - `cargo xtask policy`: passed - `cargo clippy -p victory-shader --tests -- -D warnings`: passed - `cargo test -p victory-shader --lib lds_exchange_pair -- --test-threads=1` with Microsoft `dxil.dll`: passed on **AMD Radeon RX 9060 XT (RDNA4)** and **Microsoft Basic Render Driver (WARP)** (192 lane results, 0 hardware/WARP mismatches) - Zero game files or game-derived data used (synthetic tests only).
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 04:55:22 +00:00
Author
Owner

@⁠upipibi on GitHub · 2026-11-25 05:36 UTC · original

Ran on Windows 11 with an RTX 3070 (Ampere, driver 616.56), debug build, at 85fe4dc. victory-shader: 246 passed, 3 failed, 3 ignored. The new lds_exchange_pair_ir_and_dxil and lds_exchange_pair_matches_isa pass. The 3 failures are #1744's NVIDIA failures on main. Same as main on this hardware.

Overlap, from reading: #1606 (open, conflicting with main) also lowers wrxchg2_b32 and wrxchg2st64_b32 among the other LDS atomics.

AI-assisted (Claude Code).

**@⁠upipibi** on GitHub · 2026-11-25 05:36 UTC · [original](https://github.com/Marvisak/VIctory/pull/2119#issuecomment-7153959121) Ran on Windows 11 with an RTX 3070 (Ampere, driver 616.56), debug build, at `85fe4dc`. `victory-shader`: 246 passed, 3 failed, 3 ignored. The new `lds_exchange_pair_ir_and_dxil` and `lds_exchange_pair_matches_isa` pass. The 3 failures are #1744's NVIDIA failures on `main`. Same as `main` on this hardware. Overlap, from reading: #1606 (open, conflicting with `main`) also lowers `wrxchg2_b32` and `wrxchg2st64_b32` among the other LDS atomics. AI-assisted (Claude Code).
Author
Owner

@⁠sinan-cmyk on GitHub · 2026-11-25 10:16 UTC · original

Offline measurement on a retail dump

Result: no count change against main.

I merged head 85fe4dc1 onto main 940d32f (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: 23,918 on main, 23,918 with this PR.

No program changes its failure reason. The count shows that the change rejects nothing on this data. It does not show whether the output is right.

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

**@⁠sinan-cmyk** on GitHub · 2026-11-25 10:16 UTC · [original](https://github.com/Marvisak/VIctory/pull/2119#issuecomment-7159464632) ### Offline measurement on a retail dump **Result: no count change against `main`.** I merged head 85fe4dc1 onto `main` 940d32f (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: 23,918 on `main`, 23,918 with this PR. No program changes its failure reason. The count shows that the change rejects nothing on this data. It does not show whether the output is right. No shader names or data are included, per the asset policy. AI-assisted (Claude Code).
Author
Owner

@⁠Marvisak on GitHub · 2026-11-25 10:45 UTC · original · edited 2026-11-25 22:20 UTC

Automated triage for the maintainers.

Needs rebase. This PR no longer merges cleanly into main: main has moved since the last triage, and the branch now conflicts in crates/victory-shader/src/emit/semantics_tests.rs. It will be reviewed again once it is rebased onto current main.

Previous verdict for this head: merge candidate.


Generated by Claude Code

**@⁠Marvisak** on GitHub · 2026-11-25 10:45 UTC · [original](https://github.com/Marvisak/VIctory/pull/2119#issuecomment-7160138660) · edited 2026-11-25 22:20 UTC <!-- victory-triage v1 head=85fe4dc1f1cc0c13ea7f523aa7cd1449a7eee4ef verdict=needs-rebase at=2026-11-25T22:24:00Z --> Automated triage for the maintainers. **Needs rebase.** This PR no longer merges cleanly into `main`: `main` has moved since the last triage, and the branch now conflicts in `crates/victory-shader/src/emit/semantics_tests.rs`. It will be reviewed again once it is rebased onto current `main`. Previous verdict for this head: merge candidate. --- _Generated by [Claude Code](https://claude.ai/code)_
This pull request has changes conflicting with the target branch.
  • crates/victory-shader/src/emit/semantics_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/2119/head:github-bot/gh-2119'
git switch 'github-bot/gh-2119'

Merge

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