Shaders: lane conditions along live phi edges are values, and each set is met once #2060
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/2062"
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 0xkn0wh3r3 on 2026-11-25T04:18:52Z.
The problem
Translating shaders with control flow spends time and allocations in one step that keeps repeating the same work.
Lower::live_edgeswalks every phi a lane reads, back through its incoming edges, carrying the last few branch conditions known along the path. Two costs:Vecfor those conditions, cloned for every edge and for the seen list.meet) whether some lane meets the conditions. Paths into one join ask again for the same sets.On a synthetic program of 256 blocks, 4,915 work items asked 3,047 times for 883 distinct sets.
The fix
Copyvalue (Known), not aVec.The walk and its answers are unchanged.
Measured with synthetic wave32 compute programs (divergent ifs, uniform loops, gathers) through
range::build,resource::track,io::raiseandemit_with, release build, two rounds each:emit_withon mainAllocations in
emit_withare down about 40%. 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): 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. Those fail the same way onmainon NVIDIA (the test host's views, #1835; #1887 fixes two of them here).cargo clippy -p victory-shader --all-targets: clean.Related
#999 changes
meetitself and other parts oflower.rs. This change touches onlylive_edges.Imported from Marvisak/VIctory. Originally posted by catminou4 on 2026-11-25T04:33:50Z.
Review: APPROVED
Tested locally: macOS arm64, rustc 1.98.1, PR head merged into main
940d32f69b,cargo test -p victory-shader --locked.144 passed / 0 failed / 2 ignored. Lane conditions along live phi edges as values — phi-edge condition lowering fix.
Imported from Marvisak/VIctory. Originally posted by DenRakEiw on 2026-11-25T04:36:24Z.
Review: APPROVED
Verified locally merged onto
origin/main(940d32f, Windows 11 x64, Rust 1.98.1 MSVC):cargo test -p victory-shader --lib emit::lower::tests::— 21 passed, 0 failedcargo clippy -p victory-shader --all-targets— 0 warningscargo xtask policy— ok (183 files ok)Clean memoization and value-based handling of lane conditions along live phi edges. Looks good.
AI-assisted (Gemini 4 Neon).
Imported from Marvisak/VIctory. Originally posted by sinan-cmyk on 2026-11-25T09:22:34Z.
Offline measurement on a retail dump
Result: no count change against
main.I merged head
a0163c26ontomain940d32f(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).
Imported from Marvisak/VIctory. Originally posted by Marvisak on 2026-11-25T09:25:43Z.
Automated triage for the maintainers.
Merge candidate.
This is a performance-only change to
Lower::live_edgesincrates/victory-shader/src/emit/lower.rs. The list of known branch conditions becomes a fixedCopyarray (Known, at mostMAX_KNOWN) instead of aVec. The result ofBools::meetis also cached per condition set for the walk.I checked that it behaves the same as before:
Known::anddrops the oldest condition just as the olddraindid.lenalways keep their initial value, so the derivedEq/Hashmatch the oldVeccontents.meet(structure.rs) takes&selfand starts a fresh budget on each call, so caching its answer cannot change results.The author reports byte-identical DXIL and about 5–10% faster
emit_with. A separate offline run in the thread found no change in validation counts. No other open PR changeslive_edges.CI: not run (no check runs on this head). A maintainer may need to approve the workflow run.
Recommending a look, not approving.
Generated by Claude Code