GPU BVH: guard singular and zero-scale instance determinants (#1488) #1633
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!1633
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-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?
@slopgobblercobbler on GitHub · 2026-11-24 18:26 UTC · original
slopgobblercobbler:fix/bvh-singular-transforms→main· +173 −3 · 1 files · 1 commits · openSummary
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
@Adika713 on GitHub · 2026-11-24 19:12 UTC · original
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.@Anon64 on GitHub · 2026-11-24 19:33 UTC · original
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.
@throny on GitHub · 2026-11-24 20:15 UTC · original
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.
@DavidM1911 on GitHub · 2026-11-24 20:56 UTC · original
Verification on RTX 3060 Ti (Windows 11), branch merged with current
main:cargo test -p xcl --lib: all passed, 0 failed, ~22 ignored.Thanks!
@throny on GitHub · 2026-11-24 23:07 UTC · original
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.
@throny on GitHub · 2026-11-25 00:15 UTC · original
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.
@ -218,2 +227,4 @@pub fn world_to_object(m: &[[f32; 4]; 3]) -> [f32; 12] {let a = |r: usize, c: usize| m[r][c] as f64;let det = a(0, 0) * (a(1, 1) * a(2, 2) - a(1, 2) * a(2, 1)) - a(0, 1) * (a(1, 0) * a(2, 2) - a(1, 2) * a(2, 0)) + a(0, 2) * (a(1, 0) * a(2, 1) - a(1, 1) * a(2, 0));if det.abs() <= 1e-30 || !det.is_finite() {@gut0to on GitHub · 2026-11-24 18:30 UTC · original
This 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.github-bot referenced this pull request2026-11-26 06:18:30 +00:00
View command line instructions
Manual merge helper
Use this merge commit message when completing the merge manually.
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.