perf(shader): coalesce BVH node fetches and global_load clusters (#339) #341
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/341"
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 Androtim/MiniVI. Originally posted by Androtim on 2026-12-02T14:05:11Z.
Part of #339 (Phase 1 — Software BVH & Shader Coalescing).
Summary
Pure
victory-shaderoptimizations adapted cleanly from GPL-3.0 upstreamReTerryDavis/ReVIctorycommit925ac0awhile preserving MiniVI'smemory_near,VICTORY_MEMORY_NEAR, and kind 6/7-1semantics (zero RT-off runtime impact):emit/intersect.rs):bvh_memoryinside bothbegin_guarded(guard)andkind < 6so inactive lanes and kind 6/7 misses never touchSLOT_MEMORY/SLOT_FAULTSor enter the non-uniform descriptor waterfall.16dwords,align = 16) once before diverging on box vs triangle (is_box).0..=4) in registers fromfirst_all[0..15]usingfirst_all[15], removing 4 dependentrawBufferLoad+ waterfall sequences per triangle test.bvh_test_box, consuming boxes0..=1before loading the second 64 bytes (bvh_second_words) to cut VGPR and PHI pressure.global_load_*clusters & memory lookup optimizations (emit/lower.rs):try_global_load_clusterto coalesce 2+ consecutive same-base, same-guardglobal_load_*instructions within 256 bytes into a single directory lookup and contiguousdwordx4rawBufferLoads (raw_load_words) with an exact 64 KiB page-boundary fallback.global_load_*(!memory_shares()) withbegin_guarded(guard).nonuniform = false) for scalars_load_dword*(memory_smem).URemwith a bitmask +selectfor power-of-2SLOT_FAULTShashing (MEMORY_FAULTS = 4096).emit/lower_tests.rs):global_load_cluster_coalesces_contiguous_loads_and_handles_page_cross(inspects coalesced 3-dwordmask=7rawBufferLoad, validates viadxil.dll, and verifies cross-page + same-page + inactive-lane results on hardware & WARP).smem_memory_load_uses_uniform_handle_and_validates(verifiesnonuniform_handles == 0anddxil.dllvalidation).Verification
cargo +1.98.1-x86_64-pc-windows-gnu xtask policy --stagedpassed.cargo +1.98.1-x86_64-pc-windows-gnu clippy --workspace --all-targets -- -D warningsand--all-featurespassed.cargo +1.98.1-x86_64-pc-windows-gnu test -p victory-shader --lib -- --test-threads=1: allbvh::tests(16/16),emit::intersect_tests(11/11), andemit::lower::tests(24/24, 1 ignored) passed (dxil.dll+ hardware RTX 4060 Ti + WARP). (Note: 3 unrelated pre-existing VS/GS/PS PSV0 tests fail locally only against Windows SDK10.0.22000.0dxil.dll; CI runswindows-latest.)Imported from Androtim/MiniVI. Originally posted by Androtim on 2026-12-02T14:33:36Z.
Architect Triage (
#339Phase 1 — CI46898570093GREEN, clean-room & GPL-3.0 attribution verified):victory-shaderdiff (emit/intersect.rs64-byte coalesced BVH fetch + register triangle extraction;emit/lower.rstry_global_load_cluster, uniformmemory_smemhandles, bitmaskSLOT_FAULTShashing; strong unit + hardware/WARP tests).emit/lower.rschanges (global_load_*clustering/guarding,memory_smem,SLOT_FAULTShash) also run on RT-off compute/graphics shaders, this needs a paired plain---release(no--features diagnostics) RT-off A/B vsmain(baf967fc+) confirming zero FPS/memory regression and0crashes/DRED, plus--features diagnosticsvisual PNGs before merge (per Directive #21).Imported from Androtim/MiniVI. Originally posted by Androtim on 2026-12-02T15:04:03Z.
Holding merge (
triage: needs work) per deep static audit routing (#282comment7349410307, P0/P1 findings #13, #14, #16, #17 routed to#339). Please resolve the flagged findings, re-verify CI, and run a paired plain---releaseRT-off A/B +--features diagnosticsPNG check before merge.Imported from Androtim/MiniVI. Originally posted by Androtim on 2026-12-02T15:07:08Z.
Automated triage for the maintainers (not an approval).
Verdict:
needs-rebase· CI (check):passingThis PR no longer merges cleanly into
main.To change the verdict: Rebase onto current
mainand resolve conflicts; CI and triage will run again automatically.Generated with Antigravity CLI (
agy).Imported from Androtim/MiniVI. Originally posted by Androtim on 2026-12-02T16:16:19Z.
Rebased onto \main\ (\
3efe907, resolving the \lower_tests.rs\ conflict) and resolved #282\ finding #16: added \uniform_scalars\ analysis in \crates/victory-shader/src/emit/lower.rs\ (using \ll_lane_blocks_native, shared \post_dominators/\ranch_region, RPO forward PHI convergence, and excluding \waterfall.reads, \waterfall.loads, \_readfirstlane_b32, divergent \Atom::Uniform\ branches, and loop-carried/divergent PHIs) so \memory_smem\ only uses \NonUniformIndex = false\ when all incoming scalar address words and \soffset\ are proven wave-uniform across active lanes, plus added \smem_memory_load_divergent_sgpr_keeps_nonuniform_handle\ covering both \_readfirstlane_b32\ and divergent-PHI branches. Verified \emit::lower::tests\ (\27 passed; 0 failed; 1 ignored), \emit::intersect_tests\ (\11 passed; 0 failed), workspace \clippy --all-targets\ (normal & --all-features), and \xtask policy --staged. Ready for CI and maintainer GPU A/B check.Imported from Androtim/MiniVI. Originally posted by Androtim on 2026-12-02T22:33:02Z.
Rebased cleanly onto
main(23901a5b), Deep Static Audit Pass #2 & Pass #4 verified clean, CI GREEN. Merging#339Phase 1 coalesced BVH node fetches &global_loadclusters tomain.