D3D12.X: hw_rt registry and DXR geometry translation #3697
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/3697"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
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-inXCL_HW_RT=1shadow command-list builder andXboxBvhBuilderhooks). Part of #1751.Stacked on #3662 (includes its commit
4082300baonmain5eaadb54c; the new diff on top of#3662is commitf783a5f53).Related: #2184/#2185 implement an earlier shadow-builder design; this PR isolates the pure registry and translation layer with DXR 1.1
PERFORM_UPDATEgeometry-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 dynamicXCL_RAYTRACING=0gating.(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.mdrequires new code to ship with its tests. The D3D12 command-list shadow builder, buffer pools, retirement plumbing, andXboxBvhBuilderhooks 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:Registrykeyed 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 fromcomplete_tlases().GeomSigandRegistry::can_update: verifiesALLOW_UPDATE, matching sanitized non-update build flags, matching desc count, and matching per-geometry flags, vertex/index formats & counts, and transform presence before permitting aPERFORM_UPDATErefit.translate_triangle_geometry/translate_blas_geometries,canonical_dxr_index_format,sanitize_build_flags, andRegistry::rewrite_instance_descs_with_refs(masking unresolved/rehydrated instances cleanly withAccelerationStructure = 0,InstanceMask = 0).parse_enabled/enabled_with/enabledcombining opt-inXCL_HW_RT=1withconfig().raytracing_tier_override() != Some(0).can_updaterejection cases, BLAS relocation/invalidation staleness, hybrid TLAS rewriting, and flag sanitization.Tested
rustc 1.99.0 (b940084d7 2026-09-28), DXC1.9.2609.5 (01b62ad47).cargo build --release -p xcl(commitf783a5f53f05e6caec11488cc5be73e42d371be6): succeeded, 39 warnings (0 new vsmain)..\scripts\test.ps1at the top of this stack (1f287a928352ac71dcb238a3a5d3d4dd4741c3e0, containingf783a5f53): 3006 passed, 0 failed, 52 ignored across 43 test suites (including allhle::d3d12x::hw_rttests; prior standalone run onb1bd0a442before restacking on updated #3662 was 2991 passed, 0 failed, 52 ignored).no wave64(RTX 5070 Ti is wave32-only), 2no heap windows(XCL_HEAP_WINDOWSopt-in off by default).Regression run
Not tested
hw_rt(nothing calls this module yet; the shadow builder, WARP DXR 1.1 tests, and liveXCL_HW_RT=1title run are in the stacked follow-up PR).AI use
Claude Opus 5.5): audited the registry invariants (referencing-TLAS staleness,GeomSigrefit rules, dead-code trims, and PR split) and reviewed the final diff and PR description.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.Imported from ivall/xcl. Originally posted by saintwolf on 2026-12-02T15:38:03Z.
merge-check claim
head:
b1bd0a4426Imported from ivall/xcl. Originally posted by saintwolf on 2026-12-02T15:42:18Z.
merge-check
base:
5eaadb54c1head:
b1bd0a4426merge: clean (fast-forward of #3662's
a65c38b16plus this PR'sb1bd0a442onto 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
5eaadb54is 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
Imported from ivall/xcl. Originally posted by saintwolf on 2026-12-02T15:42:22Z.
merge-check
base:
5eaadb54c1head:
b1bd0a4426merge: clean (fast-forward of #3662's
a65c38b16plus this PR'sb1bd0a442onto 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
5eaadb54is 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
Imported from ivall/xcl. Originally posted by Foniass on 2026-12-03T00:57:05Z.
merge-check
base:
078358a058head:
f783a5f53fmerge: 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 descriptionis red; otherwise no blocking finding, the suite passes and the smoke run is cleanhardware / 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
f783a5f53is 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
Checked and fine
4082300bais #3662's head commit itself (same SHA), so nothing would land twice; #3662's own review findings are handled thereHow this was tested
078358a0, thencargo build --workspaceandcargo test --workspace --no-fail-fast -- --test-threads=4.scripts/smoke.ps1: 60 s of a retail title on main078358a0and on this merge; presents per 2 s at the end: 60 60 60.XCL_RUN_SECONDS=300and 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.
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: everypull_request_targetworkflow onxcl-dev/xcl(PR checks,Auto triage,Testing feed,Discord mirror) has been returningstartup_failurerepo-wide since ~22:47 UTC on 2026-12-02, so thePR descriptionjob never started onf783a5f53(runs46994360164and46996524481). Runningmain'sscripts/pr_check.pylocally against PR #3697's current description and file list forf783a5f53passes (description ok), andBuild and test (Windows, no GPU)is green (46996521079). Oncepull_request_targetrecovers, I'll retriggerPR checksvia a no-op description edit without changingf783a5f53.Good catches on both nits too:
upsert_native(resource = Nonewith mismatched kind or smaller size): agreed it is worth guarding (debug_assertor 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
f783a5f53untouched for now so this check and the stacked PRs (#3700/#3704/#3705) stay aligned; happy to fold both nits in if#3697needs another push or in a small follow-up.Imported from ivall/xcl. Originally posted by Foniass on 2026-12-03T15:31:45Z.
merge-check
base:
078358a058head:
f783a5f53fmerge: 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
f783a5f53is 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
Checked and fine
4082300bais #3662's head commit itself (same SHA), so nothing would land twice; #3662's own review findings are handled thereHow this was tested
078358a0, thencargo build --workspaceandcargo test --workspace --no-fail-fast -- --test-threads=4.scripts/smoke.ps1: 60 s of a retail title on main078358a0and on this merge; presents per 2 s at the end: 60 60 60.XCL_RUN_SECONDS=300and 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.
View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.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.