GPU BVH: preserve small invertible instance transforms (#1488) #1688

Open
github-bot wants to merge 1 commit from github-bot/gh-1688 into main AGit
Owner

@⁠Adika713 on GitHub · 2026-11-24 19:18 UTC · original
Adika713:fix/bvh-inverse-finite-range → main · +23 −0 · 1 files · 1 commits · draft

Part of #1488.

The absolute determinant cutoff in PR #1633 rejects some finite, invertible instance transforms: its own 1e-11 × 1e-10 × 1e-10 test has determinant 1e-31 but a finite f32 inverse. This change rejects only zero/non-finite determinants, then checks the serialized f32 inverse for non-finite values before returning it.

What is in it

  • crates/xcl/src/gpu/bvh.rs: replace the scale-dependent determinant threshold with zero/non-finite detection plus a finite-output check.
  • Add world_to_object_keeps_small_invertible_transforms, covering the 1e-31 determinant case and a finite-precision overflow fallback.

Tested

  • Windows x64; AMD Radeon RX 6950 XT (driver 32.0.21045.29003); Rust 1.100.0 MSVC; debug.
  • cargo build --workspace --locked: passed; two existing Atomic::fetch_update deprecation warnings.
  • cargo test -p xcl --lib gpu::bvh::tests::world_to_object_keeps_small_invertible_transforms -- --exact --test-threads=1: 1 passed, 0 failed, 0 ignored.
  • cargo test -p xcl --lib gpu::bvh::tests:: -- --test-threads=4: 8 passed, 0 failed, 0 ignored.
  • git diff --check: clean.

Not tested

  • Full workspace suite on this PR head, retail-title regression smoke pair, real-time DXR traversal.

AI use

  • OpenCode with OpenAI GPT-6 Luna: reviewed the numeric issue, implemented the focused fix and regression test, and ran the tests above.
**@⁠Adika713** on GitHub · 2026-11-24 19:18 UTC · [original](https://github.com/xcl-dev/xcl/pull/1688) `Adika713:fix/bvh-inverse-finite-range` → `main` · +23 −0 · 1 files · 1 commits · draft Part of #1488. The absolute determinant cutoff in PR #1633 rejects some finite, invertible instance transforms: its own 1e-11 × 1e-10 × 1e-10 test has determinant 1e-31 but a finite f32 inverse. This change rejects only zero/non-finite determinants, then checks the serialized f32 inverse for non-finite values before returning it. **What is in it** - `crates/xcl/src/gpu/bvh.rs`: replace the scale-dependent determinant threshold with zero/non-finite detection plus a finite-output check. - Add `world_to_object_keeps_small_invertible_transforms`, covering the 1e-31 determinant case and a finite-precision overflow fallback. **Tested** - Windows x64; AMD Radeon RX 6950 XT (driver 32.0.21045.29003); Rust 1.100.0 MSVC; debug. - `cargo build --workspace --locked`: passed; two existing `Atomic::fetch_update` deprecation warnings. - `cargo test -p xcl --lib gpu::bvh::tests::world_to_object_keeps_small_invertible_transforms -- --exact --test-threads=1`: 1 passed, 0 failed, 0 ignored. - `cargo test -p xcl --lib gpu::bvh::tests:: -- --test-threads=4`: 8 passed, 0 failed, 0 ignored. - `git diff --check`: clean. **Not tested** - Full workspace suite on this PR head, retail-title regression smoke pair, real-time DXR traversal. **AI use** - OpenCode with OpenAI GPT-6 Luna: reviewed the numeric issue, implemented the focused fix and regression test, and ran the tests above.
A determinant cutoff is scale-dependent and rejected transforms whose inverse is finite and representable. Reject zero/non-finite determinants, then validate the serialized f32 inverse, falling back only when that output is non-finite. Add regression coverage for both cases.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 05:01:39 +00:00
Author
Owner

@⁠upipibi on GitHub · 2026-11-24 22:50 UTC · original

NVIDIA run: RTX 3070 8 GB, driver 616.56, Windows 11, debug, 0f45226 merged onto main 689f2db (clean). Tests matching bvh, including world_to_object_keeps_small_invertible_transforms and the GPU BVH tests: 12 passed, 0 failed.

AI-assisted (Claude Code). Synthetic tests only.

**@⁠upipibi** on GitHub · 2026-11-24 22:50 UTC · [original](https://github.com/xcl-dev/xcl/pull/1688#issuecomment-7146710346) NVIDIA run: RTX 3070 8 GB, driver 616.56, Windows 11, debug, `0f45226` merged onto `main` `689f2db` (clean). Tests matching `bvh`, including `world_to_object_keeps_small_invertible_transforms` and the GPU BVH tests: 12 passed, 0 failed. AI-assisted (Claude Code). Synthetic tests only.
Author
Owner

@⁠throny on GitHub · 2026-11-25 00:15 UTC · original

Two contributors checked independently and found that #1521 #1633 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.

**@⁠throny** on GitHub · 2026-11-25 00:15 UTC · [original](https://github.com/xcl-dev/xcl/pull/1688#issuecomment-7148320989) <!-- xcl-1607-hint:D52 --> Two contributors checked independently and found that #1521 #1633 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.
Author
Owner

@⁠Adika713 on GitHub · 2026-11-25 00:28 UTC · original

@⁠throny

Thanks for the D52 hint and for the independent RTX 3070 run.

I checked the current diffs of the other D52 PRs. #1521 (head 172041475f0518b778603ed1d1b980514881eb96) now guards world_to_object with if !det.is_finite() || det == 0.0 plus a finite-output check, and its test inverse_preserves_small_scales_and_rejects_unrepresentable_results covers the same small-scale and overflow cases as this PR. That is functionally the same runtime fix as #1688, so #1688 no longer adds a separate runtime change relative to #1521.

The remaining distinction is #1633: its world_to_object and build_top still use det.abs() <= 1e-30 || !det.is_finite(). That absolute cutoff rejects finite, invertible transforms; #1633's own tiny matrix 1e-11 x 1e-10 x 1e-10 has determinant 1e-31, below the cutoff, even though the serialized f32 inverse is representable. This PR's rationale is to validate the inverse instead of applying a scale-dependent cutoff.

Suggestion for the maintainers: consolidate on one implementation rather than three overlapping ones. #1521 already covers the runtime path; #1633 additionally sanitizes singular instances in build_top. If #1521 is chosen, #1688 can be closed as superseded, and the cutoff counterexample above can be used to update #1521/#1633's tests. I am not changing any PR state myself.

Note: #1688's PR-description check is still failing because the required paired retail-title smoke blocks were not run on its head. If this PR is kept rather than consolidated, I will add a real pair before asking for review.

AI use: OpenCode with Big Pickle (opencode/big-pickle) prepared this draft from gh pr diff reads of #1521 and #1633 and the full #1688 thread; no comment was posted.

**@⁠Adika713** on GitHub · 2026-11-25 00:28 UTC · [original](https://github.com/xcl-dev/xcl/pull/1688#issuecomment-7148549736) @⁠throny Thanks for the D52 hint and for the independent RTX 3070 run. I checked the current diffs of the other D52 PRs. #1521 (head `172041475f0518b778603ed1d1b980514881eb96`) now guards `world_to_object` with `if !det.is_finite() || det == 0.0` plus a finite-output check, and its test `inverse_preserves_small_scales_and_rejects_unrepresentable_results` covers the same small-scale and overflow cases as this PR. That is functionally the same runtime fix as #1688, so #1688 no longer adds a separate runtime change relative to #1521. The remaining distinction is #1633: its `world_to_object` and `build_top` still use `det.abs() <= 1e-30 || !det.is_finite()`. That absolute cutoff rejects finite, invertible transforms; #1633's own `tiny` matrix `1e-11 x 1e-10 x 1e-10` has determinant `1e-31`, below the cutoff, even though the serialized f32 inverse is representable. This PR's rationale is to validate the inverse instead of applying a scale-dependent cutoff. Suggestion for the maintainers: consolidate on one implementation rather than three overlapping ones. #1521 already covers the runtime path; #1633 additionally sanitizes singular instances in `build_top`. If #1521 is chosen, #1688 can be closed as superseded, and the cutoff counterexample above can be used to update #1521/#1633's tests. I am not changing any PR state myself. Note: #1688's PR-description check is still failing because the required paired retail-title smoke blocks were not run on its head. If this PR is kept rather than consolidated, I will add a real pair before asking for review. AI use: OpenCode with Big Pickle (opencode/big-pickle) prepared this draft from `gh pr diff` reads of #1521 and #1633 and the full #1688 thread; no comment was posted.
Author
Owner

@⁠throny on GitHub · 2026-11-25 00:29 UTC · original

@⁠Adika713 thanks for the comparison. One correction: the RTX 3070 run isn't mine; the D52 hint came from the #1607 script. Your reading of the three diffs counts as a check of D52 if you post it in #1607 as an xcl-check block with the heads you read, for example "verdict": "suggest 1521; same change as 1688" if that's your finding. #1633 can stay out of that verdict, since a verdict may name only part of a group. That's how it reaches the maintainers' table.

AI use: Claude Code (Claude Opus 5.5).

**@⁠throny** on GitHub · 2026-11-25 00:29 UTC · [original](https://github.com/xcl-dev/xcl/pull/1688#issuecomment-7148571074) @⁠Adika713 thanks for the comparison. One correction: the RTX 3070 run isn't mine; the D52 hint came from the #1607 script. Your reading of the three diffs counts as a check of D52 if you post it in #1607 as an `xcl-check` block with the heads you read, for example `"verdict": "suggest 1521; same change as 1688"` if that's your finding. #1633 can stay out of that verdict, since a verdict may name only part of a group. That's how it reaches the maintainers' table. AI use: Claude Code (Claude Opus 5.5).
Author
Owner

@⁠Toons29 on GitHub · 2026-11-25 03:35 UTC · original

Regression run of 0f452264 on the retail title, for this PR's Regression run section. Both blocks are from scripts/smoke.ps1 as printed, not edited: main on 4178e888, this PR on its head commit with no uncommitted changes, same title and time.

xcl-smoke v1
commit: 4178e888c0b5be50a2887eda45cdb832763b68a4
gpu: AMD Radeon RX 9070
title: game.exe
seconds: 60
exit: 0x0
frames shown: 1618 (PresentX 1618)
presents per 2 s (last 3): 61 60 60
device removals: 0
crashes: 0
peak commit: 14831 MB
xcl-smoke v1
commit: 0f45226423d2d6701e81222313bf3b5305261056
gpu: AMD Radeon RX 9070
title: game.exe
seconds: 60
exit: 0x0
frames shown: 1633 (PresentX 1633)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 14818 MB

Against the limits in CONTRIBUTING.md: 101 % of main's frames, 100 % of its peak commit, no crash, no device removal.

AMD Radeon RX 9070 (RDNA4, driver 32.0.32029.2010), Ryzen 7 7800X3D, 32 GB, Windows 11 build 26300, Rust 1.100.0, cargo build --release -p xcl, 60 s, XCL_NETWORK=0. This is a regression check only: it does not show whether the run reaches the code this PR changes.

AI use: Claude Code (Claude Opus 5.5) built both trees and ran scripts/smoke.ps1; I checked the blocks before posting.

**@⁠Toons29** on GitHub · 2026-11-25 03:35 UTC · [original](https://github.com/xcl-dev/xcl/pull/1688#issuecomment-7152057789) Regression run of `0f452264` on the retail title, for this PR's **Regression run** section. Both blocks are from `scripts/smoke.ps1` as printed, not edited: `main` on `4178e888`, this PR on its head commit with no uncommitted changes, same title and time. ``` xcl-smoke v1 commit: 4178e888c0b5be50a2887eda45cdb832763b68a4 gpu: AMD Radeon RX 9070 title: game.exe seconds: 60 exit: 0x0 frames shown: 1618 (PresentX 1618) presents per 2 s (last 3): 61 60 60 device removals: 0 crashes: 0 peak commit: 14831 MB ``` ``` xcl-smoke v1 commit: 0f45226423d2d6701e81222313bf3b5305261056 gpu: AMD Radeon RX 9070 title: game.exe seconds: 60 exit: 0x0 frames shown: 1633 (PresentX 1633) presents per 2 s (last 3): 60 60 60 device removals: 0 crashes: 0 peak commit: 14818 MB ``` Against the limits in CONTRIBUTING.md: 101 % of `main`'s frames, 100 % of its peak commit, no crash, no device removal. AMD Radeon RX 9070 (RDNA4, driver 32.0.32029.2010), Ryzen 7 7800X3D, 32 GB, Windows 11 build 26300, Rust 1.100.0, `cargo build --release -p xcl`, 60 s, `XCL_NETWORK=0`. This is a regression check only: it does not show whether the run reaches the code this PR changes. AI use: Claude Code (Claude Opus 5.5) built both trees and ran `scripts/smoke.ps1`; I checked the blocks before posting.
This pull request has changes conflicting with the target branch.
  • crates/xcl/src/gpu/bvh.rs
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.
git fetch -u origin '+refs/pull/1688/head:github-bot/gh-1688'
git switch 'github-bot/gh-1688'

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-1688'
git switch 'github-bot/gh-1688'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-1688'
git switch 'github-bot/gh-1688'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-1688'
git switch 'main'
git merge --squash 'github-bot/gh-1688'
git switch 'main'
git merge --ff-only 'github-bot/gh-1688'
git switch 'main'
git merge 'github-bot/gh-1688'
git push origin 'main'
This discussion has been locked. Commenting is limited to contributors.
No description provided.