BVH: guard determinant in world_to_object against zero-scale or singular transforms #1511
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/1521"
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?
Imported from ivall/xcl. Originally posted by hajduzsolt on 2026-11-24T17:15:26Z.
Runtime fix verified with unit tests and RX 9070 XT smoke run.
What is in it
crates/xcl/src/gpu/bvh.rs: inworld_to_object, return[0f32; 12]whendetis non-finite ordet.abs() <= 1e-30to prevent division by zero andNaNemission into instance nodes.crates/xcl/src/gpu/bvh.rs: add unit testzero_scale_or_singular_instance_transform_does_not_emit_nanverifying zero-scale, singular, and non-finite matrices yield finite inverse transforms and clean ray misses without panics orNaNs.Tested
cargo test)cargo test --workspace -- --test-threads=2: 749 passed, 0 failed, 12 ignoredcargo test -p xcl --lib gpu::bvh::tests: 8 passed, 0 failedRegression run
main:
PR:
Not tested
AI use
detnumerical guarding inworld_to_object, and synthetic unit test authoring.Imported from ivall/xcl. Originally posted by GonZiin on 2026-11-24T17:27:31Z.
Review: COMMENTED
The absolute determinant cutoff turns some invertible transforms into zero matrices. I reproduced a ray hit becoming a miss with a uniform scale of
1e-11on all three axes. This transform has condition number 1 and its inverse diagonal is finite inf32.Tested
bvh.rswithrustc --edition=2021 --testand ran a CPU-only probe against a real BLAS containing one unit triangle. The ray starts at[0.25s, 0.25s, -s]and points along+z, wheres = 1e-11.9e3831e1f570d3646e53ab753b19ec07eb8f1485returnedSome((1e-11, 0, 42))and an inverse diagonal of1e11. Head09877ade1de6738cfbb778ab9988bc0990bc9b0dreturnedNoneand a zero inverse. The PR's singular-transform test also passed on this head.Please preserve invertible transforms whose inverse components remain representable. Checking for a zero determinant and validating the computed inverse and translation after conversion to
f32would preserve this case.Not tested
GPU traversal and retail titles.
AI use
Codex (
gpt-6.2-sol) wrote and ran the probe and drafted this review.Imported from ivall/xcl. Originally posted by gut0to on 2026-11-24T18:50:43Z.
Review: COMMENTED
AI-assisted review; I checked this threshold against the finite inverse for a small-scale matrix.
Imported from ivall/xcl. Originally posted by DavidM1911 on 2026-11-24T18:54:01Z.
Verification on RTX 3060 Ti (Windows 11), branch merged with current
main:cargo test -p xcl --lib: all passed, 0 failed, ~21 ignored. (Intermittent single-test flake / 0xc0000005 abort under parallel scheduling; clean on single-threaded rerun — same flake seen on unmodifiedmain.)Thanks!
Imported from ivall/xcl. Originally posted by gut0to on 2026-11-24T18:50:43Z.
Code review location:
crates/xcl/src/gpu/bvh.rs; line 220This absolute determinant cutoff rejects valid invertible transforms. For diagonal scales
1e-11, 1e-10, 1e-10, the determinant is1e-31, while the inverse diagonal (1e11, 1e10, 1e10) is finite and representable asf32; returning zero makes instance-ray traversal degenerate. Could singularity handling validate the computed inverse for finiteness or use a scale-relative criterion instead of this absolute threshold? AI-assisted review; I verified the values.Imported from ivall/xcl. Originally posted by hajduzsolt on 2026-11-24T19:08:16Z.
Thanks for the concrete repro. The determinant check now rejects zero and non-finite values, and the computed inverse and translation are checked after conversion to f32. Added coverage for the small uniform scale and overflow cases.
cargo test --workspace -- --test-threads=2passed (existing ignored tests remain ignored).Imported from ivall/xcl. Originally posted by throny on 2026-11-25T00:15:33Z.
Two contributors checked independently and found that #1633 #1688 solves the same problem (for #1488) in a different way: #1607, group D52. You may want to compare them with the other author and agree on one, or say in the PR why both are needed.
This is a hint from the community triage in #1607, not a maintainer decision.
AI use: Claude Code (Claude Opus 5.5), posted by a script from the #1607 table.
Imported from ivall/xcl. Originally posted by JJAutoCompare on 2026-11-25T05:20:23Z.
Empirical test report (
17204147)Verified PR #1521 at
172041475f0518b778603ed1d1b980514881eb96.Hardware / environment
rustc 1.100.0 (0ef1bc386 2026-11-09). DXC1.9.2609.5 (01b62ad47). Cargo used the unoptimized test profile with debug info and incremental compilation disabled.Commands and results
cargo test --workspace --no-runexited 0 and built the workspace test executables.cargo test -p xcl --lib gpu::bvh::tests::inverse_preserves_small_scales_and_rejects_unrepresentable_results -- --exact --nocaptureexited 0 with 1 passed, 0 failed, and 0 ignored.cargo test -p xcl --lib gpu::bvh::tests::zero_scale_or_singular_instance_transform_does_not_emit_nan -- --exact --nocaptureexited 0 with 1 passed, 0 failed, and 0 ignored.XCL_ADAPTER=NONE_CPU_ONLYandRUST_TEST_NOCAPTURE=1. The captured output totals 2 passed, 0 failed, 0 ignored, and 0SKIPPEDlines.Observed behavior
1e-11scale retained inverse diagonal entries near1e11. Overflow in inverse translation or in an inverse coefficient yielded twelve zeros.Not tested
The full GPU workspace suite and game smoke runs were omitted.
AI use
Verified with T3 Code / Codex (gpt-6.2-sol, reasoningEffort: high). Coordinator #2 (T3 Code / Antigravity, gemini-4-neon) verified counts against
pr1521-focused.logand published.Imported from ivall/xcl. Originally posted by hajduzsolt on 2026-11-25T14:54:41Z.
Thank you for the reviews and test reports. Closing this in favor of #1688, which implements the same zero/non-finite determinant guard and validates that the computed inverse remains finite, including the small-scale case raised in review. Its implementation covers the same fix.
Imported from ivall/xcl. Originally posted by DavidM1911 on 2026-11-26T05:40:33Z.
Re-verification on RTX 3060 Ti (Windows 11): still a merge conflict with current
mainon the new head — needs another rebase before it can be tested.Pull request closed