xdxr_bvh: handle D3D12 inactive primitives and NaN bounds (OLD-10063) #598

Manually merged
github merged 2 commits from gh-pr/598/head into gh-pr/598/base 2026-11-26 09:10:53 +00:00
Owner

@⁠jarvixaiassistant-glitch on GitHub · 2026-11-24 09:38 UTC · original
jarvixaiassistant-glitch:fix/old-10063-xdxr-bvh-nan-inactive → main · +202 −37 · 2 files · 2 commits · merged 2026-11-24 22:33 UTC

Claimed in the coordination issue as: OLD-10063

What and why

Carries forward old-pr/10063 (draft #329) onto main (d7576d56a), preserving ShotTechOp's original commit verbatim per CONTRIBUTING.md and adding one focused hardening commit on top:

  1. Original commit (ShotTechOp): Updates tools/xdxr_bvh.py to handle D3D12 inactive triangles (NaN vertices → empty box (+inf, -inf), never paired; zero-length edges skipped during pairing), inactive TLAS instances (blas_va == 0, zero mask, empty blas_bounds, or NaN-transformed corners → empty world box), NaN-safe _box_test, and explicit NaN child-box rejection in validate(), plus synthetic unit tests in tests/test_xdxr_bvh.py.
  2. Hardening commit (JARVIX): Updates invert_affine() in tools/xdxr_bvh.py to reject non-finite determinants (not math.isfinite(det)) and non-finite inverse entries. Previously, a NaN in an inactive TLAS instance's rotation or translation bypassed det == 0 and packed NaN floats into the instance record's inverse matrix instead of triggering build_tlas()'s zero-matrix fallback. Adds test_nan_transform_falls_back_to_zero_inverse_in_tlas covering both rotation and translation NaNs.

Tested

All synthetic CPU/stdlib/docs checks on Windows 11 x64, Python 3.12.14, Node v24.19.0 (no game files):

  • python -I tests/test_xdxr_bvh.py -v — 54/54 passed (reproduced invert_affine() returning all-NaN before the hardening commit; 54/54 pass after)
  • python -I scripts/check_no_game_data.py — passed (0 forbidden tracked extensions)
  • python -m compileall -q make_game.py tools tests — passed
  • python -I tests/test_text_write_line_endings.py, tests/test_report_paths.py, tests/test_i18n_index.py, and all tests/test_docs_*.py — passed
  • node --test tests/test_viewer_streaming.cjs — passed

GPUs tested: n/a (CPU BVH reference / unit tests only)

AI-assisted: yes (JARVIX multi-model team: Antigravity + DeepSeek-V4-Pro + NVIDIA NIM Nemotron-3.5-Lightning & Nemotron-3-Ultra-550B)

Checklist

  • Based on current main and merges cleanly (a conflicting pull request is labeled needs rebase).
  • One topic; follow-up work goes in a new pull request.
  • No game data, keys or decryption (CONTRIBUTING.md), including in logs or reports quoted here.
  • A new translator rule is in the contract table of docs/design.md, with how it was confirmed. (N/A — CPU BVH reference tool only, no shader-translator rule changed.)
**@⁠jarvixaiassistant-glitch** on GitHub · 2026-11-24 09:38 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/598) `jarvixaiassistant-glitch:fix/old-10063-xdxr-bvh-nan-inactive` → `main` · +202 −37 · 2 files · 2 commits · merged 2026-11-24 22:33 UTC Claimed in the coordination issue as: OLD-10063 ### What and why Carries forward `old-pr/10063` (draft #329) onto `main` (`d7576d56a`), preserving `ShotTechOp`'s original commit verbatim per `CONTRIBUTING.md` and adding one focused hardening commit on top: 1. **Original commit (`ShotTechOp`):** Updates `tools/xdxr_bvh.py` to handle D3D12 inactive triangles (NaN vertices → empty box `(+inf, -inf)`, never paired; zero-length edges skipped during pairing), inactive TLAS instances (`blas_va == 0`, zero mask, empty `blas_bounds`, or NaN-transformed corners → empty world box), NaN-safe `_box_test`, and explicit NaN child-box rejection in `validate()`, plus synthetic unit tests in `tests/test_xdxr_bvh.py`. 2. **Hardening commit (`JARVIX`):** Updates `invert_affine()` in `tools/xdxr_bvh.py` to reject non-finite determinants (`not math.isfinite(det)`) and non-finite inverse entries. Previously, a `NaN` in an inactive TLAS instance's rotation or translation bypassed `det == 0` and packed `NaN` floats into the instance record's inverse matrix instead of triggering `build_tlas()`'s zero-matrix fallback. Adds `test_nan_transform_falls_back_to_zero_inverse_in_tlas` covering both rotation and translation NaNs. ### Tested All synthetic CPU/stdlib/docs checks on Windows 11 x64, Python 3.12.14, Node v24.19.0 (no game files): - `python -I tests/test_xdxr_bvh.py -v` — 54/54 passed (reproduced `invert_affine()` returning all-NaN before the hardening commit; 54/54 pass after) - `python -I scripts/check_no_game_data.py` — passed (0 forbidden tracked extensions) - `python -m compileall -q make_game.py tools tests` — passed - `python -I tests/test_text_write_line_endings.py`, `tests/test_report_paths.py`, `tests/test_i18n_index.py`, and all `tests/test_docs_*.py` — passed - `node --test tests/test_viewer_streaming.cjs` — passed GPUs tested: n/a (CPU BVH reference / unit tests only) AI-assisted: yes (JARVIX multi-model team: Antigravity + DeepSeek-V4-Pro + NVIDIA NIM Nemotron-3.5-Lightning & Nemotron-3-Ultra-550B) ### Checklist - [x] Based on current `main` and merges cleanly (a conflicting pull request is labeled `needs rebase`). - [x] One topic; follow-up work goes in a new pull request. - [x] No game data, keys or decryption (CONTRIBUTING.md), including in logs or reports quoted here. - [x] A new translator rule is in the contract table of `docs/design.md`, with how it was confirmed. *(N/A — CPU BVH reference tool only, no shader-translator rule changed.)*
A NaN entry in an inactive TLAS instance's transform previously bypassed det == 0 in invert_affine() and packed 12 NaN floats into the stored inverse matrix instead of triggering build_tlas()'s zero-matrix fallback. Reject non-finite determinants and output entries, and add synthetic regression tests for both rotation and translation NaNs.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 09:10:52 +00:00
github manually merged commit 428f9419d9 into gh-pr/598/base 2026-11-26 09:10:53 +00:00
Author
Owner

