Shaders: guard BVH node loads and split box/triangle intersection by node type #3806

Open
Vemast wants to merge 1 commit from upstream-pr/3806 into main
Vemast commented 2026-11-28 23:33:35 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by Vemast on 2026-11-28T23:33:35Z.


Summary

  • Guarded the 16-dword BVH node load and intersection in Lower::bvh_lanes (crates/victory-shader/src/emit/lower/bvh.rs) behind ty < 6, returning zeros when a node pointer is INVALID (0xFFFF_FFFF) or has ty >= 6 instead of reading from bogus title-memory addresses and risking false miss-bitmap bits.
  • Branched ty < 4 (triangle intersection) vs ty >= 4 (box intersection + conditional box32 tail load) so valid nodes only run the relevant intersection path and box-tail memory reads.
  • Added synthetic end-to-end test emit::bvh_tests::invalid_and_non_box_nodes_skip_title_memory_loads verifying INVALID/ty >= 6 and non-box32 nodes return expected results without performing bogus title-memory loads.

Verification

  • cargo test -p victory-shader --lib bvh_tests — 15/15 passed (validated by dxil.dll, ran on hardware D3D12 + WARP)
  • cargo clippy -p victory-shader --all-targets
  • cargo run -p xtask -- policy
  • No game data used.
<!-- greyfinch-sync:Marvisak/VIctory:issue:5545660781 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/3806). Originally posted by [Vemast](https://github.com/Vemast) on 2026-11-28T23:33:35Z. --- ### Summary - Guarded the 16-dword BVH node load and intersection in `Lower::bvh_lanes` (`crates/victory-shader/src/emit/lower/bvh.rs`) behind `ty < 6`, returning zeros when a node pointer is `INVALID` (`0xFFFF_FFFF`) or has `ty >= 6` instead of reading from bogus title-memory addresses and risking false miss-bitmap bits. - Branched `ty < 4` (triangle intersection) vs `ty >= 4` (box intersection + conditional `box32` tail load) so valid nodes only run the relevant intersection path and box-tail memory reads. - Added synthetic end-to-end test `emit::bvh_tests::invalid_and_non_box_nodes_skip_title_memory_loads` verifying `INVALID`/`ty >= 6` and non-`box32` nodes return expected results without performing bogus title-memory loads. ### Verification - `cargo test -p victory-shader --lib bvh_tests` — 15/15 passed (validated by `dxil.dll`, ran on hardware D3D12 + WARP) - `cargo clippy -p victory-shader --all-targets` - `cargo run -p xtask -- policy` - No game data used.
copilot-pull-request-reviewer[bot] commented 2026-11-28 23:33:44 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by copilot-pull-request-reviewer[bot] on 2026-11-28T23:33:44Z.

Review: COMMENTED


Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

<!-- greyfinch-sync:Marvisak/VIctory:review:6100556135 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/3806#pullrequestreview-6100556135). Originally posted by [copilot-pull-request-reviewer[bot]](https://github.com/apps/copilot-pull-request-reviewer) on 2026-11-28T23:33:44Z. **Review:** COMMENTED --- Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.
cloph-dsp commented 2026-11-28 23:51:33 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by cloph-dsp on 2026-11-28T23:51:33Z.


Independent local verification (Windows, Rust 1.100.0/MSVC, no game data):

  • PR #3806 at head 98cd1e341f191c57101631d37dc770c01f5a088f, base/parent 63bcca43c6a00a758510398fa43096ce7e4f7df0.
  • cargo test --locked -p victory-shader --lib -- emit::bvh_tests::invalid_and_non_box_nodes_skip_title_memory_loads --exact --test-threads=1 --quiet → 1 passed, 0 failed, 305 filtered, exit 0.
  • git grep -F for the test name on the base returned no match (test is new on this PR); git diff --check HEAD^ HEAD clean (2 files, +126/-17).
  • Used a per-worktree CARGO_TARGET_DIR (never shared) with CARGO_BUILD_JOBS=2.
  • Only the named synthetic test was replayed; full workspace suite and clippy were not run locally. The single review on this PR is a non-approving bot comment (quota exhausted), not an approval.
  • GPU/driver: N/A (CPU-only BVH lowering test). No game data, assets, extracted shaders, DRM or decrypt involved.

AI-assisted (Hy4 flash).

<!-- greyfinch-sync:Marvisak/VIctory:comment:7247710214 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/3806#issuecomment-7247710214). Originally posted by [cloph-dsp](https://github.com/cloph-dsp) on 2026-11-28T23:51:33Z. --- Independent local verification (Windows, Rust 1.100.0/MSVC, no game data): - PR #3806 at head `98cd1e341f191c57101631d37dc770c01f5a088f`, base/parent `63bcca43c6a00a758510398fa43096ce7e4f7df0`. - `cargo test --locked -p victory-shader --lib -- emit::bvh_tests::invalid_and_non_box_nodes_skip_title_memory_loads --exact --test-threads=1 --quiet` → 1 passed, 0 failed, 305 filtered, exit 0. - `git grep -F` for the test name on the base returned no match (test is new on this PR); `git diff --check HEAD^ HEAD` clean (2 files, +126/-17). - Used a per-worktree `CARGO_TARGET_DIR` (never shared) with `CARGO_BUILD_JOBS=2`. - Only the named synthetic test was replayed; full workspace suite and clippy were not run locally. The single review on this PR is a non-approving bot comment (quota exhausted), not an approval. - GPU/driver: N/A (CPU-only BVH lowering test). No game data, assets, extracted shaders, DRM or decrypt involved. AI-assisted (Hy4 flash).
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/3806:upstream-pr/3806'
git switch 'upstream-pr/3806'

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