Skip to content

d3d12_xs: the list proxy translates title-owned CPU descriptor handles (RT-LIST-HANDLES) - #416

Merged
aslan2142 merged 28 commits into
ProjectLeonida:mainfrom
Mumogg:list-descriptor-handles
Nov 25, 2026
Merged

aslan2142 merged 28 commits into
ProjectLeonida:mainfrom
Mumogg:list-descriptor-handles

Conversation

@Mumogg

@Mumogg Mumogg commented Nov 24, 2026

Copy link
Copy Markdown
Contributor

Claimed in #14 as RT-LIST-HANDLES. Depends on: the stack up to #414 (their commits come first here; this pull request is the last commit). The code needs #375 (the title's descriptor range and translate_cpu_handle); the rest of the dependency is the measurement.

What and why

Since #375 the device slots 17 to 24 translate a CPU descriptor handle in the title's own range (__XMemAllocationHooks__) to the real heap's. The five command-list methods that take such handles did not. Console list slots 50 (OMSetRenderTargets), 51 (ClearDepthStencilView), 52 (ClearRenderTargetView), 53 and 54 (the two ClearUnorderedAccessView) reached the real list with the title's address, which is no descriptor there.

On the retail boot that shows as soon as the title records its first frame: a ClearRenderTargetView with a title-owned handle, and then ID3D12GraphicsCommandList::Close failed.

They translate now, in copies: the caller's arrays are not written, and a handle outside the range is passed as it is. Slot 51 gets a typed thunk, because its depth is a FLOAT in XMM3, which the all-integer list thunk loses.

Written by me as a port: this is 0aba6c361 (LeonidaBringup), which sits on old PR 2490's list proxy and does not apply to main's. The commit message credits it.

Measured

Linux (Nobara 44, kernel 7.3), Wine 11.21 staging, RTX 5070 Ti (driver 615.78.08), clang-cl 22.1.8 + xwin SDK 10.0.26100, own 1.0.2.1 copy, network off, on main ece4ba5b3, with #142, #219, #328 and #387 applied on top for the boot runs (they are not in this branch).

--run Failed calls in the trace ExecuteCommandLists ok Close ok
up to #414 ID3D12GraphicsCommandList::Close: 1 3 585
+ this none 5 586

With it the trace of this path has no failed call at all, two more submissions go through, and in one of two runs the title's first PresentX succeeds (see #414 for the other run).

Every run now ends on the same thing: an int3 of the title on a worker thread, which tools/int3_cause.py reads as a check that a word of one of the title's objects is zero. That is the next stop and I do not know its cause yet.

xs_proxy_mock_test under Wine passes, with the new cases on a device whose heap has a title-owned range: slots 52, 53 and 54 with a handle inside the range and one outside it; slot 50 with two render-target handles (one inside, one outside) and a depth handle, checking what the real list receives and that the caller's arrays are unchanged; slot 51 through its typed thunk. The mock's integer prototype cannot see slot 51's float, so that the depth survives is not tested here.

Not built with MSVC and not run on Windows.

AI-assisted (Claude Code); built and run on the machine above.

🤖 Generated with Claude Code

https://claude.ai/code/session_01HxBQf4pXH8PWpC5oZsM4bt

Khuraie and others added 24 commits November 24, 2026 03:47
…(RT-5 stop 17)

The retail title asserts when its first full-screen render targets leave more than 2 MiB of a fixed budget unused (docs/retail_boot_chain.md, #6982). The PC size is about width x height x element bytes; the console takes whole RDNA2 SW_64KB tiles. Slot 25 adds the difference per render target description and never lowers a size. Depends on #6973.

(cherry picked from commit 8897855)
…ons (RT-5 stop 16)

The title's descriptions carry the Xbox layout word and flag bits above the PC ones. Slot 25 now passes a copy with PC flags and a PC layout; the title's array is not written. Depends on #7078.

(cherry picked from commit c7ca0f2)
…t, slot 56 offsets, full mip chains, rounded-up mip extents, B5G5R5A1, saturating sums

(cherry picked from commit 3593908)
…em hooks (RT-5 stop 17)

On the console a committed resource's memory is allocated with XMemAlloc, so it goes
through the title's __XMemAllocationHooks__. The retail title budgets its first
full-screen render targets with a per-thread hook that bump-allocates out of a range it
reserved and asserts that less than 2 MiB is left; PC resources never allocated through
the hooks, so the assert always fired. Slots 76 and 127 now allocate the slot-25 size of
each resource through the hooks, held by the resource with SetPrivateDataInterface and
freed when it is destroyed.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
(cherry picked from commit ae322da)

Adapted to main by Mumogg: the lease size is the later form of this series (d61755d, a render target's console
tile size, else the PC size), since console_render_target_extra is gone after 3593908.
…g-cl rejects 0x101 for the unfixed enum)

