BVH: guard determinant in world_to_object against zero-scale or singular transforms #1521
No reviewers
Labels
No labels
accessibility
bug
documentation
duplicate
enhancement
goal:world-load
good first issue
help wanted
invalid
keep-open
off-goal
question
stale
test-only
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/xcl-dev--xcl!1521
Loading…
Reference in a new issue
No description provided.
Delete branch "gh-pr/1521/head"
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?
@hajduzsolt on GitHub · 2026-11-24 17:15 UTC · original
hajduzsolt:fix/bvh-singular-instance-transform→main· +81 −1 · 1 files · 2 commits · closed without mergingRuntime 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.github-bot referenced this pull request2026-11-26 04:59:09 +00:00
@DavidM1911 on GitHub · 2026-11-24 18:54 UTC · original
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!
@hajduzsolt on GitHub · 2026-11-24 19:08 UTC · original
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).@throny on GitHub · 2026-11-25 00:15 UTC · original
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.
@JJAutoCompare on GitHub · 2026-11-25 05:20 UTC · original
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.@hajduzsolt on GitHub · 2026-11-25 14:54 UTC · original
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.
@gut0to on GitHub · 2026-11-24 18:50 UTC · original
On
crates/xcl/src/gpu/bvh.rsline 220 (outdated):This 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.@DavidM1911 on GitHub · 2026-11-26 05:40 UTC · original
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.@GonZiin on GitHub · 2026-11-24 17:27 UTC · original · reviewed
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.@gut0to on GitHub · 2026-11-24 18:50 UTC · original · reviewed
AI-assisted review; I checked this threshold against the finite inverse for a small-scale matrix.
Pull request closed