Shaders: ds_wrap_rtn_b32 reads both of its data operands #2789

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

@⁠lcg007xd-c on GitHub · 2026-11-25 20:27 UTC · original
lcg007xd-c:gfx10/ds-wrap-two-data → main · +15 −1 · 2 files · 1 commits · open

What this fixes

ds_wrap_rtn_b32 computes tmp >= DATA0 ? tmp - DATA0 : tmp + DATA1 (RDNA2 ISA), so it reads two data VGPRs. The decoder gave it only one: DATA1 was neither printed in SP3 text nor reported as a register read.

d8d00010 08060402
llvm-mc -mcpu=gfx1030: ds_wrap_rtn_b32 v8, v2, v4, v6 offset:16
VIctory before:        ds_wrap_rtn_b32 v8, v2, v4 offset:16
VIctory after:         ds_wrap_rtn_b32 v8, v2, v4, v6 offset:16

I found it while diffing about 15.5k encodings with valid operands, covering every opcode of every encoding, between gfx10::decode and llvm-mc --disassemble -mcpu=gfx1030. Outside known aliases and already-claimed items, this was one of the few remaining disagreements.

The change

fields.rs: ds_wrap_rtn_b32 joins the two-data branch with cmpst/mskor. The lowering doesn't handle this opcode yet, so nothing that translates today changes.

Tested (Linux, Rust 1.98.1)

  • New gfx10::sp3::tests::ds_wrap_reads_both_data_operands, checked against llvm-mc's text. It fails without the change (v6 missing) and passes with it.
  • cargo test -p victory-shader --lib: 159 passed, 0 failed, 2 ignored. Building the shader tests on Linux needs #2766.
  • cargo clippy -p victory-shader --all-targets --target x86_64-pc-windows-msvc -- -D warnings: clean.
  • rustfmt --check on both files: clean.

🤖 Generated with Claude Code

