D3D12.X: a singular TLAS instance gets a zero world-to-object matrix #1757

Closed
b3IKK wants to merge 1 commit from upstream-pr/1767 into main
b3IKK commented 2026-11-24 20:24:36 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by b3IKK on 2026-11-24T20:24:36Z.


Addresses XCL-BT-021 from #1488.

bvh::world_to_object divided the adjugate by the determinant without looking at it: a TLAS instance whose transform is singular — a zero scale on one axis, say — got a NaN / Inf world-to-object matrix in its instance node, so the shader's object-space ray became NaN. An instance of no volume is simply never hit, so the matrix cannot carry an inverse at all.

This writes zeros for a singular (or non-finite) inverse: every point maps to the object origin and every direction to 0, which the triangle test misses — no NaN reaches the shader.

What is in it

  • crates/xcl/src/gpu/bvh.rs: world_to_object returns [0.0; 12] when the determinant is zero or the inverse is not finite; add test a_singular_instance_transform_has_a_zero_inverse (a y-squashed instance, then the same instance with full rank). Fails on main with left: [NaN, NaN, …, inf, …], right: [0.0; 12].

Tested

  • hardware (GPU + driver, CPU), Windows build, Rust version, debug / release: NVIDIA GeForce RTX 5080 (driver 32.0.16.1088), AMD Ryzen 9 9950X3D, Windows 11 10.0.26300, Rust 1.100.0 (stable-x86_64-pc-windows-msvc), DXC 1.9.2609.5, debug (scripts/test.ps1) and release (scripts/smoke.ps1)
  • .\scripts\test.ps1 (cargo build --workspace + cargo test --workspace -- --test-threads=4): 960 passed, 0 failed, 43 ignored (SKIPPED: the wave64 / direct-DXIL per-lane tests that need 64-lane hardware or a semantics mode this adapter refuses, no heap windows, and cannot disable the driver cache (Windows Developer Mode is required))
  • cargo test -p xcl --lib bvh: 8 passed, 0 failed

Regression run

main (c4d37be, clean tree, no local changes):

xcl-smoke v1
commit: c4d37bec1bb4286eb373aea963404a23f13401fa
gpu: NVIDIA GeForce RTX 5080
title: 9cc6a39e
seconds: 60
exit: 0x0
frames shown: 1639 (PresentX 1640)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 14618 MB

PR (582f45a, clean tree, no local changes):

xcl-smoke v1
commit: 582f45a514853767c20ca9a078e5691a7eb5cfb6
gpu: NVIDIA GeForce RTX 5080
title: 9cc6a39e
seconds: 60
exit: 0x0
frames shown: 1641 (PresentX 1641)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 14615 MB

Not tested

  • a title that builds a TLAS with a degenerate instance through the console's XboxBvhBuilder (no game here does; the builder and its test are XCL's own)
  • AMD GPUs and native wave64 hardware
  • other titles (Minecraft Preview, Unicorn Overlord, Fortnite, XDefiant) and Linux / Wine

AI use

  • OpenCode, Gemini 4 Neon: checked XCL-BT-021 against world_to_object/build_top, wrote the guard and test (and confirmed it fails without it), rebased onto c4d37be, ran the test suite and scripts/smoke.ps1 regression runs with #677's title hashing, and drafted this PR description.
