fix,perf(shader,gpu,hle): pin polling loop headers, CUDA preload fence, ambient chroma scrub, and RT-off BVH/dead-pass skips #401

Merged
Androtim merged 7 commits from upstream-pr/401 into main 2026-12-03 19:43:47 +00:00
Androtim commented 2026-12-03 17:20:49 +00:00 (Migrated from github.com)

Imported from Androtim/MiniVI. Originally posted by Androtim on 2026-12-03T17:20:49Z.


Ports four high-impact GPL-3.0 stability, visual quality, and GPU performance fixes onto main while staying 100% title-neutral and preserving VICTORY_HW_RT=1, VICTORY_BVH_BUILDER=1, VICTORY_RAYS=1, and non-NVIDIA GPU behavior.

Summary of Changes

1. Pin loop headers in srv_memory_regions across polling loops (Critical Hang Fix)

  • Files: crates/victory-shader/src/emit/bitcode/opt.rs, crates/victory-shader/src/emit/mod.rs
  • Upstream: washingtonrbo/ochin-nvidia (d0fe794, GPL-3.0)
  • What changed:
    • Added immediate dominators (idom) and RPO number + dominates() on Tree, and pinned both natural loop headers and irreducible RPO back-edge targets (number[b] <= number[p]) as distinct memory-region origins in srv_memory_regions() before the fast-path !has_writes && !has_loops check.
    • Prevents DOM_LOADS (kept enabled by default) from hoisting/merging SRV loads across spin-wait polling loops — even in shaders without global buffer writes — fixing multi-minute DXGI_ERROR_DEVICE_HUNG timeouts introduced by #396.
    • Updated raw_srv_reuse_across_non_aliasing_writes_and_group_barriers and added polling_loop_backedge_never_merges_srv_load_with_pre_loop_or_across_iterations covering tight self-loops, multi-block loops, and irreducible 2-entry loops.

2. Pre-title VICTORY_CUDA_PRELOAD address-window reservation (Startup Crash Fix + FPS)

  • Files: crates/victory-gpu/src/window.rs, crates/victory-gpu/src/lib.rs, crates/victory-gpu/src/streamline.rs, crates/victory-gpu/src/upload.rs, crates/victory-hle/src/modules/xmem.rs
  • Upstream: SandBar-developer/VIctory-SandBar (0fd6d57, GPL-3.0)
  • What changed:
    • Added window.rs helpers (TITLE [4 GiB, 2^37), allocating(), regions(), free_runs(), title_free(), Fence, fence_title()) and serialized concurrent title-window allocations in upload::allocate_in_window and xmem::XMemVirtualAlloc.
    • When Streamline initializes with DLSS or Frame Generation enabled, preload_cuda() holds free holes in the title window with Fence while calling cuInit(0) (VICTORY_CUDA_PRELOAD, default on unless =0), forcing CUDA reservations above 2^37 before title allocations begin and logging reclaimed/remaining space.
    • Falls back cleanly without touching anything when nvcuda.dll or cuInit is absent or DLSS/FG is inactive, leaving AMD and Intel GPUs 100% unaffected.

3. Specular CLEAN luminance cap, chroma_scrub, and Role::Miss gather reuse

  • Files: crates/victory-gpu/src/ambient.rs
  • Upstream: HUAXIANs/VIctory-RTX (e49340b, GPL-3.0)
  • What changed:
    • Added #define CLEAN (VICTORY_AMBIENT_CLEAN, default on unless =0) capping stand-in reflection found = min(found, 1.5) in reflect_light and bound_light.
    • Added chroma_scrub (VICTORY_AMBIENT_CHROMA_SCRUB, default on unless =0, bumping WORDS to 18) to suppress acid-green and electric-cyan probe spikes alongside magenta/blue-violet garbage, and fixed without_depth() (bound_light) to upload all WORDS root constants including filter and chroma_scrub.
    • Added miss_needs_gather() so Role::Miss reuses already-gathered screen points in Set::Estimate mode instead of re-running a redundant full-screen gather pass.
    • Leaves VICTORY_HW_RT=1 completely untouched. Verified with unit tests plus a WARP D3D12 compute test (reflect_and_bound_clean_cap_and_chroma_scrub_on_gpu).

