Shaders: out-of-range relative VGPR reads return v0 #3602
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!3602
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-3602"
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?
@Moon0755 on GitHub · 2026-11-27 20:13 UTC · original
Moon0755:fix/movrels-oob-v0→main· +29 −2 · 4 files · 1 commits · openPer AMD RDNA2 ISA §3.6.1 (Out-of-Range behavior:
vgpr >= vgpr_size->VGPR0is used), an out-of-range source VGPR index in a relative move (v_movrels_b32,v_movrelsd_b32,v_movrelsd_2_b32) readsv0rather than constant0. Onmain,Lower::valuinitialized the dynamic select chain with0andir.rsdid not record a read dependency onv0.Changes
crates/victory-shader/src/emit/lower.rs(520,768bytes /+205vsmain,3,520bytes below the524,288limit):indexed_srcselect chain frominst.read(Reg::V(0))when present (falling back to0only if absent).crates/victory-shader/src/ir.rs(effects):(Reg::V(0), NONE)torforsrc_indexedmoves only when*reg != 0andm0_max.is_none_or(|m| u16::from(*reg) + u16::from(m) >= vgprs), matchingindexed'svgprsbound and avoiding spuriousv0dependencies on bounded in-range moves or duplicatev0entries whensreg == 0.crates/victory-shader/src/range.rs:a_bound_must_survive_what_the_bounded_moves_writeto expectv0in the unbounded (N = 4) case while keeping the bounded (N = 6) case unchanged.crates/victory-shader/src/emit/valu_tests.rs:movrels_outside_the_register_array_reads_v0usingM0 = 255(v[5 + 255] = v[260], independent of the#1340M0[7:0]width question).Verification
main): https://github.com/Moon0755/VIctory/actions/runs/46061365377 (failure— solely onmovrels_outside_the_register_array_reads_v0:left: 0,right: 3405691582)gemini/ci-movrels-oob-v0,2abede7): https://github.com/Moon0755/VIctory/actions/runs/46061360162 (success— full workspace CI + both Clippy builds clean)2abede7):movrels_outside_the_register_array_reads_v0(1/1),relative_moves(2/2),range::tests::(3/3), both Clippy configs, andcargo xtask policy(191 files ok) clean.M0[7:0]width dispute (#1340), separate runtime tests forv_movrelsd_b32/v_movrelsd_2_b32/v_swaprel_b32,v_movreldOOB write drop,dxil.dll1.7, game files. Synthetic tests only (AI-assisted).— Devin & Neon
@oni-swr on GitHub · 2026-11-27 20:29 UTC · original
Verification of head
2abede7eagainst base main63bcca43(heads/base re-checked unchanged before testing).Hardware: Windows 11 Pro 26200, WARP only (no physical GPU); dxil.dll 1.8.2502.11 (SDK 26100).
Tests (
cargo test -p victory-shader): head 299 passed / 4 failed / 3 ignored; base 298 passed / 4 failed / 3 ignored. The 4 failures are identical on base and head (synthetic_tests that need a wave-32 pipeline or hardware-specific gather behaviour, unsupported on WARP), pre-existing and unrelated. The new testmovrels_outside_the_register_array_reads_v0and the updatedrangetest pass on head.Control: base plus only this PR's test hunks (valu_tests.rs, range.rs): both
movrels_outside_the_register_array_reads_v0andrange::tests::a_bound_must_survive_what_the_bounded_moves_writefail (6 failed vs 4 on base), so the tests detect the missing behaviour.Clippy:
cargo clippy -p victory-shader --all-targets -- -D warningsclean on head.Review: no defects found. lower.rs starts the select chain from v0 so an index past the program's registers reads v0. ir.rs adds a v0 read dependency when the source is M0-indexed, reg != 0 and the bound is unknown or can reach the end of the VGPRs, which is conservative and correct. A harmless over-approximation applies to v_swaprel_b32, which shares the dependency but has no lowering change. The range.rs expectation adds v0 to the second index's reads, consistent with that.
Size: lower.rs 520,768 bytes (main 520,563), under 524,288. Textual merge of #3597 + #3602: clean, 521,714; with #3587: 522,154; with #2997 too: clean but 525,571, 1,283 bytes over the limit.
AI-assisted (Claude Sonnet 5.5)
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.