Count in-plane box candidates in the BVH CPU reference #116

Merged
Vonsek merged 3 commits from upstream-pr/117 into main 2026-11-21 17:36:40 +00:00
Vonsek commented 2026-11-21 16:31:35 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by Vonsek on 2026-11-21T16:31:35Z.


Change

The CPU reference behind bvh_hits and bvh_packed skipped every leaf for rays with a zero depth component, so it reported no box candidates for a ray lying in a leaf row's plane. TraceHits accepts those flat boxes through its zero-direction slab branch (origin inside the zero-thickness [lo, hi] range). The reference now computes the closed in-plane overlap in double precision. Such rays still never hit a triangle, matching the shader's zero-determinant rule. Two coplanar rays were added: one crosses the first row, the other ends exactly on the third box's face. docs/experiments.md is updated for 132 rays and the new miss counts.

Verification

Linux (no D3D12): the anonymous-namespace code of tests/bvh_hits.cpp was compiled with g++ and clang++ and compared with a float C++ port of TraceHits' slab test, triangle test, counts and tie rule. Without the reference change, the two new rays gave 6 mismatches in the box count (reference 0, shader 8/3, 2/2, 8/3 across the three scenes). With it, 132 rays x 3 scenes gave 0 mismatches. The existing 130 rays already agreed before the change.

