GPU BVH: guard singular and zero-scale instance determinants (#1488) #1623
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/1633"
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 slopgobblercobbler on 2026-11-24T18:26:39Z.
Summary
Guards against singular and zero-scale instance transform determinants in
crates/xcl/src/gpu/bvh.rs(Issue #1488, findingXCL-BT-021):bvh::world_to_object, the 3x3 cofactor matrix was unconditionally divided bydet(row.map(|x| x / det)).det == 0.0), populating inverse transform words withNaN/±inf.if det.abs() <= 1e-30 || !det.is_finite()returning a safe zero transform[0.0; 12], plus finite post-checks.build_top:build_top, when an instance matrix is singular or zero-scale (det.abs() <= 1e-30 || !det.is_finite()), clear thetranslation_onlybit so rays do not bypass the inverse transform on culled instances, and sanitize non-finite elements.transform_aabbandBvh::boundsagainst degenerate / invalid inputs.world_to_object_singular_and_zero_scale_fallbackstesting all-zero, zero-scale with translation, axis-singular, linearly dependent/rank-deficient matrices, underflow, and exact inverse matrix preservation for invertible transforms.build_top_handles_singular_and_zero_scale_instancesbuilding TLAS with all-zero, zero-scale, singular, NaN, and active instances, validating finite bounds and clean scene ray traversal.Changes
crates/xcl/src/gpu/bvh.rs:world_to_object.build_top.Tested
cargo test -p xcl -- bvh: 12 passed, 0 failed.upstream/main, GPL-2.0-only compliant, zero retail game data or keys.Not Tested
AI Use
Co-Authored-By: Claude Code (Claude Opus 5.5) / Gemini Antigravity
Imported from ivall/xcl. Originally posted by gut0to on 2026-11-24T18:30:50Z.
Review: COMMENTED
AI-assisted review; I checked the determinant and inverse values in the new test.
Imported from ivall/xcl. Originally posted by gut0to on 2026-11-24T18:30:51Z.
Code review location:
crates/xcl/src/gpu/bvh.rs; line 230This absolute determinant cutoff rejects an invertible transform. The new
tinytest uses diagonal scales1e-11, 1e-10, 1e-10: its determinant is1e-31, but its inverse diagonal (1e11, 1e10, 1e10) is finite and representable asf32. Returning an all-zero inverse for this instance makes its ray transform degenerate and can lose hits. Could singularity handling use a scale-relative test or validate the computed inverse for finiteness, and keep this tiny transform as a valid case? AI-assisted review; I verified these values.Imported from ivall/xcl. Originally posted by Adika713 on 2026-11-24T19:12:36Z.
I independently checked the determinant cutoff concern and reproduced the arithmetic from the PR’s
tinytest: determinant 1e-31, while the inverse diagonal is finite and f32-representable (1e11, 1e10, 1e10). Thus the absolute cutoff rejects a valid transform. I tested the alternative in a clean local worktree at upstreamc160d86: reject only zero/non-finite determinant, then check the serialized f32 inverse for non-finite values. Added regression coverage for the small invertible transform and an inverse that overflows f32.cargo test -p xcl --lib gpu::bvh::passed (8 passed, 0 failed, 0 ignored); two existing Atomic::fetch_update deprecation warnings. Not yet pushed or smoke-tested on a retail title.Imported from ivall/xcl. Originally posted by Anon64 on 2026-11-24T19:33:16Z.
Regression run for this PR: head
d94e880, based onmain9e3831e. RTX 3060 12 GB (581.80, wave32), Windows 11 26200, release,XCL_NETWORK=0, A pressed every 4 s from 20 s,scripts/smoke.ps1on a retail title for 60 s, in one batch with themainrun.main
9e3831e:this PR:
No device removals or crashes; 101 % of main's frames, 98 % of its peak commit.
Peak commit on this machine is mostly the pipeline preload's DXC compiles (#1035) and varies from run to run, so it says little about this PR.
Not tested: the whole suite; whether the title reaches the changed code in these 60 s.
Written with Claude Code (Claude Opus 5.5) from runs on this machine.
Imported from ivall/xcl. Originally posted by throny on 2026-11-24T20:15:42Z.
Two contributors checked independently and found that #1688 solves the same problem (for #1488) in a different way: #1607, group D40. 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, not a request from the maintainers; nobody from the project has adopted #1607 so far.
AI use: Claude Code (Claude Opus 5.5), posted by a script from the #1607 table.
Imported from ivall/xcl. Originally posted by DavidM1911 on 2026-11-24T20:56:10Z.
Verification on RTX 3060 Ti (Windows 11), branch merged with current
main:cargo test -p xcl --lib: all passed, 0 failed, ~22 ignored.Thanks!
upstream-sync referenced this pull request2026-11-24 23:06:49 +00:00
Imported from ivall/xcl. Originally posted by throny on 2026-11-24T23:07:11Z.
Two contributors checked independently and found that #1322 solves the same problem in a different way: #1607, group D69. 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 throny on 2026-11-25T00:15:34Z.
Two contributors checked independently and found that #1521 #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 CalvyPZ on 2026-11-25T22:41:30Z.
This PR has been marked as a duplicate and closed after multiple agreeing checks in #1607. If you believe this is incorrect please re-open with why.
upstream-sync referenced this pull request2026-11-26 09:06:34 +00:00
Imported from ivall/xcl. Originally posted by github-actions[bot] on 2026-11-29T20:44:33Z.
Nothing has happened on this PR for 3 days, so it is marked
staleand will be closed in 4 days. A push or a comment takes the mark off: rebase it ontomainif it conflicts, and say in one line what it still fixes. If it only waits for a maintainer, a comment saying so is enough.Imported from ivall/xcl. Originally posted by Foniass on 2026-12-01T06:20:30Z.
Triage (#1607) – head
d94e880#1688 (draft, opened later) fixes the same #1488 problem differently. It zeroes world_to_object only for a zero or non-finite determinant or a non-finite inverse. This PR also rejects |det| <= 1e-30 and guards build_top, transform_aabb and Bvh::bounds.
bvh.rs:world_to_object: the 1e-30 cutoff also zeroes small transforms that can be inverted (the
tinycase, scale 1e-10/1e-11, has a representable inverse that #1688 keeps). The added!is_singular &&in build_top changes nothing, since an identity 3x3 is never singular.bvh.rs:Bvh::bounds: main already handles an empty root (#1322, merged) by returning the inverted empty box ([inf], [-inf]). This PR returns a zero box, which would add the origin to any bounds merged with it. On rebase, keep main's version.
Recommendation: keep open.
AI review: Claude Code (Claude Opus 5.5), diffs read only, not built or run; not checked by a human.
View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.