<!-- greyfinch-sync:ivall/xcl:issue:6590709086 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/1767). Originally posted by [b3IKK](https://github.com/b3IKK) on 2026-11-24T20:24:36Z. --- Addresses `XCL-BT-021` from #1488. `bvh::world_to_object` divided the adjugate by the determinant without looking at it: a TLAS instance whose transform is singular — a zero scale on one axis, say — got a `NaN` / `Inf` world-to-object matrix in its instance node, so the shader's object-space ray became NaN. An instance of no volume is simply never hit, so the matrix cannot carry an inverse at all. This writes zeros for a singular (or non-finite) inverse: every point maps to the object origin and every direction to 0, which the triangle test misses — no NaN reaches the shader. **What is in it** - `crates/xcl/src/gpu/bvh.rs`: `world_to_object` returns `[0.0; 12]` when the determinant is zero or the inverse is not finite; add test `a_singular_instance_transform_has_a_zero_inverse` (a y-squashed instance, then the same instance with full rank). Fails on `main` with `left: [NaN, NaN, …, inf, …], right: [0.0; 12]`. **Tested** - hardware (GPU + driver, CPU), Windows build, Rust version, debug / release: NVIDIA GeForce RTX 5080 (driver 32.0.16.1088), AMD Ryzen 9 9950X3D, Windows 11 10.0.26300, Rust 1.100.0 (`stable-x86_64-pc-windows-msvc`), DXC 1.9.2609.5, debug (`scripts/test.ps1`) and release (`scripts/smoke.ps1`) - `.\scripts\test.ps1` (`cargo build --workspace` + `cargo test --workspace -- --test-threads=4`): 960 passed, 0 failed, 43 ignored (SKIPPED: the wave64 / direct-DXIL per-lane tests that need 64-lane hardware or a semantics mode this adapter refuses, `no heap windows`, and `cannot disable the driver cache (Windows Developer Mode is required)`) - `cargo test -p xcl --lib bvh`: 8 passed, 0 failed **Regression run** main (`c4d37be`, clean tree, no local changes): ``` xcl-smoke v1 commit: c4d37bec1bb4286eb373aea963404a23f13401fa gpu: NVIDIA GeForce RTX 5080 title: 9cc6a39e seconds: 60 exit: 0x0 frames shown: 1639 (PresentX 1640) presents per 2 s (last 3): 60 60 60 device removals: 0 crashes: 0 peak commit: 14618 MB ``` PR (`582f45a`, clean tree, no local changes): ``` xcl-smoke v1 commit: 582f45a514853767c20ca9a078e5691a7eb5cfb6 gpu: NVIDIA GeForce RTX 5080 title: 9cc6a39e seconds: 60 exit: 0x0 frames shown: 1641 (PresentX 1641) presents per 2 s (last 3): 60 60 60 device removals: 0 crashes: 0 peak commit: 14615 MB ``` **Not tested** - a title that builds a TLAS with a degenerate instance through the console's `XboxBvhBuilder` (no game here does; the builder and its test are XCL's own) - AMD GPUs and native wave64 hardware - other titles (Minecraft Preview, Unicorn Overlord, Fortnite, XDefiant) and Linux / Wine **AI use** - OpenCode, Gemini 4 Neon: checked `XCL-BT-021` against `world_to_object`/`build_top`, wrote the guard and test (and confirmed it fails without it), rebased onto `c4d37be`, ran the test suite and `scripts/smoke.ps1` regression runs with #677's title hashing, and drafted this PR description.
futurepro62 commented 2026-11-24 21:30:05 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by futurepro62 on 2026-11-24T21:23:50Z.


Full-suite run, since this PR has no test report yet. Tested exact head d3d6e63 (on its base c160d86).

Tested

  • NVIDIA GeForce RTX 5070 Ti 16 GB (Blackwell, 32-lane waves only, mesh shaders), driver 616.64, Ryzen 7 9800X3D, Windows 11 Home 26300, Rust 1.100.0 MSVC, DXC + dxil.dll 1.9.2602.17 (Windows SDK 10.0.26100), debug, D3D12 debug layer installed.
  • cargo build --workspace, then XCL_REQUIRE_GPU=mesh cargo test --workspace -- --test-threads=4 --skip heap_window_out_of_memory_falls_back_to_the_switch_form --skip pso_measurement_compiles_an_exact_synthetic_record: 858 passed, 0 failed, 42 ignored. SKIPPED (no wave64): gpu_geometry_wave32_prefix_count_over_a_mask, gpu_wave32_program_in_wave64_hardware.
  • The new tests ran and passed: a_singular_instance_transform_has_a_zero_inverse.
  • Same head on the AMD Radeon integrated GPU (iGPU) of the Ryzen 7 9800X3D (RDNA2, XCL_ADAPTER=radeon), cargo test --workspace -- --test-threads=4: 859 passed, 0 failed, 42 ignored. SKIPPED: heap_window_out_of_memory_falls_back_to_the_switch_form (no heap windows).
  • Two tests were skipped with --skip on NVIDIA. Both fail on main 7f7e768 too, not because of this PR: under XCL_REQUIRE_GPU=mesh, runner::skip_test turns their skips into failures. heap_window_out_of_memory_falls_back_to_the_switch_form skips when XCL_HEAP_WINDOWS is unset (#1651), and shaders::tests::pso_measurement_compiles_an_exact_synthetic_record skips because Developer Mode is off on this PC (it cannot disable the driver cache). The AMD run does not set XCL_REQUIRE_GPU, so there both just print SKIPPED.

Not tested

  • a release build, a game (test run only).

AI use

  • Claude Code (Claude Opus 5.5) ran the tests and wrote this report. I checked it before posting.
<!-- greyfinch-sync:ivall/xcl:comment:7144874898 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/1767#issuecomment-7144874898). Originally posted by [futurepro62](https://github.com/futurepro62) on 2026-11-24T21:23:50Z. --- Full-suite run, since this PR has no test report yet. Tested exact head `d3d6e63` (on its base `c160d86`). **Tested** - NVIDIA GeForce RTX 5070 Ti 16 GB (Blackwell, 32-lane waves only, mesh shaders), driver 616.64, Ryzen 7 9800X3D, Windows 11 Home 26300, Rust 1.100.0 MSVC, DXC + dxil.dll 1.9.2602.17 (Windows SDK 10.0.26100), debug, D3D12 debug layer installed. - `cargo build --workspace`, then `XCL_REQUIRE_GPU=mesh cargo test --workspace -- --test-threads=4 --skip heap_window_out_of_memory_falls_back_to_the_switch_form --skip pso_measurement_compiles_an_exact_synthetic_record`: **858 passed, 0 failed, 42 ignored**. SKIPPED (no wave64): `gpu_geometry_wave32_prefix_count_over_a_mask`, `gpu_wave32_program_in_wave64_hardware`. - The new tests ran and passed: `a_singular_instance_transform_has_a_zero_inverse`. - Same head on the AMD Radeon integrated GPU (iGPU) of the Ryzen 7 9800X3D (RDNA2, `XCL_ADAPTER=radeon`), `cargo test --workspace -- --test-threads=4`: **859 passed, 0 failed, 42 ignored**. SKIPPED: `heap_window_out_of_memory_falls_back_to_the_switch_form` (no heap windows). - Two tests were skipped with `--skip` on NVIDIA. Both fail on main `7f7e768` too, not because of this PR: under `XCL_REQUIRE_GPU=mesh`, `runner::skip_test` turns their skips into failures. `heap_window_out_of_memory_falls_back_to_the_switch_form` skips when `XCL_HEAP_WINDOWS` is unset (#1651), and `shaders::tests::pso_measurement_compiles_an_exact_synthetic_record` skips because Developer Mode is off on this PC (it cannot disable the driver cache). The AMD run does not set `XCL_REQUIRE_GPU`, so there both just print SKIPPED. **Not tested** - a release build, a game (test run only). **AI use** - Claude Code (Claude Opus 5.5) ran the tests and wrote this report. I checked it before posting.
b3IKK commented 2026-11-24 21:30:11 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by b3IKK on 2026-11-24T21:29:47Z.


Rebased onto c4d37be and re-ran both with the current scripts/smoke.ps1 (#677's hashed itle: line): 960 passed, 0 failed, 43 ignored.

<!-- greyfinch-sync:ivall/xcl:comment:7145006337 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/1767#issuecomment-7145006337). Originally posted by [b3IKK](https://github.com/b3IKK) on 2026-11-24T21:29:47Z. --- Rebased onto c4d37be and re-ran both with the current scripts/smoke.ps1 (#677's hashed itle: line): 960 passed, 0 failed, 43 ignored.
upstream-sync closed this pull request 2026-11-25 00:07:43 +00:00
b3IKK commented 2026-11-25 00:09:10 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by b3IKK on 2026-11-25T00:03:58Z.


Closing in favour of #1521, which came first and makes the same change (#1607, group D52): world_to_object returns zeros for a singular or non-finite transform. AI use: OpenCode, Claude Fable 5.2.

<!-- greyfinch-sync:ivall/xcl:comment:7148099202 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/1767#issuecomment-7148099202). Originally posted by [b3IKK](https://github.com/b3IKK) on 2026-11-25T00:03:58Z. --- Closing in favour of #1521, which came first and makes the same change (#1607, group D52): `world_to_object` returns zeros for a singular or non-finite transform. AI use: OpenCode, Claude Fable 5.2.

Pull request closed

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!1757
No description provided.