victory-shader: omit NonUniform on provably uniform title-memory handles #198
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!198
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-198"
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 07:30 UTC · original
Mhyster:opt/shader-uniform-memory-nonuniform→main· +204 −19 · 4 files · 1 commits · openWhat
Omits
NonUniformResourceIndexon title-memory descriptor heap handles (Lower::memory,Lower::memory_loads,Lower::root_memory) whenever the title address is provably uniform across every active lane of a host wave:non_uniform_valuesincrates/victory-shader/src/emit/lower.rs):st.masks,st.highs), de-waterfalled descriptor read/load (waterfall.reads,waterfall.loads), every VGPR value (Reg::V), and every scalar phi at the frontier of a per-lane branch (lane_regions) as potentially non-uniform, then propagates taint to a fixed point (treatingv_readfirstlane_b32outsidewaterfall.readsas wave-uniform, and conservatively tainting all multi-predecessor phis if any uniform branch condition becomes tainted).Lower::memory,Lower::memory_loads,Lower::root_memory):memory_smem(s_load_dword*by title address) passesuniform = truewhen both base SGPRs andsoffsetare absent fromnon_uniform.smem(s_buffer_load_dword*viaroot_memory) and constant-offset global loads through a root view passuniform = truewhen the dynamic offset andsoffsetare absent fromnon_uniformandinsideisNone.memory_flat,intersect.rs,buffer_*with VGPR offsets /inside.is_some()) keepnonuniform = true.TRANSLATOR_VERSIONfrom 13 to 14 (crates/victory-shader/src/lib.rs).Reproduces console wave-wide scalar loads (
s_load_dword*/s_buffer_load_dword*), allowing RADV/ACO to lower uniform title-memory accesses withoutv_readfirstlanewaterfall loops.The reference
crates/victory-shader/src/emit/lower.rs(Lower::handle,lane_regions):Lower::handlealready omitsNonUniformfor non-waterfallSource::Loaded,Source::Phi, andSource::Selectdescriptors (heap_handle_at(..., false, ...)), whileLower::memorypreviously hardcodednonuniform = truefor all callers including scalars_load_dword*and scalarroot_memory.Evidence
translate-diracross all 19,161 containers insource.sqlite):19,161 / 19,161translated with0failures on bothvktory6/mainand this branch.32compute shaders changed (by_stage={'CS': 32}), including ray-walking / BVH compute shaders (8e5d070d8d4793ea5864d1c3795c71c3,381ef16494cc782dd71de1090c34b2ab,f6e47efa50226beb5574b5038367bffe,a1b20bc47e3c9597942d18a198af9309).dxil-probe+spirv-val --target-env vulkan1.3): 32 / 32 (100%) of changed shaders passedspirv-valcleanly.NonUniformreduction across all 32 changed shaders:17,084 -> 16,790(-294NonUniformdecorations, ~98 eliminated waterfall loops), withOpLoadunchanged (13,065 -> 13,065, +0 instructions).crates/victory-shader/src/emit/lower.rs:uniform_smem_memory_load_omits_nonuniform_while_flat_keeps_itverifiess_load_dwordx2from uniform SGPRs yieldsnonuniform_handles == 0whileglobal_load_dwordfrom VGPRs keepsnonuniform_handles == 1.cargo test -p victory-shader -p victory-formats -p victory-core -p xtask --locked(241 passed, 2 ignored invictory-shader)(cd greenfield && cargo test -p umem -p frame -p vkback --lib --locked && cargo test -p vkback --test policy --locked)cargo clippy --all-targets --locked -- -D warningson root native crates,greenfield,greenfield/wine, andgreenfield/vkback/translate.victory-shadertests under Proton, live game / AMD GPU A/B frame timing (frames.py), and Vulkan validation run (house scene) could not be run in this session (no live game / GPU run performed);cargo xwin clippyruns in GitHub Actions CI.Checklist (docs/AGENTS.md)
docs/TASKS.mdnot edited, the fixed item named above (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. Dropping NonUniform where the address is uniform is a good idea, but a wrongly dropped NonUniform is silent wrong data on RADV, so the bar is high. Please:
lane_uniforminstead of adding a second taint pass (rules 3 and 33).is_uniform_valuelanded insidememory's doc comment, and both are garbled now.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.