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

Open
Adika713 wants to merge 1 commit from upstream-pr/1688 into main
Adika713 commented 2026-11-24 19:18:01 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by Adika713 on 2026-11-24T19:18:01Z.


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.
<!-- greyfinch-sync:ivall/xcl:issue:5478729881 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/1688). Originally posted by [Adika713](https://github.com/Adika713) on 2026-11-24T19:18:01Z. --- 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.
upipibi commented 2026-11-24 23:08:34 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by upipibi on 2026-11-24T22:50:40Z.


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.

<!-- greyfinch-sync:ivall/xcl:comment:7146710346 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/1688#issuecomment-7146710346). Originally posted by [upipibi](https://github.com/upipibi) on 2026-11-24T22:50:40Z. --- 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.
throny commented 2026-11-25 01:10:38 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by throny on 2026-11-25T00:15:36Z.


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.

<!-- greyfinch-sync:ivall/xcl:comment:7148320989 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/1688#issuecomment-7148320989). Originally posted by [throny](https://github.com/throny) on 2026-11-25T00:15:36Z. --- <!-- 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.
Adika713 commented 2026-11-25 01:10:43 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by Adika713 on 2026-11-25T00:28:40Z.


@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.

<!-- greyfinch-sync:ivall/xcl:comment:7148549736 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/1688#issuecomment-7148549736). Originally posted by [Adika713](https://github.com/Adika713) on 2026-11-25T00:28:40Z. --- @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.
throny commented 2026-11-25 01:10:43 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by throny on 2026-11-25T00:29:55Z.


@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).

<!-- greyfinch-sync:ivall/xcl:comment:7148571074 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/1688#issuecomment-7148571074). Originally posted by [throny](https://github.com/throny) on 2026-11-25T00:29:55Z. --- @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).
Toons29 commented 2026-11-25 04:10:35 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by Toons29 on 2026-11-25T03:35:33Z.


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.

<!-- greyfinch-sync:ivall/xcl:comment:7152057789 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/1688#issuecomment-7152057789). Originally posted by [Toons29](https://github.com/Toons29) on 2026-11-25T03:35:33Z. --- 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.
upstream-sync closed this pull request 2026-11-25 23:07:35 +00:00
CalvyPZ commented 2026-11-25 23:09:13 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by CalvyPZ on 2026-11-25T22:41:33Z.


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.

<!-- greyfinch-sync:ivall/xcl:comment:7176674622 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/1688#issuecomment-7176674622). Originally posted by [CalvyPZ](https://github.com/CalvyPZ) on 2026-11-25T22:41:33Z. --- 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 reopened this pull request 2026-11-26 00:04:32 +00:00
github-actions[bot] commented 2026-11-29 20:44:38 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by github-actions[bot] on 2026-11-29T20:44:38Z.


Nothing has happened on this PR for 3 days, so it is marked stale and will be closed in 4 days. A push or a comment takes the mark off: rebase it onto main if it conflicts, and say in one line what it still fixes. If it only waits for a maintainer, a comment saying so is enough.

<!-- greyfinch-sync:ivall/xcl:comment:7262322587 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/1688#issuecomment-7262322587). Originally posted by [github-actions[bot]](https://github.com/apps/github-actions) on 2026-11-29T20:44:38Z. --- Nothing has happened on this PR for 3 days, so it is marked `stale` and will be closed in 4 days. A push or a comment takes the mark off: rebase it onto `main` if it conflicts, and say in one line what it still fixes. If it only waits for a maintainer, a comment saying so is enough.
Foniass commented 2026-12-01 06:29:35 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by Foniass on 2026-12-01T06:29:35Z.


Triage (#1607) – head 0f45226

Overlaps #1633 (same issue #1488, same function bvh.rs::world_to_object) as a different approach: #1633 also zeroes transforms with |det| <= 1e-30 and guards build_top, transform_aabb and empty bounds; this PR only refuses a zero or non-finite determinant or a non-finite f32 inverse, keeping small invertible transforms (its test covers the 1e-31 case #1633 zeroes). The closed #1521 and #1767 made this same change.
No problems found in the diff. Main's world_to_object still has no guard. The PR is a draft and conflicts with main.
Recommendation: keep open.

AI review: Claude Code (Claude Opus 5.5), diffs read only, not built or run; not checked by a human.

<!-- greyfinch-sync:ivall/xcl:comment:7302936345 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/1688#issuecomment-7302936345). Originally posted by [Foniass](https://github.com/Foniass) on 2026-12-01T06:29:35Z. --- **Triage (#1607)** – head 0f45226 Overlaps #1633 (same issue #1488, same function `bvh.rs::world_to_object`) as a different approach: #1633 also zeroes transforms with |det| <= 1e-30 and guards `build_top`, `transform_aabb` and empty `bounds`; this PR only refuses a zero or non-finite determinant or a non-finite f32 inverse, keeping small invertible transforms (its test covers the 1e-31 case #1633 zeroes). The closed #1521 and #1767 made this same change. No problems found in the diff. Main's `world_to_object` still has no guard. The PR is a draft and conflicts with main. Recommendation: keep open. AI review: Claude Code (Claude Opus 5.5), diffs read only, not built or run; not checked by a human.
This pull request cannot be merged automatically due to conflicts.
Merge manually to resolve the conflicts.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin 'upstream-pr/1688:upstream-pr/1688'
git switch 'upstream-pr/1688'

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.

git switch 'main'
git merge --no-ff 'upstream-pr/1688'
git switch 'upstream-pr/1688'
git rebase 'main'
git switch 'main'
git merge --ff-only 'upstream-pr/1688'
git switch 'upstream-pr/1688'
git rebase 'main'
git switch 'main'
git merge --no-ff 'upstream-pr/1688'
git switch 'main'
git merge --squash 'upstream-pr/1688'
git switch 'main'
git merge --ff-only 'upstream-pr/1688'
git switch 'main'
git merge 'upstream-pr/1688'
git push origin 'main'
Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
xcl-dev/xcl!1678
No description provided.