perf(shader): per-barrier UAV fence elision, aligned 16-bit buffer fast path, and exact integer peepholes #4037
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/4037"
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 trustno1-coder/VIctory-NVIDIA. Originally posted by jarvixaiassistant-glitch on 2026-11-30T15:03:21Z.
Summary
Three self-contained, exact
victory-shadercompiler optimizations (zero floating-point behavior changes, zero runtime coupling, minimal+15/-9lines inlower.rs):Per-barrier UAV memory-fence reachability (
emit/barrier_uav.rs)s_barrieremitteddx.op.barrierbit2(UAVMemoryFence/MEMBAR.GLdevice stall on NVIDIA) — andself.memory_fence()onhalf_meet— on everys_barrierwhenever whole-shaderwrites_uavswas true.barrier_needs_uav_fence) computing the exact(block, inst)s_barriersites reachable from any UAV store/atomic (Image/Buffer/Smemstore/atomic,global_*non-load,flat_*store/atomic) without crossing an intervening emitteds_barrier.1 | 8(GroupSync | TGSMFence) instead of1 | 2 | 8, while preserving bit2across loops, branch joins, and suppressedno_barrierblocks.Single-dword fast path for 2-byte aligned 16-bit buffer loads/stores (
lower.rs,bitcode/opt.rs)Module::maybe_set(v, depth)conservative known-bits analysis (preserving guaranteed trailing zero bits throughAdd,Sub, andMuleven across modular wrap-around, e.g.(idx << 1) + 4,(idx * 6) + 2).bits == 16andmaybe_set(byte, 6) & 1 == 0,within = byte & 3is guaranteed0or2(never3), so a 16-bit access cannot straddle a 4-byte boundary.load_subword()emits a single dword load (omitting the second load + select) andbuffer_store_shortomits the second guardedatomicBinOppair.Exact bit-level unpack-of-pack & equality-compare peepholes (
bitcode/opt.rs)maybe_set: drops dead sides of(x | y)/(x ^ y)underAnd,LShr,Shl, andTrunc(e.g.((x & 0xFFFF) | (y << 16)) & 0xFFFF -> x & 0xFFFF,>> 16 -> y & 0xFFFF,trunc(x | (y << 16), i16) -> trunc(x, i16)).Cmp(EQ|NE)folding overXor/Sub/Add:(x ^ y) ==/!= 0 -> x ==/!= y,(x - y) ==/!= 0 -> x ==/!= y,(x ^ k1) ==/!= k2 -> x ==/!= (k1 ^ k2),(x + k1) ==/!= k2 -> x ==/!= (k2 - k1).Verification (Windows 11,
VICTORY_WARP=1)cargo clippy -p victory-shader --lib --locked -- -D warnings: 0 warnings.xtask policy --staged:asset policy: 3 files ok.VICTORY_WARP=1 cargo test -p victory-shader --lib --locked -- --skip hw_tests: 528 passed, including all 4 newbarrier_uavCFG unit tests,maybe_set_alignment_and_unpack_cmp_peepholes,cbv_byte_and_halfword_loads_read_the_addressed_bytes, andevery_pass_leaves_what_random_programs_storerandomized parity fuzzing. (The 10 hardware-onlyWaveSize(32)tests failed only becauseVICTORY_WARP=1forces 4-lane WARP, which refusesWaveSize(32).)GPL-3.0-or-later, zero game data / zero RVAs.AI-assisted: yesImported from trustno1-coder/VIctory-NVIDIA. Originally posted by trustno1-coder on 2026-12-01T18:46:58Z.
Closing this as part of moving main to the texture and video-memory rework (v2026.12.01.01-test). A lot of the code changed, and this pull request no longer applies cleanly to it; it would need to be rewritten against the new main rather than rebased. Thank you for the work. If the change is still needed, please open a new pull request based on the current main.
Pull request closed