perf(rt): add opt-in VICTORY_BVH_NO_HIT and dead-RT compute pass skipping #254

Open
github-bot wants to merge 1 commit from github-bot/gh-254 into main AGit
Owner

@⁠Vladimir-Human on GitHub · 2026-11-27 12:31 UTC · original
Vladimir-Human:perf/bvh-no-hit-skip-dead-rt → main · +579 −6 · 5 files · 1 commits · open

Summary

Adds strictly opt-in (OFF by default), independently selectable switches for avoiding unrehydrated BVH memory walks and dead ray-tracing compute work when VICTORY_BVH_BUILDER is off (related to #168, #143):

  1. VICTORY_BVH_NO_HIT=1 (opt-in, OFF by default):
    • Ported from fxceless/victory-fork: lowers image_bvh_intersect_ray / image_bvh64_intersect_ray to immediate miss constants (MISS for triangles / other, NONE for boxes) with zero SLOT_MEMORY loads and zero SLOT_FAULTS writes.
    • Always forced OFF when VICTORY_BVH_BUILDER=1.
    • Keyed in shader_cache.rs (VICTORY_BVH_NO_HIT=1\0) only when active so default / builder-on shader caches are completely unaffected.
  2. VICTORY_RT_SKIP_DEAD=1 (opt-in, OFF by default, independent of VICTORY_BVH_NO_HIT):
    • Skips dead-RT compute pipelines (CSComputeSkinning*, CSGenerateHairVB, CS_ScreenProbes_TraceRays*_BVH*, CS_RaytraceVBuffer* excluding Voxels/Fallback) in pipeline/make.rs.
    • Strictly restricted to compute stage; non-RT skinning (CS_PedStandardSkinning*, CS_PosOnlyLodSkinning*, computeclothSkinning) and non-BVH trace/resolve passes never match.
    • Always forced OFF when VICTORY_BVH_BUILDER=1.
  3. VICTORY_RT_SKIP_GATHER_COPY=1 (opt-in, OFF by default, independent):
    • Independently skips CS_Primary_GatherCopy compute pipelines when VICTORY_BVH_BUILDER != 1.

Because all three switches default to OFF and are independently toggleable, default behavior is unchanged and each arm can be A/B tested cleanly against the same baseline:

  • Baseline: unset (all off)
  • Arm 1 (shader miss-only): VICTORY_BVH_NO_HIT=1
  • Arm 2 (skip dead RT compute producers): VICTORY_RT_SKIP_DEAD=1
  • Arm 3 (both): VICTORY_BVH_NO_HIT=1 VICTORY_RT_SKIP_DEAD=1
  • Arm 4 (add primary gather-copy skip): + VICTORY_RT_SKIP_GATHER_COPY=1

Changed Files

  • crates/victory-shader/src/emit/mod.rs: bvh_no_hit(), bvh_no_hit_for().
  • crates/victory-shader/src/emit/intersect.rs: miss-only lowering path (no_hit()).
  • crates/victory-shader/src/emit/intersect_tests.rs: env policy unit tests + hardware/WARP zero-SLOT_MEMORY/SLOT_FAULTS execution tests.
  • crates/victory-gpu/src/shader_cache.rs: cache-key registration for active VICTORY_BVH_NO_HIT=1 + subprocess cache-key separation tests.
  • crates/victory-gpu/src/pipeline/make.rs: DeadRtKind, dead_rt_kind, DeadRtPolicy, and stage/container/policy unit tests.

Verification

Verified on local D3D12 hardware (NVIDIA GeForce RTX 4070 SUPER) and WARP (VICTORY_D3D12_DEBUG=1, --test-threads=1, 0 D3D12 debug errors):

  • cargo clippy -p victory-shader -p victory-gpu --all-targets --locked -- -D warnings (default & --features victory-gpu/diagnostics): 0 warnings.
  • cargo test -p victory-shader --locked emit::intersect_tests -- --test-threads=1: 10/10 passed (hardware + WARP, 0 skips).
  • cargo test -p victory-gpu --locked pipeline::make::tests -- --test-threads=1: 11/11 (default), 12/12 (diagnostics).
  • cargo test -p victory-gpu --locked shader_cache::tests -- --test-threads=1: 5/5 (default & diagnostics).
  • cargo run -p xtask --locked -- policy & cargo test -p xtask --locked: 11/11 passed.
**@⁠Vladimir-Human** on GitHub · 2026-11-27 12:31 UTC · [original](https://github.com/TaynanGT/Vice-Tay/pull/254) `Vladimir-Human:perf/bvh-no-hit-skip-dead-rt` → `main` · +579 −6 · 5 files · 1 commits · open ## Summary Adds strictly **opt-in (OFF by default)**, **independently selectable** switches for avoiding unrehydrated BVH memory walks and dead ray-tracing compute work when `VICTORY_BVH_BUILDER` is off (related to #168, #143): 1. **`VICTORY_BVH_NO_HIT=1` (opt-in, OFF by default):** - Ported from `fxceless/victory-fork`: lowers `image_bvh_intersect_ray` / `image_bvh64_intersect_ray` to immediate miss constants (`MISS` for triangles / other, `NONE` for boxes) with zero `SLOT_MEMORY` loads and zero `SLOT_FAULTS` writes. - Always forced OFF when `VICTORY_BVH_BUILDER=1`. - Keyed in `shader_cache.rs` (`VICTORY_BVH_NO_HIT=1\0`) only when active so default / builder-on shader caches are completely unaffected. 2. **`VICTORY_RT_SKIP_DEAD=1` (opt-in, OFF by default, independent of `VICTORY_BVH_NO_HIT`):** - Skips dead-RT compute pipelines (`CSComputeSkinning*`, `CSGenerateHairVB`, `CS_ScreenProbes_TraceRays*_BVH*`, `CS_RaytraceVBuffer*` excluding `Voxels`/`Fallback`) in `pipeline/make.rs`. - Strictly restricted to `compute` stage; non-RT skinning (`CS_PedStandardSkinning*`, `CS_PosOnlyLodSkinning*`, `computeclothSkinning`) and non-BVH trace/resolve passes never match. - Always forced OFF when `VICTORY_BVH_BUILDER=1`. 3. **`VICTORY_RT_SKIP_GATHER_COPY=1` (opt-in, OFF by default, independent):** - Independently skips `CS_Primary_GatherCopy` compute pipelines when `VICTORY_BVH_BUILDER != 1`. Because all three switches default to OFF and are independently toggleable, default behavior is unchanged and each arm can be A/B tested cleanly against the same baseline: - Baseline: unset (all off) - Arm 1 (shader miss-only): `VICTORY_BVH_NO_HIT=1` - Arm 2 (skip dead RT compute producers): `VICTORY_RT_SKIP_DEAD=1` - Arm 3 (both): `VICTORY_BVH_NO_HIT=1 VICTORY_RT_SKIP_DEAD=1` - Arm 4 (add primary gather-copy skip): `+ VICTORY_RT_SKIP_GATHER_COPY=1` ## Changed Files - `crates/victory-shader/src/emit/mod.rs`: `bvh_no_hit()`, `bvh_no_hit_for()`. - `crates/victory-shader/src/emit/intersect.rs`: miss-only lowering path (`no_hit()`). - `crates/victory-shader/src/emit/intersect_tests.rs`: env policy unit tests + hardware/WARP zero-`SLOT_MEMORY`/`SLOT_FAULTS` execution tests. - `crates/victory-gpu/src/shader_cache.rs`: cache-key registration for active `VICTORY_BVH_NO_HIT=1` + subprocess cache-key separation tests. - `crates/victory-gpu/src/pipeline/make.rs`: `DeadRtKind`, `dead_rt_kind`, `DeadRtPolicy`, and stage/container/policy unit tests. ## Verification Verified on local D3D12 hardware (NVIDIA GeForce RTX 4070 SUPER) and WARP (`VICTORY_D3D12_DEBUG=1`, `--test-threads=1`, `0` D3D12 debug errors): - `cargo clippy -p victory-shader -p victory-gpu --all-targets --locked -- -D warnings` (default & `--features victory-gpu/diagnostics`): **0 warnings**. - `cargo test -p victory-shader --locked emit::intersect_tests -- --test-threads=1`: **10/10 passed** (hardware + WARP, 0 skips). - `cargo test -p victory-gpu --locked pipeline::make::tests -- --test-threads=1`: **11/11** (default), **12/12** (`diagnostics`). - `cargo test -p victory-gpu --locked shader_cache::tests -- --test-threads=1`: **5/5** (default & `diagnostics`). - `cargo run -p xtask --locked -- policy` & `cargo test -p xtask --locked`: **11/11 passed**.
When VICTORY_BVH_BUILDER != 1, unstubbed ray-tracing node tests
(image_bvh*_intersect_ray) still traverse unrehydrated packed memory and
ray-only compute passes consume substantial GPU time producing unused results
(also contributing to chromatic probe/foliage artifacts in #168).

1. Port VICTORY_BVH_NO_HIT from fxceless/victory-fork into
   crates/victory-shader/src/emit/{mod.rs,intersect.rs}: auto-enabled whenever
   VICTORY_BVH_BUILDER != 1 (VICTORY_BVH_NO_HIT=0 restores full traversal;
   never active when VICTORY_BVH_BUILDER=1), returning bvh::NONE for box nodes
   and bvh::MISS for all other kinds with zero SLOT_MEMORY loads and zero
   SLOT_FAULTS writes, keyed in crates/victory-gpu/src/shader_cache.rs.
2. Auto-skip dead ray-tracing compute passes in
   crates/victory-gpu/src/pipeline/make.rs whenever VICTORY_BVH_BUILDER != 1
   and bvh_no_hit() is active (kill-switch VICTORY_RT_SKIP_DEAD=0):
   - CSComputeSkinning* and CSGenerateHairVB (adapted from edsuuu/VI-BR-PORT
     ab4571df/1556de82/24f8d2e; non-RT skinning such as
     CS_PedStandardSkinning*, CS_PosOnlyLodSkinning*, and computeclothSkinning
     never matches)
   - CS_ScreenProbes_TraceRays*_BVH* and non-Voxels/non-Fallback
     CS_RaytraceVBuffer*
   - Opt-in CS_Primary_GatherCopy via VICTORY_RT_SKIP_GATHER_COPY=1 (adapted
     from Dathinel/victory-4gb#4)

Verified with D3D12 HW and WARP tests proving zero SLOT_MEMORY/SLOT_FAULTS
bindings under no_hit(), shader cache key separation, and container/stage
matcher unit tests.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-27 12:32:14 +00:00
Author
Owner

@⁠CowboyBingus on GitHub · 2026-11-27 12:40 UTC · original

For reference: #143 (open, mergeable) also makes the ray-tracing node test answer none / miss, behind VICTORY_RT_MISS=1, with run-time skip lists (VICTORY_RT_SKIN_NAMES, VICTORY_RT_TRACE_NAMES) that take effect only with that switch on and VICTORY_BVH_BUILDER not 1.

Measured there on an RTX 5070 Ti (ms/frame medians, interleaved runs; the two sets used different builds; full setup and tables in the linked comments):

  • Without vs with the miss mode plus the lists: A1 41.5, R1 39.3, A2 40.5, R2 40.3; dropped draws A 255 / 252, R 354 / 353.
  • Miss mode alone (M) vs miss mode plus the lists (ML): ms/frame M 39.2 / 41.9, ML 41.9 / 38.0 ("Which arm is faster flips between the two rounds, so I do not read a frame-time difference from these four runs"); dropped draws M 244 / 254, ML 346 / 346. On the last per-reason dropped .../frame without a host pipeline lines, the skinning list accounts for 95.3 (ML1) and 95.1 (ML2) per frame and the tracing list for 4.0 per frame in both.

On #143 the maintainer wrote: "I’ll keep the lists opt-in."

This PR's description says VICTORY_BVH_BUILDER is "off (default)", the no-hit mode is "Auto-enabled whenever VICTORY_BVH_BUILDER != 1" and the pass skipping is "Active whenever VICTORY_BVH_BUILDER != 1 && victory_shader::emit::bvh_no_hit()", with its skinning and tracing passes listed there. In its code at 9633fe2, its tests assert that bvh_no_hit_for(None, None) is true and that DeadRtPolicy::from_env(None, true, None, None) gives skip_dead: true, so with none of these variables set both are on. VICTORY_BVH_NO_HIT=0 turns off both, and VICTORY_RT_SKIP_DEAD=0 turns off the pass skipping.

**@⁠CowboyBingus** on GitHub · 2026-11-27 12:40 UTC · [original](https://github.com/TaynanGT/Vice-Tay/pull/254#issuecomment-7218533073) For reference: [#143](https://git.gtahub.st/github/TaynanGT--Vice-Tay/pulls/143) (open, mergeable) also makes the ray-tracing node test answer none / miss, behind `VICTORY_RT_MISS=1`, with run-time skip lists (`VICTORY_RT_SKIN_NAMES`, `VICTORY_RT_TRACE_NAMES`) that take effect only with that switch on and `VICTORY_BVH_BUILDER` not `1`. Measured there on an RTX 5070 Ti (ms/frame medians, interleaved runs; the two sets used different builds; full setup and tables in the linked comments): - [Without vs with the miss mode plus the lists](https://git.gtahub.st/github/TaynanGT--Vice-Tay/pulls/143): A1 41.5, R1 39.3, A2 40.5, R2 40.3; dropped draws A 255 / 252, R 354 / 353. - [Miss mode alone (M) vs miss mode plus the lists (ML)](https://git.gtahub.st/github/TaynanGT--Vice-Tay/pulls/143): ms/frame M 39.2 / 41.9, ML 41.9 / 38.0 ("Which arm is faster flips between the two rounds, so I do not read a frame-time difference from these four runs"); dropped draws M 244 / 254, ML 346 / 346. On the last per-reason `dropped .../frame without a host pipeline` lines, the skinning list accounts for 95.3 (ML1) and 95.1 (ML2) per frame and the tracing list for 4.0 per frame in both. On #143 the maintainer [wrote](https://git.gtahub.st/github/TaynanGT--Vice-Tay/pulls/143): "I’ll keep the lists opt-in." This PR's description says `VICTORY_BVH_BUILDER` is "off (default)", the no-hit mode is "Auto-enabled whenever `VICTORY_BVH_BUILDER != 1`" and the pass skipping is "Active whenever `VICTORY_BVH_BUILDER != 1 && victory_shader::emit::bvh_no_hit()`", with its skinning and tracing passes listed there. In its code at `9633fe2`, its tests assert that `bvh_no_hit_for(None, None)` is true and that `DeadRtPolicy::from_env(None, true, None, None)` gives `skip_dead: true`, so with none of these variables set both are on. `VICTORY_BVH_NO_HIT=0` turns off both, and `VICTORY_RT_SKIP_DEAD=0` turns off the pass skipping.
Author
Owner

@⁠TaynanGT on GitHub · 2026-11-27 12:41 UTC · original

@⁠Vladimir-Human Please keep no-hit and pass skipping opt-in for the first matched run. A miss-only shader and a skipped producer change different parts of the frame. Compare them separately with the same cache state, skinning, hair and water in view, and keep the existing builder guard intact.

**@⁠TaynanGT** on GitHub · 2026-11-27 12:41 UTC · [original](https://github.com/TaynanGT/Vice-Tay/pull/254#issuecomment-7218567366) @⁠Vladimir-Human Please keep no-hit and pass skipping opt-in for the first matched run. A miss-only shader and a skipped producer change different parts of the frame. Compare them separately with the same cache state, skinning, hair and water in view, and keep the existing builder guard intact.
Author
Owner

@⁠TaynanGT on GitHub · 2026-11-27 12:47 UTC · original

@⁠CowboyBingus The #143 split is the right reference: the lists removed about 99 draws per frame, with no consistent gain in the two rounds. Your check of the default policy confirms why these switches need to stay opt-in. Let’s keep miss handling and producer skipping separately selectable and compare them against the same baseline.

**@⁠TaynanGT** on GitHub · 2026-11-27 12:47 UTC · [original](https://github.com/TaynanGT/Vice-Tay/pull/254#issuecomment-7218671709) @⁠CowboyBingus The #143 split is the right reference: the lists removed about 99 draws per frame, with no consistent gain in the two rounds. Your check of the default policy confirms why these switches need to stay opt-in. Let’s keep miss handling and producer skipping separately selectable and compare them against the same baseline.
github-bot changed title from perf(rt): port VICTORY_BVH_NO_HIT and auto-skip dead RT compute passes (#168) to perf(rt): add opt-in VICTORY_BVH_NO_HIT and dead-RT compute pass skipping 2026-11-27 13:34:53 +00:00
github-bot force-pushed github-bot/gh-254 from 9633fe21a1 to ade3409766 2026-11-27 13:34:54 +00:00 Compare
Author
Owner

@⁠Vladimir-Human on GitHub · 2026-11-27 13:32 UTC · original

Thank you @⁠CowboyBingus and @⁠TaynanGT for the review and #143 context! Updated in ade34097:

  • Flipped VICTORY_BVH_NO_HIT, VICTORY_RT_SKIP_DEAD, and VICTORY_RT_SKIP_GATHER_COPY to strictly opt-in (OFF by default) so default runtime behavior and default shader cache keys are unchanged.
  • Decoupled VICTORY_RT_SKIP_DEAD and VICTORY_RT_SKIP_GATHER_COPY from VICTORY_BVH_NO_HIT so each switch can be A/B tested independently or combined against the same baseline (while VICTORY_BVH_BUILDER=1 still forces all three off).
  • Updated bvh_no_hit_for, DeadRtPolicy::from_env, Pending::new_with, and shader_cache::tests accordingly and re-verified clippy (-D warnings, default + diagnostics), xtask, and D3D12 HW + WARP tests (0 debug layer errors).
**@⁠Vladimir-Human** on GitHub · 2026-11-27 13:32 UTC · [original](https://github.com/TaynanGT/Vice-Tay/pull/254#issuecomment-7219617473) Thank you @⁠CowboyBingus and @⁠TaynanGT for the review and #143 context! Updated in `ade34097`: - Flipped `VICTORY_BVH_NO_HIT`, `VICTORY_RT_SKIP_DEAD`, and `VICTORY_RT_SKIP_GATHER_COPY` to **strictly opt-in (OFF by default)** so default runtime behavior and default shader cache keys are unchanged. - Decoupled `VICTORY_RT_SKIP_DEAD` and `VICTORY_RT_SKIP_GATHER_COPY` from `VICTORY_BVH_NO_HIT` so each switch can be A/B tested independently or combined against the same baseline (while `VICTORY_BVH_BUILDER=1` still forces all three off). - Updated `bvh_no_hit_for`, `DeadRtPolicy::from_env`, `Pending::new_with`, and `shader_cache::tests` accordingly and re-verified clippy (`-D warnings`, default + `diagnostics`), `xtask`, and D3D12 HW + WARP tests (0 debug layer errors).
Author
Owner

@⁠TaynanGT on GitHub · 2026-11-27 13:37 UTC · original

@⁠Vladimir-Human The independent opt-ins make this comparable with #143. Keep the baseline, miss-only and skip-only runs on the same camera path and cache state. The builder’s override is the right guard for the combined case.

**@⁠TaynanGT** on GitHub · 2026-11-27 13:37 UTC · [original](https://github.com/TaynanGT/Vice-Tay/pull/254#issuecomment-7219727204) @⁠Vladimir-Human The independent opt-ins make this comparable with #143. Keep the baseline, miss-only and skip-only runs on the same camera path and cache state. The builder’s override is the right guard for the combined case.
This pull request can be merged automatically.
This branch is out-of-date with the base branch
You are not authorized to merge this pull request.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin '+refs/pull/254/head:github-bot/gh-254'
git switch 'github-bot/gh-254'

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-254'
git switch 'github-bot/gh-254'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-254'
git switch 'github-bot/gh-254'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-254'
git switch 'main'
git merge --squash 'github-bot/gh-254'
git switch 'main'
git merge --ff-only 'github-bot/gh-254'
git switch 'main'
git merge 'github-bot/gh-254'
git push origin 'main'
This discussion has been locked. Commenting is limited to contributors.
No description provided.