Iter 19: Reuse same-page directory looks in ray walkers (VICTORY_MEMORY_NEAR) #4
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/4"
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-11-28T00:49:52Z.
Summary
Ports
fxceless/victory-forkcommitf299fba'sVICTORY_MEMORY_NEARoptimization into MiniVI:within > 0xFF80(only ~1 in 1,024 nodes crosses a page boundary), eliminating the second 16 MiB directory lookup, fault check, and bindless heap pick on every step of every ray.Lower::memory_near/Lower::memory_near_words/Lower::look_beforeso consecutiveglobal_load_*instructions reading from the same 64 KiB page reuse the earlier view handle and offset calculation.VICTORY_MEMORY_NEAR=0restores per-load directory lookups for A/B comparison, and the shader cache keys onVICTORY_MEMORY_NEAR.intersect.rs,intersect_tests.rs,shader_cache.rs, and non-overlapping sections oflower.rs/emit/mod.rs— zero conflicts with open PR #1, PR #2, and PR #3.Rig Specs Tested On
33,304,932KiB visible)10.0.26300), NVIDIA driver32.0.16.2124Run Settings & Profile
diag/release@93970edVICTORY_EARLY_DEPTH=1,VICTORY_NAN_SCRUB=1)intersect_testsBVH shader executionVICTORY_*Overrides: default (VICTORY_MEMORY_NEARunset -> enabled)Measurements & Verification
0cargo clippy --workspace --all-targets -- -D warnings(0 warnings)cargo clippy --workspace --all-targets --all-features -- -D warnings(0 warnings)cargo test -p xtask(6 passed) +xtask policy(294 files ok)cargo test -p victory-shader --lib intersect_tests -- --test-threads=1(7 passed; 0 failed, includingmemory_near_toggles_second_half_fast_path_and_keeps_results_identicalon hardware GPU & WARP across 64 KiB page boundary)cargo test -p victory-gpu --lib shader_cache -- --test-threads=1(2 passed; 0 failed)Imported from Androtim/MiniVI. Originally posted by Androtim on 2026-11-28T01:07:36Z.
Verification summary for
feat/iter19-memory-near-ray-walkers@93970ed:46089977893completed withsuccess(after rerunning the earlier unrelatedvictory-gpuviews_off_their_elements_get_a_copy_of_their_bytesaddress-reuse flake).cargo +1.98.1-x86_64-pc-windows-gnu run -p xtask -- policy:asset policy: 294 files okcargo +1.98.1-x86_64-pc-windows-gnu test -p xtask:6 passed; 0 failedcargo +1.98.1-x86_64-pc-windows-gnu clippy --workspace --all-targets -- -D warnings:0warningscargo +1.98.1-x86_64-pc-windows-gnu clippy --workspace --all-features --all-targets -- -D warnings:0warningscargo +1.98.1-x86_64-pc-windows-gnu test -p victory-shader --lib intersect_tests -- --test-threads=1:7 passed; 0 failed(includingmemory_near_toggles_second_half_fast_path_and_keeps_results_identicalexecuting on hardware GPU & WARP across a 64 KiB page boundary)cargo +1.98.1-x86_64-pc-windows-gnu test -p victory-gpu --lib shader_cache -- --test-threads=1:2 passed; 0 faileddiag\victory.exe,diag\victory_sm.exe, andrelease\victory.exeintoD:\victory-build\miniviwithRUSTFLAGS='-C link-self-contained=yes'(non_system_mingw_dlls=0on all 3).warm-iter19.log,VICTORY_EARLY_DEPTH=1,VICTORY_NAN_SCRUB=1,VICTORY_MEMORY_NEARdefault enabled):25,759 shaders in the cache, 226 do not translatein697 s(exit=0) — zero regressions across the entire corpus (198container metadata-only,23wave64,5descriptor-read-only-as-data).Imported from Androtim/MiniVI. Originally posted by Androtim on 2026-11-28T02:04:45Z.
Automated triage for the maintainers (not an approval).
Verdict:
needs-gpu-test· CI (check):passingReview Summary
This PR ports the
VICTORY_MEMORY_NEARoptimization for ray-walking shaders:crates/victory-shader/src/emit/intersect.rs: ReplacesLower::bvh_second_halfwithLower::bvh_second_words, keeping the second 64 bytes of a 128-byte box node on the first half's already-looked-up 64 KiB page and view whenever(low & 0xFFFF) <= 0xFF80, and only falling back to a second directory lookup (bvh_memory(..., top = false)) when crossing a page boundary.bvh_memoryat the top ofintersect(top = true) routes throughLower::memory_near.crates/victory-shader/src/emit/lower.rs: FactorsLower::memoryintomemory_page,memory_entry, andmemory_view, and addsmemory_near,memory_near_words,memory_handle, andlook_beforeto reuse dominating same-page directory lookups within the current loop body for non-spilled (!is_spilled)global_load_*instructions.crates/victory-shader/src/emit/mod.rs&crates/victory-gpu/src/shader_cache.rs: Addsmemory_near()(default-on, opt-out viaVICTORY_MEMORY_NEAR=0),TEST_MEMORY_NEARfor unit tests, and keys the shader cache onVICTORY_MEMORY_NEAR.crates/victory-shader/src/emit/intersect_tests.rs: Addsmemory_near_toggles_second_half_fast_path_and_keeps_results_identical, covering both same-page and cross-page (within = 0xFFC0) 128-byte box nodes.Checks & Edge Cases
within > 0xFF80(pred::IUGT) accurately identifies when a 128-byte node (within..=within+127) crosses a 64 KiB page boundary.memory_nearandmemory_near_wordsgate reuse onsame && look.there, ensuring unmapped pages still executememory_entryunder the current laneguard. Inbvh_second_words, an unmapped first half has already noted the page fault and returnsmapped = false, which propagates through thetherephi intobvh_boxes.look_beforerestricts reuse tocur_irand its dominators up to the innermost loop header (self.counters), so hoistingmemory_handle(look.home, look.slot)into an earlierLook'shomeblock is dominated bylook.slotand dominates the reusing load.bvh_second_wordsandbvh_memory(..., top = true)->memory_near, while theglobal_load_*->memory_near_wordsreuse path has no dedicated unit test (only offline corpus/runtime coverage).Verdict
CI is passing and the shader IR/DXIL logic looks solid, with no conflicts or security concerns. Because this changes default-on DXIL codegen for ray-tracing traversal and bindless handle placement (
memory_handle/memory_near_words), a quick local real-GPU in-game ray-tracing smoke test (comparing default vsVICTORY_MEMORY_NEAR=0) is recommended before merging. (Automated review; not formal maintainer approval.)Generated with Antigravity CLI (
agy).Imported from Androtim/MiniVI. Originally posted by Androtim on 2026-11-28T21:11:18Z.
Real-GPU Playtest Report (Combined Build 1 Stack — RT ON)
Tested in combined Build 1 (
origin/main+ Build 1 PRs including#3, #4, #7, #10) on NVIDIA GeForce RTX 4060 Ti (8 GB), Windows, Series S (quality-720p, DLSS Quality,-RayTracing):1c-build1-rt.log) — 0 crashes, 0 DRED resets, clean exit.7.6 fps(132.2 ms/frame,4,022draws/frame).12,653pages /790 MBacross13arenas,98build dispatches/frame).0"a shader reads view addresses without a view heap set"warnings.1,374DLSS upscalings (0failed); VRAM stayed bounded (6,460 MBin use,554 MBfree across27texture blocks).