Iter 19: Reuse same-page directory looks in ray walkers (VICTORY_MEMORY_NEAR) #4

Merged
Androtim merged 1 commit from upstream-pr/4 into main 2026-11-28 21:16:59 +00:00
Androtim commented 2026-11-28 00:49:52 +00:00 (Migrated from github.com)

Imported from Androtim/MiniVI. Originally posted by Androtim on 2026-11-28T00:49:52Z.


Summary

Ports fxceless/victory-fork commit f299fba's VICTORY_MEMORY_NEAR optimization into MiniVI:

  • 128-byte BVH box node fast path (intersect.rs): Keeps the second 64 bytes on the first half's already-looked-up 64 KiB page and view unless 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.
  • Same-page ray-walker look reuse (lower.rs): Tracks dominating directory lookups within the current loop body via Lower::memory_near / Lower::memory_near_words / Lower::look_before so consecutive global_load_* instructions reading from the same 64 KiB page reuse the earlier view handle and offset calculation.
  • Opt-out & cache keying (mod.rs, shader_cache.rs): VICTORY_MEMORY_NEAR=0 restores per-load directory lookups for A/B comparison, and the shader cache keys on VICTORY_MEMORY_NEAR.
  • Conflict-free: Touches only intersect.rs, intersect_tests.rs, shader_cache.rs, and non-overlapping sections of lower.rs / emit/mod.rs — zero conflicts with open PR #1, PR #2, and PR #3.

Rig Specs Tested On

  • CPU: Intel Core i7-13700F (13th Gen)
  • GPU & VRAM: NVIDIA GeForce RTX 4060 Ti (8 GiB VRAM)
  • System RAM: 32 GiB (33,304,932 KiB visible)
  • OS & GPU Driver: Windows 11 Home (10.0.26300), NVIDIA driver 32.0.16.2124

Run Settings & Profile

  • Build & Commit SHA: diag / release @ 93970ed
  • Console Profile & Internal Resolution / Scale: hardware GPU + WARP BVH tests & full offline shader cache warm (VICTORY_EARLY_DEPTH=1, VICTORY_NAN_SCRUB=1)
  • Ray Tracing: Active in intersect_tests BVH shader execution
  • Upscaling: N/A (offline shader translation & BVH execution verification)
  • Frame Generation: N/A
  • Launcher Command / Preset & Extra VICTORY_* Overrides: default (VICTORY_MEMORY_NEAR unset -> enabled)
  • Scene / Area & Session Length: Automated BVH GPU/WARP suite + full offline shader corpus translation check

Measurements & Verification

  • Base FPS (without Frame Gen): N/A (CI + hardware GPU/WARP BVH tests + offline shader corpus check)
  • Frame-Gen FPS (if enabled): N/A
  • VRAM / RAM Usage: N/A
  • Crashes / DRED Resets: 0
  • Automated Checks:
    • cargo 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, including memory_near_toggles_second_half_fast_path_and_keeps_results_identical on hardware GPU & WARP across 64 KiB page boundary)
    • cargo test -p victory-gpu --lib shader_cache -- --test-threads=1 (2 passed; 0 failed)
