Shaders: ds_wrap_rtn_b32 reads both of its data operands #2787
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/2789"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Imported from Marvisak/VIctory. Originally posted by lcg007xd-c on 2026-11-25T20:27:26Z.
What this fixes
ds_wrap_rtn_b32computestmp >= 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.I found it while diffing about 15.5k encodings with valid operands, covering every opcode of every encoding, between
gfx10::decodeandllvm-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_b32joins the two-data branch withcmpst/mskor. The lowering doesn't handle this opcode yet, so nothing that translates today changes.Tested (Linux, Rust 1.98.1)
gfx10::sp3::tests::ds_wrap_reads_both_data_operands, checked against llvm-mc's text. It fails without the change (v6missing) 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 --checkon both files: clean.🤖 Generated with Claude Code
Imported from Marvisak/VIctory. Originally posted by kotekompotek on 2026-11-25T20:37:44Z.
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.
Imported from Marvisak/VIctory. Originally posted by fuzeofficlal on 2026-11-25T20:46:57Z.
Reviewed and verified
d80aedfcon Windows 11 againstmain(13f91ca).name == "ds_wrap_rtn_b32"to the 2-data-operand branch infields.rs:314-320matches RDNA2 ISA (DATA0andDATA1), producing the expectedds_wrap_rtn_b32 v8, v2, v4, v6 offset:16disassembly and recording both VGPR source reads inir.rs, while leavingds_inc_*/ds_dec_*at 1 data operand.cargo test --locked -p victory-shader --lib -- gfx10::: 17/17 passed (includingds_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; cleangit merge-treevs13f91caand#2783.Imported from Marvisak/VIctory. Originally posted by oni-swr on 2026-11-25T20:58:45Z.
WARP/CPU verification of head
d80aedfc43bb539b4e0b95d682864fe5dde873b2Environment: 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/mainbaseline: 267 passed, 3 failed, 3 ignored.gfx10::sp3::tests::ds_wrap_reads_both_data_operands).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_b32clause disabled, the new test fails (ds_wrap_rtn_b32 v8, v2, v4 offset:16instead of... v2, v4, v6 ...).Lint:
cargo clippy --all-targets -- -D warningsclean.cargo fmt --check: no new hunks (891 on main, 891 with the PR). Note:cargo fmt --checkis already red onorigin/mainhere (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).
Imported from Marvisak/VIctory. Originally posted by AwsAli05 on 2026-11-25T23:15:44Z.
Review: COMMENTED
The focused disassembly test passed at the current
6520dbahead on Windows. This fixes the decoder's two source operands. The lowering still has nods_wrap_rtn_b32case, so this change is useful for register tracking and decompilation. Please keep the runtime description scoped to decoding, and consider asserting both virtual-register reads in the IR as well as their displayed names.AI-assisted review and test.
Imported from Marvisak/VIctory. Originally posted by Marvisak on 2026-11-25T23:21:30Z.
Automated triage for the maintainers.
This PR adds
ds_wrap_rtn_b32to the two-data-operand branch inInstructionfield 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 newds_wrap_reads_both_data_operandstest. 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
Imported from Marvisak/VIctory. Originally posted by DenRakEiw on 2026-11-26T00:47:55Z.
Review: APPROVED
Verified against
origin/main(63bcca4) on Windows 11 + NVIDIA GeForce RTX 5090 and WARP:ds_wrap_rtn_b32is clean and verified.cargo test -p victory-shader ds_wrap: 1/1 passed (ds_wrap_reads_both_data_operands).cargo clippy -p victory-shader --all-targets -- -D warnings: 0 warnings.cargo xtask policy: 192 files ok.Synthetic tests only (no game files used). AI-assisted (Gemini 4 Neon).
Imported from Marvisak/VIctory. Originally posted by fuzeofficlal on 2026-11-27T00:34:52Z.
Review: APPROVED
LGTM! Verified
ds_wrap_rtn_b32(0x034) against RDNA2 DS encoding: it takes bothDATA0andDATA1(subtractingDATA0or addingDATA1), there is no non-_rtnds_wrap_b32variant on RDNA2, and the0xD8D0_0010, 0x0806_0402test case accurately decodes and formatsds_wrap_rtn_b32 v8, v2, v4, v6 offset:16while IR tracks both data register reads.Checks passed:
rustfmt --edition 2024 --checkoncrates/victory-shader/src/gfx10/{fields.rs,sp3.rs}cargo xtask policy(191 files ok)cargo clippy -p victory-shader --locked --all-targets&--all-features(-D warnings)cargo test -p victory-shader --locked --lib gfx10(17/17 passed, includingds_wrap_reads_both_data_operands)Imported from Marvisak/VIctory. Originally posted by lcg007xd-c on 2026-12-01T13:32:03Z.
@greptileai Please review the latest changes.
Imported from Marvisak/VIctory. Originally posted by lcg007xd-c on 2026-12-01T14:24:06Z.
@Marvisak @Dukestar69 Please review this contribution when you have time.
@greptileai Please review the current changes.
View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.