BVH: keep absent children behind real hits #230

Closed
space-de wants to merge 4 commits from upstream-pr/230 into main
space-de commented 2026-11-24 22:50:46 +00:00 (Migrated from github.com)

Imported from fxceless/victory-fork. Originally posted by space-de on 2026-11-24T22:50:46Z.


Fixes #173.

When a BVH child pointer is NONE, its stored bounds can still intersect the ray. The current slab test then gives that absent child a finite distance, so the sorting network can place the NONE sentinel ahead of a real hit. Traversal that stops at the first absent child can miss valid geometry.

Require a present child in both implementations: the CPU reference and the matching DXIL emitter. Absent children now remain misses with infinite distance, so sorting keeps valid intersections ahead of them.

Checks

  • cargo check -p victory-shader --locked
  • cargo clippy -p victory-shader --locked -- -D warnings
  • rustfmt --edition 2024 --check crates/victory-shader/src/bvh.rs crates/victory-shader/src/emit/intersect.rs
  • git diff --check

No in-game run was performed. This is a BVH traversal correctness fix; no frame-rate improvement is claimed.

<!-- greyfinch-sync:fxceless/victory-fork:issue:6592991436 --> Imported from [fxceless/victory-fork](https://github.com/fxceless/victory-fork/pull/230). Originally posted by [space-de](https://github.com/space-de) on 2026-11-24T22:50:46Z. --- Fixes #173. When a BVH child pointer is `NONE`, its stored bounds can still intersect the ray. The current slab test then gives that absent child a finite distance, so the sorting network can place the `NONE` sentinel ahead of a real hit. Traversal that stops at the first absent child can miss valid geometry. Require a present child in both implementations: the CPU reference and the matching DXIL emitter. Absent children now remain misses with infinite distance, so sorting keeps valid intersections ahead of them. **Checks** - `cargo check -p victory-shader --locked` - `cargo clippy -p victory-shader --locked -- -D warnings` - `rustfmt --edition 2024 --check crates/victory-shader/src/bvh.rs crates/victory-shader/src/emit/intersect.rs` - `git diff --check` No in-game run was performed. This is a BVH traversal correctness fix; no frame-rate improvement is claimed.
towiice commented 2026-11-25 00:09:30 +00:00 (Migrated from github.com)

Imported from fxceless/victory-fork. Originally posted by towiice on 2026-11-24T23:28:12Z.

Review: COMMENTED


Tested:

  • Hardware: NVIDIA GeForce GTX 1650 SUPER (Turing TU116, 4 GB VRAM, wave32, driver 610.88), Windows 11 x64 (26H2 / build 26300), DXC v1.9.2609, rustc 1.100.0 (stable-x86_64-pc-windows-gnullvm, llvm-mingw 23.1.6).
  • cargo +stable-x86_64-pc-windows-gnullvm test -p victory-shader --lib bvh: 15 passed, 0 failed (0.06 s).
  • cargo +stable-x86_64-pc-windows-gnullvm test -p victory-shader --lib intersect: 6 passed, 0 failed (5.77 s) on hardware GPU and WARP.
<!-- greyfinch-sync:fxceless/victory-fork:review:6049053842 --> Imported from [fxceless/victory-fork](https://github.com/fxceless/victory-fork/pull/230#pullrequestreview-6049053842). Originally posted by [towiice](https://github.com/towiice) on 2026-11-24T23:28:12Z. **Review:** COMMENTED --- **Tested:** - Hardware: NVIDIA GeForce GTX 1650 SUPER (Turing TU116, 4 GB VRAM, wave32, driver `610.88`), Windows 11 x64 (26H2 / build `26300`), DXC `v1.9.2609`, `rustc 1.100.0` (`stable-x86_64-pc-windows-gnullvm`, `llvm-mingw` 23.1.6). - `cargo +stable-x86_64-pc-windows-gnullvm test -p victory-shader --lib bvh`: **15 passed, 0 failed** (0.06 s). - `cargo +stable-x86_64-pc-windows-gnullvm test -p victory-shader --lib intersect`: **6 passed, 0 failed** (5.77 s) on hardware GPU and WARP.
kaayzouee commented 2026-11-25 02:10:07 +00:00 (Migrated from github.com)

Imported from fxceless/victory-fork. Originally posted by kaayzouee on 2026-11-25T01:23:12Z.


Duplicate of #213?

<!-- greyfinch-sync:fxceless/victory-fork:comment:7149491535 --> Imported from [fxceless/victory-fork](https://github.com/fxceless/victory-fork/pull/230#issuecomment-7149491535). Originally posted by [kaayzouee](https://github.com/kaayzouee) on 2026-11-25T01:23:12Z. --- Duplicate of #213?
upstream-sync closed this pull request 2026-11-25 06:06:17 +00:00

Pull request closed

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
fxceless/victory-fork!230
No description provided.