@⁠PierreEbele on GitHub · 2026-11-24 19:59 UTC · original

Reviewed 428f941: ran python3 -I tests/test_xdxr_bvh.py (54 OK; all 7 added tests fail on main),
compileall, and edge-case probes on both trees: active-only builds are byte-identical and trace
== brute_force; NaN-inactive triangles/instances now build and validate cleanly where main
aborted TLAS builds (ValueError on singular inactive instances) or wrote NaN bounds/inverses;
the pair remap rework diverges only for zero-area triangles, which never hit. Two non-blocking
notes: brute_force now raises on NaN-transform scene entries that build_tlas treats as inactive
(reference stricter than builder), and validate still accepts NaN header scene bounds.
AI-assisted review.

**@⁠PierreEbele** on GitHub · 2026-11-24 19:59 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/598#issuecomment-7142881461) Reviewed 428f941: ran `python3 -I tests/test_xdxr_bvh.py` (54 OK; all 7 added tests fail on main), compileall, and edge-case probes on both trees: active-only builds are byte-identical and trace == brute_force; NaN-inactive triangles/instances now build and validate cleanly where main aborted TLAS builds (ValueError on singular inactive instances) or wrote NaN bounds/inverses; the pair remap rework diverges only for zero-area triangles, which never hit. Two non-blocking notes: brute_force now raises on NaN-transform scene entries that build_tlas treats as inactive (reference stricter than builder), and validate still accepts NaN header scene bounds. AI-assisted review.
Author
Owner

@⁠aslan2142 on GitHub · 2026-11-24 22:33 UTC · original

Merged. Thanks, and thanks to ShotTechOp for the original commit. Checked locally on today's main + 428f9419d:

  • Claim: valid. claiming: OLD-10063 was posted at 09:38 UTC, before this PR, and is unedited. #743 carried the first commit only and was closed as a duplicate of this one.
  • tests/test_xdxr_bvh.py: 47 tests pass on main, 54 with this PR.
  • On GPU-built BVHs: tools/xdxr_bvh.py check-build <cases> --rays 1000 over the case files that the xdxr_build and d3d12_xdxr_rt tests wrote in two local Wine runs (llvmpipe and an RDNA2 iGPU; four sets, 74 files each run) reports all cases matching, the same as main's tool on the same files.
  • Also clean: check_no_game_data.py on both files and test_text_write_line_endings. It merges without conflicts.
  • CI did not run on this PR (the workflows were waiting for approval), so the merge rests on the runs above and on PierreEbele's (54 tests OK on this head).

PierreEbele's two notes are fine as follow-ups: brute_force is stricter than build_tlas on NaN transforms, and validate accepts NaN header bounds.

AI-assisted (Claude Code, Claude Fable 5.2 and Claude Opus 5.5).

**@⁠aslan2142** on GitHub · 2026-11-24 22:33 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/598#issuecomment-7146381360) Merged. Thanks, and thanks to ShotTechOp for the original commit. Checked locally on today's `main` + `428f9419d`: - **Claim:** valid. `claiming: OLD-10063` was posted at 09:38 UTC, before this PR, and is unedited. #743 carried the first commit only and was closed as a duplicate of this one. - **`tests/test_xdxr_bvh.py`:** 47 tests pass on `main`, 54 with this PR. - **On GPU-built BVHs:** `tools/xdxr_bvh.py check-build <cases> --rays 1000` over the case files that the `xdxr_build` and `d3d12_xdxr_rt` tests wrote in two local Wine runs (llvmpipe and an RDNA2 iGPU; four sets, 74 files each run) reports all cases matching, the same as `main`'s tool on the same files. - **Also clean:** `check_no_game_data.py` on both files and `test_text_write_line_endings`. It merges without conflicts. - **CI did not run on this PR** (the workflows were waiting for approval), so the merge rests on the runs above and on PierreEbele's (54 tests OK on this head). PierreEbele's two notes are fine as follow-ups: `brute_force` is stricter than `build_tlas` on NaN transforms, and `validate` accepts NaN header bounds. AI-assisted (Claude Code, Claude Fable 5.2 and Claude Opus 5.5).
This discussion has been locked. Commenting is limited to contributors.
No description provided.