<!-- greyfinch-sync:Androtim/MiniVI:issue:5535088947 --> Imported from [Androtim/MiniVI](https://github.com/Androtim/MiniVI/pull/4). Originally posted by [Androtim](https://github.com/Androtim) on 2026-11-28T00:49:52Z. --- ## Summary Ports `fxceless/victory-fork` commit `f299fba`'s `VICTORY_MEMORY_NEAR` optimization into MiniVI: - **128-byte BVH box node fast path ([intersect.rs](crates/victory-shader/src/emit/intersect.rs)):** Keeps the second 64 bytes on the first half's already-looked-up 64 KiB page and view unless `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. - **Same-page ray-walker look reuse ([lower.rs](crates/victory-shader/src/emit/lower.rs)):** Tracks dominating directory lookups within the current loop body via `Lower::memory_near` / `Lower::memory_near_words` / `Lower::look_before` so consecutive `global_load_*` instructions reading from the same 64 KiB page reuse the earlier view handle and offset calculation. - **Opt-out & cache keying ([mod.rs](crates/victory-shader/src/emit/mod.rs), [shader_cache.rs](crates/victory-gpu/src/shader_cache.rs)):** `VICTORY_MEMORY_NEAR=0` restores per-load directory lookups for A/B comparison, and the shader cache keys on `VICTORY_MEMORY_NEAR`. - **Conflict-free:** Touches only `intersect.rs`, `intersect_tests.rs`, `shader_cache.rs`, and non-overlapping sections of `lower.rs` / `emit/mod.rs` — zero conflicts with open PR #1, PR #2, and PR #3. ## Rig Specs Tested On - **CPU:** Intel Core i7-13700F (13th Gen) - **GPU & VRAM:** NVIDIA GeForce RTX 4060 Ti (8 GiB VRAM) - **System RAM:** 32 GiB (`33,304,932` KiB visible) - **OS & GPU Driver:** Windows 11 Home (`10.0.26300`), NVIDIA driver `32.0.16.2124` ## Run Settings & Profile - **Build & Commit SHA:** `diag` / `release` @ `93970ed` - **Console Profile & Internal Resolution / Scale:** hardware GPU + WARP BVH tests & full offline shader cache warm (`VICTORY_EARLY_DEPTH=1`, `VICTORY_NAN_SCRUB=1`) - **Ray Tracing:** Active in `intersect_tests` BVH shader execution - **Upscaling:** N/A (offline shader translation & BVH execution verification) - **Frame Generation:** N/A - **Launcher Command / Preset & Extra `VICTORY_*` Overrides:** default (`VICTORY_MEMORY_NEAR` unset -> enabled) - **Scene / Area & Session Length:** Automated BVH GPU/WARP suite + full offline shader corpus translation check ## Measurements & Verification - **Base FPS (without Frame Gen):** N/A (CI + hardware GPU/WARP BVH tests + offline shader corpus check) - **Frame-Gen FPS (if enabled):** N/A - **VRAM / RAM Usage:** N/A - **Crashes / DRED Resets:** `0` - **Automated Checks:** - [x] `cargo clippy --workspace --all-targets -- -D warnings` (0 warnings) - [x] `cargo clippy --workspace --all-targets --all-features -- -D warnings` (0 warnings) - [x] `cargo test -p xtask` (`6 passed`) + `xtask policy` (`294 files ok`) - [x] `cargo test -p victory-shader --lib intersect_tests -- --test-threads=1` (`7 passed; 0 failed`, including `memory_near_toggles_second_half_fast_path_and_keeps_results_identical` on hardware GPU & WARP across 64 KiB page boundary) - [x] `cargo test -p victory-gpu --lib shader_cache -- --test-threads=1` (`2 passed; 0 failed`)
Androtim commented 2026-11-28 01:07:36 +00:00 (Migrated from github.com)

Imported from Androtim/MiniVI. Originally posted by Androtim on 2026-11-28T01:07:36Z.


Verification summary for feat/iter19-memory-near-ray-walkers @ 93970ed:

  • GitHub Actions CI: Run 46089977893 completed with success (after rerunning the earlier unrelated victory-gpu views_off_their_elements_get_a_copy_of_their_bytes address-reuse flake).
  • Policy & Tests:
    • cargo +1.98.1-x86_64-pc-windows-gnu run -p xtask -- policy: asset policy: 294 files ok
    • cargo +1.98.1-x86_64-pc-windows-gnu test -p xtask: 6 passed; 0 failed
    • cargo +1.98.1-x86_64-pc-windows-gnu clippy --workspace --all-targets -- -D warnings: 0 warnings
    • cargo +1.98.1-x86_64-pc-windows-gnu clippy --workspace --all-features --all-targets -- -D warnings: 0 warnings
    • cargo +1.98.1-x86_64-pc-windows-gnu test -p victory-shader --lib intersect_tests -- --test-threads=1: 7 passed; 0 failed (including memory_near_toggles_second_half_fast_path_and_keeps_results_identical executing 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 failed
  • Standalone Binaries: Built diag\victory.exe, diag\victory_sm.exe, and release\victory.exe into D:\victory-build\minivi with RUSTFLAGS='-C link-self-contained=yes' (non_system_mingw_dlls=0 on all 3).
  • Full Offline Shader Corpus Warm (warm-iter19.log, VICTORY_EARLY_DEPTH=1, VICTORY_NAN_SCRUB=1, VICTORY_MEMORY_NEAR default enabled):
    • 25,759 shaders in the cache, 226 do not translate in 697 s (exit=0) — zero regressions across the entire corpus (198 container metadata-only, 23 wave64, 5 descriptor-read-only-as-data).
<!-- greyfinch-sync:Androtim/MiniVI:comment:7231439497 --> Imported from [Androtim/MiniVI](https://github.com/Androtim/MiniVI/pull/4#issuecomment-7231439497). Originally posted by [Androtim](https://github.com/Androtim) on 2026-11-28T01:07:36Z. --- Verification summary for `feat/iter19-memory-near-ray-walkers` @ `93970ed`: - **GitHub Actions CI:** Run `46089977893` completed with `success` (after rerunning the earlier unrelated `victory-gpu` `views_off_their_elements_get_a_copy_of_their_bytes` address-reuse flake). - **Policy & Tests:** - `cargo +1.98.1-x86_64-pc-windows-gnu run -p xtask -- policy`: `asset policy: 294 files ok` - `cargo +1.98.1-x86_64-pc-windows-gnu test -p xtask`: `6 passed; 0 failed` - `cargo +1.98.1-x86_64-pc-windows-gnu clippy --workspace --all-targets -- -D warnings`: `0` warnings - `cargo +1.98.1-x86_64-pc-windows-gnu clippy --workspace --all-features --all-targets -- -D warnings`: `0` warnings - `cargo +1.98.1-x86_64-pc-windows-gnu test -p victory-shader --lib intersect_tests -- --test-threads=1`: `7 passed; 0 failed` (including `memory_near_toggles_second_half_fast_path_and_keeps_results_identical` executing 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 failed` - **Standalone Binaries:** Built `diag\victory.exe`, `diag\victory_sm.exe`, and `release\victory.exe` into `D:\victory-build\minivi` with `RUSTFLAGS='-C link-self-contained=yes'` (`non_system_mingw_dlls=0` on all 3). - **Full Offline Shader Corpus Warm (`warm-iter19.log`, `VICTORY_EARLY_DEPTH=1`, `VICTORY_NAN_SCRUB=1`, `VICTORY_MEMORY_NEAR` default enabled):** - `25,759 shaders in the cache, 226 do not translate` in `697 s` (`exit=0`) — zero regressions across the entire corpus (`198` container metadata-only, `23` wave64, `5` descriptor-read-only-as-data).
Androtim commented 2026-11-28 02:04:45 +00:00 (Migrated from github.com)

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): passing

Review Summary

This PR ports the VICTORY_MEMORY_NEAR optimization for ray-walking shaders:

  • crates/victory-shader/src/emit/intersect.rs: Replaces Lower::bvh_second_half with Lower::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_memory at the top of intersect (top = true) routes through Lower::memory_near.
  • crates/victory-shader/src/emit/lower.rs: Factors Lower::memory into memory_page, memory_entry, and memory_view, and adds memory_near, memory_near_words, memory_handle, and look_before to 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: Adds memory_near() (default-on, opt-out via VICTORY_MEMORY_NEAR=0), TEST_MEMORY_NEAR for unit tests, and keys the shader cache on VICTORY_MEMORY_NEAR.
  • crates/victory-shader/src/emit/intersect_tests.rs: Adds memory_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

  • Page-boundary math: within > 0xFF80 (pred::IUGT) accurately identifies when a 128-byte node (within..=within+127) crosses a 64 KiB page boundary.
  • Unmapped pages & faults: memory_near and memory_near_words gate reuse on same && look.there, ensuring unmapped pages still execute memory_entry under the current lane guard. In bvh_second_words, an unmapped first half has already noted the page fault and returns mapped = false, which propagates through the there phi into bvh_boxes.
  • Dominance & handle hoisting: look_before restricts reuse to cur_ir and its dominators up to the innermost loop header (self.counters), so hoisting memory_handle(look.home, look.slot) into an earlier Look's home block is dominated by look.slot and dominates the reusing load.
  • Minor note: Unit test coverage exercises bvh_second_words and bvh_memory(..., top = true) -> memory_near, while the global_load_* -> memory_near_words reuse 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 vs VICTORY_MEMORY_NEAR=0) is recommended before merging. (Automated review; not formal maintainer approval.)


Generated with Antigravity CLI (agy).

<!-- greyfinch-sync:Androtim/MiniVI:comment:7232115094 --> Imported from [Androtim/MiniVI](https://github.com/Androtim/MiniVI/pull/4#issuecomment-7232115094). Originally posted by [Androtim](https://github.com/Androtim) on 2026-11-28T02:04:45Z. --- <!-- minivi-triage v1 head=93970edc42528f5ab0524a99266b804ae9d998b5 verdict=needs-gpu-test ci=passing at=2026-11-28T02:05:12Z --> Automated triage for the maintainers (not an approval). **Verdict:** `needs-gpu-test` · **CI (`check`):** `passing` ### Review Summary This PR ports the `VICTORY_MEMORY_NEAR` optimization for ray-walking shaders: - **`crates/victory-shader/src/emit/intersect.rs`**: Replaces `Lower::bvh_second_half` with `Lower::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_memory` at the top of `intersect` (`top = true`) routes through `Lower::memory_near`. - **`crates/victory-shader/src/emit/lower.rs`**: Factors `Lower::memory` into `memory_page`, `memory_entry`, and `memory_view`, and adds `memory_near`, `memory_near_words`, `memory_handle`, and `look_before` to 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`**: Adds `memory_near()` (default-on, opt-out via `VICTORY_MEMORY_NEAR=0`), `TEST_MEMORY_NEAR` for unit tests, and keys the shader cache on `VICTORY_MEMORY_NEAR`. - **`crates/victory-shader/src/emit/intersect_tests.rs`**: Adds `memory_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 - **Page-boundary math**: `within > 0xFF80` (`pred::IUGT`) accurately identifies when a 128-byte node (`within..=within+127`) crosses a 64 KiB page boundary. - **Unmapped pages & faults**: `memory_near` and `memory_near_words` gate reuse on `same && look.there`, ensuring unmapped pages still execute `memory_entry` under the current lane `guard`. In `bvh_second_words`, an unmapped first half has already noted the page fault and returns `mapped = false`, which propagates through the `there` phi into `bvh_boxes`. - **Dominance & handle hoisting**: `look_before` restricts reuse to `cur_ir` and its dominators up to the innermost loop header (`self.counters`), so hoisting `memory_handle(look.home, look.slot)` into an earlier `Look`'s `home` block is dominated by `look.slot` and dominates the reusing load. - **Minor note**: Unit test coverage exercises `bvh_second_words` and `bvh_memory(..., top = true)` -> `memory_near`, while the `global_load_*` -> `memory_near_words` reuse 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 vs `VICTORY_MEMORY_NEAR=0`) is recommended before merging. *(Automated review; not formal maintainer approval.)* --- _Generated with Antigravity CLI (`agy`)._
Androtim commented 2026-11-28 21:11:18 +00:00 (Migrated from github.com)

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):

  • Duration & Stability: 7-minute RT-ON open-world session (1c-build1-rt.log) — 0 crashes, 0 DRED resets, clean exit.
  • Performance: 7.6 fps (132.2 ms/frame, 4,022 draws/frame).
  • RT / Memory Telemetry:
    • Active RT/BVH builds (12,653 pages / 790 MB across 13 arenas, 98 build dispatches/frame).
    • 0 "a shader reads view addresses without a view heap set" warnings.
    • 1,374 DLSS upscalings (0 failed); VRAM stayed bounded (6,460 MB in use, 554 MB free across 27 texture blocks).
<!-- greyfinch-sync:Androtim/MiniVI:comment:7245835483 --> Imported from [Androtim/MiniVI](https://github.com/Androtim/MiniVI/pull/4#issuecomment-7245835483). Originally posted by [Androtim](https://github.com/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`)**: - **Duration & Stability:** **7-minute** RT-ON open-world session (`1c-build1-rt.log`) — **0 crashes, 0 DRED resets**, clean exit. - **Performance:** `7.6 fps` (`132.2 ms/frame`, `4,022` draws/frame). - **RT / Memory Telemetry:** - Active RT/BVH builds (`12,653` pages / `790 MB` across `13` arenas, `98` build dispatches/frame). - `0` `"a shader reads view addresses without a view heap set"` warnings. - `1,374` DLSS upscalings (`0` failed); VRAM stayed bounded (`6,460 MB` in use, `554 MB` free across `27` texture blocks).
Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
Androtim/MiniVI!4
No description provided.