Repository navigation
Conversation
Phase 1 shader optimizations (pure victory-shader, zero RT-off runtime impact): - Move `bvh_memory` inside both the lane guard and `kind < 6` check so inactive lanes and kind 6/7 misses never touch `SLOT_MEMORY` or enter the non-uniform descriptor waterfall. - Fetch bytes 0..63 (16 dwords, align=16) once before branching on box vs triangle and select triangle vertices directly in registers from `first_all[0..15]`, eliminating dependent `id -> vertex` waterfall loads. - Evaluate AABBs sequentially (`bvh_test_box`) and test boxes 0..1 before loading the second 64 bytes of 32-bit box nodes to cut live VGPRs/PHIs. - Wrap unguarded single `global_load_*` on `MEMORY` in `begin_guarded`, coalesce consecutive same-base/same-guard `global_load_*` runs within 256 bytes via `try_global_load_cluster` (with single-page check and cross-page fallback), use wave-uniform heap handles for `s_load_dword*` (`memory_smem`), and replace `URem` with power-of-2 bitmask + select for `SLOT_FAULTS` hashing. Adapted from GPL-3.0 upstream `ReTerryDavis/ReVIctory` commit `925ac0a` preserving MiniVI's `memory_near`, `VICTORY_MEMORY_NEAR`, and kind 6/7 `0xFFFFFFFF` semantics.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.)