D3D12.X: hw_rt registry and DXR geometry translation #3697

Open
Kalmarv wants to merge 2 commits from upstream-pr/3697 into main
Kalmarv commented 2026-12-02 15:14:42 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by Kalmarv on 2026-12-02T15:14:42Z.


Add the pure acceleration-structure shadow registry and DXR 1.1 triangle geometry / TLAS instance translation helpers in hle::d3d12x::hw_rt. Nothing calls this module yet, so default runtime behavior is unchanged; Caller: #3700 (the opt-in XCL_HW_RT=1 shadow command-list builder and XboxBvhBuilder hooks). Part of #1751.

Stacked on #3662 (includes its commit 4082300ba on main 5eaadb54c; the new diff on top of #3662 is commit f783a5f53).

Related: #2184/#2185 implement an earlier shadow-builder design; this PR isolates the pure registry and translation layer with DXR 1.1 PERFORM_UPDATE geometry-signature validation, referencing-TLAS staleness tracking when a BLAS GPU VA relocates or is invalidated, console typeless index format canonicalization (R16_TYPELESS/R32_TYPELESS -> R16_UINT/R32_UINT), and dynamic XCL_RAYTRACING=0 gating.

(Why this is 970 lines and not split further: ~640 lines are the pure registry and DXR 1.1 geometry/instance translation helpers, and ~330 lines are their unit tests, kept together because CONTRIBUTING.md requires new code to ship with its tests. The D3D12 command-list shadow builder, buffer pools, retirement plumbing, and XboxBvhBuilder hooks are split into the stacked follow-up PR.)

What is in it

  • crates/xcl/src/hle/d3d12x/hw_rt.rs & crates/xcl/src/hle/d3d12x/mod.rs:
    • Registry keyed by console AS GPU VA (NativeAs, NativeAsSnapshot, RewriteReport, CopySource, HwRtStats), tracking live BLAS/TLAS entries and rehydrated-only VAs.
    • mark_referencing_tlases_stale: tracks sorted, deduplicated native BLAS GPU VAs baked into each TLAS so relocating, rehydrating, or invalidating a BLAS immediately removes referencing TLASes from complete_tlases().
    • GeomSig and Registry::can_update: verifies ALLOW_UPDATE, matching sanitized non-update build flags, matching desc count, and matching per-geometry flags, vertex/index formats & counts, and transform presence before permitting a PERFORM_UPDATE refit.
    • translate_triangle_geometry / translate_blas_geometries, canonical_dxr_index_format, sanitize_build_flags, and Registry::rewrite_instance_descs_with_refs (masking unresolved/rehydrated instances cleanly with AccelerationStructure = 0, InstanceMask = 0).
    • parse_enabled / enabled_with / enabled combining opt-in XCL_HW_RT=1 with config().raytracing_tier_override() != Some(0).
    • 6 pure unit tests covering env/override gating, geometry translation and typeless index canonicalization, can_update rejection cases, BLAS relocation/invalidation staleness, hybrid TLAS rewriting, and flag sanitization.

