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
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.