shader: static Wave32 LDS alias & lane-private analysis for native Wave32 compute #1140
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/fxceless--victory-fork!1140
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-1140"
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?
@Vladimir-Human on GitHub · 2026-11-25 21:26 UTC · original
Vladimir-Human:shader/wave32-lds-disjoint→main· +3490 −142 · 4 files · 3 commits · openSummary
AI-assisted port of static Wave32 LDS alias/hazard proof analysis (
crates/victory-shader/src/emit/lds.rs) ontofxceless/victory-forkmain, unlocking native Wave32 execution on NVIDIA/32-wide GPUs for compute shaders whose LDS (ds_*) operations live inside control flow or use disjoint/lane-private addressing, while preservingwave64fallback whenever safety cannot be statically proven.Key Details & Soundness Guarantees
MAX_OFFSET = 1 MiB32-bit bounds (<4-byte unaligned vs>=4-byte dword collision guard, zero RMWs, acyclic!allregions, symmetric RAW/WAR/WAW).v_mbcntconsole_lane(group <= 64), aligned, sub-array split, non-wrapping, and cross-cluster disjoint.dstverification (is_primary_sop_dst/is_primary_valu_dst) prevents VOP3Bv.carry/Reg::Sccmisidentification as group-uniform values.c < cs.user_sgprs()+Input::GroupId, refusingscratch_wave_offsetand uninitialized SGPRs).!allregions contains_barrieror non-inline special SOP constants (c != 253).wave64_testspreserved intact.Verification (
86e93bb1c)git merge-tree --write-tree origin/main HEADagainst latestmain(c36971b2).cargo clippy -p victory-shader --all-targets -- -D warnings: exit 0, 0 warnings.VICTORY_REQUIRE_HW_GPU=1 cargo test -p victory-shader --lib emit::wave64_tests::lds_ -- --nocapture: 4 passed; 0 failed on hardware D3D12 (no skip).cargo test -p victory-shader --all-targets: 233 passed; 0 failed; 3 ignored (14/14emit::lds::tests::*).Co-Authored-By: AI Assistant
@GDKAYKY on GitHub · 2026-11-25 21:28 UTC · original
does this have improvement on frametime,fps or VRAM usage?
@Vladimir-Human on GitHub · 2026-11-25 23:10 UTC · original
@GDKAYKY Target and effect summary:
ds_*) operations sit inside control flow or per-lane offsets.emit/lds.rs) proves native Wave32 execution produces identical results. The exact full-frame FPS delta depends on how many active compute shaders in a given scene hit that Wave64 LDS fallback path, and hasn't been measured in a live title run yet.@HAL9000RELOADED on GitHub · 2026-11-26 09:29 UTC · original
RX 7900 XTX (RDNA3), driver 32.0.32015.7029, Windows 10 22H2,
86e93bbon main32b31f7+ #402 (Agility, WARP skips here).victory-shader234 passed, 0 failed; the 18 new tests pass, including the three*_execute_wave32_on_hardwareruns on the card.lds_*_execute_wave32_on_hardwareget 64 instead of 32,lds_shared_returning_atomic_stays_wave64gets 32 instead of 64).AI-assisted (Claude Code): tests run on my machine, text drafted with Claude.
@Vladimir-Human on GitHub · 2026-11-26 09:46 UTC · original
Pushed follow-up commit
d12852cincorporating live 32-lane NVIDIA review findings and diagnostic improvements:32-lane opt-in
VICTORY_LDS_WRITE_ONLY_OK=1+has_plain_read(emit/lds.rs):has_plain_readstrictly onKind::Read(ds_read*), distinct fromKind::Rmw(LDS atomics).host_max_wave() == 32andVICTORY_LDS_WRITE_ONLY_OK=1(off by default, always disabled on 64-lane hosts). When enabled on 32-lane hosts,!allwrite-only regions and!allLDS atomic regions with no plainds_read*are accepted for native Wave32, while divergents_barrier, unhandled DS instructions, and mixed regions with an explicit plainds_read*remain refused.Specific
VICTORY_WAVE_WHY=1refusal diagnostics (emit/lds.rs,emit/lower.rs):lds::Refusalvariants vialds::analyze(...)soVICTORY_WAVE_WHY=1accurately distinguishes overlapping plain writes, atomics with no plain LDS read, mixed regions with an explicit plainds_read*, divergent barriers, unhandled DS ops, and cyclic shared writes.Note on @GDKAYKY's question (frame pacing / NVIDIA skinning shaders):
WaveSize(64)is rejected by D3D12CreateComputePipelineState(E_INVALIDARG), which drops those dispatches (including skinning compute passes) or forces slower fallback paths. Proving more branched-LDS compute shaders safe for native Wave32 keeps those pipelines compiling and executing cleanly on 32-lane hardware without Wave64 software emulation overhead, directly helping frame pacing and rendering completeness on NVIDIA.Verification:
ds_read*, 32-lane vs 64-lane host gating, the 4-kernel lowering matrix (same-dword write-only, separate writes, overlapping read+write, disjoint read + writes), negatives_barrier/ds_nopchecks, andVICTORY_WAVE_WHYreason strings.cargo test -p victory-shader -- --test-threads=4: 235 passed; 0 failed; 3 ignored (including the 3 hardware D3D12 Wave32 LDS execution tests).cargo clippy -p victory-shader --all-targets -- -D warnings: 0 warnings.d12852c206toc629faf815@Dathinel on GitHub · 2026-11-26 20:16 UTC · original · edited 2026-11-26 20:17 UTC
At
c629faf, the CPU-side LDS analysis accepts a cross-lane byte alias in a partial workgroup. I compiled the PR's region_lane_private, injective_lane_disp and ranges_may_overlap functions in isolation with Rust and supplied two synthetic Access records. No GPU or game input is needed.Use threads = [n, 1, 1], no uniforms, uniform_tz = 32, console_lane = 0. The write has width 1, tid = [1,0,0], off = 0. The read has width 1, tid = [0,0,0], off = n-1. Thread n-1 writes the byte that every thread reads. The two accesses therefore cannot be proven lane-private.
For n=33 the aggregate write footprint is [0,33). The cross-cluster check passes 33 as an instruction width to ranges_may_overlap, which rounds the upper bound down to 32 on the aligned path. The final byte disappears. Compare the already-computed half-open footprint bounds directly at this call site, retaining the existing alignment guard, and add the 33-thread case as a regression. This reproduces the analyzer decision only. AI-assisted review.
CPU check of the proposed change: I compiled both versions of region_lane_private and enumerated byte writes at initial + stride * tid.x and a uniform byte read at offset r. Parameters were n=32..65 inclusive, stride in {1,2,4}, initial=0..3, and r=0..n*stride+4 inclusive. The oracle enumerated all n write addresses and checked whether any equaled r. Every thread reads r, so a match is cross-thread sharing.
Across 48,212 inputs the original accepted 442 sharing cases as private. Replacing only the cross-cluster ranges_may_overlap call with (a.min_lo < b.max_hi && b.min_lo < a.max_hi) reduced that count to zero. Conservative rejections of genuinely disjoint cases changed from 26,282 to 25,840, including 170 safe cases newly rejected. Bounding intervals can include holes between strided writes. These results cover byte accesses in this family only.
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.