**@⁠lcg007xd-c** on GitHub · 2026-11-25 20:27 UTC · [original](https://github.com/Marvisak/VIctory/pull/2789) `lcg007xd-c:gfx10/ds-wrap-two-data` → `main` · +15 −1 · 2 files · 1 commits · open ## What this fixes `ds_wrap_rtn_b32` computes `tmp >= DATA0 ? tmp - DATA0 : tmp + DATA1` (RDNA2 ISA), so it reads two data VGPRs. The decoder gave it only one: DATA1 was neither printed in SP3 text nor reported as a register read. ``` d8d00010 08060402 llvm-mc -mcpu=gfx1030: ds_wrap_rtn_b32 v8, v2, v4, v6 offset:16 VIctory before: ds_wrap_rtn_b32 v8, v2, v4 offset:16 VIctory after: ds_wrap_rtn_b32 v8, v2, v4, v6 offset:16 ``` I found it while diffing about 15.5k encodings with valid operands, covering every opcode of every encoding, between `gfx10::decode` and `llvm-mc --disassemble -mcpu=gfx1030`. Outside known aliases and already-claimed items, this was one of the few remaining disagreements. ## The change `fields.rs`: `ds_wrap_rtn_b32` joins the two-data branch with `cmpst`/`mskor`. The lowering doesn't handle this opcode yet, so nothing that translates today changes. ## Tested (Linux, Rust 1.98.1) - New `gfx10::sp3::tests::ds_wrap_reads_both_data_operands`, checked against llvm-mc's text. It fails without the change (`v6` missing) and passes with it. - `cargo test -p victory-shader --lib`: 159 passed, 0 failed, 2 ignored. Building the shader tests on Linux needs #2766. - `cargo clippy -p victory-shader --all-targets --target x86_64-pc-windows-msvc -- -D warnings`: clean. - `rustfmt --check` on both files: clean. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
Its result is `tmp >= DATA0 ? tmp - DATA0 : tmp + DATA1` (RDNA2 ISA), and
LLVM's gfx1030 disassembler prints both, but the decoder gave it one data
operand, so DATA1 was neither printed nor seen as a register read.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 05:14:15 +00:00
Author
Owner

@⁠kotekompotek on GitHub · 2026-11-25 20:37 UTC · original

Matches the ISA: ds_wrap_rtn_b32 wraps lane indices as (tid + DATA1 - DATA0), so both data operands are live reads. The llvm-mc encoding in the test confirms DATA0/DATA1 map to v4/v6.

**@⁠kotekompotek** on GitHub · 2026-11-25 20:37 UTC · [original](https://github.com/Marvisak/VIctory/pull/2789#issuecomment-7173951346) Matches the ISA: ds_wrap_rtn_b32 wraps lane indices as (tid + DATA1 - DATA0), so both data operands are live reads. The llvm-mc encoding in the test confirms DATA0/DATA1 map to v4/v6.
Author
Owner

@⁠fuzeofficlal on GitHub · 2026-11-25 20:46 UTC · original

Reviewed and verified d80aedfc on Windows 11 against main (13f91ca).

  • Adding name == "ds_wrap_rtn_b32" to the 2-data-operand branch in fields.rs:314-320 matches RDNA2 ISA (DATA0 and DATA1), producing the expected ds_wrap_rtn_b32 v8, v2, v4, v6 offset:16 disassembly and recording both VGPR source reads in ir.rs, while leaving ds_inc_*/ds_dec_* at 1 data operand.
  • cargo test --locked -p victory-shader --lib -- gfx10::: 17/17 passed (including ds_wrap_reads_both_data_operands); ir::: 9/9 passed.
  • cargo clippy --locked -p victory-shader --all-targets -- -D warnings (default & --features host): 0 warnings; cargo xtask policy: 184 files ok; clean git merge-tree vs 13f91ca and #2783.
**@⁠fuzeofficlal** on GitHub · 2026-11-25 20:46 UTC · [original](https://github.com/Marvisak/VIctory/pull/2789#issuecomment-7174179410) Reviewed and verified `d80aedfc` on Windows 11 against `main` (`13f91ca`). - Adding `name == "ds_wrap_rtn_b32"` to the 2-data-operand branch in `fields.rs:314-320` matches RDNA2 ISA (`DATA0` and `DATA1`), producing the expected `ds_wrap_rtn_b32 v8, v2, v4, v6 offset:16` disassembly and recording both VGPR source reads in `ir.rs`, while leaving `ds_inc_*`/`ds_dec_*` at 1 data operand. - `cargo test --locked -p victory-shader --lib -- gfx10::`: **17/17 passed** (including `ds_wrap_reads_both_data_operands`); `ir::`: **9/9 passed**. - `cargo clippy --locked -p victory-shader --all-targets -- -D warnings` (default & `--features host`): **0 warnings**; `cargo xtask policy`: **184 files ok**; clean `git merge-tree` vs `13f91ca` and `#2783`.
Author
Owner

@⁠oni-swr on GitHub · 2026-11-25 20:58 UTC · original

WARP/CPU verification of head d80aedfc43bb539b4e0b95d682864fe5dde873b2

Environment: Windows 11 x64, rustc/cargo 1.98.1, WARP/CPU only (VICTORY_WARP=1, VICTORY_D3D12_WARP=1), no physical GPU, no game files. DXIL validation with Windows SDK 10.0.26100.0 x64 dxil.dll 1.8.2502.11. PR head merged cleanly onto origin/main 13f91caee2.

Tests (cargo test --no-fail-fast -p victory-shader)

  • origin/main baseline: 267 passed, 3 failed, 3 ignored.
  • With this PR: 268 passed, 3 failed, 3 ignored (+1: gfx10::sp3::tests::ds_wrap_reads_both_data_operands).
  • The same 3 failures as on origin/main, unrelated (a_mask_joined_with_data_at_a_uniform_loop_is_its_number, gathers_at_a_level_match_the_hardware, permutes_read_the_lane_named_and_zero_from_lanes_left_out; they compare against hardware lane results and fail on WARP).

Negative control: with the ds_wrap_rtn_b32 clause disabled, the new test fails (ds_wrap_rtn_b32 v8, v2, v4 offset:16 instead of ... v2, v4, v6 ...).

Lint: cargo clippy --all-targets -- -D warnings clean. cargo fmt --check: no new hunks (891 on main, 891 with the PR). Note: cargo fmt --check is already red on origin/main here (891 hunks, none from these PRs), so I compared per-file hunk counts against that baseline.

Review: read the full diff. The change is minimal and the test matches the described operand semantics (DATA0 subtracted, DATA1 added). No game files, dumps, shader names, or retail hashes.

AI disclosure: this verification was done by Claude Code (Claude Sonnet 5.5).

**@⁠oni-swr** on GitHub · 2026-11-25 20:58 UTC · [original](https://github.com/Marvisak/VIctory/pull/2789#issuecomment-7174445817) **WARP/CPU verification of head `d80aedfc43bb539b4e0b95d682864fe5dde873b2`** **Environment:** Windows 11 x64, rustc/cargo 1.98.1, WARP/CPU only (VICTORY_WARP=1, VICTORY_D3D12_WARP=1), no physical GPU, no game files. DXIL validation with Windows SDK 10.0.26100.0 x64 dxil.dll 1.8.2502.11. PR head merged cleanly onto origin/main 13f91caee25f2fdf2c062be5f7a27f058e51cbca. **Tests (`cargo test --no-fail-fast -p victory-shader`)** - `origin/main` baseline: 267 passed, 3 failed, 3 ignored. - With this PR: 268 passed, 3 failed, 3 ignored (+1: `gfx10::sp3::tests::ds_wrap_reads_both_data_operands`). - The same 3 failures as on `origin/main`, unrelated (`a_mask_joined_with_data_at_a_uniform_loop_is_its_number`, `gathers_at_a_level_match_the_hardware`, `permutes_read_the_lane_named_and_zero_from_lanes_left_out`; they compare against hardware lane results and fail on WARP). **Negative control:** with the `ds_wrap_rtn_b32` clause disabled, the new test fails (`ds_wrap_rtn_b32 v8, v2, v4 offset:16` instead of `... v2, v4, v6 ...`). **Lint:** `cargo clippy --all-targets -- -D warnings` clean. `cargo fmt --check`: no new hunks (891 on main, 891 with the PR). Note: `cargo fmt --check` is already red on `origin/main` here (891 hunks, none from these PRs), so I compared per-file hunk counts against that baseline. **Review:** read the full diff. The change is minimal and the test matches the described operand semantics (DATA0 subtracted, DATA1 added). No game files, dumps, shader names, or retail hashes. AI disclosure: this verification was done by Claude Code (Claude Sonnet 5.5).
Author
Owner

@⁠Marvisak on GitHub · 2026-11-25 23:21 UTC · original

Automated triage for the maintainers.

This PR adds ds_wrap_rtn_b32 to the two-data-operand branch in Instruction field decoding (crates/victory-shader/src/gfx10/fields.rs), so DATA1 is printed and reported as a VGPR read. This matches the RDNA2 ISA (the result uses both DATA and DATA2) and llvm-mc's gfx1030 disassembly quoted in the new ds_wrap_reads_both_data_operands test. The opcode is not lowered yet, so nothing that translates today changes. CI passes.

This is a recommendation for a maintainer to look, not an approval.


Generated by Claude Code

**@⁠Marvisak** on GitHub · 2026-11-25 23:21 UTC · [original](https://github.com/Marvisak/VIctory/pull/2789#issuecomment-7177450903) <!-- victory-triage v1 head=6520dbafb6f31d4b0e074a0d47c8715c1fc4d1bf verdict=merge-candidate at=2026-11-25T23:21:25Z --> Automated triage for the maintainers. This PR adds `ds_wrap_rtn_b32` to the two-data-operand branch in `Instruction` field decoding (`crates/victory-shader/src/gfx10/fields.rs`), so DATA1 is printed and reported as a VGPR read. This matches the RDNA2 ISA (the result uses both DATA and DATA2) and llvm-mc's gfx1030 disassembly quoted in the new `ds_wrap_reads_both_data_operands` test. The opcode is not lowered yet, so nothing that translates today changes. CI passes. This is a recommendation for a maintainer to look, not an approval. --- _Generated by [Claude Code](https://claude.ai/code)_
This pull request can be merged automatically.
This branch is out-of-date with the base branch
You are not authorized to merge this pull request.
View command line instructions

Checkout

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

Merge

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