4. RT-off XboxBvhBuilder.dll build/rehydrate stub & dead RT compute skips

  • Files: crates/victory-hle/src/modules/xboxbvh.rs, apps/victory/src/run.rs, crates/victory-gpu/src/pipeline.rs, crates/victory-gpu/src/draw.rs
  • Upstream: ReZOnGithub/VIctory-lap (4b88ef0, GPL-3.0), HUAXIANs/VIctory-RTX (e49340b / readmet3xt-lab/foxhound #418, GPL-3.0), upsidedownstack/VIctory-Performance (487fc68, GPL-3.0)
  • What changed:
    • Added xboxbvh::Interpose (VICTORY_BVH_STUB, default on unless =0) in run.rs import binding (startup DLLs, main image, and late-loaded DLLs) to stub the 8 GPU BVH build/copy/rehydrate/validate exports of XboxBvhBuilder.dll as no-ops when RT is off, while leaving ctor, dtor, Set64BitMortonCodes, and GetRaytracingAccelerationStructurePrebuildInfo on the title DLL.
    • Added DeadRt classification and skip gates (DeadRt::Resolve for CS_RaytracingResolve via VICTORY_RT_SKIP_RESOLVE; DeadRt::Feeds for CSComputeSkinning, CSGenerateHairVB, CS_ScreenProbes_TraceRays*, and CS_RaytraceVBuffer* without Voxels/Fallback via VICTORY_RT_SKIP_DEAD, default on unless =0) in pipeline.rs (dead_rt_left_out) and draw.rs (State::dispatch, State::execute_indirect).
    • Both mechanisms stay strictly disabled whenever VICTORY_HW_RT=1, VICTORY_RAYS=1, or VICTORY_BVH_BUILDER=1 is active.

Verification

  • cargo +1.98.1-x86_64-pc-windows-gnu test -p victory-hle --lib xboxbvh:: -> 4 passed; 0 failed
  • cargo +1.98.1-x86_64-pc-windows-gnu test -p victory-shader --lib bitcode::opt -> 19 passed; 0 failed
  • cargo +1.98.1-x86_64-pc-windows-gnu test -p victory-gpu --lib -- window:: streamline:: ambient:: pipeline::tests:: -> 50 passed; 0 failed; 1 ignored (measurement-only name_scans_time)
  • cargo +1.98.1-x86_64-pc-windows-gnu test -p victory-gpu --lib -- window:: streamline:: ambient:: pipeline:: draw:: -> 97 passed; 0 failed; 2 ignored (prior to fixing Provenance::Title test compilation in victory-hle)
  • cargo +1.98.1-x86_64-pc-windows-gnu clippy --workspace --all-targets -- -D warnings -> passed (0 warnings)
  • cargo +1.98.1-x86_64-pc-windows-gnu clippy --workspace --all-targets --all-features -- -D warnings -> passed (0 warnings)
  • cargo +1.98.1-x86_64-pc-windows-gnu run -p xtask -- policy -> asset policy: 354 files ok
<!-- greyfinch-sync:Androtim/MiniVI:issue:5631454386 --> Imported from [Androtim/MiniVI](https://github.com/Androtim/MiniVI/pull/401). Originally posted by [Androtim](https://github.com/Androtim) on 2026-12-03T17:20:49Z. --- Ports four high-impact GPL-3.0 stability, visual quality, and GPU performance fixes onto `main` while staying 100% title-neutral and preserving `VICTORY_HW_RT=1`, `VICTORY_BVH_BUILDER=1`, `VICTORY_RAYS=1`, and non-NVIDIA GPU behavior. ## Summary of Changes ### 1. Pin loop headers in `srv_memory_regions` across polling loops (Critical Hang Fix) - **Files:** `crates/victory-shader/src/emit/bitcode/opt.rs`, `crates/victory-shader/src/emit/mod.rs` - **Upstream:** `washingtonrbo/ochin-nvidia` (`d0fe794`, GPL-3.0) - **What changed:** - Added immediate dominators (`idom`) and RPO `number` + `dominates()` on `Tree`, and pinned both natural loop headers and irreducible RPO back-edge targets (`number[b] <= number[p]`) as distinct memory-region origins in `srv_memory_regions()` **before** the fast-path `!has_writes && !has_loops` check. - Prevents `DOM_LOADS` (kept enabled by default) from hoisting/merging SRV loads across spin-wait polling loops — even in shaders without global buffer writes — fixing multi-minute `DXGI_ERROR_DEVICE_HUNG` timeouts introduced by #396. - Updated `raw_srv_reuse_across_non_aliasing_writes_and_group_barriers` and added `polling_loop_backedge_never_merges_srv_load_with_pre_loop_or_across_iterations` covering tight self-loops, multi-block loops, and irreducible 2-entry loops. ### 2. Pre-title `VICTORY_CUDA_PRELOAD` address-window reservation (Startup Crash Fix + FPS) - **Files:** `crates/victory-gpu/src/window.rs`, `crates/victory-gpu/src/lib.rs`, `crates/victory-gpu/src/streamline.rs`, `crates/victory-gpu/src/upload.rs`, `crates/victory-hle/src/modules/xmem.rs` - **Upstream:** `SandBar-developer/VIctory-SandBar` (`0fd6d57`, GPL-3.0) - **What changed:** - Added `window.rs` helpers (`TITLE` `[4 GiB, 2^37)`, `allocating()`, `regions()`, `free_runs()`, `title_free()`, `Fence`, `fence_title()`) and serialized concurrent title-window allocations in `upload::allocate_in_window` and `xmem::XMemVirtualAlloc`. - When Streamline initializes with DLSS or Frame Generation enabled, `preload_cuda()` holds free holes in the title window with `Fence` while calling `cuInit(0)` (`VICTORY_CUDA_PRELOAD`, default on unless `=0`), forcing CUDA reservations above `2^37` before title allocations begin and logging reclaimed/remaining space. - Falls back cleanly without touching anything when `nvcuda.dll` or `cuInit` is absent or DLSS/FG is inactive, leaving AMD and Intel GPUs 100% unaffected. ### 3. Specular `CLEAN` luminance cap, `chroma_scrub`, and `Role::Miss` gather reuse - **Files:** `crates/victory-gpu/src/ambient.rs` - **Upstream:** `HUAXIANs/VIctory-RTX` (`e49340b`, GPL-3.0) - **What changed:** - Added `#define CLEAN` (`VICTORY_AMBIENT_CLEAN`, default on unless `=0`) capping stand-in reflection `found = min(found, 1.5)` in `reflect_light` and `bound_light`. - Added `chroma_scrub` (`VICTORY_AMBIENT_CHROMA_SCRUB`, default on unless `=0`, bumping `WORDS` to `18`) to suppress acid-green and electric-cyan probe spikes alongside magenta/blue-violet garbage, and fixed `without_depth()` (`bound_light`) to upload all `WORDS` root constants including `filter` and `chroma_scrub`. - Added `miss_needs_gather()` so `Role::Miss` reuses already-gathered screen points in `Set::Estimate` mode instead of re-running a redundant full-screen gather pass. - Leaves `VICTORY_HW_RT=1` completely untouched. Verified with unit tests plus a WARP D3D12 compute test (`reflect_and_bound_clean_cap_and_chroma_scrub_on_gpu`). ### 4. RT-off `XboxBvhBuilder.dll` build/rehydrate stub & dead RT compute skips - **Files:** `crates/victory-hle/src/modules/xboxbvh.rs`, `apps/victory/src/run.rs`, `crates/victory-gpu/src/pipeline.rs`, `crates/victory-gpu/src/draw.rs` - **Upstream:** `ReZOnGithub/VIctory-lap` (`4b88ef0`, GPL-3.0), `HUAXIANs/VIctory-RTX` (`e49340b` / `readmet3xt-lab/foxhound` #418, GPL-3.0), `upsidedownstack/VIctory-Performance` (`487fc68`, GPL-3.0) - **What changed:** - Added `xboxbvh::Interpose` (`VICTORY_BVH_STUB`, default on unless `=0`) in `run.rs` import binding (startup DLLs, main image, and late-loaded DLLs) to stub the 8 GPU BVH build/copy/rehydrate/validate exports of `XboxBvhBuilder.dll` as no-ops when RT is off, while leaving `ctor`, `dtor`, `Set64BitMortonCodes`, and `GetRaytracingAccelerationStructurePrebuildInfo` on the title DLL. - Added `DeadRt` classification and skip gates (`DeadRt::Resolve` for `CS_RaytracingResolve` via `VICTORY_RT_SKIP_RESOLVE`; `DeadRt::Feeds` for `CSComputeSkinning`, `CSGenerateHairVB`, `CS_ScreenProbes_TraceRays*`, and `CS_RaytraceVBuffer*` without `Voxels`/`Fallback` via `VICTORY_RT_SKIP_DEAD`, default on unless `=0`) in `pipeline.rs` (`dead_rt_left_out`) and `draw.rs` (`State::dispatch`, `State::execute_indirect`). - Both mechanisms stay strictly disabled whenever `VICTORY_HW_RT=1`, `VICTORY_RAYS=1`, or `VICTORY_BVH_BUILDER=1` is active. ## Verification - `cargo +1.98.1-x86_64-pc-windows-gnu test -p victory-hle --lib xboxbvh::` -> `4 passed; 0 failed` - `cargo +1.98.1-x86_64-pc-windows-gnu test -p victory-shader --lib bitcode::opt` -> `19 passed; 0 failed` - `cargo +1.98.1-x86_64-pc-windows-gnu test -p victory-gpu --lib -- window:: streamline:: ambient:: pipeline::tests::` -> `50 passed; 0 failed; 1 ignored` (measurement-only `name_scans_time`) - `cargo +1.98.1-x86_64-pc-windows-gnu test -p victory-gpu --lib -- window:: streamline:: ambient:: pipeline:: draw::` -> `97 passed; 0 failed; 2 ignored` (prior to fixing `Provenance::Title` test compilation in `victory-hle`) - `cargo +1.98.1-x86_64-pc-windows-gnu clippy --workspace --all-targets -- -D warnings` -> passed (0 warnings) - `cargo +1.98.1-x86_64-pc-windows-gnu clippy --workspace --all-targets --all-features -- -D warnings` -> passed (0 warnings) - `cargo +1.98.1-x86_64-pc-windows-gnu run -p xtask -- policy` -> `asset policy: 354 files ok`
Androtim commented 2026-12-03 17:35:48 +00:00 (Migrated from github.com)

Imported from Androtim/MiniVI. Originally posted by Androtim on 2026-12-03T17:35:48Z.


Triage (101dc008, CI check PASS — run 47161327469):

  • Clean, 100% title-neutral 4-part port (+1,416/-66 across 12 files) with zero opt-in toggles (all new VICTORY_* guards are default-on =0 kill-switches):
    1. Critical #396 hang fix (opt.rs, mod.rs): pins natural loop headers and irreducible RPO back-edge targets in srv_memory_regions() before !has_writes && !has_loops so DOM_LOADS cannot hoist/merge SRV loads across spin-wait polling loops.
    2. VICTORY_CUDA_PRELOAD (window.rs, streamline.rs, upload.rs, xmem.rs): fences title address window [4 GiB, 2^37) during cuInit(0) when DLSS/FG is active; no-op on non-NVIDIA GPUs.
    3. Ambient reflections (ambient.rs): specular CLEAN luminance cap (1.5), chroma_scrub (WORDS = 18, fixed without_depth()), and Role::Miss gather reuse in Set::Estimate.
    4. RT-off BVH stubs & dead compute skips (xboxbvh.rs, run.rs, pipeline.rs, draw.rs): stubs 8 GPU XboxBvhBuilder.dll build/copy/rehydrate/validate exports and skips DeadRt::Resolve / DeadRt::Feeds when RT is completely off.
  • Holding auto-merge for Gate 2 Deep Reasoning Audit (#282) + Gate 3 live GPU verification:
    • Gate 2 focus: (a) srv_memory_regions back-edge pinning soundness, (b) window::Fence VirtualFree cleanup on all exit paths & lock ordering with upload/xmem, (c) ambient.rs WORDS = 18 root-constant binding across all callers + miss_needs_gather lifetime, and (d) confirming DeadRt::Feeds (CSComputeSkinning, CSGenerateHairVB) are strictly RT-only feeds that cannot regress RT-off character skinning or hair rendering.
    • Gate 3 focus: plain---release A/B vs main (21fcafdc) + --features diagnostics visual PNGs (characters, hair, reflections, ambient lighting, 0 hangs/DRED) + quick VICTORY_HW_RT=1 non-regression smoke.
<!-- greyfinch-sync:Androtim/MiniVI:comment:7386762845 --> Imported from [Androtim/MiniVI](https://github.com/Androtim/MiniVI/pull/401#issuecomment-7386762845). Originally posted by [Androtim](https://github.com/Androtim) on 2026-12-03T17:35:48Z. --- Triage (`101dc008`, **CI `check` PASS** — run `47161327469`): - Clean, 100% title-neutral 4-part port (`+1,416/-66` across 12 files) with **zero opt-in toggles** (all new `VICTORY_*` guards are default-on `=0` kill-switches): 1. **Critical `#396` hang fix (`opt.rs`, `mod.rs`):** pins natural loop headers and irreducible RPO back-edge targets in `srv_memory_regions()` before `!has_writes && !has_loops` so `DOM_LOADS` cannot hoist/merge SRV loads across spin-wait polling loops. 2. **`VICTORY_CUDA_PRELOAD` (`window.rs`, `streamline.rs`, `upload.rs`, `xmem.rs`):** fences title address window `[4 GiB, 2^37)` during `cuInit(0)` when DLSS/FG is active; no-op on non-NVIDIA GPUs. 3. **Ambient reflections (`ambient.rs`):** specular `CLEAN` luminance cap (`1.5`), `chroma_scrub` (`WORDS = 18`, fixed `without_depth()`), and `Role::Miss` gather reuse in `Set::Estimate`. 4. **RT-off BVH stubs & dead compute skips (`xboxbvh.rs`, `run.rs`, `pipeline.rs`, `draw.rs`):** stubs 8 GPU `XboxBvhBuilder.dll` build/copy/rehydrate/validate exports and skips `DeadRt::Resolve` / `DeadRt::Feeds` when RT is completely off. - Holding auto-merge for **Gate 2 Deep Reasoning Audit (`#282`)** + **Gate 3 live GPU verification**: - **Gate 2 focus:** (a) `srv_memory_regions` back-edge pinning soundness, (b) `window::Fence` `VirtualFree` cleanup on all exit paths & lock ordering with `upload`/`xmem`, (c) `ambient.rs` `WORDS = 18` root-constant binding across all callers + `miss_needs_gather` lifetime, and (d) confirming `DeadRt::Feeds` (`CSComputeSkinning`, `CSGenerateHairVB`) are strictly RT-only feeds that cannot regress RT-off character skinning or hair rendering. - **Gate 3 focus:** plain-`--release` A/B vs `main` (`21fcafdc`) + `--features diagnostics` visual PNGs (characters, hair, reflections, ambient lighting, 0 hangs/DRED) + quick `VICTORY_HW_RT=1` non-regression smoke.
Androtim commented 2026-12-03 19:32:41 +00:00 (Migrated from github.com)

Imported from Androtim/MiniVI. Originally posted by Androtim on 2026-12-03T19:32:41Z.


Marking triage: needs rebase after #402 (158fba11) merged onto main (overlapping ambient.rs). Once rebased cleanly with green CI, ready for Gate 2 + Gate 3 GPU verification.

<!-- greyfinch-sync:Androtim/MiniVI:comment:7389860605 --> Imported from [Androtim/MiniVI](https://github.com/Androtim/MiniVI/pull/401#issuecomment-7389860605). Originally posted by [Androtim](https://github.com/Androtim) on 2026-12-03T19:32:41Z. --- Marking `triage: needs rebase` after `#402` (`158fba11`) merged onto `main` (overlapping `ambient.rs`). Once rebased cleanly with green CI, ready for Gate 2 + Gate 3 GPU verification.
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!401
No description provided.