shader: hoist flat load/store runs within overhang, sibling handles, and single-dword ds_write guard #174
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/vktory6--VKtory!174
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-174"
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?
@Mhyster on GitHub · 2026-12-02 00:04 UTC · original
Mhyster:opt/flat-load-run-and-shader-ir→main· +405 −33 · 5 files · 1 commits · openWhat
Reduces redundant
NonUniformtitle-window descriptor lookups and conditional guard branches invictory-shaderwithout changing console semantics, and bumpsTRANSLATOR_VERSIONfrom13to14:flat_load_run+memory_loads(crates/victory-shader/src/emit/memory_flat.rs):OVERHANG = (FLAT_VIEW_BYTES - (1u64 << FLAT_SLICE_BITS)) as i32directly fromemit::shader::FLAT_VIEW_BYTES(rule 3, single source of truth).memory_loadsatmin(offset)and omits the off-slice fix-up branch and extraself.memory(...)lookup for every part whose[off - off0, off - off0 + 4*n]lies within the 64 KiBFLAT_VIEW_BYTESoverhang of the anchor's 2 GiB slice.flat_load_runacross intervening non-memory-writing instructions (is_load_hoist_safe:s_nop,s_waitcnt*, purev_*/s_*ALU, and read-only loads) in the same block while staying under the same guard, outside whole-wave sections, withinOVERHANG, and verifying whenguard.is_some()that no skipped intervening instruction defines an old destination VGPR SSA value read by the hoisted load's guardedwrite.flat_store_run+memory_store_run(crates/victory-shader/src/emit/memory_flat.rs,lower.rs):global_store_dword*to the same SSA address VGPR pair (acrosss_nop,s_waitcnt*, and pure ALU whose defs do not feed a store's data VGPRs, withinOVERHANG, under the same guard) to share one writable title-window view and onebegin_guardedblock while preserving exact store order.crates/victory-shader/src/emit/bitcode/opt.rs):Module::hoist_sibling_handlesunderREUSE(up to 6 fixed-point rounds inModule::optimise): when both arms ofCondBr(_, t, f)(each with single predecessorb) construct the identical puredx.op.createHandleFromHeapordx.op.annotateHandlefrom operands dominatingb, hoists one copy intobso the nextmergededuplicates both arms.ds_writeguard merge (crates/victory-shader/src/emit/lower.rs):guardand LDS bounds checkinsideviaboth(self, guard, inside)into onebegin_guardedblock whenstores.len() == 1(matchingds_write_b8/b16).The reference
No direct vkd3d-proton or
crates/victory-gpucounterpart (this is our native GFX10 → DXIL lowering and IR pass invictory-shader). The 64 KiB slice overhang relies onemit::shader::FLAT_VIEW_BYTES(crates/victory-shader/src/emit/shader.rs) andgreenfield/vkback/src/flatviews.rs(view_range), which are kept in sync byflatviews::tests::flat_views_match_the_translator.Evidence
TRANSLATOR_VERSIONbumped13→14(crates/victory-shader/src/lib.rs).vktory6/mainvs this branch, all 19,161 containers insource.sqliteviatranslate-dir):19,161 / 19,161translated, 0 failures on both base and branch.CS).dxil-probe+spirv-val --target-env vulkan1.3passed 20/20 on the 20 largest changed CS shaders (OpBranchConditional:31,359 → 31,094,−265).CS/f22a76fc: DXIL107,080 → 94,892 B(−11.4%); SPIR-VNonUniform732 → 624(−108),OpLoad566 → 526(−40),OpBranchConditional419 → 346(−73),spirv-valOK.CS/3592426e: DXIL200,652 → 179,884 B(−20,768 B).CS/b58eb3ca: DXIL194,824 → 174,036 B(−20,788 B).CS/6d7fe774: DXIL220,180 → 204,028 B(−16,152 B).CS/a1b20bc4: DXIL126,588 → 126,568 B(OpBranchConditional341 → 337),spirv-valOK.cargo test -p victory-shader -p victory-formats -p victory-core -p xtask --locked(all passed, including newconsecutive_stores_share_one_view, updateda_load_that_writes_the_address_ends_the_run, andsibling_handles_hoist_to_branch_block).(cd greenfield && cargo test -p umem -p frame -p vkback --lib --locked && cargo test -p vkback --test policy --locked)(all passed).--locked -- -D warnings: native root crates,greenfield,greenfield/wine, andgreenfield/vkback/translateall clean.victory-shadertests under Proton (tests-shwin.sh).VKB_LAT+greenfield/tools/frec/frames.py).VK_LAYER_KHRONOS_validation).cargo xwin clippy(CI will verify).Checklist (docs/AGENTS.md)
docs/TASKS.mdnot edited (rule 29)unsafeblock has a// SAFETY:comment; no raw pointer around the borrow checker (rule 36)TRANSLATOR_VERSIONbumped if the translator's output changes (rule 27)@vktory6 on GitHub · 2026-12-02 15:28 UTC · original
Thanks, the logic looks sound where we traced it: the overhang reasoning matches
flatviews::view_range, and the hoist safety excludes stores, atomics, barriers and branches. But it is four translator topics in one PR (longer flat-load runs, store runs, sibling-handle hoisting, the single-dwordds_writemerge), and translator changes have the highest bar we have. Please send one PR per topic, each with:tests-shwin.sh);Heads-up: #198 and #206 also bump
TRANSLATOR_VERSION, so whichever lands later bumps it again.View command line instructions
Manual merge helper
Use this merge commit message when completing the merge manually.
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.