shader: lower v_movrelsd_2_b32 and v_swaprel_b32 #498
No reviewers
Labels
No labels
accessibility
area: build
area: formats
area: gpu
area: loader
area: runtime
area: shader
bug
documentation
duplicate
enhancement
good first issue
gpu: amd
gpu: intel
gpu: nvidia
help wanted
host: wine
invalid
out of scope
question
request
run report
triage: confirmed
triage: has patch
triage: merge candidate
triage: needs info
triage: needs rebase
triage: needs work
triage: proposed close
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/Marvisak--VIctory!498
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-498"
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?
@NolanCotter on GitHub · 2026-11-24 04:08 UTC · original
NolanCotter:movrelsd2-swaprel→main· +209 −27 · 1 files · 2 commits · openDepends on #404 (shares the
lowers_ldstest helper; rebases to one commit once it lands).Summary
v_movrelsd_2_b32andv_swaprel_b32— the two M0-relative VGPR ops the IR already enumerates (ir.rs marks both(true, true)andv_swaprel_b32's src range as a write) but the emitter refused atinteger()'s fallthrough.read_at/write_atclosures and the plain movrel forms keep the whole-M0 index.v_swaprel_b32writes both operand ranges, so a register can carry two write tokens (reads resolve to the last):write_atpicks first/last token and seeds the old value from what an earlier chain wrote, which also makes a swap of equal indices a no-op.m0_split_relative_moveshand-encodesv[5+20] = v[1+10]/v[5+20] <-> v[1+10]with M0 = (20 << 16) | 10 feeding an LDS store; refused on main, lowers now.Test plan
cargo test -p victory-shader— 58 passedcargo clippy -p victory-shader— cleancargo fmt --check— cleanAI-assisted (Devin). Field split verified against the RDNA2 ISA opcode description (source M0[9:0], destination M0[25:16]); no game files used.
Generated with Devin
Each lane reads src0 of a lane in the other row of 16 of its 32-lane half, the pick taken from nibble i of the {src2, src1} selector. The lowering mirrors the whole-wave model wave.rs already uses for the op, through the same cross_lane/read_lane machinery as v_writelane_b32, and the console_lanes detector now covers the v_permlane family so host lanes are relabeled where the op appears. Generated with [Devin](https://devin.ai) Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>@Lyrnc on GitHub · 2026-11-24 05:53 UTC · original
RDNA2 hardware measurement of the M0 split: it matches this PR.
Setup. AMD Radeon iGPU of a Ryzen 7 9800X3D, gfx1036 (RDNA2), AMD driver 32.0.21042.62, Windows 11 Pro 26200. A HIP kernel (assembled by the AMD driver's amd_comgr) fills
v10..v25with distinct values, sets M0, and runs oneop v12, v11per run, for 11 M0 values. Reading back all 16 registers shows which one was written from which. RDNA2 desktop silicon, not the console's. No game data.v_movrelsd_2_b32 v12, v11v_swaprel_b32 v12, v110x000000000x000000010x000100000x000300020x000500030x000a00040x000700070x0000fc010x000204000xfc0200010x040000030x0000fc01,0x00020400,0xfc020001and0x04000003.v_swaprel_b32writes both registers, and with equal indices it changes nothing. That is the no-op yourwrite_attoken handling gives.v10..v25changed in any run.For reference, in the same runs
v_movrels_b32,v_movreld_b32andv_movrelsd_b32used the whole M0 as the index. With M0 =0x00010000the source is far outside the allocation, andv_movrels_b32read 0.AI use: Claude Code (Claude Opus 5.5) wrote the probes, ran them on the GPU above and drafted this comment; the numbers come from the hardware run.
@slint6614-dev on GitHub · 2026-11-24 10:42 UTC · original
Measured on the full retail shader pack (26,503 containers) with
victory translate --validate --pipelines(pipelines on an AMD RX 9070, Windows 11, dxil.dll from SDK 10.0.26100). Counts are emitted / validated / pipelines. Merged locally with current mainc7a5f49(main: CS 1440 / 1417).CS 1441 / 1418 (+1 validated); VS/PS and MS unchanged.
@catminou4 on GitHub · 2026-11-24 12:36 UTC · original
Triage note: this overlaps #627, which implements the same instructions (
v_swaprel_b32,v_movrelsd_2_b32, pluss_movrelsd_2_b32) withir.rseffects tracking and a round-trip test, and currently merges cleanly with main. This PR (#498) hasmergeable=falseagainst current main (ffe310e). Whichever the maintainer prefers, the other needs a rebase — flagging so review effort isn't duplicated.@DrDarkDK on GitHub · 2026-11-24 13:40 UTC · original
I reran the dynamic-M0 readback fixture from #775 on this PR’s head (
4f48c59). On native Windows 11,v_swaprel_b32andv_movrelsd_2_b32returned the expected values across all four M0 inputs per instruction on both RTX 4070 Ti (621.01) and WARP. The fixture sets M0 from a root constant and varies it between dispatches of the same shader. No adapter skips.m0_split_relative_movesalso passed. Synthetic tests only. AI-assisted testing and reporting.@Yaekai on GitHub · 2026-11-24 16:40 UTC · original
Independent verification on Windows 11 + NVIDIA RTX 3070 (Rust 1.98.1) at head
4f48c59:cargo test -p victory-shader --lib -- --skip valu_tests --skip waterfall_tests: 64 passed, 0 failed.cargo clippy -p victory-shader -- -D warnings: 0 warnings.1.0.2.1,--console series-s, 19-min world run): no regressions. Ready to merge once rebased onmain!@Marvisak on GitHub · 2026-11-25 00:21 UTC · original
Automated triage for the maintainers.
Needs rebase. This PR does not merge cleanly into current
main(ac2525d). Conflicting files:crates/victory-shader/src/emit/lower.rs.The content has not been reviewed yet; it will be once the branch is rebased onto
main.Generated by Claude Code
@andrewpozdnakov7-jpg on GitHub · 2026-11-25 11:39 UTC · original
I extracted the
v_movrelsd_2_b32portion of4f48c59onto940d32fin20828f1with the original Git author intact. The existing move code uses the source and destination M0 fields for this opcode. The separate swap PR #1569 merges cleanly with this branch.f150609reads back three destination registers for four synthetic M0 values.940d32frejected the instruction asUnsupported. On the rebase all 12 WARP results match, including differing source and destination offsets, unrelated M0 bits, and unchanged neighboring registers. All 29 VALU tests pass with Microsoft DXIL validation. Strict shader Clippy and staged asset policy pass.If you adopt the readback in a combined commit, please retain
Co-authored-by: andrewpozdnakov7-jpg <[email protected]>. ClaimView 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.Merge
Merge the changes and update on Forgejo.