Tested

  • Hardware & toolchain: NVIDIA GeForce RTX 5070 Ti (driver 610.74), AMD Ryzen 9 9950X, Windows 11 x64, rustc 1.99.0 (b940084d7 2026-09-28), DXC 1.9.2609.5 (01b62ad47).
  • cargo build --release -p xcl (commit f783a5f53f05e6caec11488cc5be73e42d371be6): succeeded, 39 warnings (0 new vs main).
  • .\scripts\test.ps1 at the top of this stack (1f287a928352ac71dcb238a3a5d3d4dd4741c3e0, containing f783a5f53): 3006 passed, 0 failed, 52 ignored across 43 test suites (including all hle::d3d12x::hw_rt tests; prior standalone run on b1bd0a442 before restacking on updated #3662 was 2991 passed, 0 failed, 52 ignored).
  • SKIPPED GPU tests (24): 22 no wave64 (RTX 5070 Ti is wave32-only), 2 no heap windows (XCL_HEAP_WINDOWS opt-in off by default).

Regression run

xcl-smoke v1
commit: 5eaadb54c14e0fc29597b2a1689d7dbd83491303
gpu: NVIDIA GeForce RTX 5070 Ti
title: ea3b5e4d
seconds: 60
exit: 0x0
frames shown: 1658 (PresentX 1658)
presents per 2 s (last 3): 60 61 60
device removals: 0
crashes: 0
peak commit: 16763 MB
xcl-smoke v1
commit: f783a5f53f05e6caec11488cc5be73e42d371be6
gpu: NVIDIA GeForce RTX 5070 Ti
title: ea3b5e4d
seconds: 60
exit: 0x0
frames shown: 1625 (PresentX 1625)
presents per 2 s (last 3): 60 61 60
device removals: 0
crashes: 0
peak commit: 16352 MB

Not tested

  • Live D3D12 command-list execution of hw_rt (nothing calls this module yet; the shadow builder, WARP DXR 1.1 tests, and live XCL_HW_RT=1 title run are in the stacked follow-up PR).
  • AMD / Intel GPUs and wave64-only GPU tests.

AI use

  • Claude Code (Claude Opus 5.5): audited the registry invariants (referencing-TLAS staleness, GeomSig refit rules, dead-code trims, and PR split) and reviewed the final diff and PR description.
  • Antigravity (Gemini 4 Neon): split and implemented the registry and translation module with its unit tests, ran the build, test suite, and regression smoke, and drafted the PR description.
<!-- greyfinch-sync:ivall/xcl:issue:5609308870 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/3697). Originally posted by [Kalmarv](https://github.com/Kalmarv) on 2026-12-02T15:14:42Z. --- Add the pure acceleration-structure shadow registry and DXR 1.1 triangle geometry / TLAS instance translation helpers in `hle::d3d12x::hw_rt`. Nothing calls this module yet, so default runtime behavior is unchanged; Caller: #3700 (the opt-in `XCL_HW_RT=1` shadow command-list builder and `XboxBvhBuilder` hooks). Part of #1751. Stacked on #3662 (includes its commit `4082300ba` on `main` `5eaadb54c`; the new diff on top of `#3662` is commit `f783a5f53`). Related: #2184/#2185 implement an earlier shadow-builder design; this PR isolates the pure registry and translation layer with DXR 1.1 `PERFORM_UPDATE` geometry-signature validation, referencing-TLAS staleness tracking when a BLAS GPU VA relocates or is invalidated, console typeless index format canonicalization (`R16_TYPELESS`/`R32_TYPELESS` -> `R16_UINT`/`R32_UINT`), and dynamic `XCL_RAYTRACING=0` gating. (Why this is 970 lines and not split further: ~640 lines are the pure registry and DXR 1.1 geometry/instance translation helpers, and ~330 lines are their unit tests, kept together because `CONTRIBUTING.md` requires new code to ship with its tests. The D3D12 command-list shadow builder, buffer pools, retirement plumbing, and `XboxBvhBuilder` hooks are split into the stacked follow-up PR.) **What is in it** - `crates/xcl/src/hle/d3d12x/hw_rt.rs` & `crates/xcl/src/hle/d3d12x/mod.rs`: - `Registry` keyed by console AS GPU VA (`NativeAs`, `NativeAsSnapshot`, `RewriteReport`, `CopySource`, `HwRtStats`), tracking live BLAS/TLAS entries and rehydrated-only VAs. - `mark_referencing_tlases_stale`: tracks sorted, deduplicated native BLAS GPU VAs baked into each TLAS so relocating, rehydrating, or invalidating a BLAS immediately removes referencing TLASes from `complete_tlases()`. - `GeomSig` and `Registry::can_update`: verifies `ALLOW_UPDATE`, matching sanitized non-update build flags, matching desc count, and matching per-geometry flags, vertex/index formats & counts, and transform presence before permitting a `PERFORM_UPDATE` refit. - `translate_triangle_geometry` / `translate_blas_geometries`, `canonical_dxr_index_format`, `sanitize_build_flags`, and `Registry::rewrite_instance_descs_with_refs` (masking unresolved/rehydrated instances cleanly with `AccelerationStructure = 0`, `InstanceMask = 0`). - `parse_enabled` / `enabled_with` / `enabled` combining opt-in `XCL_HW_RT=1` with `config().raytracing_tier_override() != Some(0)`. - 6 pure unit tests covering env/override gating, geometry translation and typeless index canonicalization, `can_update` rejection cases, BLAS relocation/invalidation staleness, hybrid TLAS rewriting, and flag sanitization. **Tested** - Hardware & toolchain: NVIDIA GeForce RTX 5070 Ti (driver 610.74), AMD Ryzen 9 9950X, Windows 11 x64, `rustc 1.99.0 (b940084d7 2026-09-28)`, DXC `1.9.2609.5 (01b62ad47)`. - `cargo build --release -p xcl` (commit `f783a5f53f05e6caec11488cc5be73e42d371be6`): succeeded, 39 warnings (0 new vs `main`). - `.\scripts\test.ps1` at the top of this stack (`1f287a928352ac71dcb238a3a5d3d4dd4741c3e0`, containing `f783a5f53`): **3006 passed, 0 failed, 52 ignored** across 43 test suites (including all `hle::d3d12x::hw_rt` tests; prior standalone run on `b1bd0a442` before restacking on updated #3662 was 2991 passed, 0 failed, 52 ignored). - SKIPPED GPU tests (24): 22 `no wave64` (RTX 5070 Ti is wave32-only), 2 `no heap windows` (`XCL_HEAP_WINDOWS` opt-in off by default). **Regression run** ``` xcl-smoke v1 commit: 5eaadb54c14e0fc29597b2a1689d7dbd83491303 gpu: NVIDIA GeForce RTX 5070 Ti title: ea3b5e4d seconds: 60 exit: 0x0 frames shown: 1658 (PresentX 1658) presents per 2 s (last 3): 60 61 60 device removals: 0 crashes: 0 peak commit: 16763 MB ``` ``` xcl-smoke v1 commit: f783a5f53f05e6caec11488cc5be73e42d371be6 gpu: NVIDIA GeForce RTX 5070 Ti title: ea3b5e4d seconds: 60 exit: 0x0 frames shown: 1625 (PresentX 1625) presents per 2 s (last 3): 60 61 60 device removals: 0 crashes: 0 peak commit: 16352 MB ``` **Not tested** - Live D3D12 command-list execution of `hw_rt` (nothing calls this module yet; the shadow builder, WARP DXR 1.1 tests, and live `XCL_HW_RT=1` title run are in the stacked follow-up PR). - AMD / Intel GPUs and wave64-only GPU tests. **AI use** - Claude Code (`Claude Opus 5.5`): audited the registry invariants (referencing-TLAS staleness, `GeomSig` refit rules, dead-code trims, and PR split) and reviewed the final diff and PR description. - Antigravity (`Gemini 4 Neon`): split and implemented the registry and translation module with its unit tests, ran the build, test suite, and regression smoke, and drafted the PR description.
saintwolf commented 2026-12-02 15:38:03 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by saintwolf on 2026-12-02T15:38:03Z.


merge-check claim
head: b1bd0a4426

<!-- greyfinch-sync:ivall/xcl:comment:7350659052 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/3697#issuecomment-7350659052). Originally posted by [saintwolf](https://github.com/saintwolf) on 2026-12-02T15:38:03Z. --- merge-check claim head: b1bd0a4426bd3906ef38eb1ec4718ef11b1965d4
saintwolf commented 2026-12-02 15:42:18 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by saintwolf on 2026-12-02T15:42:18Z.


merge-check
base: 5eaadb54c1
head: b1bd0a4426
merge: clean (fast-forward of #3662's a65c38b16 plus this PR's b1bd0a442 onto main; git diff --check clean; +2109/-1 in 6 files - new hle/bvh_builder.rs and hle/d3d12x/hw_rt.rs, Path::BvhBuild in view_want.rs, resolver.rs import wiring, two module declarations)
build: cargo build --workspace -> ok (39 lib warnings, same count as main; none from the new code)
tests: cargo test --workspace -- --test-threads=4 -> 2991 passed, 0 failed, 52 ignored across 43 binaries (main 5eaadb54 is 2974 + the 17 new tests - 11 bvh_builder, 6 hw_rt - all confirmed run and passing here by name). SKIPPED: 27, the standard set for this card (22 no wave64, 2 no heap windows, 1 driver cache, 2 no xgameruntime.dll). XCL_SAMPLE_DLLS is not set here, so the pre-existing console_dlls_e2e XboxBvhBuilder tests early-return on main and head alike.
review: no blocking finding; every hunk of both commits read. Verified against the installed DXR 1.1 SDK (10.0.26100): the console build flags the ABI uses (ALLOW_UPDATE 0x1, PERFORM_UPDATE 0x20) are exactly the PC values in that SDK (0x2 is ALLOW_COMPACTION there), so the 0x3F mask in sanitize_build_flags / can_update is an exact console-to-PC translation and implements the DXR 1.1 refit rules (originally ALLOW_UPDATE, matching sanitized non-update flags, same desc count, matching per-geometry flags / vertex+index formats and counts / transform presence); InstanceMask is bits 24-31 of the first UINT of D3D12_RAYTRACING_INSTANCE_DESC, so the masking and its test are exact; all ten hardcoded DXGI format numbers match dxgiformat.h. The ABI structs are size/offset-pinned by tests; the PrebuildInfo mangled symbol is byte-identical to the one the existing e2e tests call on the real DLL, and the two Batched2X manglings are parameter-exact against the hook signatures. Gating: the exports are wrapped only while the UMA has view windows (the 16-window layout), so the default layout is unchanged by construction (one string compare per XboxBvhBuilder import); Path::BvhBuild is appended with stable discriminants and carries real prebuild sizes rather than the sizeless reach. Registry invariants sound: an in-place rebuild at the same native VA keeps referencing TLASes complete (instance descs point at the buffer VA), while relocating, invalidating or rehydrating a BLAS marks them stale at once, and live_as_bytes balances on every insert/remove path. Non-blocking: (1) upsert_native rebuilding the same console VA as a different AS kind with resource = None returns the old handle (the same buffer) for deferred retirement while the new entry keeps None - a caller-contract edge in a module nothing calls yet; the follow-up shadow-builder PR drives it; (2) the UPDATE_SCRATCH cache grows per distinct dest VA (bounded by the title's AS destinations, removed on a non-ALLOW_UPDATE rebuild at that VA); (3) +2109 lines over the two stacked commits (this PR's own commit is 970: ~640 code + ~330 tests kept together per CONTRIBUTING) is over the ~400 soft target.
performance: nothing by default (no view windows: one string compare per XboxBvhBuilder import, no hooks installed). In the 16-window layout: per batched build/rehydrate call one call of the DLL's own prebuild query, a readable() walk of the descs, and one is_view compare per asked range (tile mapping only for ranges in view windows). hw_rt is called by nothing in this PR, so it costs zero at runtime here.
verdict: safe to merge
hardware / tool and model: RTX 4070 SUPER (driver 32.0.16.2140), Ryzen 7 7800X3D, Windows 11 build 26300, Rust 1.100.0 / OpenCode, Qwen 3.8 27B

<!-- greyfinch-sync:ivall/xcl:comment:7350778084 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/3697#issuecomment-7350778084). Originally posted by [saintwolf](https://github.com/saintwolf) on 2026-12-02T15:42:18Z. --- merge-check base: 5eaadb54c14e0fc29597b2a1689d7dbd83491303 head: b1bd0a4426bd3906ef38eb1ec4718ef11b1965d4 merge: clean (fast-forward of #3662's a65c38b16 plus this PR's b1bd0a442 onto main; git diff --check clean; +2109/-1 in 6 files - new hle/bvh_builder.rs and hle/d3d12x/hw_rt.rs, Path::BvhBuild in view_want.rs, resolver.rs import wiring, two module declarations) build: cargo build --workspace -> ok (39 lib warnings, same count as main; none from the new code) tests: cargo test --workspace -- --test-threads=4 -> 2991 passed, 0 failed, 52 ignored across 43 binaries (main 5eaadb54 is 2974 + the 17 new tests - 11 bvh_builder, 6 hw_rt - all confirmed run and passing here by name). SKIPPED: 27, the standard set for this card (22 no wave64, 2 no heap windows, 1 driver cache, 2 no xgameruntime.dll). XCL_SAMPLE_DLLS is not set here, so the pre-existing console_dlls_e2e XboxBvhBuilder tests early-return on main and head alike. review: no blocking finding; every hunk of both commits read. Verified against the installed DXR 1.1 SDK (10.0.26100): the console build flags the ABI uses (ALLOW_UPDATE 0x1, PERFORM_UPDATE 0x20) are exactly the PC values in that SDK (0x2 is ALLOW_COMPACTION there), so the 0x3F mask in sanitize_build_flags / can_update is an exact console-to-PC translation and implements the DXR 1.1 refit rules (originally ALLOW_UPDATE, matching sanitized non-update flags, same desc count, matching per-geometry flags / vertex+index formats and counts / transform presence); InstanceMask is bits 24-31 of the first UINT of D3D12_RAYTRACING_INSTANCE_DESC, so the masking and its test are exact; all ten hardcoded DXGI format numbers match dxgiformat.h. The ABI structs are size/offset-pinned by tests; the PrebuildInfo mangled symbol is byte-identical to the one the existing e2e tests call on the real DLL, and the two Batched2X manglings are parameter-exact against the hook signatures. Gating: the exports are wrapped only while the UMA has view windows (the 16-window layout), so the default layout is unchanged by construction (one string compare per XboxBvhBuilder import); Path::BvhBuild is appended with stable discriminants and carries real prebuild sizes rather than the sizeless reach. Registry invariants sound: an in-place rebuild at the same native VA keeps referencing TLASes complete (instance descs point at the buffer VA), while relocating, invalidating or rehydrating a BLAS marks them stale at once, and live_as_bytes balances on every insert/remove path. Non-blocking: (1) upsert_native rebuilding the same console VA as a different AS kind with resource = None returns the old handle (the same buffer) for deferred retirement while the new entry keeps None - a caller-contract edge in a module nothing calls yet; the follow-up shadow-builder PR drives it; (2) the UPDATE_SCRATCH cache grows per distinct dest VA (bounded by the title's AS destinations, removed on a non-ALLOW_UPDATE rebuild at that VA); (3) +2109 lines over the two stacked commits (this PR's own commit is 970: ~640 code + ~330 tests kept together per CONTRIBUTING) is over the ~400 soft target. performance: nothing by default (no view windows: one string compare per XboxBvhBuilder import, no hooks installed). In the 16-window layout: per batched build/rehydrate call one call of the DLL's own prebuild query, a readable() walk of the descs, and one is_view compare per asked range (tile mapping only for ranges in view windows). hw_rt is called by nothing in this PR, so it costs zero at runtime here. verdict: safe to merge hardware / tool and model: RTX 4070 SUPER (driver 32.0.16.2140), Ryzen 7 7800X3D, Windows 11 build 26300, Rust 1.100.0 / OpenCode, Qwen 3.8 27B
saintwolf commented 2026-12-02 15:42:22 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by saintwolf on 2026-12-02T15:42:22Z.


merge-check
base: 5eaadb54c1
head: b1bd0a4426
merge: clean (fast-forward of #3662's a65c38b16 plus this PR's b1bd0a442 onto main; git diff --check clean; +2109/-1 in 6 files - new hle/bvh_builder.rs and hle/d3d12x/hw_rt.rs, Path::BvhBuild in view_want.rs, resolver.rs import wiring, two module declarations)
build: cargo build --workspace -> ok (39 lib warnings, same count as main; none from the new code)
tests: cargo test --workspace -- --test-threads=4 -> 2991 passed, 0 failed, 52 ignored across 43 binaries (main 5eaadb54 is 2974 + the 17 new tests - 11 bvh_builder, 6 hw_rt - all confirmed run and passing here by name). SKIPPED: 27, the standard set for this card (22 no wave64, 2 no heap windows, 1 driver cache, 2 no xgameruntime.dll). XCL_SAMPLE_DLLS is not set here, so the pre-existing console_dlls_e2e XboxBvhBuilder tests early-return on main and head alike.
review: no blocking finding; every hunk of both commits read. Verified against the installed DXR 1.1 SDK (10.0.26100): the console build flags the ABI uses (ALLOW_UPDATE 0x1, PERFORM_UPDATE 0x20) are exactly the PC values in that SDK (0x2 is ALLOW_COMPACTION there), so the 0x3F mask in sanitize_build_flags / can_update is an exact console-to-PC translation and implements the DXR 1.1 refit rules (originally ALLOW_UPDATE, matching sanitized non-update flags, same desc count, matching per-geometry flags / vertex+index formats and counts / transform presence); InstanceMask is bits 24-31 of the first UINT of D3D12_RAYTRACING_INSTANCE_DESC, so the masking and its test are exact; all ten hardcoded DXGI format numbers match dxgiformat.h. The ABI structs are size/offset-pinned by tests; the PrebuildInfo mangled symbol is byte-identical to the one the existing e2e tests call on the real DLL, and the two Batched2X manglings are parameter-exact against the hook signatures. Gating: the exports are wrapped only while the UMA has view windows (the 16-window layout), so the default layout is unchanged by construction (one string compare per XboxBvhBuilder import); Path::BvhBuild is appended with stable discriminants and carries real prebuild sizes rather than the sizeless reach. Registry invariants sound: an in-place rebuild at the same native VA keeps referencing TLASes complete (instance descs point at the buffer VA), while relocating, invalidating or rehydrating a BLAS marks them stale at once, and live_as_bytes balances on every insert/remove path. Non-blocking: (1) upsert_native rebuilding the same console VA as a different AS kind with resource = None returns the old handle (the same buffer) for deferred retirement while the new entry keeps None - a caller-contract edge in a module nothing calls yet; the follow-up shadow-builder PR drives it; (2) the UPDATE_SCRATCH cache grows per distinct dest VA (bounded by the title's AS destinations, removed on a non-ALLOW_UPDATE rebuild at that VA); (3) +2109 lines over the two stacked commits (this PR's own commit is 970: ~640 code + ~330 tests kept together per CONTRIBUTING) is over the ~400 soft target.
performance: nothing by default (no view windows: one string compare per XboxBvhBuilder import, no hooks installed). In the 16-window layout: per batched build/rehydrate call one call of the DLL's own prebuild query, a readable() walk of the descs, and one is_view compare per asked range (tile mapping only for ranges in view windows). hw_rt is called by nothing in this PR, so it costs zero at runtime here.
verdict: safe to merge
hardware / tool and model: RTX 4070 SUPER (driver 32.0.16.2140), Ryzen 7 7800X3D, Windows 11 build 26300, Rust 1.100.0 / OpenCode, Qwen 3.8 27B

<!-- greyfinch-sync:ivall/xcl:comment:7350780233 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/3697#issuecomment-7350780233). Originally posted by [saintwolf](https://github.com/saintwolf) on 2026-12-02T15:42:22Z. --- merge-check base: 5eaadb54c14e0fc29597b2a1689d7dbd83491303 head: b1bd0a4426bd3906ef38eb1ec4718ef11b1965d4 merge: clean (fast-forward of #3662's a65c38b16 plus this PR's b1bd0a442 onto main; git diff --check clean; +2109/-1 in 6 files - new hle/bvh_builder.rs and hle/d3d12x/hw_rt.rs, Path::BvhBuild in view_want.rs, resolver.rs import wiring, two module declarations) build: cargo build --workspace -> ok (39 lib warnings, same count as main; none from the new code) tests: cargo test --workspace -- --test-threads=4 -> 2991 passed, 0 failed, 52 ignored across 43 binaries (main 5eaadb54 is 2974 + the 17 new tests - 11 bvh_builder, 6 hw_rt - all confirmed run and passing here by name). SKIPPED: 27, the standard set for this card (22 no wave64, 2 no heap windows, 1 driver cache, 2 no xgameruntime.dll). XCL_SAMPLE_DLLS is not set here, so the pre-existing console_dlls_e2e XboxBvhBuilder tests early-return on main and head alike. review: no blocking finding; every hunk of both commits read. Verified against the installed DXR 1.1 SDK (10.0.26100): the console build flags the ABI uses (ALLOW_UPDATE 0x1, PERFORM_UPDATE 0x20) are exactly the PC values in that SDK (0x2 is ALLOW_COMPACTION there), so the 0x3F mask in sanitize_build_flags / can_update is an exact console-to-PC translation and implements the DXR 1.1 refit rules (originally ALLOW_UPDATE, matching sanitized non-update flags, same desc count, matching per-geometry flags / vertex+index formats and counts / transform presence); InstanceMask is bits 24-31 of the first UINT of D3D12_RAYTRACING_INSTANCE_DESC, so the masking and its test are exact; all ten hardcoded DXGI format numbers match dxgiformat.h. The ABI structs are size/offset-pinned by tests; the PrebuildInfo mangled symbol is byte-identical to the one the existing e2e tests call on the real DLL, and the two Batched2X manglings are parameter-exact against the hook signatures. Gating: the exports are wrapped only while the UMA has view windows (the 16-window layout), so the default layout is unchanged by construction (one string compare per XboxBvhBuilder import); Path::BvhBuild is appended with stable discriminants and carries real prebuild sizes rather than the sizeless reach. Registry invariants sound: an in-place rebuild at the same native VA keeps referencing TLASes complete (instance descs point at the buffer VA), while relocating, invalidating or rehydrating a BLAS marks them stale at once, and live_as_bytes balances on every insert/remove path. Non-blocking: (1) upsert_native rebuilding the same console VA as a different AS kind with resource = None returns the old handle (the same buffer) for deferred retirement while the new entry keeps None - a caller-contract edge in a module nothing calls yet; the follow-up shadow-builder PR drives it; (2) the UPDATE_SCRATCH cache grows per distinct dest VA (bounded by the title's AS destinations, removed on a non-ALLOW_UPDATE rebuild at that VA); (3) +2109 lines over the two stacked commits (this PR's own commit is 970: ~640 code + ~330 tests kept together per CONTRIBUTING) is over the ~400 soft target. performance: nothing by default (no view windows: one string compare per XboxBvhBuilder import, no hooks installed). In the 16-window layout: per batched build/rehydrate call one call of the DLL's own prebuild query, a readable() walk of the descs, and one is_view compare per asked range (tile mapping only for ranges in view windows). hw_rt is called by nothing in this PR, so it costs zero at runtime here. verdict: safe to merge hardware / tool and model: RTX 4070 SUPER (driver 32.0.16.2140), Ryzen 7 7800X3D, Windows 11 build 26300, Rust 1.100.0 / OpenCode, Qwen 3.8 27B
Foniass commented 2026-12-03 00:57:05 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by Foniass on 2026-12-03T00:57:05Z.


merge-check
base: 078358a058
head: f783a5f53f
merge: clean
build: ok
tests: 3024 passed, 0 failed, 52 ignored; 28 skipped, the same as on main
review: 1 medium, 2 nits (below)
performance: 60 s smoke run: 1669 → 1665 frames (99 % of main), peak commit 17577 → 17450 MB, no device removal, no crash
title run: retail title on the RTX 5070 Ti (driver 621.14), into the world by scripted presses: 226 s there, 0 device removals, 0 crashes, 2.8 presents/s; run with XCL_SKIP_CS=95cc13288a27a96e (the NVIDIA hang at the end of loading, #3541) and NVIDIA's 2048 MB shader heap (#2590)
verdict: not yet: PR description is red; otherwise no blocking finding, the suite passes and the smoke run is clean
hardware / tool and model: RTX 5070 Ti (driver 621.14), Ryzen 7 7800X3D, Windows 11 26300 / Claude Code with Claude Opus 5.5


In short: Adds the hw_rt registry (native BLAS/TLAS keyed by console VA, refit checks, stale-TLAS tracking) and the DXR geometry/instance translation helpers, with pure unit tests; nothing calls it yet (the caller is #3700). It also carries #3662's commit 4082300ba, so merging this lands #3662 too. Reading found no bug in the registry or the translation, and the default runtime is unchanged; nothing blocks it beyond #3662 having to be ready as well.

Medium

  1. Size over the limit, reason given. This PR's own commit f783a5f53 is 970 lines (~640 code, ~330 tests), and the whole diff against main is 2309 lines because #3662 is carried. The description gives a reason (tests ship with the code, the builder is split into #3700), which fits CONTRIBUTING's "new code not yet called, with its tests" step, but it is still over ~800.

Nit

  1. upsert_native does not enforce its in-place contract. hw_rt.rs ~379: with resource = None and an existing entry of a different kind or smaller size, the in-place branch is skipped, the old entry's buffer is returned for retirement and the new entry keeps a GPU VA inside it. #3700's callers only pass None after reusable_buffer matched kind and size, so it can't happen today; a debug_assert, or refusing that case, would keep a later caller from retiring a live buffer.
  2. Only the Tier 1.0 vertex formats are accepted. hw_rt.rs ~541 is_valid_dxr_vertex_format rejects the formats Tier 1.1 adds (R16G16B16A16_UNORM, R16G16_UNORM, R10G10B10A2_UNORM, R8G8B8A8/R8G8 UNORM/SNORM), so such geometry stays on the console path. Conservative, not wrong; a comment saying so would help.
Checked and fine
  • The carried #3662 commit 4082300ba is #3662's head commit itself (same SHA), so nothing would land twice; #3662's own review findings are handled there
  • Default path unchanged: the module is only declared (pub mod hw_rt) and nothing calls it in this PR
  • Registry invariants: relocating, invalidating or rehydrating a BLAS marks referencing TLASes stale at once, an in-place rebuild at the same native VA keeps them complete, and live_as_bytes is balanced on every insert/remove path
  • can_update follows the DXR refit rules (ALLOW_UPDATE on the source, same sanitized non-update flags, same desc count, same per-geometry signature)
  • DXGI numbers (R16/R32 TYPELESS to UINT, the vertex formats) and the InstanceMask masking (bits 24-31 of the first word) are correct, and the tests check them
  • 6 pure unit tests with real assertions, no GPU dependency; no assertions removed
How this was tested
  • Merged onto main 078358a0, then cargo build --workspace and cargo test --workspace --no-fail-fast -- --test-threads=4.
  • The skipped GPU tests are those this card can't run (no wave64 on NVIDIA, no D3D12 debug layer, and similar).
  • scripts/smoke.ps1: 60 s of a retail title on main 078358a0 and on this merge; presents per 2 s at the end: 60 60 60.
  • Title run: the release build of this merge launched the retail title with XCL_RUN_SECONDS=300 and scripted A presses counted from the first frame (XCL_PRESS_BASE=frame, #3712) into the world from an existing save; time in the world is counted from the first in-world draw call to the end of the run.

Written by Claude Code (Claude Opus 5.5) and posted by Foniass without a human check of each point.

<!-- greyfinch-sync:ivall/xcl:comment:7363778725 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/3697#issuecomment-7363778725). Originally posted by [Foniass](https://github.com/Foniass) on 2026-12-03T00:57:05Z. --- merge-check base: 078358a058f7ba5d16690dba8dc4e55d2c88ae0a head: f783a5f53f05e6caec11488cc5be73e42d371be6 merge: clean build: ok tests: 3024 passed, 0 failed, 52 ignored; 28 skipped, the same as on main review: 1 medium, 2 nits (below) performance: 60 s smoke run: 1669 → 1665 frames (99 % of main), peak commit 17577 → 17450 MB, no device removal, no crash title run: retail title on the RTX 5070 Ti (driver 621.14), into the world by scripted presses: 226 s there, 0 device removals, 0 crashes, 2.8 presents/s; run with `XCL_SKIP_CS=95cc13288a27a96e` (the NVIDIA hang at the end of loading, #3541) and NVIDIA's 2048 MB shader heap (#2590) verdict: not yet: `PR description` is red; otherwise no blocking finding, the suite passes and the smoke run is clean hardware / tool and model: RTX 5070 Ti (driver 621.14), Ryzen 7 7800X3D, Windows 11 26300 / Claude Code with Claude Opus 5.5 --- **In short:** Adds the hw_rt registry (native BLAS/TLAS keyed by console VA, refit checks, stale-TLAS tracking) and the DXR geometry/instance translation helpers, with pure unit tests; nothing calls it yet (the caller is #3700). It also carries #3662's commit 4082300ba, so merging this lands #3662 too. Reading found no bug in the registry or the translation, and the default runtime is unchanged; nothing blocks it beyond #3662 having to be ready as well. #### Medium 1. **Size over the limit, reason given.** This PR's own commit f783a5f53 is 970 lines (~640 code, ~330 tests), and the whole diff against main is 2309 lines because #3662 is carried. The description gives a reason (tests ship with the code, the builder is split into #3700), which fits CONTRIBUTING's "new code not yet called, with its tests" step, but it is still over ~800. #### Nit 2. **upsert_native does not enforce its in-place contract.** hw_rt.rs ~379: with resource = None and an existing entry of a different kind or smaller size, the in-place branch is skipped, the old entry's buffer is returned for retirement and the new entry keeps a GPU VA inside it. #3700's callers only pass None after reusable_buffer matched kind and size, so it can't happen today; a debug_assert, or refusing that case, would keep a later caller from retiring a live buffer. 3. **Only the Tier 1.0 vertex formats are accepted.** hw_rt.rs ~541 is_valid_dxr_vertex_format rejects the formats Tier 1.1 adds (R16G16B16A16_UNORM, R16G16_UNORM, R10G10B10A2_UNORM, R8G8B8A8/R8G8 UNORM/SNORM), so such geometry stays on the console path. Conservative, not wrong; a comment saying so would help. <details><summary>Checked and fine</summary> - The carried #3662 commit 4082300ba is #3662's head commit itself (same SHA), so nothing would land twice; #3662's own review findings are handled there - Default path unchanged: the module is only declared (pub mod hw_rt) and nothing calls it in this PR - Registry invariants: relocating, invalidating or rehydrating a BLAS marks referencing TLASes stale at once, an in-place rebuild at the same native VA keeps them complete, and live_as_bytes is balanced on every insert/remove path - can_update follows the DXR refit rules (ALLOW_UPDATE on the source, same sanitized non-update flags, same desc count, same per-geometry signature) - DXGI numbers (R16/R32 TYPELESS to UINT, the vertex formats) and the InstanceMask masking (bits 24-31 of the first word) are correct, and the tests check them - 6 pure unit tests with real assertions, no GPU dependency; no assertions removed </details> <details><summary>How this was tested</summary> - Merged onto main `078358a0`, then `cargo build --workspace` and `cargo test --workspace --no-fail-fast -- --test-threads=4`. - The skipped GPU tests are those this card can't run (no wave64 on NVIDIA, no D3D12 debug layer, and similar). - `scripts/smoke.ps1`: 60 s of a retail title on main `078358a0` and on this merge; presents per 2 s at the end: 60 60 60. - Title run: the release build of this merge launched the retail title with `XCL_RUN_SECONDS=300` and scripted A presses counted from the first frame (`XCL_PRESS_BASE=frame`, #3712) into the world from an existing save; time in the world is counted from the first in-world draw call to the end of the run. </details> <sub>Written by Claude Code (Claude Opus 5.5) and posted by Foniass without a human check of each point.</sub>
Kalmarv commented 2026-12-03 01:13:04 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by Kalmarv on 2026-12-03T01:13:04Z.


Thanks for the merge-check and title run @Foniass!

On `PR description` is red: every pull_request_target workflow on xcl-dev/xcl (PR checks, Auto triage, Testing feed, Discord mirror) has been returning startup_failure repo-wide since ~22:47 UTC on 2026-12-02, so the PR description job never started on f783a5f53 (runs 46994360164 and 46996524481). Running main's scripts/pr_check.py locally against PR #3697's current description and file list for f783a5f53 passes (description ok), and Build and test (Windows, no GPU) is green (46996521079). Once pull_request_target recovers, I'll retrigger PR checks via a no-op description edit without changing f783a5f53.

Good catches on both nits too:

  • upsert_native (resource = None with mismatched kind or smaller size): agreed it is worth guarding (debug_assert or rejecting that path).
  • is_valid_dxr_vertex_format: intentionally conservative to the Tier 1.0 subset so Tier 1.1 UNORM/SNORM formats stay on the console path; agreed a doc comment saying so would help.

Leaving f783a5f53 untouched for now so this check and the stacked PRs (#3700 / #3704 / #3705) stay aligned; happy to fold both nits in if #3697 needs another push or in a small follow-up.

<!-- greyfinch-sync:ivall/xcl:comment:7364089544 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/3697#issuecomment-7364089544). Originally posted by [Kalmarv](https://github.com/Kalmarv) on 2026-12-03T01:13:04Z. --- Thanks for the merge-check and title run @Foniass! On `` `PR description` is red ``: every `pull_request_target` workflow on `xcl-dev/xcl` (`PR checks`, `Auto triage`, `Testing feed`, `Discord mirror`) has been returning `startup_failure` repo-wide since ~22:47 UTC on 2026-12-02, so the `PR description` job never started on `f783a5f53` (runs `46994360164` and `46996524481`). Running `main`'s `scripts/pr_check.py` locally against PR #3697's current description and file list for `f783a5f53` passes (`description ok`), and `Build and test (Windows, no GPU)` is green (`46996521079`). Once `pull_request_target` recovers, I'll retrigger `PR checks` via a no-op description edit without changing `f783a5f53`. Good catches on both nits too: - `upsert_native` (`resource = None` with mismatched kind or smaller size): agreed it is worth guarding (`debug_assert` or rejecting that path). - `is_valid_dxr_vertex_format`: intentionally conservative to the Tier 1.0 subset so Tier 1.1 UNORM/SNORM formats stay on the console path; agreed a doc comment saying so would help. Leaving `f783a5f53` untouched for now so this check and the stacked PRs (`#3700` / `#3704` / `#3705`) stay aligned; happy to fold both nits in if `#3697` needs another push or in a small follow-up.
Foniass commented 2026-12-03 15:31:45 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by Foniass on 2026-12-03T15:31:45Z.


merge-check
base: 078358a058
head: f783a5f53f
merge: clean
build: ok
tests: 3024 passed, 0 failed, 52 ignored; 28 skipped, the same as on main
review: 1 medium, 2 nits (below)
performance: 60 s smoke run: 1669 → 1665 frames (99 % of main), peak commit 17577 → 17450 MB, no device removal, no crash
title run: retail title on the RTX 5070 Ti (driver 621.14), into the world by scripted presses: 226 s there, 0 device removals, 0 crashes, 2.8 presents/s; run with XCL_SKIP_CS=95cc13288a27a96e (the NVIDIA hang at the end of loading, #3541) and NVIDIA's 2048 MB shader heap (#2590)
verdict: safe to merge: no blocking finding (the points below are medium or nits), the suite passes and the smoke run is clean
hardware / tool and model: RTX 5070 Ti (driver 621.14), Ryzen 7 7800X3D, Windows 11 26300 / Claude Code with Claude Opus 5.5


In short: Adds the hw_rt registry (native BLAS/TLAS keyed by console VA, refit checks, stale-TLAS tracking) and the DXR geometry/instance translation helpers, with pure unit tests; nothing calls it yet (the caller is #3700). It also carries #3662's commit 4082300ba, so merging this lands #3662 too. Reading found no bug in the registry or the translation, and the default runtime is unchanged; nothing blocks it beyond #3662 having to be ready as well.

Medium

  1. Size over the limit, reason given. This PR's own commit f783a5f53 is 970 lines (~640 code, ~330 tests), and the whole diff against main is 2309 lines because #3662 is carried. The description gives a reason (tests ship with the code, the builder is split into #3700), which fits CONTRIBUTING's "new code not yet called, with its tests" step, but it is still over ~800.

Nit

  1. upsert_native does not enforce its in-place contract. hw_rt.rs ~379: with resource = None and an existing entry of a different kind or smaller size, the in-place branch is skipped, the old entry's buffer is returned for retirement and the new entry keeps a GPU VA inside it. #3700's callers only pass None after reusable_buffer matched kind and size, so it can't happen today; a debug_assert, or refusing that case, would keep a later caller from retiring a live buffer.
  2. Only the Tier 1.0 vertex formats are accepted. hw_rt.rs ~541 is_valid_dxr_vertex_format rejects the formats Tier 1.1 adds (R16G16B16A16_UNORM, R16G16_UNORM, R10G10B10A2_UNORM, R8G8B8A8/R8G8 UNORM/SNORM), so such geometry stays on the console path. Conservative, not wrong; a comment saying so would help.
Checked and fine
  • The carried #3662 commit 4082300ba is #3662's head commit itself (same SHA), so nothing would land twice; #3662's own review findings are handled there
  • Default path unchanged: the module is only declared (pub mod hw_rt) and nothing calls it in this PR
  • Registry invariants: relocating, invalidating or rehydrating a BLAS marks referencing TLASes stale at once, an in-place rebuild at the same native VA keeps them complete, and live_as_bytes is balanced on every insert/remove path
  • can_update follows the DXR refit rules (ALLOW_UPDATE on the source, same sanitized non-update flags, same desc count, same per-geometry signature)
  • DXGI numbers (R16/R32 TYPELESS to UINT, the vertex formats) and the InstanceMask masking (bits 24-31 of the first word) are correct, and the tests check them
  • 6 pure unit tests with real assertions, no GPU dependency; no assertions removed
How this was tested
  • Merged onto main 078358a0, then cargo build --workspace and cargo test --workspace --no-fail-fast -- --test-threads=4.
  • The skipped GPU tests are those this card can't run (no wave64 on NVIDIA, no D3D12 debug layer, and similar).
  • scripts/smoke.ps1: 60 s of a retail title on main 078358a0 and on this merge; presents per 2 s at the end: 60 60 60.
  • Title run: the release build of this merge launched the retail title with XCL_RUN_SECONDS=300 and scripted A presses counted from the first frame (XCL_PRESS_BASE=frame, #3712) into the world from an existing save; time in the world is counted from the first in-world draw call to the end of the run.

Written by Claude Code (Claude Opus 5.5) and posted by Foniass without a human check of each point.

<!-- greyfinch-sync:ivall/xcl:comment:7383297839 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/3697#issuecomment-7383297839). Originally posted by [Foniass](https://github.com/Foniass) on 2026-12-03T15:31:45Z. --- merge-check base: 078358a058f7ba5d16690dba8dc4e55d2c88ae0a head: f783a5f53f05e6caec11488cc5be73e42d371be6 merge: clean build: ok tests: 3024 passed, 0 failed, 52 ignored; 28 skipped, the same as on main review: 1 medium, 2 nits (below) performance: 60 s smoke run: 1669 → 1665 frames (99 % of main), peak commit 17577 → 17450 MB, no device removal, no crash title run: retail title on the RTX 5070 Ti (driver 621.14), into the world by scripted presses: 226 s there, 0 device removals, 0 crashes, 2.8 presents/s; run with `XCL_SKIP_CS=95cc13288a27a96e` (the NVIDIA hang at the end of loading, #3541) and NVIDIA's 2048 MB shader heap (#2590) verdict: safe to merge: no blocking finding (the points below are medium or nits), the suite passes and the smoke run is clean hardware / tool and model: RTX 5070 Ti (driver 621.14), Ryzen 7 7800X3D, Windows 11 26300 / Claude Code with Claude Opus 5.5 --- **In short:** Adds the hw_rt registry (native BLAS/TLAS keyed by console VA, refit checks, stale-TLAS tracking) and the DXR geometry/instance translation helpers, with pure unit tests; nothing calls it yet (the caller is #3700). It also carries #3662's commit 4082300ba, so merging this lands #3662 too. Reading found no bug in the registry or the translation, and the default runtime is unchanged; nothing blocks it beyond #3662 having to be ready as well. #### Medium 1. **Size over the limit, reason given.** This PR's own commit f783a5f53 is 970 lines (~640 code, ~330 tests), and the whole diff against main is 2309 lines because #3662 is carried. The description gives a reason (tests ship with the code, the builder is split into #3700), which fits CONTRIBUTING's "new code not yet called, with its tests" step, but it is still over ~800. #### Nit 2. **upsert_native does not enforce its in-place contract.** hw_rt.rs ~379: with resource = None and an existing entry of a different kind or smaller size, the in-place branch is skipped, the old entry's buffer is returned for retirement and the new entry keeps a GPU VA inside it. #3700's callers only pass None after reusable_buffer matched kind and size, so it can't happen today; a debug_assert, or refusing that case, would keep a later caller from retiring a live buffer. 3. **Only the Tier 1.0 vertex formats are accepted.** hw_rt.rs ~541 is_valid_dxr_vertex_format rejects the formats Tier 1.1 adds (R16G16B16A16_UNORM, R16G16_UNORM, R10G10B10A2_UNORM, R8G8B8A8/R8G8 UNORM/SNORM), so such geometry stays on the console path. Conservative, not wrong; a comment saying so would help. <details><summary>Checked and fine</summary> - The carried #3662 commit 4082300ba is #3662's head commit itself (same SHA), so nothing would land twice; #3662's own review findings are handled there - Default path unchanged: the module is only declared (pub mod hw_rt) and nothing calls it in this PR - Registry invariants: relocating, invalidating or rehydrating a BLAS marks referencing TLASes stale at once, an in-place rebuild at the same native VA keeps them complete, and live_as_bytes is balanced on every insert/remove path - can_update follows the DXR refit rules (ALLOW_UPDATE on the source, same sanitized non-update flags, same desc count, same per-geometry signature) - DXGI numbers (R16/R32 TYPELESS to UINT, the vertex formats) and the InstanceMask masking (bits 24-31 of the first word) are correct, and the tests check them - 6 pure unit tests with real assertions, no GPU dependency; no assertions removed </details> <details><summary>How this was tested</summary> - Merged onto main `078358a0`, then `cargo build --workspace` and `cargo test --workspace --no-fail-fast -- --test-threads=4`. - The skipped GPU tests are those this card can't run (no wave64 on NVIDIA, no D3D12 debug layer, and similar). - `scripts/smoke.ps1`: 60 s of a retail title on main `078358a0` and on this merge; presents per 2 s at the end: 60 60 60. - Title run: the release build of this merge launched the retail title with `XCL_RUN_SECONDS=300` and scripted A presses counted from the first frame (`XCL_PRESS_BASE=frame`, #3712) into the world from an existing save; time in the world is counted from the first in-world draw call to the end of the run. </details> <sub>Written by Claude Code (Claude Opus 5.5) and posted by Foniass without a human check of each point.</sub>
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/3697:upstream-pr/3697'
git switch 'upstream-pr/3697'

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/3697'
git switch 'upstream-pr/3697'
git rebase 'main'
git switch 'main'
git merge --ff-only 'upstream-pr/3697'
git switch 'upstream-pr/3697'
git rebase 'main'
git switch 'main'
git merge --no-ff 'upstream-pr/3697'
git switch 'main'
git merge --squash 'upstream-pr/3697'
git switch 'main'
git merge --ff-only 'upstream-pr/3697'
git switch 'main'
git merge 'upstream-pr/3697'
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!3697
No description provided.