feat(victory-shader): implement s_movrels_b32 and s_movreld_b32 lowering #608
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/608"
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 Amit89-beep on 2026-11-24T05:29:41Z.
Summary
Implements IR lowering and DXIL emission support for GFX10 scalar relative-indexing move instructions (
s_movrels_b32ands_movreld_b32) invictory-shader, replacing the previousShaderError::Unsupportedpath.Changes
crates/victory-shader/src/ir.rs):s_movrels_b32(sdst = sgpr[src_base + m0]) for relative scalar source reads indexed byM0.s_movreld_b32(sgpr[dst_base + m0] = ssrc) for relative scalar destination writes indexed byM0.M0offsets cannot produce out-of-bounds SGPR accesses or invalid DXIL IR.M0offsets for boths_movrels_b32ands_movreld_b32, verifying round-trip register updates and DXIL emission/validation.Verification
cargo fmt --checkcargo clippy -p victory-shader --all-targetscargo test -p victory-shaderImported from Marvisak/VIctory. Originally posted by Lyrnc on 2026-11-24T06:02:15Z.
RDNA2 hardware check of the two rules: they match.
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
s20..s35with distinct values, sets M0, runs one instruction and reads all 16 back. RDNA2 desktop silicon, not the console's. No game data.s_movrels_b32 s22, s21s_movreld_b32 s22, s21So
sdst = s[src + M0]ands[dst + M0] = srcwith the whole M0, as here. Nothing else in the window changed.Out of range: with M0 =
0x00010000or0x41,s_movrels_b32read values that are none of the window's (0x057a9400,0x35a00002), ands_movreld_b32changed nothing in the window. So the hardware gives no defined result there, and your clamping is a choice rather than a semantic.In case a follow-up adds the 64-bit forms: in the same runs
s_movrels_b64/s_movreld_b64rounded the index down to even (M0 = 1 behaves as 0, 3 as 2).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.
Imported from Marvisak/VIctory. Originally posted by catminou4 on 2026-11-24T10:19:48Z.
Review: COMMENTED
Conflicts with current main (
ffe310e) inlower.rs/bitcode.rs— needs a rebase.Static review: the M0-relative lowering handles static M0 (constant-folded via the new
Module::as_i32) and dynamic M0 (select chain over the reachable SGPR span), with the IR'seffectsextended so the span is tracked as reads/writes — therelative_sgpr_access_spans_up_to_106test covers that. Two things I'd want before approving:lowers(...)smoke tests — they prove translation, not values. A host test (like the valu suite) writing known SGPRs and checkings_movrels_b32/s_movreld_b32results for a few M0 values (in range, out of range, negative) would make this solid, especially the out-of-range-returns-0 behavior which I can't verify from the ISA docs alone.Rebase and I'll re-run.
Imported from Marvisak/VIctory. Originally posted by mercuryVM on 2026-11-24T11:26:18Z.
Review: APPROVED
Tested
481afd9on Windows 11, RTX 5070, MSVC:cargo test -p victory-shader -- --test-threads=171 passed.cargo clippy -p victory-shader --all-targetsis clean.victory translate --validate --pipelineson the local title executable still reports 12 of 12 emitted, validated and built into pipelines.SGPR[D] = SGPR[S0.addr + M0]andSGPR[D.addr + M0] = S0, with the full M0 as the offset (unlike the VOP1_2forms in #627).ir.rslists the same read and write sets, so liveness agrees with the lowering.shortcut:comment would make that explicit.AI-assisted (Claude Code).
Imported from Marvisak/VIctory. Originally posted by catminou4 on 2026-11-24T14:53:57Z.
Review: CHANGES_REQUESTED
The
s_movrels_b32/s_movreld_b32lowering itself reads correctly (M0 bounds-checked against the SGPR window, static-M0 fast path, dynamic select chain, destination read-modify-write preserved fors_movreld_b32), andModule::as_i32is a clean helper for it. Two blockers before this can land:1. Semantic conflict with main — does not compile after merge. Main's test helper is now
fn lowers(words: &[u32], rsrc2: u32)(the computersrc2/threads field), and this PR's five new calls still use the old one-argument form:Verified fix: pass
0asrsrc2(these tests don't exercise threads) —lowers(&static_rels, 0).unwrap();etc. With that one-token change on the merge with current main (ffe310e),cargo test -p victory-shader --locked(macOS arm64, rustc 1.98.1) → 96 passed / 0 failed / 1 ignored.2. Two existing tests are deleted with no replacement. The diff removes
packed_buffer_formats_by_numberandsmall_floats_widen_as_halves(plus thehalfhelper) fromlower.rs's test module — coverage of the packed buffer-format table and half-float widening — and they don't reappear in any other file of this PR. Unless that coverage moved somewhere I can't see, please restore them; thes_movrel_loweringaddition is no reason to drop unrelated tests.Windows note: the M0-relative behavior on hardware is
valu_tests-gated like the rest, so the Windows lane should confirm once this compiles.Imported from Marvisak/VIctory. Originally posted by alexdeliu on 2026-11-24T17:24:04Z.
Merged onto
main@ffe310eb, this PR (cc6b6984) no longer compiles its tests.crates/victory-shader/src/emit/lower.rs:7443(and 7455, 7466, 7478, 7490) calls thelowers(&words)test helper. Since25b0f888it islowers(words, rsrc2); main's tests pass0. Clippy also flagshalf_shiftas an unused import atlower.rs:7031.Checked with CI's steps (both clippy runs with
-D warnings,cargo test --workspace) on Windows 11, AMD RX 9070. Every open PR: https://gist.github.com/alexdeliu/ef9ef0ebc1776ff104b5aa8eaea18e87Imported from Marvisak/VIctory. Originally posted by Marvisak on 2026-11-25T00:26:03Z.
Automated triage for the maintainers. Closing because by our reading the change is incorrect or would break something that works today.
If this is mistaken, reply here with what was missed (or push a change and say so) and it will be looked at again. Thank you for the contribution.
Pull request closed