Shaders: mask M0[7:0] on v_movrel* and allow scalar/const src0 on v_movreld_b32 #1340
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!1340
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-1340"
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?
@AscilCH on GitHub · 2026-11-24 17:33 UTC · original
AscilCH:fix/v-movrel-m0-mask-8bit→main· +116 −6 · 2 files · 1 commits · openBugs
In
crates/victory-shader/src/emit/lower.rs, the M0-relative VGPR move instructions had two issues against the RDNA2 (GFX10.3) ISA:v_movrels_b32,v_movreld_b32, andv_movrelsd_b32compared the full 32-bitM0register instead ofM0[7:0](& 0xFF). On RDNA2, relative VGPR indexing only uses the low 8 bits ofM0; any non-zero bits inM0[31:8]causedv_movrels_b32to read0andv_movreld_b32/v_movrelsd_b32to silently drop writes.v_movreld_b32rejected non-VGPRsrc0operands withUnsupported { what: "an M0-relative move" }, even though onlyvdstis M0-indexed on RDNA2 andsrc0is any general VOP1 source (VGPR, SGPR, inline constant, or literal).Reproduction (Before Fix)
With a synthetic RDNA2 compute shader lowered to DXIL and executed on hardware (NVIDIA RTX 3050 6GB Laptop GPU, Windows 11) and WARP:
And lowering
v_movreld_b32 v1, s0orv_movreld_b32 v1, 42failed withUnsupported { what: "an M0-relative move" }.Fix
M0with0xFFbefore comparing against each VGPR offsetk.Operand::Vectoronsrc0only whenindexed_src(v_movrels_b32/v_movrelsd_b32); readv_movreld_b32src0vias(self, 0)?so SGPRs, inline constants, and literals work, and reject unsupported modifiers.dxil.dlltestemit::valu_tests::v_movrel_masks_m0_and_accepts_scalar_src0testingM0[31:8] != 0acrossv_movrels_b32,v_movreld_b32, andv_movrelsd_b32, plus SGPR and inline-constantsrc0onv_movreld_b32.Verification
Tested on Windows 11, NVIDIA RTX 3050 6GB Laptop GPU, WARP, and Windows SDK
dxil.dll:rustfmt --edition 2024 --checkonvalu_tests.rs: cleancargo xtask policy:154 files okcargo clippy --workspace --all-targets --locked -- -D warnings: cleancargo clippy --workspace --all-targets --all-features --locked -- -D warnings: cleancargo test -p victory-shader --locked -- v_movrel_masks_m0_and_accepts_scalar_src0 --nocapture --test-threads=1: passed (hardware + WARP +dxil.dll)VICTORY_WARP=1 cargo test -p victory-shader --locked -- --test-threads=1:121 passed, 0 failed, 1 ignored@marquezinii on GitHub · 2026-11-24 18:33 UTC · original
Ran on an RTX 5070 (desktop, driver 621.40, the only adapter), Windows 11 26300, Rust 1.98.1 at
89189ec.cargo test -p victory-shader --lib -- --test-threads=1 --nocapturegives 121 passed, 0 failed, 1 ignored.v_movrel_masks_m0_and_accepts_scalar_src0passes on the hardware adapter and WARP.A question on the main claim. The tests check the
M0[7:0]masking against the translation's own reference, so they show the lowering does what the PR intends, not what the hardware does. Which part of the RDNA 2 ISA document says onlyM0[7:0]is used for the relative VGPR index? The instruction descriptions I know write it asVGPR[S0 + M0]. A citation, or a native run like the D16 probes on #1437/#1441, would settle it. Thesrc0part (an SGPR or a constant as the source ofv_movreld_b32) is independent and looks right to me.@Marvisak on GitHub · 2026-11-25 01:23 UTC · original
Automated triage for the maintainers.
Needs rebase. This pull request conflicts with
main(conflicting:crates/victory-shader/src/emit/valu_tests.rs). It will be reviewed once it is rebased onto the currentmain.Generated by Claude Code
@sinan-cmyk on GitHub · 2026-11-25 01:48 UTC · original
Offline measurement on a retail dump, and the shader tests on Ada
Result: no count change against
main.Offline. I merged head
89189econtomainffe310e(clean merge) and ranvictory translate --validate --listonshaders.rpf(1.0.2.1), with dxil.dll 1.8.2502.11. I compared the result withmainprogram by program (25,889 programs). Validated: 21,724 onmain, 21,724 with this PR.No program changes its failure reason either. That is the expected result for a fix whose instructions sit behind the earlier failures on
main. The count shows that the change rejects nothing. It does not show whether the output is right.Tests: with the same merge,
cargo test --locked -p victory-shader --libpassed 121, failed 0. The bitcode benchmark is ignored, as onmain, where 120 pass. The run was on an RTX 4070 SUPER (Ada, 32-lane waves, driver 32.0.16.1088), the default adapter, withVICTORY_WARPunset.No shader names or data are included, per the asset policy. AI-assisted (Claude Code).
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.Merge
Merge the changes and update on Forgejo.