Shaders: opt-in VICTORY_BVH_MISS to miss BVH nodes at the root #3398

Open
danielibabet wants to merge 1 commit from upstream-pr/3398 into main
danielibabet commented 2026-11-26 22:08:16 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by danielibabet on 2026-11-26T22:08:16Z.


Summary

Adds an opt-in VICTORY_BVH_MISS=1 switch (off by default) in crates/victory-shader/src/emit/lower/bvh.rs to return a node miss at the root without reading BVH memory or running box/triangle tests, plus includes it in the shader_cache build key.

Why

When the title's BVH structure builder is inactive (e.g., on 32-lane hosts where 64-lane compute shaders are refused), BVH memory holds stale nodes. Skipping BVH traversal at the root avoids stalls/hangs and saves ~10 ms/frame while keeping default behaviour unchanged unless VICTORY_BVH_MISS=1 is set.

Credits

Adapted from trustno1-coder/VIctory-NVIDIA (VICTORY_BVH_MISS=1).

Verification

  • cargo test -p victory-gpu --lib shader_cache:: -- --test-threads=1 (4/4 passed)
  • cargo clippy -p victory-shader -p victory-gpu --all-targets -- -D warnings (clean)
  • cargo xtask policy (191 files ok)
<!-- greyfinch-sync:Marvisak/VIctory:issue:5517811186 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/3398). Originally posted by [danielibabet](https://github.com/danielibabet) on 2026-11-26T22:08:16Z. --- ## Summary Adds an opt-in `VICTORY_BVH_MISS=1` switch (off by default) in `crates/victory-shader/src/emit/lower/bvh.rs` to return a node miss at the root without reading BVH memory or running box/triangle tests, plus includes it in the `shader_cache` build key. ### Why When the title's BVH structure builder is inactive (e.g., on 32-lane hosts where 64-lane compute shaders are refused), BVH memory holds stale nodes. Skipping BVH traversal at the root avoids stalls/hangs and saves ~10 ms/frame while keeping default behaviour unchanged unless `VICTORY_BVH_MISS=1` is set. ### Credits Adapted from `trustno1-coder/VIctory-NVIDIA` (`VICTORY_BVH_MISS=1`). ### Verification - `cargo test -p victory-gpu --lib shader_cache:: -- --test-threads=1` (4/4 passed) - `cargo clippy -p victory-shader -p victory-gpu --all-targets -- -D warnings` (clean) - `cargo xtask policy` (191 files ok)
Dukestar69 commented 2026-11-26 22:29:12 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by Dukestar69 on 2026-11-26T22:29:12Z.

Review: APPROVED


LGTM — verified on RTX 5090 (Windows / D3D12) against origin/main (63bcca4).

  • Opt-in VICTORY_BVH_MISS is cleanly isolated, included in the shader cache key, and leaves default BVH traversal untouched.
  • cargo test -p victory-shader --lib emit::bvh_tests:: -- --test-threads=1: 14 passed, 0 failed.
  • cargo test -p victory-gpu --lib shader_cache:: -- --test-threads=1: 4 passed, 0 failed.
  • cargo clippy -p victory-shader -p victory-gpu --all-targets -- -D warnings: clean.
  • cargo xtask policy: 191 files ok.

Synthetic tests only (no game files used). AI-assisted (Gemini 4 Neon).

<!-- greyfinch-sync:Marvisak/VIctory:review:6081130021 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/3398#pullrequestreview-6081130021). Originally posted by [Dukestar69](https://github.com/Dukestar69) on 2026-11-26T22:29:12Z. **Review:** APPROVED --- LGTM — verified on RTX 5090 (Windows / D3D12) against `origin/main` (`63bcca4`). - Opt-in `VICTORY_BVH_MISS` is cleanly isolated, included in the shader cache key, and leaves default BVH traversal untouched. - `cargo test -p victory-shader --lib emit::bvh_tests:: -- --test-threads=1`: 14 passed, 0 failed. - `cargo test -p victory-gpu --lib shader_cache:: -- --test-threads=1`: 4 passed, 0 failed. - `cargo clippy -p victory-shader -p victory-gpu --all-targets -- -D warnings`: clean. - `cargo xtask policy`: 191 files ok. Synthetic tests only (no game files used). AI-assisted (Gemini 4 Neon).
Jackster commented 2026-11-26 22:36:59 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by Jackster on 2026-11-26T22:36:59Z.


Windows 11, 63bcca4 + this PR:

  • cargo test -p victory-shader --lib --features host bvh: 14 passed (1.29 s).
  • cargo clippy -p victory-shader --all-targets -- -D warnings: clean.

No test is added: the switch gates a translation path (VICTORY_BVH_MISS) and the existing BVH tests pass unchanged. I did not exercise the switch itself — that needs a shader that reads BVH nodes, which is title-side. Synthetic only. AI-assisted.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7204836521 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/3398#issuecomment-7204836521). Originally posted by [Jackster](https://github.com/Jackster) on 2026-11-26T22:36:59Z. --- Windows 11, `63bcca4` + this PR: - `cargo test -p victory-shader --lib --features host bvh`: 14 passed (1.29 s). - `cargo clippy -p victory-shader --all-targets -- -D warnings`: clean. No test is added: the switch gates a translation path (`VICTORY_BVH_MISS`) and the existing BVH tests pass unchanged. I did not exercise the switch itself — that needs a shader that reads BVH nodes, which is title-side. Synthetic only. AI-assisted.
fuzeofficlal commented 2026-11-26 23:15:12 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by fuzeofficlal on 2026-11-26T23:15:12Z.

Review: APPROVED


Reviewed 846362d0 merged onto main (63bcca43) — clean opt-in BVH miss switch with proper shader-cache isolation.

Verification

  • cargo xtask policy: 191 files ok; cargo clippy --locked -p victory-shader -p victory-gpu --all-targets -- -D warnings (both default and --features diagnostics): 0 warnings.
  • Confirmed victory_shader::emit::bvh_miss() (emit/mod.rs:270) is off by default and included in the shader-cache key (shader_cache.rs:71, 79-85) with unit-test coverage (shader_cache.rs:492), preventing VICTORY_BVH_MISS=1 translations from polluting normal cache entries.
  • victory-shader BVH tests (14/14) and victory-gpu shader_cache::tests:: (4/4) passed with default settings on RTX 5090 and WARP.
  • Live GPU/WARP + dxil.dll probe with VICTORY_BVH_MISS=1: ran all 4 combinations (image_bvh_intersect_ray and image_bvh64_intersect_ray × root SRV and title-memory pointers) over 256 lanes with node memory poisoned (0xDEAD_BEEF) on both RTX 5090 and WARP — every shader passed dxil.dll validation, read no node memory, and returned exact [+Inf, 1.0, 0, 0] for triangle nodes (ty < 4) and [0xFFFF_FFFF; 4] for non-triangle nodes (ty >= 4), matching bvh_triangle/bvh_box miss sentinels (bvh.rs:192-209).

LGTM.

<!-- greyfinch-sync:Marvisak/VIctory:review:6081392615 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/3398#pullrequestreview-6081392615). Originally posted by [fuzeofficlal](https://github.com/fuzeofficlal) on 2026-11-26T23:15:12Z. **Review:** APPROVED --- Reviewed `846362d0` merged onto `main` (`63bcca43`) — clean opt-in BVH miss switch with proper shader-cache isolation. ### Verification - `cargo xtask policy`: 191 files ok; `cargo clippy --locked -p victory-shader -p victory-gpu --all-targets -- -D warnings` (both default and `--features diagnostics`): 0 warnings. - Confirmed `victory_shader::emit::bvh_miss()` (`emit/mod.rs:270`) is off by default and included in the shader-cache key (`shader_cache.rs:71, 79-85`) with unit-test coverage (`shader_cache.rs:492`), preventing `VICTORY_BVH_MISS=1` translations from polluting normal cache entries. - `victory-shader` BVH tests (14/14) and `victory-gpu` `shader_cache::tests::` (4/4) passed with default settings on RTX 5090 and WARP. - **Live GPU/WARP + `dxil.dll` probe with `VICTORY_BVH_MISS=1`**: ran all 4 combinations (`image_bvh_intersect_ray` and `image_bvh64_intersect_ray` × root SRV and title-memory pointers) over 256 lanes with node memory poisoned (`0xDEAD_BEEF`) on both RTX 5090 and WARP — every shader passed `dxil.dll` validation, read no node memory, and returned exact `[+Inf, 1.0, 0, 0]` for triangle nodes (`ty < 4`) and `[0xFFFF_FFFF; 4]` for non-triangle nodes (`ty >= 4`), matching `bvh_triangle`/`bvh_box` miss sentinels (`bvh.rs:192-209`). LGTM.
This pull request cannot be merged automatically due to conflicts.
Merge manually to resolve the conflicts.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin 'upstream-pr/3398:upstream-pr/3398'
git switch 'upstream-pr/3398'

Merge

Merge the changes and update on Forgejo.

Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.

git switch 'main'
git merge --no-ff 'upstream-pr/3398'
git switch 'upstream-pr/3398'
git rebase 'main'
git switch 'main'
git merge --ff-only 'upstream-pr/3398'
git switch 'upstream-pr/3398'
git rebase 'main'
git switch 'main'
git merge --no-ff 'upstream-pr/3398'
git switch 'main'
git merge --squash 'upstream-pr/3398'
git switch 'main'
git merge --ff-only 'upstream-pr/3398'
git switch 'main'
git merge 'upstream-pr/3398'
git push origin 'main'
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
Marvisak/VIctory!3398
No description provided.