d3d12: hardware ray tracing on DXR 1.1 (LEONIDA_HW_RT, off: a trial) - carry of #2972 #3058
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/3058"
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 ubiquitarianism/leonida. Originally posted by OreoFR on 2026-12-02T06:39:24Z.
Carry of #2972 (Callimann8's hardware ray tracing). Claimed as
D3D12-HW-RT-CARRY: https://github.com/ProjectLeonida/mandy/issues/2570#issuecomment-7336497942The #2972 head
923a4e98f2711683061f88001172e24cddea1c6ewith main merged in (mergedaf7242f2). Every commit is Callimann8's, with the credits listed below. The only conflicts were the launcher switch lists inscripts/play-d3d12.ps1andd3d12/scripts/play-nvidia.ps1, where #2986 had added-PrecompileAll; both switches are kept. Nothing else was changed.In-game result
RTX 4070 Laptop 8 GB, driver 621.40, Windows 11. Series S, no DLSS, no frame generation, the same warm data. Walk 330 s (lift at 340 s).
-RayTracing(main, software traversal)-HardwareRT(this PR)LEONIDA_HW_RT), so nothing changes for anyone who does not turn it on.Not done yet
AI-assisted (oreofr-agent for OreoFR, Claude).
The original description of #2972 (Callimann8)
Claimed in the coordination issue as: claiming: D3D12 runtime: hardware ray tracing (DXR 1.1, LEONIDA_HW_RT)
What and why
Hardware ray tracing for the D3D12 runtime (
d3d12/), off by default, a trial:LEONIDA_HW_RT=1(
-HardwareRTof the play scripts, a launcher checkbox, the F1 menu's HARDWARE RAY TRACING (TRIAL)), in place of-RayTracing/LEONIDA_BVH_BUILDER=1.With
-RayTracingthe title's own structure builder and its software traversal run as translated shaders, which isslow (6 frames a second on the test PC below). With this, the title's rays run on the card's ray-tracing hardware
(DXR 1.1 inline ray queries).
It is a port of trustno1-coder/VIctory-NVIDIA's hardware ray tracing (its #3706; from
Leslie-d-a/VIctory-NVIDIA-HWRT 61e389e0 and 5f55bca8, original by dakisback2 ecc49d5b and 72f8316a; GPL-3.0, as this
repository), fitted to this tree, which had diverged from VIctory-NVIDIA since
bafb0e25b:leonida-shader:emit/rayquery.rslifts the traversal loops of the trace programs toRayQuery, wired intothis tree's
lower.rs(the plan, the handles, TLAS root SRVst230..t241, the analyses that leave the liftedloops out). Written for this tree: a program in the paired form is not lifted; with
LEONIDA_HW_RT=1the nodetest of a loop that is not lifted misses every node (
emit/intersect.rsbvh_miss), since the consolestructures are never written then.
leonida-gpu:hwrt.rsbuilds host bottom and top levels from the title'sXboxBvhBuildercalls. Writtenfor this tree:
list::external(work of ours at its place in a title list, with aLEONIDA_THINop), the TLASviews in the descriptor heaps,
Deferred::held, the ray queries in the shader cache's entries, the counters inthe frame log.
dxr.rscomes with it for the recordshwrt.rsuses; itsLEONIDA_BVH_SIZE_ANSWERwrappers arenot bound here.
leonida-hle:modules/xboxbvh.rsreplaces the exports of the title'sXboxBvhBuilder.dllwhen the switchis on (export names only; no title bytes).
builder; the play script leaves DLSS frame generation off, as with
-RayTracing.Here that stretched and flickered textures and cost 30 to 45 ms a frame, so it is opt-in
(
LEONIDA_HW_RT_COPY_BACK=1) andLEONIDA_WC_NO_BACKstays as the play script sets it.d3d12/docs/fork-ray-tracing.md(new section),README.md(-HardwareRT),d3d12/docs/switches.mdregenerated.
Nothing changes with the switch off, except that shader cache entries can carry a ray-query record (none for a
program without one, so existing entries read as before).
Tested
cargo build --workspace --all-targets --locked,cargo build -p leonida --features diagnostics,mimalloc --locked,cargo test --workspace --exclude xtask --locked -- --skip depth_bounds_pipeline_loads_and_filters_draws,cargo test -p leonida-gpu --features diagnostics --test replay --locked: TEST_RESULTemit::rayquery_tests(the lifted form validates and makes a pipeline on WARP; the fallback misseswith the switch on;
LEONIDA_HW_RT_LIFT=0),shader_cache(a program's ray queries come back, one without themreads as before).
the_local_shader_cache_lifts_its_ray_queriesover one localknown-shaders.bin(counts only): 64 ray-tracing programs, 56 wholly lifted, 6 partly (
bvh32: unrecognized live-out value), 2 thatdo not translate without this either, none lifted that does not validate; loops 76 of 76 (64-bit nodes) and 299
of 315 (32-bit).
python -I tests/test_leonida_launcher.py,python -I tests/test_d3d12_switches.py,python -I scripts/check_no_game_data.py <changed files>: pass.own lines): 22 to 25 frames a second with hardware ray tracing, 14 of 14 ray-tracing programs in use wholly
lifted, about 4,900 bottom levels and 5 top levels alive; the same save with
-RayTracing6 frames a second(104 to 118 ms of the card a frame). The picture was judged by eye only ("texture problems are gone" after the
copy-back change); it was not compared with the builder's picture frame by frame.
in use of a budget of 10,793 MB, 1,095 MB of it bottom levels; the PC had 125 MB left to commit). The Series X
profile fills this 12 GB card without the structures too. The bottom levels' budget is a tenth of the card's.
LEONIDA_HW_RT_COPY_BACK=1afterthe change.
GPUs tested: NVIDIA GeForce RTX 4070 (12 GB), driver 621.40, Windows 11
AI-assisted: yes (ported and written by Claude at the requester's direction; the requester ran the game)
Checklist
mainand merges cleanly (a conflicting pull request is labeledneeds rebase).docs/design.md, with how it was confirmed. (n/a: no ruleof the Python translator changes; this is the D3D12 runtime's own translator.)
🤖 Generated with Claude Code
Imported from ubiquitarianism/leonida. Originally posted by OreoFR on 2026-12-02T06:53:59Z.
Merging (oreofr-agent, with OreoFR's written OK as maintainer): head
43af833d195edf1e6987ae5582c3913a31e55b28, CI green including d3d12 (windows-latest); merges cleanly into mainf37c4a87d. Off by default (LEONIDA_HW_RT). Measured on the RTX 4070 Laptop atdaf7242f2(this head minus #2756 and the regenerated switches page): 21.6 fps with-HardwareRTagainst 2.3 fps with-RayTracing, 0 device lost.