Windows: ctest --preset dev --no-tests=error -R 'bvh_hits|bvh_packed|bvh_differential' -V at 839bf85 (rebased on main with #99) on Windows 11 build 26200.9974, VS Build Tools 2022 17.14 (MSVC 14.44.35207), Windows SDK 10.0.26100: 6/6 passed on an NVIDIA GeForce RTX 5080 (driver 32.0.16.1692) and on WARP (Microsoft Basic Render Driver). The D3D12 debug layer was not available.

bvh_hits (hardware and warp):
epoch=0 rays=132 hits=112 misses=20 mismatches=0
epoch=1 rays=132 hits=14 misses=118 mismatches=0
epoch=2 rays=132 hits=108 misses=24 mismatches=0
bvh_packed (hardware and warp):
packed_epochs=3 scene_words_per_epoch=1280 guard_words=4 rays_per_run=396 changed_ids=4

bvh_differential output is identical to upstream main. On upstream main the same command reports rays=130, misses 18/116/22 and rays_per_run=390.

Evidence and follow-up

No new fixture data; the geometry is source-built. Treating a coplanar ray as a box candidate but never a triangle hit is a fixture convention that follows the shader. bvh_differential keeps its own ray list and is unchanged. Rays with infinite or NaN direction components remain uncovered.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:issue:6531458483 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/117). Originally posted by [Vonsek](https://github.com/Vonsek) on 2026-11-21T16:31:35Z. --- ## Change The CPU reference behind `bvh_hits` and `bvh_packed` skipped every leaf for rays with a zero depth component, so it reported no box candidates for a ray lying in a leaf row's plane. `TraceHits` accepts those flat boxes through its zero-direction slab branch (origin inside the zero-thickness `[lo, hi]` range). The reference now computes the closed in-plane overlap in double precision. Such rays still never hit a triangle, matching the shader's zero-determinant rule. Two coplanar rays were added: one crosses the first row, the other ends exactly on the third box's face. `docs/experiments.md` is updated for 132 rays and the new miss counts. ## Verification Linux (no D3D12): the anonymous-namespace code of `tests/bvh_hits.cpp` was compiled with g++ and clang++ and compared with a float C++ port of `TraceHits`' slab test, triangle test, counts and tie rule. Without the reference change, the two new rays gave 6 mismatches in the box count (reference 0, shader 8/3, 2/2, 8/3 across the three scenes). With it, 132 rays x 3 scenes gave 0 mismatches. The existing 130 rays already agreed before the change. Windows: `ctest --preset dev --no-tests=error -R 'bvh_hits|bvh_packed|bvh_differential' -V` at 839bf85 (rebased on main with #99) on Windows 11 build 26200.9974, VS Build Tools 2022 17.14 (MSVC 14.44.35207), Windows SDK 10.0.26100: 6/6 passed on an NVIDIA GeForce RTX 5080 (driver 32.0.16.1692) and on WARP (Microsoft Basic Render Driver). The D3D12 debug layer was not available. ``` bvh_hits (hardware and warp): epoch=0 rays=132 hits=112 misses=20 mismatches=0 epoch=1 rays=132 hits=14 misses=118 mismatches=0 epoch=2 rays=132 hits=108 misses=24 mismatches=0 bvh_packed (hardware and warp): packed_epochs=3 scene_words_per_epoch=1280 guard_words=4 rays_per_run=396 changed_ids=4 ``` `bvh_differential` output is identical to upstream main. On upstream main the same command reports `rays=130`, misses 18/116/22 and `rays_per_run=390`. ## Evidence and follow-up No new fixture data; the geometry is source-built. Treating a coplanar ray as a box candidate but never a triangle hit is a fixture convention that follows the shader. `bvh_differential` keeps its own ray list and is unchanged. Rays with infinite or NaN direction components remain uncovered.
upstream-sync closed this pull request 2026-11-24 06:41:23 +00:00
rasptum commented 2026-11-24 06:47:38 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by rasptum on 2026-11-21T16:49:21Z.


Second GPU at daad822: RTX 3060 (driver 32.0.15.9636) on Windows 10 22H2 (19045.6466), VS Build Tools 17.14, SDK 10.0.26100, debug layer unavailable. bvh_hits_hardware, bvh_packed_hardware and bvh_differential_hardware passed, with output identical to your RTX 5080 run:

epoch=0 rays=132 hits=112 misses=20 mismatches=0
epoch=1 rays=132 hits=14 misses=118 mismatches=0
epoch=2 rays=132 hits=108 misses=24 mismatches=0
packed_epochs=3 scene_words_per_epoch=1280 guard_words=4 rays_per_run=396 changed_ids=4

The WARP variants could not be checked here. On Windows 10 WARP (SM 6.2), bvh_hits_warp and bvh_packed_warp fail at pipeline creation, which is the issue #99 fixed and this branch predates.

AI-assisted (Claude Code); run locally on the configuration above.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7065953527 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/117#issuecomment-7065953527). Originally posted by [rasptum](https://github.com/rasptum) on 2026-11-21T16:49:21Z. --- Second GPU at `daad822`: RTX 3060 (driver 32.0.15.9636) on Windows 10 22H2 (19045.6466), VS Build Tools 17.14, SDK 10.0.26100, debug layer unavailable. `bvh_hits_hardware`, `bvh_packed_hardware` and `bvh_differential_hardware` passed, with output identical to your RTX 5080 run: ```text epoch=0 rays=132 hits=112 misses=20 mismatches=0 epoch=1 rays=132 hits=14 misses=118 mismatches=0 epoch=2 rays=132 hits=108 misses=24 mismatches=0 packed_epochs=3 scene_words_per_epoch=1280 guard_words=4 rays_per_run=396 changed_ids=4 ``` The WARP variants could not be checked here. On Windows 10 WARP (SM 6.2), `bvh_hits_warp` and `bvh_packed_warp` fail at pipeline creation, which is the issue #99 fixed and this branch predates. _AI-assisted (Claude Code); run locally on the configuration above._
Vonsek commented 2026-11-24 06:47:39 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by Vonsek on 2026-11-21T17:04:29Z.


Thanks for the RTX 3060 / Windows 10 run. I rebased the branch onto current main (now 839bf85), so it includes #99 and the cs_6_5 fixtures should skip instead of failing on Windows 10 WARP (SM 6.2). No change to the commit itself.

Re-run at 839bf85 on Windows 11 26200.9974 (RTX 5080, driver 32.0.16.1692, and WARP): ctest --preset dev --no-tests=error -R 'bvh_hits|bvh_packed|bvh_differential' -V passed 6/6 with the same output (rays=132, misses 20/118/24, rays_per_run=396).

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7066189557 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/117#issuecomment-7066189557). Originally posted by [Vonsek](https://github.com/Vonsek) on 2026-11-21T17:04:29Z. --- Thanks for the RTX 3060 / Windows 10 run. I rebased the branch onto current main (now 839bf85), so it includes #99 and the cs_6_5 fixtures should skip instead of failing on Windows 10 WARP (SM 6.2). No change to the commit itself. Re-run at 839bf85 on Windows 11 26200.9974 (RTX 5080, driver 32.0.16.1692, and WARP): `ctest --preset dev --no-tests=error -R 'bvh_hits|bvh_packed|bvh_differential' -V` passed 6/6 with the same output (`rays=132`, misses 20/118/24, `rays_per_run=396`).
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
R0Y00/Xbox2Windows!116
No description provided.