shaders: opt-in wave64→wave32 fold (VICTORY_WAVE_FOLDED) #125
No reviewers
Labels
No labels
accessibility
bug
documentation
duplicate
enhancement
good first issue
help wanted
invalid
question
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/ReTerryDavis--ReVIctory!125
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-124"
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?
@SovietBearz0r on GitHub · 2026-12-05 13:26 UTC · original
SovietBearz0r:longroad-wave-fold→main· +5412 −84 · 24 files · 1 commits · draftPort Darner/longroad's wave64→wave32 fold as an opt-in translator path:
VICTORY_WAVE_FOLDED=1(off by default).What
A console wave64 compute program becomes a wave32 program where host lane t runs console lanes t and t+32: VGPR twins, EXEC kept in a spare SGPR pair, every vector operation run twice; translated as wave32. Ported from longroad
526ec934(itself Darnere6245bf5):fold.rs(~1700 L),oracle64.rs(CPU 64-lane oracle, ~2000 L), the folded GPU/join tests, and thefolded()integration into structure/resource/lowering. Adapted to this tree: IR VGPR numbers widened tou16(MAX_VGPRS=512, opcode base table),gfx14/ir::machine_effects, hooks spread over the split lowering modules, cache keys on the switch/filters only when on,VICTORY_*names.Integration is conservative: attempted only inside main's
stuckwave64-compute block (Cs && wave64 && host_max_wave()==32), at the head of the non-exact phase of the retry ladder — after every exact wave32 form failed, before barrier-costing forms and approximate local waves, so it overrides none of main's safety decisions.VICTORY_WAVE_FOLDED_ONLY/_SKIPname filters withlightAtlasskipped by default;TRANSLATOR_VERSIONunchanged (default output unchanged).Not ported (honest scope): longroad's
VICTORY_EXACT64LDS-ordering layer and its oracle feed (needed before folding reflection programs relying on 64-lane LDS order);THREAD_TICKET(main takes 2-D/3-D console threads from an LDS counter already). The upstream doc file is gitignored here; provenance is in the commit/module docs.Verification (private target dir — the shared one served a stale cross-worktree binary once)
cargo test -p victory-shader --lib: 343 passed, 0 failed, 2 ignored (226 s); 19/19 folded tests pass, and they really dispatch on this machine's RX 9070 XT (wave32 D3D12 pipelines accepted, console semantics bit-for-bit); 5 also go through the integratedfolded()/emit()path.halves_round_tripand the new folded CPU-oracle test pass (16 worlds identical, 1024 memory words, 257 instructions), so the fold is validated on CPU here too; the title/refused-program digest tests skip honestly (needVICTORY_EXACT64_SHADERS/VICTORY_FOLD_CHECK_DIR).cargo test -p victory-dxil21 passed;cargo check -p victory;cargo xtask policy(443 files); clippy: only main's pre-existing lints.wide_by_default.all_lane_blockslacks longroad's extra waterfall-reads argument, so a few masks may refuse to fold (fallback, not miscompile).Source: Lesloo/longroad
526ec934/ Darnere6245bf5.Port longroad's wave64->wave32 "fold" onto main's IR and lowering, opt-in behind VICTORY_WAVE_FOLDED=1 (off by default; Darner's ladder had it on). A console wave64 compute program becomes a wave32 program where host lane t runs console lanes t and t+32: VGPR twins named through per-instruction VGPR bases (the IR's VGPR numbers widened to u16, MAX_VGPRS = 512), the console's EXEC kept in a spare SGPR pair, every vector instruction run twice; the result is translated as wave32 by the ordinary exact path. Cross-lane operations become exact: ballots, lane reads/writes, v_mbcnt, mask arithmetic, saveexec branches, LDS/barriers (one host wave per console wave). Source: Lesloo/longroad commit 526ec93466643bd2efb661b483c56cc376baaa7f ("Shader: console wave64 compute folded two lanes to a host lane (Darner's fold)"), itself ported from Darner (trustno1-coder, GPL-3.0-or-later, darner-shader e6245bf5). Both are GPL-3.0-or-later, as ReVIctory. Ported: crates/victory-shader/src/fold.rs (the rewrite), oracle64.rs (the CPU 64-lane oracle, test-only), emit/folded_tests.rs and emit/folded_join_tests.rs (19 GPU tests + a CPU-oracle test), the IR's u16 VGPRs and VGPR bases (gfx10::Instruction::vgpr_base, gfx10::opcode), and the lowering hooks for a folded program: FOLDED/with_folded and Lower::every_lane (lower/settings.rs, lower/mod.rs), the mask_dword "whole" test (lower/operands.rs), the read-join walk (lower/export.rs), and the permlane OP_SEL[2:3] relaxation (lower/valu.rs) that one folded test needs. Placement: at the head of the non-exact phase of emit()'s wave64 retry ladder. It only runs after every exact wave32 form failed, before the forms that cost group barriers and the approximate ones, so no safety decision of main's is overridden. VICTORY_WAVE_FOLDED_ONLY/_SKIP filter programs by name (lightAtlas skipped by default, as in longroad). The shader cache keys on the switch and the filters (victory-gpu/src/shader_cache.rs), only when on so existing caches keep their key. Not ported (longroad-only follow-ups): its VICTORY_EXACT64 LDS-ordering layer and oracle feed, and VICTORY_THREAD_TICKET as such (main already takes 2-D/3-D groups' console threads from an LDS counter). The porting notes (including the longroad docs/wave64-folded.md content) are kept out of the tree because ReVIctory gitignores /docs/; the module docs of fold.rs carry the summary and provenance. Tests (private CARGO_TARGET_DIR, isolated from the shared qol/target whose cross-worktree artifacts can collide): - cargo test -p victory-shader --lib: 343 passed, 0 failed, 2 ignored. Of these, the 19 folded tests and the folded CPU-oracle test pass, and the 19 really dispatch on this machine's RX 9070 XT (wave32 D3D12 pipelines are accepted) bit for bit against console semantics; AMD is not the intended target, so in-game NVIDIA verification is still owed. - oracle64: halves_round_trip passes; refused_programs_fold_exactly and title_programs_fold_exactly skip (they need title shader containers via VICTORY_EXACT64_SHADERS / VICTORY_FOLD_CHECK_DIR, which this checkout does not have). - cargo test -p victory-dxil: 21 passed. cargo check -p victory: ok. cargo xtask policy: 443 files ok. clippy -p victory-shader --all-targets and -p victory-gpu --lib: only main's pre-existing host.rs byte-grouping and victory-gpu lints, none from this change.@ReTerryDavis on GitHub · 2026-12-05 17:38 UTC · original
Marking this as draft for now. At +5,412 lines across 24 files (including widening
Reg::V(u8 -> u16)across IR/GFX10/lowering), this is a very large maintenance surface to carry onmainwithout any NVIDIA in-game A/B verification yet — especially whileVICTORY_EXACT64LDS ordering isn't included and known VGPR spills onlightAtlasstill need a hardcoded skip list. Happy to revisit once it has real NVIDIA in-game testing and frame-time/visual A/B results.github-bot referenced this pull request2026-12-05 19:35:21 +00:00
github-bot referenced this pull request2026-12-05 19:35:26 +00:00
github-bot referenced this pull request2026-12-05 19:35:33 +00:00
github-bot referenced this pull request2026-12-05 19:35:59 +00:00
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.