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

Closed
github-bot wants to merge 1 commit from gh-pr/1767/head into gh-pr/1767/base
Owner

@⁠b3IKK on GitHub · 2026-11-24 20:24 UTC · original
b3IKK:d3d12x/bvh-singular-instance-inverse → main · +32 −0 · 1 files · 1 commits · closed without merging

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.
**@⁠b3IKK** on GitHub · 2026-11-24 20:24 UTC · [original](https://github.com/xcl-dev/xcl/pull/1767) `b3IKK:d3d12x/bvh-singular-instance-inverse` → `main` · +32 −0 · 1 files · 1 commits · closed without merging 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.
bvh::world_to_object divided the cofactors by the determinant without
checking it: an instance with a zero scale on one axis (or any singular
transform) was written to the TLAS with a NaN / Inf matrix, so the
shader's object-space ray was NaN. Zeros map every point to the object
origin and every direction to 0, which the triangle test misses - the
right answer for an instance of no volume.

Assisted-by: OpenCode (Gemini 4 Neon)
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 05:04:19 +00:00
github-bot closed this pull request 2026-11-26 05:04:19 +00:00
Author
Owner

@⁠b3IKK on GitHub · 2026-11-24 21:29 UTC · original

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

**@⁠b3IKK** on GitHub · 2026-11-24 21:29 UTC · [original](https://github.com/xcl-dev/xcl/pull/1767#issuecomment-7145006337) Rebased onto c4d37be and re-ran both with the current scripts/smoke.ps1 (#677's hashed itle: line): 960 passed, 0 failed, 43 ignored.
Author
Owner

@⁠futurepro62 on GitHub · 2026-11-24 21:23 UTC · original · edited 2026-11-24 22:03 UTC

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.
**@⁠futurepro62** on GitHub · 2026-11-24 21:23 UTC · [original](https://github.com/xcl-dev/xcl/pull/1767#issuecomment-7144874898) · edited 2026-11-24 22:03 UTC 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.
Author
Owner

@⁠b3IKK on GitHub · 2026-11-25 00:03 UTC · original

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.

**@⁠b3IKK** on GitHub · 2026-11-25 00:03 UTC · [original](https://github.com/xcl-dev/xcl/pull/1767#issuecomment-7148099202) 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

This discussion has been locked. Commenting is limited to contributors.
No description provided.