Shaders: a relative move's program is built at its full range only if no bound is proven #2079
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!2079
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-2079"
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?
@0xkn0wh3r3 on GitHub · 2026-11-25 04:25 UTC · original
0xkn0wh3r3:shader/range-build-lazy→main· +48 −14 · 2 files · 1 commits · openThe problem
Translating a program with a relative move (
v_movrel*orv_swaprel) cost nearly three times as much inrange::buildas the same program without one.range::buildbuilt the program with every relative move at its full range, and its structure, before trying to prove bounds. It uses that full-range program only where no bound is proven (and to give up at once where its structure fails). The bounded rounds then build the program and its structure again, so the first build was mostly wasted work.Synthetic 256-block program: 20.7 ms with a relative move against 7.2 ms without.
The fix
ir::build_decodedtakes the decoded list, so a program without relative moves decodes and builds once as before, and each round saves a decode.One case changes: a program whose full-range structure fails but whose bounded form proves every bound now translates instead of being refused. The bounds hold by the same induction; only the fallback was refused.
Measured with synthetic wave32 compute programs, release build, three rounds each:
The DXIL is byte-identical for every program (FNV hash of the output).
Testing
cargo test -p victory-shader --lib -- --test-threads=1on an RTX 5070 Ti (driver 621.24), includingrange.rs's bound tests: all pass exceptemit::stride_tests::a_heap_buffer_read_by_element_takes_the_views_stride,emit::stride_tests::a_heap_buffer_read_where_no_buffer_view_is_reads_zerosandemit::synthetic_tests::gathers_at_a_level_match_the_hardware, which fail the same way onmainon NVIDIA (the test host's views, #1835).cargo clippy -p victory-shader --all-targets: clean.v_movrels_b32indexed by a bounded M0).Not covered / Related
range.rs(operand access, shift bounds); this touches onlybuild.@sinan-cmyk on GitHub · 2026-11-25 09:07 UTC · original
Offline measurement on a retail dump
Result: no count change against
main.I merged head 955cde3d onto
main940d32f(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: 23,918 onmain, 23,918 with this PR.No program changes its failure reason. The count shows that the change rejects nothing on this data. It does not show whether the output is right.
No shader names or data are included, per the asset policy. AI-assisted (Claude Code).
@Marvisak on GitHub · 2026-11-25 10:30 UTC · original · edited 2026-11-26 01:20 UTC
Automated triage for the maintainers.
Merge candidate (unchanged). The push since the last triage (
955cde3to99d33d4) is a rebase onto currentmain. The diff tocrates/victory-shader/src/range.rsandcrates/victory-shader/src/ir.rsis identical, and it merges cleanly.range::buildfinds relative moves in the decoded list and decodes once (ir::build_decoded, whichir::build/build_boundednow delegate to with the same arguments). It builds the full-range program only when the bounded rounds prove nothing. The one behaviour change, translating a program whose bounds are all proven even though its full-range structure fails, follows from the induction in the function's doc comment. The retail census in the comments showed no change in validated counts.CI: passing (
check).Recommending a look, not approving.
Generated by Claude Code
@DenRakEiw on GitHub · 2026-11-25 04:31 UTC · original · approved these changes
Verified locally merged onto
origin/main(940d32f, Windows 11 x64, Rust 1.98.1 MSVC):cargo test -p victory-shader --lib range::— 3 passed, 0 failedcargo clippy -p victory-shader --all-targets— 0 warningscargo xtask policy— ok (183 files ok)Clean refinement avoiding full-range rebuilds when a relative move's index bound is already proven. Looks good.
AI-assisted (Gemini 4 Neon).
@catminou4 on GitHub · 2026-11-25 04:34 UTC · original · approved these changes
Tested locally: macOS arm64, rustc 1.98.1, PR head merged into main
940d32f69b,cargo test -p victory-shader --locked.144 passed / 0 failed. Relative move's program built at its full range only when needed — movrel program-size fix.
@fuzeofficlal on GitHub · 2026-11-26 19:50 UTC · original · approved these changes
Looks good to me — clean optimization avoiding unnecessary full-range IR/structure builds unless bound inference fails to prove a bound, while sharing a single
gfx10::decodeacross rounds.Verified locally on Windows 11 with head
99d33d41cleanly merged ontomain(63bcca43):crates/victory-shader/src/ir.rs:138-153andcrates/victory-shader/src/range.rs:41-99:range::buildscans the decoded instruction list once for relative moves, restrictsassumedto reached instructions on round0, preserves exact endpoint bounds (vgprs.min(u16::from(reg) + u16::from(m) + 1)), and falls back to full-rangeir::build_decoded(..., &HashMap::new())atrange.rs:97only when bounds cannot be proven.cargo run -p xtask -- policy(191 files ok) andcargo clippy --locked -p victory-shader --all-targets -- -D warnings(both default and--all-features) pass.cargo test --locked -p victory-shader --lib ir:::9 passed; 0 failed(0.12s).cargo test --locked -p victory-shader --lib range:::3 passed; 0 failed(0.00s).rustfmt --edition 2024 --checkpasses onrange.rs, and the newly added lines inir.rs(144-152) are formatting-clean (only pre-existing lines340and841inir.rsreport diffs).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.