Skip to content

d3d12_xs: list methods translate the title's CPU descriptor handles (OMSetRenderTargets, the clears; depends on #2490, #7021) - #8372

Closed
lunarminus wants to merge 10 commits into
ProjectLeonida:mainfrom
lunarminus:list-cpu-handles
Closed

lunarminus wants to merge 10 commits into
ProjectLeonida:mainfrom
lunarminus:list-cpu-handles

Conversation

@lunarminus

@lunarminus lunarminus commented Nov 23, 2026 •

Copy link
Copy Markdown

Claimed in the coordination issue as: #8186 (comment) (the command-list half of the CPU-handle translation that tupacfan04 listed as an open follow-up for #7021).

Depends on: #2490, #7021. This branch is stacked on both. Commit 1397f3ce merges them, with their conflicts resolved: the shared overridden-slot list, the includes and the mock's object kinds. Review only the last commit, ad0a688b; it rebases off once they land.

What and why

With #7021, a title's descriptor heaps sit at the title's own addresses, so its CPU descriptor handles point into its memory. Device slots 17–24 translate those handles before the PC call. The command-list methods that take CPU handles did not, so the PC list received a handle that isn't a layer view record.

On a Wine boot of my own 1.0.2.1 retail executable (Radeon 760M; the stack is in #7154):

The list proxy now translates the CPU handles of the five list methods that take them, at console list slots 50–54 (PC 46–50, the +4 shift the proxy already uses):

Console slot PC slot Method What is translated
50 46 OMSetRenderTargets the render target handles (or the single range's start) and the depth-stencil handle, in copies; the title's arrays are not written
51 47 ClearDepthStencilView the handle
52 48 ClearRenderTargetView the handle
53 / 54 49 / 50 ClearUnorderedAccessView{Uint,Float} the CPU handle (the second argument); the GPU handle is unchanged

Tested

clang-cl 23.1.5 + xwin SDK 10.0.26100 cross build (RelWithDebInfo), run under Wine 11.22 on CachyOS Linux; AMD Radeon 760M (RDNA3 iGPU), RADV Mesa 26.3.1.

  • xs_proxy_mock_test: PASS, including the new check_list_cpu_handles:
    • a heap at a title address through the heap hook;
    • ClearRenderTargetView and both UAV clears reach the mock PC list with the translated handle, and a handle outside every range passes unchanged;
    • OMSetRenderTargets with an array, then with a single range, captured with typed functions in a copy of the mock list's vtable: translated copies, and the title's array untouched;
    • ClearDepthStencilView translates its handle and keeps its depth (0.375), stencil and flags.
  • Negative control: with this commit's d3d12_xs_device.cpp reverted, the test fails at its first ClearRenderTargetView check.
  • ctest -R 'xs_proxy|queue_proxy|list_proxy|d3d12_xs': 7/7 passed. device_proxy_test needs a real D3D12 device and fails with "no device" under Wine on main too.
  • Retail boot (my own 1.0.2.1 executable, network off; full stack in Boot log for coding agents: where the executable stops and which PRs get past it #7154), two runs each:
    • before: 379–520 failed Close per run;
    • after: 0 failed Close; ClearRenderTargetView is reached 425–539 times per run.
    • The boot still ends at the same title break further on, so this isn't the stop. It removes the invalid lists in front of it.

No game data in the PR: hand-written mock inputs, counts and slot numbers only.

AI-assisted (Claude Code).

🤖 Generated with Claude Code

Khuraie and others added 9 commits November 23, 2026 23:42
The d3d12_xs shim's device now hands callers console-shaped command
lists (160-slot vtable, object body at +0x18 with the write cursor
pinned at the record limits, console slots 27-30 recorded not
forwarded, slot map measured to the PC table: 60->58, 61->59,
146->80). Queue layout detection is atomic and device-wide; SignalX
(slot 23/25 by layout) forwards as Signal, PresentX (30/32) reaches
the presentation core, and ambiguous slot 18 serves the timestamp-
frequency getter until the layout is proven.

AllocateUploadMemory (console slot 148) carves a bump arena out of
persistently-mapped UPLOAD-heap buffers; the six root-VA setters and
the IA/SO view setters translate arena pointers to buffer device
addresses in proxy-owned copies. Impossible sizes and non-power-of-
two alignments are refused before any arithmetic that could wrap.

PC-compiled callers opt into real PC-shaped lists with
console_lists=false on create_device_proxy, and PC-compiled guests
with LEONIDA_D3D12_LISTS=pc — the fixture path check_tiny_frame.py
sets, so a guest ClearRenderTargetView at PC slot 48 reaches the
real list. The GPU tests take the flag; unmeasured console slots
stay console-shaped for the title path.

docs/d3d12_xs_console_abi.md records the measured ABI.

Split from ItsNotRexed#2490 (third of three): fixes the run_tiny_frame failure
the revert reported. AI-assisted. Hardware verification on the
earlier identical code is in ItsNotRexed#2490's thread (RTX 3060 Ti-5080, RX
7600/9060/9070/7900 XT, Intel UHD, RADV; 177/177). Wine/clang-cl on
the build host: xs_proxy_mock PASS incl. the overflow regression,
queue_proxy child-runner section fails identically on unmodified
main (Wine env), loader_test 86/0 upstream count.

Generated with [Devin](https://devin.ai)

Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
test_every_variable_is_named_in_a_document fails when a code-used
environment variable is documented nowhere. The variable is described
in the command-list section where the two list layouts are defined.

Generated with [Devin](https://devin.ai)

Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Upstream's device routes Xbox slot 73, but returned the real PC list
unwrapped: the title's next console-slot call read through the PC
vtable. With console_lists the device now builds the real list as
ID3D12GraphicsCommandList and wraps it like the slot-12 path; a
console IID is answered by the list proxy's QueryInterface.
The title's first call on a wrapped list is QueryInterface with the
console command-list IID c3827890-...-51dc4874; is_list_iid knew only
PC IIDs and refused it. Port the measured console->PC IID table from
(closed, unmerged) ProjectLeonida#7124 into d3d12_xs_command_list_iid.h and run the
requested IID through it in list_query_interface and in the PC-mode
slot-73 path, so a console IID maps to ID3D12GraphicsCommandList6 and
the caller gets the console-shaped proxy back.
create_device_proxy's console_lists default was true, so every test
harness that links the TU and calls it directly got console-shaped
lists and crashed or failed Close on PC vtable indices (kormocicsaba:
d3d12_bindless_churn segfault, d3d12_mesh Close). The console shape is
the title path: D3D12XboxCreateDevice opts in (unless
LEONIDA_D3D12_LISTS=pc), and the default is now false so direct
callers keep the pre-PR behaviour. The mock test pins both: slot 12
on a console_lists=false device returns the real list.
Pipodi measured the retail title calling console list slot 139 with
(allocator proxy, pso) before recording — Reset, at PC slot 10. Map it
and unwrap the allocator (and a pipeline state the same way); the
unwrap now keys on the PC slot so console-10 and console-139 both land
on the real Reset.

xs_proxy_mock: PASS under Wine

Generated with [Devin](https://devin.ai)

Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
…his PR; the conflicts are the shared slot list, includes and mock kinds)
@skorex

skorex commented Nov 23, 2026

Copy link
Copy Markdown

Duplicate of #7880

#7880 makes the same change and was opened earlier. Topic: ListProxy CPU descriptor handle translation for console list slots 50-54 with the ClearDepthStencilView XMM3 thunk.

Suggest closing this PR in favour of #7880, and porting anything this one adds that #7880 lacks there.

…OMSetRenderTargets, the clears)

With ItsNotRexed#7021's descriptor heaps at the title's addresses, the title's CPU
handles point into its own memory. The device's view slots 17-24 translate
them; the command-list methods that take CPU handles did not, so the PC list
got a handle that is not a layer view: ClearRenderTargetView failed its check,
the list was marked invalid and Close returned E_INVALIDARG.

The list proxy now translates the CPU handles of OMSetRenderTargets (render
target array or single-range start, and the depth-stencil handle, in copies),
ClearRenderTargetView, ClearDepthStencilView and ClearUnorderedAccessView
{Uint,Float}: console list slots 50-54, PC 46-50. ClearDepthStencilView gets a
thunk with its own signature, because its FLOAT depth travels in XMM3, which
the integer forwarder cannot carry.

Measured on a Wine boot of the retail executable: the failed Closes per run
go from about 1,000 to 0.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@lunarminus

Copy link
Copy Markdown
Author

Closing as a duplicate of #7880, thanks @skorex. #7880 was opened earlier (17:42 UTC against 18:35) with a claim in #7694, and makes the same change. My claim search missed it, my mistake.

I'll test #7880 on the same retail Wine boot I measured here (Radeon 760M, RADV) and post the result there.

AI-assisted (Claude Code).

@lohant27-netizen

Copy link
Copy Markdown

Tested edd87f618 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 dfe4e4ad3 together with #8379, #8372, #8376 and #8342 (no conflicts between them): pass.

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.

5 participants