Reported by YaBulochka and sovljanskii on #7154; #7110's current head has the same form.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
(cherry picked from commit bee4718)
…console-form calls only

With the console tile sizes applied to every caller, a PC-form call through the proxy no longer answered what the
PC device answers, and the code that compares the two failed on Windows: device_proxy_test's two slot 25 checks
and d3d12_vulkan_device_test's allocation_mismatches (reported on ProjectLeonida#375 from MSVC builds on AMD and NVIDIA, the
first bad commit being the one that cleans the descriptions). Together with b4d1ba1, which scopes the cleaning
the same way, a PC-form caller now gets the PC device's own answer for its own description; the title's call,
which comes in the console form, gets the cleaned description and the console sizes as before.

xs_proxy_mock_test: the PC-form slot 25 case expects the mock device's size (it expected the console size), and
the mixed slot 56 case is asked in the console form. device_proxy_test includes d3d12_xs_desc_clean.h for the
cleaned description b4d1ba1's check compares with.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01HxBQf4pXH8PWpC5oZsM4bt
…ole-extended heap

A heap that main's console-extended handler created already sits at the address the title named, so
proxy_create_descriptor_heap asks the title's XMem hooks for a backing address only when the heap came from a
plain PC description (follow-up asked for in review on ProjectLeonida#375).

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01HxBQf4pXH8PWpC5oZsM4bt
…TCH (slot 41)

The retail title creates five one-argument command signatures with no root
signature at startup (device slot 41, CreateCommandSignature at its PC
position). One has the console argument type 105 and a 12-byte stride, next
to a DISPATCH and a DISPATCH_MESH of 12 bytes. The PC layer refuses the
unknown type, which is stop 19 of the RT-5 boot measurements.

Read statically from the title's call sites (shapes only): the two
ExecuteIndirect sites of that signature pass MaxCommandCount 1 and an offset
into the same argument buffer as the DISPATCH sites. Right before, they set
the same compute state as the DISPATCH path (pipeline, compute root signature,
tables, constants, SRV and UAV); they record on a second command list of the
title's context. So the argument is taken as a D3D12_DISPATCH_ARGUMENTS.

Slot 41 now has its own handler. A description that holds type 105 is copied
with that type replaced by DISPATCH (logged once). Any other description is
forwarded as the same pointer. What the console does differently for type 105
is left open in docs/d3d12_vulkan.md (section 4.9).

xs_proxy_mock_test: a two-argument description (a root constant, then type
105) reaches the PC slot 41 as a copy with DISPATCH, the same stride, count,
root signature, IID and output, and the caller's description is untouched; a
PC description is passed through unchanged. With main's d3d12_xs_device.cpp
the new check fails.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
(cherry picked from commit 4c04c0f)
105 is outside D3D12_INDIRECT_ARGUMENT_TYPE's range [0, 15], so clang-cl
rejects a constant expression that casts it to the enum (reported by
umnitus on #7163). The handler now reads each argument's Type field as a
uint32_t through memcpy and compares it with 105; the test writes and reads
the raw value the same way, and the mock records it the same way.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
(cherry picked from commit 084c8c6)
…device with mesh shaders

The Vulkan layer created signatures for draw, draw-indexed and dispatch only and answered E_NOTIMPL
for DISPATCH_MESH, which the PC runtime creates on any mesh-shader tier 1 device. A title that
creates such a signature at startup and asserts on the result stopped there.

The signature is created when the device has VK_EXT_mesh_shader (MeshShaderTier 1), as a new
IndirectKind::dispatch_mesh (the name and value #3777 uses, so the two merge). ExecuteIndirect with
it records nothing yet and says so once; #3777 replays it as vkCmdDrawMeshTasksIndirectEXT.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
(cherry picked from commit efc3478)
…H has a record size and returns after it

Resolving the cherry-pick of efc3478 I dropped main's record-size, stride and span checks (e1ec785), which
d3d12_execute_indirect_validation_test depends on and which matter to every D3D12 user (found in review on
ubiquitarianism#377). They are back as on main, the record-size chain knows D3D12_DISPATCH_MESH_ARGUMENTS, and the early
return for a DISPATCH_MESH signature comes after the checks.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01HxBQf4pXH8PWpC5oZsM4bt
…ateSampler

The retail title calls device slot 61 as CreateSamplerX(desc, dest handle), once
per sampler, after its descriptor heaps exist (stop 20 of the RT-5 boot
measurements in the coordination issue). The generic thunk forwarded it to the
PC slot 61, which is CreateMetaCommand, so the sampler was never written.

Slot 61 now has its own handler, like 62 and 67. It passes the description's
PC D3D12_SAMPLER_DESC prefix and the handle to the PC CreateSampler (slot 22).
That was enough to get the title past this call under Wine. Whatever follows
the prefix in the console description is not known and is not read. A null
description is skipped and logged once. A handle in the title's own heap range
is #7021's translation.

xs_proxy_mock_test: slot 61 reaches the mock's slot 22 with the same two words
and never its slot 61; a null description reaches nothing. With main's
d3d12_xs_device.cpp the new check fails.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
(cherry picked from commit e229944)
…t caller gets PC CreateMetaCommand

The proxy also serves host callers: d3d12_vulkan_device_test drives the Vulkan device through it,
and its ID3D12Device5::CreateMetaCommand call (PC slot 61) landed in proxy_create_sampler_x
(found by nullmarsh on #7115: the test stopped at line 5763 instead of main's known line 6574).

Slot 61 now checks the caller's return address with a classifier the runtime installs
(set_console_caller, the name #7490 uses): D3D12XboxCreateDevice installs
rt::shims::mapped_image_base, so only a caller in an image the guest loader mapped gets
CreateSamplerX. Any other caller, and every caller when no classifier is installed, is forwarded
to the PC slot 61.

xs_proxy_mock_test checks all three cases: no classifier (PC slot 61), a guest caller (PC
CreateSampler with the same words; a null description skipped) and a host caller under an
installed classifier (PC slot 61). d3d12_vulkan_device_test again stops at line 6574, as on main.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
(cherry picked from commit 8f756ebe048af042638ce51a61490f35f4f44ee3)
(cherry picked from commit c915e1d)
…riptor range

Slot 61 passed the destination handle to the PC CreateSampler as given. With the title's descriptor range
honoured (__XMemAllocationHooks__), a handle in that range has to be translated to the real heap's, as device
slots 17 to 24 do (asked for in review on ProjectLeonida#377).

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01HxBQf4pXH8PWpC5oZsM4bt
… of reaching PC ShaderCacheControl (#7231)

The retail title calls slot 74 once; the PC slot 74 reads the first pointer as kinds and returns E_INVALIDARG, so the title hits an int3. The proxy handler does not call the PC device, writes nothing, logs the three words once, and yields to an env slot override that moves a route onto 74.

(cherry picked from commit cdeee35)

Adapted to main by Mumogg: the queue route inside route_xbox_device_slot calls proxy_create_command_queue_xbox
(the 32-byte description of 0cde63d), as the inline route did before this commit moved the routes into a
function.
…gets PC ShaderCacheControl

The stand-in also took a host's ID3D12Device9::ShaderCacheControl call through the proxy and answered S_OK
without reaching the device (found on native Windows by BadgersMC in the review of this change). Slot 74 now
asks the caller classifier slot 61 uses (set_console_caller): a caller in an image the guest loader mapped gets
the stand-in, any other caller, and every caller when no classifier is installed, is forwarded to the PC slot 74
or refused past the PC device's table.

xs_proxy_mock_test: the guest case under a classifier, and the host case with a classifier and with none, on a
device that has ShaderCacheControl and on one that does not.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01HxBQf4pXH8PWpC5oZsM4bt
Asked for in review on ProjectLeonida#377.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01HxBQf4pXH8PWpC5oZsM4bt
(cherry picked from commit e925b63)

Adapted to main by Mumogg: main has command-list proxies, so the shared execute function replaces them by their
real lists in a copy of the array (UnwrappedArray), for the console slot 35 as for the PC slot 10, whose test
failed otherwise. The slot 35 mock case passes two mock lists instead of two numbers and checks that they arrive
and that the caller's array is not written.
…ow in the Xbox-only table

Asked for in review on ProjectLeonida#377.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01HxBQf4pXH8PWpC5oZsM4bt
The retail title resets its command lists through list slot 139, with (allocator proxy, pipeline state). main's
slot map had no entry for it, so the call was recorded and dropped and the list stayed closed. The map sends it
to the PC slot 10, and the unwrap keys on the PC slot, so console slot 10 and console slot 139 both hand the real
list its real allocator (and a wrapped pipeline state the same way) and re-pin the inline cursor.

The mapping and the unwrap rule are those of ef9d075 (Nolan Cotter; measured by Pipodi), written again for
main's list proxy, where that commit does not apply. xs_proxy_mock_test checks the map entry and a slot 139 call.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01HxBQf4pXH8PWpC5oZsM4bt
…etDesc

Queue slot 18 is ID3D12CommandQueue::GetDesc on the PC: a struct return that writes a 16-byte description through
the hidden pointer. The retail title calls slot 18 with one pointer to 8 bytes, the shape of
GetTimestampFrequency(UINT64*), which the console queue has there (two methods are inserted at 14/15, so the PC
slots 16 to 18 sit two later). Forwarded as GetDesc, the call wrote a description over the title's 8 bytes and
what follows them; the title then went wrong a little later, after its first submission.

The title's call (set_console_caller, as device slots 61 and 74) now goes to the PC slot 16. A host caller, and
every caller when no classifier is installed, keeps the PC GetDesc.

The reading of slot 18 is that of the console queue work in old PR 2490 (Nolan Cotter), which answers an
undetected slot 18 as the frequency getter because it is the only reading that cannot overrun its argument. That
work's layout detection does not apply to main's queue proxy; this is the one rule the boot needs, written for
it. xs_proxy_mock_test: the guest call reaches the mock queue's slot 16 with its pointer and leaves the words
around it; a host call, with a classifier and with none, reaches slot 18.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01HxBQf4pXH8PWpC5oZsM4bt
Mumogg and others added 4 commits November 24, 2026 03:52
…ntation core

The retail title presents through command-queue slot 32, past the PC queue's 19 slots, so main refused it with
E_NOTIMPL and nothing could be shown. The slot now calls XboxPresentation::PresentX (xbox_present.h) with the
title's plane count, planes and parameters. The first call on a device builds a window and the Vulkan layer's
presenter for it, once; a device that cannot present answers S_OK and shows nothing, so the title's frame loop
runs either way. The mock and COM builds of this file have no presenter and answer S_OK.

The wiring follows old PR 2490's (Nolan Cotter, 2be25ce), written again for main's queue proxy, where that
commit does not apply. Not carried over: the queue layout detection (the older layout has PresentX at slot 30)
and presenting into the title's own window (old PR 8591); the window here is one this layer creates.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01HxBQf4pXH8PWpC5oZsM4bt
…oken source

Device slot 80 (WaitFrameEventX, from #6935) numbered its tokens with a
counter of its own, while XboxPresentation's pacer refuses any token above
the ones it issued itself. A title that waits through the device and
presents through the device's XboxPresentation therefore had every
PresentX refused with E_INVALIDARG once its tokens ran ahead of the
pacer's.

leonida::FrameTokenSource is now the counter both use: a pacer takes an
optional shared source (a standalone pacer still owns its own and numbers
as before), the device proxy owns one and exposes it through
rt::d3d12_xs::device_frame_tokens, and XboxPresentation passes a given
source to its pacer. A token that was never issued is still refused.

Reported by rafaelpssz in #7496.

(cherry picked from commit afb14d5)

Adapted to main by Mumogg: main's uncapped pacer path issues its token from the shared source too, the device
proxy keeps the PresentX state next to the token source, and the queue's PresentX hands the device's source to
its XboxPresentation, which is what makes the title's tokens valid there.
The coverage gate asks for every queue slot to have been called, and skips the overridden ones in its sweep of
the refused tail. Slot 32 is overridden since the PresentX wiring, so nothing called it and the gate failed
("queue slot 32 never called"). The test now calls it where it calls the console ExecuteCommandLists slot: this
build of the proxy has no presenter, so the answer is S_OK.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01HxBQf4pXH8PWpC5oZsM4bt
…s (console list slots 50 to 54)

Device slots 17 to 24 translate a CPU descriptor handle in the title's own range (__XMemAllocationHooks__) to
the real heap's. The five command-list methods that take such handles did not: OMSetRenderTargets (console slot
50), ClearDepthStencilView (51), ClearRenderTargetView (52) and the two ClearUnorderedAccessView (53, 54) went
to the real list with the title's address, which is no descriptor there. On the retail boot the first
ClearRenderTargetView made the list's Close fail.

They translate now, in copies: the caller's arrays are not written, and a handle outside the range is passed as
it is. Slot 51 gets a typed thunk, because its depth is a FLOAT in XMM3, which the all-integer list thunk loses.

This is 0aba6c3 (LeonidaBringup) written again for main's list proxy, where that commit does not apply (it
sits on old PR 2490's list proxy). xs_proxy_mock_test: the five slots with a handle inside the range, one
outside it, and the caller's arrays unchanged.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01HxBQf4pXH8PWpC5oZsM4bt
@3L1A5-1

3L1A5-1 commented Nov 25, 2026

Copy link
Copy Markdown

Native Windows + MSVC + NVIDIA result. I rebased this PR's own commit only, since #414's three commits conflict with main (#402's presentation handler in d3d12_xs_device.cpp, as noted on #414). adc4f314b applies to main cleanly without them: 3L1A5-1/leonida@rebase/416 (56e4d2587, author kept) on main b4b7756e8.

  • ctest: 318/318 passed, 0 failed (2 gameinput disabled, no SDL3). xs_proxy_mock, xs_proxy_mock_env_slots and queue_proxy pass.
  • scripts/run_gpu_tests.py: 207 passed, 0 failed, 49 skipped. With LEONIDA_W64_EMULATE=1: 239 passed, 0 failed, 17 skipped.
  • No result differs from main on this machine.

Hardware: RTX 2060 SUPER 8 GB (Turing), driver 617.14, Windows 11 26300, 16 GB RAM, MSVC 19.44, RelWithDebInfo. Synthetic tests only, no retail run.

AI-assisted: yes

aslan2142 added a commit to Mumogg/leonida-continued that referenced this pull request Nov 25, 2026
Everything below this rung (ProjectLeonida#414, ProjectLeonida#416, ProjectLeonida#427) and the rung's own routing are in
main already, through ProjectLeonida#984 and ProjectLeonida#939, in main's form; what is left of ProjectLeonida#430 is
its test of queue slot 17, ported onto main's layout detection.

Conflicts, all resolved to main's form:
- runtime/shims/d3d12_xs_device.cpp: main's queue slot 16/17 rule (a fence
  there is the newer layout's Signal/Wait, for any caller) replaces the
  rung's caller-gated rule; main's PresentX routing (slot 30, or 32 once the
  newer layout is detected, LEONIDA_XS_PRESENT_X_SLOT) and lazily built
  presenter replace the fixed slot 32 of ProjectLeonida#414; main's list proxy already
  translates the CPU handles of console list slots 50 to 54 (ProjectLeonida#416) and
  drops unordered access from a depth-stencil texture at slot 76 (ProjectLeonida#427).
- runtime/shims/d3d12_xs_device.h, runtime/shims/xbox_present.cpp,
  runtime/shims/xbox_present.h, runtime/src/frame_pacer.h: main's shared
  FrameTokenSource (Logan's piece of ProjectLeonida#414, as ProjectLeonida#984 carried it).
- runtime/shims/d3d12_xs_desc_clean.h, runtime/test/device_proxy_test.cpp:
  main's without_depth_stencil_uav and its slot 25/76 test (ProjectLeonida#427).
- runtime/test/xs_proxy_mock_test.cpp: main's file, which already has
  check_list_cpu_handles (ProjectLeonida#416's cases and more); the rung's slot 16/17 case
  is ported to main's form at the end of check_xbox_queue_slots: slot 16 and
  17 with a fence reach PC Signal and Wait with the real fence, not the PC
  getters, and the fence proxy's vtable pointer is unchanged. The rung's
  host-caller and no-fence expectations are dropped: under main's rule a
  fence at 16 proves the newer layout, after which those calls answer S_OK.
Auto-merged, then set to main's content:
- runtime/test/queue_proxy_test.cpp: ProjectLeonida#414's call of queue slot 32 as an
  overridden slot; on main slot 32 is routed only on the newer layout and the
  sweep of the console tail already calls it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@aslan2142
aslan2142 merged commit adc4f31 into ProjectLeonida:main Nov 25, 2026
8 of 13 checks passed
@aslan2142

Copy link
Copy Markdown
Collaborator

Marked merged through #430, whose branch contains this one. The content was already in main: console list slots 50–54 translate the title's CPU handles (the port of 0aba6c361), with the typed thunk for slot 51, and check_list_cpu_handles in xs_proxy_mock_test covers these cases and more, including that the float depth survives. Thanks.

AI-assisted (Claude Code, Claude Opus 5.5).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

needs rebase Conflicts with the base branch: rebase it on main

Projects

None yet

Development

Successfully merging this pull request may close these issues.