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

Manually merged
github merged 3 commits from gh-pr/117/head into gh-pr/117/base 2026-11-26 21:28:07 +00:00
Owner

@⁠Vonsek on GitHub · 2026-11-21 16:31 UTC · original
Vonsek:bvh-cpu-reference → main · +30 −6 · 2 files · 3 commits · merged 2026-11-21 17:36 UTC

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.

**@⁠Vonsek** on GitHub · 2026-11-21 16:31 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/117) `Vonsek:bvh-cpu-reference` → `main` · +30 −6 · 2 files · 3 commits · merged 2026-11-21 17:36 UTC ## 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.
The CPU reference skipped every leaf for rays with a zero depth
component, so it reported no box candidates when such a ray lies in a
leaf row's plane. TraceHits' zero-direction slab branch accepts those
flat boxes. Model the closed in-plane overlap in double precision and
add two coplanar rays, one ending exactly on a box face.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 21:28:04 +00:00
github manually merged commit 801431d6d2 into gh-pr/117/base 2026-11-26 21:28:07 +00:00
Author
Owner

@⁠rasptum on GitHub · 2026-11-21 16:49 UTC · original

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.

**@⁠rasptum** on GitHub · 2026-11-21 16:49 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/117#issuecomment-7065953527) 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._
Author
Owner

@⁠Vonsek on GitHub · 2026-11-21 17:04 UTC · original

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).

**@⁠Vonsek** on GitHub · 2026-11-21 17:04 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/117#issuecomment-7066189557) 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`).
This discussion has been locked. Commenting is limited to contributors.
No description provided.