Skip to content

D3D12.X & GPU: raytracing SRVs, 64-bit multi-window BVH traversal, and title-list BVH builder slots - #26

Merged
ivall merged 1 commit into
xcl-dev:mainfrom
raylitebull:raytracing-dxr
Nov 22, 2026
Merged

ivall merged 1 commit into
xcl-dev:mainfrom
raylitebull:raytracing-dxr

Conversation

@raylitebull

@raylitebull raylitebull commented Nov 22, 2026 •

Copy link
Copy Markdown
Member

Summary

Improves inline raytracing / BVH readiness on default title command lists and multi-window UMA without guessing unverified DXR 1.0 console vtable slots:

  • Acceleration-structure SRVs in console descriptor heaps (gpu/desc.rs, hle/d3d12x/real.rs, console_heap.rs):
    • Added desc::bvh_words(address, box_sort) to encode the 4-dword RDNA2 BVH SRSRC (w[3] >> 28 < 8 so CopyDescriptors leaves it verbatim instead of renumbering it as a T# image).
    • Updated dev_create_srv_x to handle D3D12_SRV_DIMENSION_RAYTRACING_ACCELERATION_STRUCTURE (pResource == NULL, Location == console VA) directly rather than forwarding a console VA to PC and zeroing the console slot.
  • 64-bit multi-window image_bvh64_intersect_ray & AABB edge cases (gpu/recomp/emit.rs, gpu/bvh.rs):
    • Updated image_bvh64_intersect_ray to use both vaddr[0] and vaddr[1] with the 48-bit BVH base address when selecting the UMA memory window ((uint)(addr >> 32)), so BVH nodes in windows 1-3 (including sparse title memory) resolve cleanly.
    • Fixed axis-aligned grazing rays (o == mn / o == mx with d == 0, inv == ±inf causing 0 * inf = NaN) and rejected NaN-disabled / inverted (mn > mx) child boxes in both HLSL bvh_intersect and CPU bvh::intersect_node.
    • Added bvh::prebuild_size (matching XboxBvhBuilder.dll) and bvh::is_compressed_header.
  • Default title command list slots for XboxBvhBuilder.dll (hle/d3d12x/real.rs, bind.rs, list_x.rs):
    • Wired command list slots #146 (global UAV barrier) and #148 (AllocateUploadMemory in UMA, freed on allocator reset) into default title_list command lists, and sized extended vtables to cover the highest slot in console_slots / console_remap.
  • Configurable CheckFeatureSupport(D3D12_OPTIONS5) reporting (config.rs, real.rs, null.rs):
    • Added raytracing config option (auto, tier1_1, tier1_0, off; XCL_RAYTRACING overrides) and one-time logging of the reported RaytracingTier.

Testing

  • cargo test --workspace -- --test-threads=4: all unit, GPU recompiler, and xcl_testtitle e2e checks pass.
  • Added unit tests for desc::bvh_words, console-heap BVH descriptor copies, bvh::prebuild_size / is_compressed_header, grazing rays & NaN/inverted boxes, and parse_raytracing_tier.
  • Added GPU test gpu_bvh64_intersect_ray_across_memory_windows_and_grazing (2 UMA windows above 4 GiB).
  • Added testtitle e2e check gpu::raytracing_surface covering OPTIONS5 (12 B and 16 B probes), RAYTRACING_ACCELERATION_STRUCTURE SRV descriptor output, and #148 / #146 on a default title list.

…d title-list BVH builder slots

- Encode RDNA2 BVH descriptors (desc::bvh_words) for RAYTRACING_ACCELERATION_STRUCTURE SRVs in console descriptor heaps instead of zeroing the slot when pResource is NULL, and preserve them across descriptor copies.
- Fix image_bvh64_intersect_ray to use the full 64-bit node pointer (including vaddr[1]) and 48-bit BVH base address when selecting UMA memory windows, so BVH nodes above 4 GiB (including sparse title windows) resolve cleanly.
- Fix axis-aligned grazing rays (0 * inf = NaN) and reject NaN/inverted child boxes in both HLSL bvh_intersect and CPU bvh::intersect_node; add console prebuild_size and compressed-header helpers.
- Wire XboxBvhBuilder.dll command list slots xcl-dev#146 (global UAV barrier) and xcl-dev#148 (AllocateUploadMemory in UMA) into default title command lists (and size extended vtables to cover all console slots).
- Add configurable CheckFeatureSupport(D3D12_OPTIONS5) RaytracingTier reporting (config.raytracing / XCL_RAYTRACING: auto, tier1_1, tier1_0, off) with one-time tier logging in real and null backends.
- Add unit, multi-window GPU, and testtitle end-to-end tests.
@ivall
ivall merged commit e7e0dd0 into xcl-dev:main Nov 22, 2026
gbuyssens added a commit to gbuyssens/xcl that referenced this pull request Nov 23, 2026
…ts, what pointers point at

The thunk hands the tracer its frame (the saved rcx / rdx / r8 / r9, the caller's stack): a
method a title calls with a layout XCL does not expect (a 2026 title crashes inside
GetCustomHeapProperties, xcl-dev#26) is then readable from the log.
gbuyssens added a commit to gbuyssens/xcl that referenced this pull request Nov 23, 2026
…sult pointer in rcx, the device in rdx)

A 2026 title calls device slot xcl-dev#26 with the hidden result pointer first and the device second;
D3D12 took the stack for this and faulted. Both argument orders are answered with the device's
properties.
gbuyssens added a commit to gbuyssens/xcl that referenced this pull request Nov 23, 2026
…ts, what pointers point at

The thunk hands the tracer its frame (the saved rcx / rdx / r8 / r9, the caller's stack): a
method a title calls with a layout XCL does not expect (a 2026 title crashes inside
GetCustomHeapProperties, xcl-dev#26) is then readable from the log.
gbuyssens added a commit to gbuyssens/xcl that referenced this pull request Nov 23, 2026
…sult pointer in rcx, the device in rdx)

A 2026 title calls device slot xcl-dev#26 with the hidden result pointer first and the device second;
D3D12 took the stack for this and faulted. Both argument orders are answered with the device's
properties.
gbuyssens added a commit to gbuyssens/xcl that referenced this pull request Nov 23, 2026
…ts, what pointers point at

The thunk hands the tracer its frame (the saved rcx / rdx / r8 / r9, the caller's stack): a
method a title calls with a layout XCL does not expect (a 2026 title crashes inside
GetCustomHeapProperties, xcl-dev#26) is then readable from the log.
gbuyssens added a commit to gbuyssens/xcl that referenced this pull request Nov 23, 2026
…sult pointer in rcx, the device in rdx)

A 2026 title calls device slot xcl-dev#26 with the hidden result pointer first and the device second;
D3D12 took the stack for this and faulted. Both argument orders are answered with the device's
properties.
gbuyssens added a commit to gbuyssens/xcl that referenced this pull request Nov 23, 2026
…ts, what pointers point at

The thunk hands the tracer its frame (the saved rcx / rdx / r8 / r9, the caller's stack): a
method a title calls with a layout XCL does not expect (a 2026 title crashes inside
GetCustomHeapProperties, xcl-dev#26) is then readable from the log.
gbuyssens added a commit to gbuyssens/xcl that referenced this pull request Nov 23, 2026
…ts, what pointers point at

The thunk hands the tracer its frame (the saved rcx / rdx / r8 / r9, the caller's stack): a
method a title calls with a layout XCL does not expect (a title crashes inside
GetCustomHeapProperties, xcl-dev#26) is then readable from the log.
gbuyssens added a commit to gbuyssens/xcl that referenced this pull request Nov 23, 2026
…ts, what pointers point at

The thunk hands the tracer its frame (the saved rcx / rdx / r8 / r9, the caller's stack): a
method a title calls with a layout XCL does not expect (a 2026 title crashes inside
GetCustomHeapProperties, xcl-dev#26) is then readable from the log.
CalvyPZ pushed a commit to CalvyPZ/xcl that referenced this pull request Nov 24, 2026
Add standalone host-driver parity and contract tests for D3D12.X's
memory-layout and copy-footprint query hooks (Part of xcl-dev#480):
GetResourceAllocationInfo (xcl-dev#25), GetResourceAllocationInfo2 (console
xcl-dev#108 vs PC ID3D12Device8 xcl-dev#68), GetCustomHeapProperties (xcl-dev#26), and
GetCopyableFootprints (xcl-dev#38).

No runtime files outside crates/xcl/tests/ are modified. Full suite
(.\scripts\test.ps1) passed 895 passed, 0 failed, 42 ignored (1 GPU
test skipped: heap_window_out_of_memory_falls_back_to_the_switch_form).

Part of xcl-dev#480
Assisted-by: Antigravity
raylitebull pushed a commit that referenced this pull request Nov 25, 2026
…irst or second

A retail title calls the device's struct-returning methods the C way
(return buffer, then the object). The null device took the second
argument for the buffer in all seven of its such methods, so the title's
first call of device #26 (GetCustomHeapProperties) wrote the 20 bytes of
its result over the device object, vtable pointer first, and the second
call jumped through it: `unhandled exception 0xc0000005 in 0x0 (execute
at address 0x0)` in the same millisecond as "creating a FALLBACK DEVICE".
That is what a run ends in when no D3D12 device can be created, or with
`graphics = "null"`.

The seven methods now find the object as the argument whose first word
is one of the null device's own vtables, as `real::this_first` does for
the real backend.

`struct_returning_methods_take_the_buffer_first_or_second` failed before
(the device came back in place of the buffer). The title with
`graphics = "null"`: before, the fault above at 1.2 s; after, both calls
return and it goes on to device #48 and #73, which the null device does
not implement, and stops there.

Co-Authored-By: Claude Fable 5.2 <[email protected]>
IvyNotFound pushed a commit to IvyNotFound/xcl that referenced this pull request Nov 25, 2026
…rceBarrier

Console command list slot xcl-dev#146 is ID3D12GraphicsCommandList7::Barrier(NumBarrierGroups, pBarrierGroups) on both older and newer layouts; previously it emitted only a wildcard UAV barrier, dropping every texture layout transition.

- Parse D3D12_BARRIER_GROUP (GLOBAL, TEXTURE, BUFFER) safely with readable() checks; unparseable calls fall back to the legacy global UAV barrier.
- Map D3D12_BARRIER_LAYOUT 0..=31 including 0x1F (DIRECT_QUEUE_GENERIC_READ_COMPUTE_QUEUE_ACCESSIBLE) and fall back to access bits for console-only layouts > 0x1F; align device xcl-dev#127/xcl-dev#133 initial layout states with texture-vs-buffer awareness.
- Track whole-resource states across xcl-dev#127/xcl-dev#133 creation, legacy xcl-dev#26, and enhanced xcl-dev#146 (cleared on res_release) for UNDEFINED Before layouts, forward emitted transitions to title_textures::note_transitions, emit wildcard aliasing barriers for UNDEFINED placed textures, keep non-UAV textures out of UNORDERED_ACCESS, and skip states disallowed on compute/copy lists.
theaustinayers added a commit to theaustinayers/xcl that referenced this pull request Nov 25, 2026
… it with

Review of d4624b7: the PC heap behind a shader-visible console sampler heap
now holds 2 048 samplers, and descriptor heap xcl-dev#8 GetDesc was not hooked, so a
title asking its 128-slot sampler heap for its description read 2 048. A title
that sizes an allocator or a loop from that count makes samplers or copies at
console handles past its 128 16-byte slots: console_heap::slot finds none
there, dev_create_sampler_x hands the handle to the PC CreateSampler as it is,
and the driver writes a sampler descriptor at that address in the title's
memory. A view heap already read twice its slots, and one whose views are in
the shared heap read no shader-visible flag. Whether the retail title calls
GetDesc on these heaps was not checked (no trace taken).

Device xcl-dev#14 now keeps the description each console CBV/SRV/UAV and sampler heap
was made with (the title's type, 4 included, count, flags and node mask) until
the heap's last Release, and xcl-dev#8 answers it to calls from the title's images,
returned through the hidden pointer called the C++ way or the C way
(this_first, as device xcl-dev#25 / xcl-dev#26). Other heaps, and every call from XCL itself
(the split slot: list_x::pc_heaps reads the PC flags), get the PC
description as before.

New test a_console_heap_describes_itself_as_the_title_made_it, on a WARP device
adopted as a title's: a shader-visible sampler heap of 128 made through device
xcl-dev#14 answers [1, 128, 1, 0] both ways while XCL's own GetDesc says 2 048; a view
heap answers the PC description until it is known as a console heap of type 4
and 64 slots, then that; both are forgotten when released; xcl-dev#8 is in the
descriptor heap's console slots. Checked that it fails with the hook answering
the PC description ("the sampler heap": [1, 2048, 1, 1]). The view heap's
recording at creation is not covered (making a view heap through xcl-dev#14 makes the
process-wide shared heap).

Tested on the software adapter only (WARP). Not run on the hardware GPU or on a
title.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
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.

2 participants