xdxr_bvh: handle singular TLAS transforms, cyclic/short BVHs, and case validation (XDXR-BVH-SINGULAR-CYCLES-AND-BOUNDS) #1469
No reviewers
No assignees
Labels
No labels
bug
dependencies
documentation
enhancement
missing claim
needs rebase
needs-triage
question
ready-for-agent
submodules
No project
No milestone
Dependencies
No dependencies set
Notifications
1 participant
Due date
No due date set.
Reference
leonida/mandy!1469
Loading…
Reference in a new issue
No description provided.
Delete branch "fix/xdxr-bvh-cycles-singular-and-bounds"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Pull request successfully merged and closed
Claimed in the coordination issue as:
XDXR-BVH-SINGULAR-CYCLES-AND-BOUNDS(#14)Summary
Hardens
tools/xdxr_bvh.py(CPU reference encoder, validator, walker, and GPU build checker — zero other open PRs touch this file):build_tlas,brute_force): Perdocs/bvh.md§7a andruntime/src/xdxr_build.comp(MODE_INSTANCES), an instance with a singular transform gets a zero inverse and an empty world box even when its BLAS address is non-null. Previouslybuild_tlas()andbrute_force()raisedValueError("singular or non-finite instance transform")on a singular transform with a real BLAS. Both now treat singular/non-finite instances as inactive (whileinvert_affine()itself continues to raiseValueError).ptr,build_tlas):ptr(offset, kind)now rejects booleans, negative offsets, andkindoutside0..7(previouslyptr(-64, BOX16)returned-4andptr(64, 8)silently overflowed into the unit index).build_tlas()validatesblas_vais a non-bool integer in0..2^40-1and 256-byte aligned (matchingdocs/bvh.md§7a: stored asblas_va >> 8inu32), raisingValueErrorinstead of crashing insidestruct.pack_intowithstruct.error.offsetToParentsalignment check (validate): RejectsoffsetToParents % 4 != 0(docs/bvh.md§3.1 confirms 4-byte alignment across all 272,864/272,864 streams), while preserving the existing console negative-offset and unstored-entry handling.box16_rounding,node_census,pair_rotations,_trace_blas,trace):box16_rounding()checks header/node bounds, rejects non-triangle/non-box node types, and tracks active recursion frames (visiting) so cyclic BVHs report a cycle error instead of crashing withRecursionError.node_census()andpair_rotations()guard header/node bounds and trackvisitedpointers so cyclic BVHs terminate instead of hanging in an infinite loop._trace_blas()andtrace()trackvisitedpointers per traversal and raiseValueError("cycle in BVH ...")instead of looping forever.check-buildresilience (_load_case,check_build):os.path.joinfor Windows path safety and decodes case JSON withutf-8-sigso UTF-8 BOM files load cleanly.boolvalues forinstance["blas"],address,mask,bias, andrays, validatesrays >= 1, 12-element transforms, and triangle schemas withCaseErrornaming the offending.json..binis truncated (< 64 bytes) or fails traversal (IndexError/ValueError, e.g., cyclic BVH or mismatched instance root),check_build()records it as a case problem (exit1) instead of aborting early with exit2(ERROR: a case in ... does not describe a build) or hanging.Verification
arm64, CPU-only, no GPU, no game files), Python 3.14python3 -I tests/test_xdxr_bvh.py→60/60 OK(0.824s)python3 -m compileall -q make_game.py tools tests→ exit0python3 -I scripts/check_no_game_data.py tools/xdxr_bvh.py tests/test_xdxr_bvh.py→ exit0python3 -I tests/test_text_write_line_endings.py→3/3 OKpython3 -I tests/test_ci_registration.py→16/16 OKupstream/main(b4b7756e8): copiedtests/test_xdxr_bvh.pyonto a detached worktree ofupstream/main; all 8 new/extended test cases failed (Layout.test_pointer_encoding:failures=5;ClosestHit.test_instance_record:failures=1, errors=2;ClosestHit.test_singular_transform_with_valid_blas_is_inactive_in_tlas_and_brute_force:errors=1;Validate.test_misaligned_offset_to_parents_is_rejected:failures=1;Validate.test_cyclic_and_short_buffers_terminate_cleanly_across_walkers:errors=1(RecursionError);Cli.test_check_build_accepts_utf8_bom_case_json:failures=1;Cli.test_check_build_rejects_bool_indices_and_bad_transform_or_rays:failures=4;Cli.test_check_build_corrupt_truncated_or_cyclic_bin_exits_1_not_2: infinite loop timeout > 3s).Independent verification (CPU/tools-only, native Windows, Python 3.11.9 — stdlib-only tools so representative): diff reviewed line-by-line, all claimed fixes present and covered by the new tests; neighboring suites green. Details in the verification batch log. AI-assisted verification.
Red/green: the PR's tests fail on main 4938673 and pass on head ff2833bde1e0 (Linux, Python 3.13.18).
Targeted batch of 11 PRs (their tests, the tests importing the changed modules, the docs tests) on main 3ca0707: no new failure, Linux / Python 3.13.
AI-assisted (Claude Code, Claude Opus 5.5)