Skip to content

Stabilize XDXR inverses for extreme instance scales - #8155

Open
gautch29 wants to merge 1 commit into
ItsNotRexed:mainfrom
gautch29:codex/xdxr-instance-scale
Open

gautch29 wants to merge 1 commit into
ItsNotRexed:mainfrom
gautch29:codex/xdxr-instance-scale

Conversation

@gautch29

Copy link
Copy Markdown

Coordination claim

Depends on: #4011, #5092 (overlap in the builder and regenerated shader only). This branch applies independently to main.

What changed

An invertible TLAS instance matrix can have a determinant outside the float32 range. Mixed scales can also overflow or underflow an inverse cofactor while the determinant remains representable. The builder could drop the instance or store an incorrect inverse in these cases.

For extreme transforms, normalize each matrix row by a power of two before inverting and undo that scaling in the result. The ordinary inverse path is retained for normal-range transforms. Singular controls still produce inactive instances. Nearly dependent rows and widely varying components within a single row remain subject to float32 precision.

Verification

  • Apple M3 Pro, macOS 27.0, MoltenVK 1.4.2. Eight synthetic transform cases pass, covering ordinary and singular controls, out-of-range determinants, and mixed scales that lose cofactors on main.
  • The GPU builder and CPU reference agree on 30 synthetic cases and 26,200 rays. Both XDXR CTests passed.
  • The embedded shader regenerated byte-for-byte with glslc 2026.4 and passed spirv-val --target-env vulkan1.2.

Synthetic geometry only. AI-assisted (Codex).

@senyurah

Copy link
Copy Markdown

Tested 308cf13bd on Windows 11 (26200), RTX 4060 Ti driver 621.24, GCC 15.2 Release. xdxr_build and xdxr_build_check both passed. All eight scale cases passed, and the CPU reference matched the GPU results for all 30 cases and 26,200 rays. The embedded shader also passed spirv-val --target-env vulkan1.2.

I also ran the same local probe against dde82f27e and this head. The synthetic TLAS instance’s affine transform mapped (u, v, w) to (2^100*v + 2^100, -2^80*w - 2^81, 2^-90*u + 3*2^-90). This exercises non-diagonal terms and inverse translation in the rescaled path. The base failed the inverse assertion. This head produced the expected inverse linear terms, inverse translation (-3, -1, -2), and world bounds exactly.

AI-assisted verification. Synthetic geometry only.

@kamilolejnik

Copy link
Copy Markdown

Tested 308cf13 on Intel Iris Xe Graphics (TGL GT2, Xe-LP), Mesa ANV 26.3.1, Vulkan 1.4.363, Linux 6.12 (Arch container), GCC, CMake + Ninja RelWithDebInfo: pass. The first non-NVIDIA, non-Apple run.

ctest -R xdxr --output-on-failure:

tree xdxr_build_output xdxr_descs xdxr_build xdxr_build_check
this PR Passed Passed Passed Passed (96 s)
negative control: this PR's test with runtime/src/xdxr_build.comp and .inc reverted to the merge-base dde82f27e Passed Passed Failed: line 662: bounds[axis] == lo && bounds[axis + 3] == hi Not Run

So the new extreme-scale cases catch the old inverse on ANV too, and the scaled inverse fixes them.

Synthetic geometry only, no game files. AI-assisted (Claude Code).

@rojasruiz

Copy link
Copy Markdown

Tested 308cf13 (on main dde82f2) on NVIDIA GeForce RTX 3080, driver 615.78.08, Linux 7.2.15, native GCC/CMake build of the portable runtime subset: pass, with a negative control, on a second vendor next to your MoltenVK run.

  • vk_xdxr_build_test <out>: "tlas instance scales: 8 cases verified", "built every case", exit 0.
  • Negative control: the same test binary built against main's xdxr_build.comp / xdxr_build.inc (only those two files swapped back) exits 1 at the new case: line 662: bounds[axis] == lo && bounds[axis + 3] == hi. So the new cases catch the old inverse on this GPU too.
  • No change for ordinary transforms: all 30 .bin outputs are byte-identical to main's vk_xdxr_build_test on the same GPU, and the 30 .json files differ only in "address".
  • ctest -R xdxr: 4/4 passed (including xdxr_build_check). run_gpu_tests.py: 192/241, 48 skipped, identical to main. check_no_game_data.py on the four files: clean.

AI-assisted (Claude Code).

@lohant27-netizen

Copy link
Copy Markdown

Tested 308cf13bd on Windows 11 (10.0.26300), NVIDIA GeForce RTX 5070 (driver 32.0.16.2101, subgroup 32), MSVC with SDK 10.0.26100, Release, merged onto main 77fa308f9 together with #8180, #8159, #8152, #8138 and #8155 (no conflicts): pass.

@leonidassupporter

Copy link
Copy Markdown

Tested 308cf13bd applied onto main dde82f27e on NVIDIA GeForce RTX 3060 Ti (Ampere), driver 621.14, Windows 11 (26300), native MSVC 19.44, Vulkan SDK 1.4.363, RelWithDebInfo: pass (first check on Windows / NVIDIA, as far as I can see).

  • Regenerated xdxr_build.inc from this head's xdxr_build.comp with glslc --target-env=vulkan1.2 -O -mfmt=c (shaderc v2026.4): byte-identical to the committed .inc. Same check on main: identical too.
  • ctest -R xdxr: xdxr_build_output, xdxr_descs, xdxr_build, xdxr_build_check (GPU builder vs CPU reference), d3d12_xdxr_rt, d3d12_xdxr_rt_check: 6/6 pass, --repeat until-fail:3. The same 6 pass on main (baseline).

Synthetic geometry only, no game files. AI-assisted (Claude Code).

@justrealyme

Copy link
Copy Markdown

Tested 308cf13 on NVIDIA GeForce RTX 5070 Ti, driver 617.42, Windows 11 build 26300, VS 2022 Build Tools (MSVC 19.44), Windows SDK 10.0.26100, Vulkan SDK 1.4.363.0, RelWithDebInfo: pass.

Built vk_xdxr_build_test and ran ctest -R "^xdxr_build(_check)?$": xdxr_build Passed (1.1 s), xdxr_build_check Passed (70 s).

Synthetic inputs only, no game files. AI-assisted (Claude Code).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants