Skip to content

Runtime: console-order command-list proxy at device slots 12/51 (D3D-136, Depends on #1270) - #1325

Draft
quackottu wants to merge 4 commits into
ItsNotRexed:mainfrom
quackottu:xs-console-list-proxy
Draft

quackottu wants to merge 4 commits into
ItsNotRexed:mainfrom
quackottu:xs-console-list-proxy

Conversation

@quackottu

Copy link
Copy Markdown
Contributor

Depends on: #1270 (BUILD-231, the Xbox-ABI queue and fence proxies). This branch has #1270's head merged in. Its own changes are the two d3d12_xs list proxy commits plus the slot-10 call site in the merge commit; once #1270 lands they are all this PR shows. Don't merge it before #1270: without the queue proxy, ExecuteCommandLists would hand list proxies to the host queue and to the Vulkan layer's queue.

D3D-136: the console-order command-list proxy (docs/d3d12_command_objects.md §3.5a). Claim and interface agreed with @AimLogin in #1006 / #1218.

What changes

  • Device slots 12 CreateCommandList and 51 CreateCommandList1 wrap the PC list in a list proxy. They stay at the public slots. Neither is measured on the console, the same assumption as 8/9/36.

  • The list proxy's vtable is the measured console order:

    Console slot PC slot
    0–26 0–26 14, 15, 25, 26 are measured at their PC index, so nothing is inserted before 26; 7 GetDevice returns the device proxy
    32 28 SetDescriptorHeaps heap proxies are replaced by their PC heaps (until now a heap proxy reached the real list as it was)
    33, 35, 41, 53, 61 29, 31, 37, 49, 59 33 and 41 inferred from the argument shape
    any other, up to 160 — counted, logged once, E_NOTIMPL, no PC call
  • The console fields past the vtable. The object keeps +0x08..+0x608 free for them, with the write cursor (+0x18) equal to both limits (+0x28, +0x30). A console-compiled caller then has no room to write packets itself and calls the vtable for every command (§3.5a; fsr_dispatch_test's test proxy uses the same rule).

  • Ownership. One reference on the PC list and one on the device proxy, released when the proxy's own count reaches zero. QueryInterface answers every list interface the PC list implements with the same proxy.

  • Unwrap at execution, as agreed in Coordinating who works on what (5) (moved to #1380) #1218.

    • proxy_real_object() knows the list vtable.
    • Queue slot 10 ExecuteCommandLists passes the real queue a copy of the array with each proxy replaced by its PC list. It uses Runtime: Xbox-ABI proxies for the command queue and the fence (BUILD-231) #1270's UnwrappedArray: 16 entries inline, a longer array from new (std::nothrow), and E_OUTOFMEMORY when that fails.
    • Nothing is AddRef'd or released there.
    • The thunk keeps every argument word in its position.
  • Accessors in d3d12_xs_device.h: is_list_proxy, list_proxy_real_list (borrowed; null for a non-proxy), and list_slot_pc_slot / list_slot_hits / list_slot_first_call_seen.

  • Test helper. C++ tests that record through the PC header (d3d12_vulkan_device_test, d3d12_descriptor_test, d3d12_debug_markers_test, d3d12_copy_compare.h) now record on the PC list, via runtime/test/xs_pc_list.h. Past slot 26 the console order is not the PC one, so those calls would be refused on the proxy.

  • Docs: d3d12_vulkan.md §3.1 (the table above) and d3d12_command_objects.md §3.5a/§5.2 and the queue-proxy section.

Tests

Windows 11, RTX 5070 (driver 621.24), VS 2022 Build Tools. LEONIDA_D3D12=vulkan, LEONIDA_VK_VALIDATION=1, VK_IMPLICIT_LAYER_PATH set to an empty folder.

Check Result
Full ctest (66 tests, gameinput disabled) 66/66. loader failed once under -j 6 and passed alone (the known load flake). queue_proxy takes 682 s here.
device_proxy_test (WARP): slot 12 list proxy, QI, GetDevice, refcounts, refused slots 27/141, then a UAV clear (console 53) through a heap proxy bound at console 32, a barrier (26) and a copy (15), Close (9), executed as the list proxy on the queue proxy and read back pass
d3d12_vulkan_device_test: a copy through console slots 15/9 on the Vulkan device, executed the same way and read back pass
Negative control: slots 12/51 forwarded as on main device_proxy_test fails 3 checks
Negative control: queue slot 10 without the unwrap device_proxy_test fails the readback, and the host device is then broken for #1270's later checks

No game files, no Xbox DLLs. fsr_dispatch_test and bvh_builder_test need package DLLs and skip here; they create their lists on the PC device, so this doesn't change them.

AI-assisted.

quackottu and others added 4 commits November 22, 2026 14:28
Lists from the Xbox-ABI device are wrapped in a proxy whose vtable is the
console list order measured with the FSR DLL (d3d12_command_objects.md
section 3.5a): 0-26 at the PC index, 32 -> SetDescriptorHeaps with heap
proxies unwrapped, 33/35/41/53/61 -> 29/31/37/49/59, every other slot up
to 160 counted, logged once and refused with E_NOTIMPL. The object keeps
the console fields past the vtable with the write cursor at both limits,
so a console-compiled caller takes the vtable for every command.

is_list_proxy / list_proxy_real_list give a queue the PC list for
ExecuteCommandLists. Tests that record through the PC header use
list_proxy_real_list (runtime/test/xs_pc_list.h).
…fixes

The list proxy's GetDevice and device slots 12/51 clear the output before
any failure, as ItsNotRexed#1158 does for the other proxy slots. d3d12_vulkan_device_test
copies through console slots 15/9 on a slot-12 list and executes its PC list.
The docs no longer say every proxy slot forwards in PC order.
…231)

Device slots 8 (CreateCommandQueue), 75 (CreateCommandQueue1), 36
(CreateFence) and 32 (OpenSharedHandle of a fence) now return queue and
fence proxies. They forward the public chain in PC order (19 queue slots,
11 or 12 fence slots), refuse and log a slot past it up to the end of the
proxy's table, and name a read past the table through a guard region and
a vectored handler.

Heap, queue and fence proxies are unwrapped wherever a device or queue
method hands them to the real runtime: queue Signal/Wait, device slots
31/34/35/45/46/50. Arrays are copied without exceptions. QueryInterface
answers only the modelled interfaces, and logs one the real object has
but the proxy does not model. Outputs are cleared on failure as for
slots 14/62/76. --trace-d3d12 records proxy calls in the README grammar.
Every function a thunk hands its words to keeps them in the same
positions, because a title passes only as many as the method takes.

Tests: queue_proxy_test (host WARP, host hardware, Vulkan device;
differential per-process error cases, guard faults, identity, threads,
raw-slot client, child-runner self-test), xs_proxy_mock_test (older
devices, fences without Fence1, OpenSharedHandle branches, allocation
failures; three guard-setup fault modes), and device_proxy_test through
the D3D12XboxCreateDevice shim. No game files.

AI-assisted (Claude Code).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ist proxy

Queue slot 10 ExecuteCommandLists hands the real queue the PC list behind each
list proxy (UnwrappedArray: 16 inline, E_OUTOFMEMORY when a longer copy cannot
be allocated), and proxy_real_object knows the list vtable. device_proxy_test
and d3d12_vulkan_device_test execute the list proxy itself on the queue proxy.
@AimLogin

Copy link
Copy Markdown
Contributor

@quackottu, #1270 is rebased onto current main (c0ac5fd6). The new BUILD-231 commit is 62593f47, which replaces 74764c5a. The only conflict was in runtime/CMakeLists.txt: upstream's d3d12_fence_events_test registration landed at the same spot as queue_proxy_test, and both are kept. git range-diff shows no content change, and the shim files are byte-for-byte what you merged. #1325 still carries 74764c5a plus the merge commit, so please rebase it onto 62593f47. #1270 stays a draft.

One review note on the slot-10 branch in child_slot:

UnwrappedArray lists;
if (!lists.fill(a2, a1)) return hr_to_u64(E_OUTOFMEMORY);

ExecuteCommandLists returns void, so the title ignores that E_OUTOFMEMORY. If the allocation for more than 16 lists fails, the lists are silently not executed, and the title then waits on a fence that never moves. A suggestion that needs no allocation at all: unwrap and forward in chunks of 16, the inline size, calling the real ExecuteCommandLists once per chunk in order. The lists still run in the order given, just split into several submissions. If you'd rather keep a single call, at least log the failure once, so a hang there has a line pointing at it.

Results on the rebased commit: CTest 70/70 with Vulkan validation, including synchronization validation, which I confirmed is active with a positive control (a missing barrier is reported as a WRITE_AFTER_WRITE hazard, and adding the barrier clears it). Current main is 65/65 in the same mode. RTX 4060 Ti, driver 621.01.

AI-assisted (Claude Code).

@kapitche

Copy link
Copy Markdown
Contributor

Tested on Windows 11 with two GPUs on one machine (runtime built from this PR's head, MSVC 14.51): pass. ctest: 66/66 on the RTX 4080 SUPER. On the Intel UHD 770 the 3 failures are known and unrelated: d3d12_vulkan_device (#962, fixed by #1285), d3d12_descriptor (min-LOD truncation) and d3d12_copy_xfmt. (vk_binary_occlusion passes here only because this branch predates 29345889, which broke it on Intel. #1321 fixes that.)

@UlteriorMotive00

Copy link
Copy Markdown
Contributor

Tested 7037991 (457 behind main) on two GPUs: Windows 11 Home 10.0.26300, MSVC 14.44 (scripts/build_runtime.ps1), Vulkan SDK 1.4.363.0, LEONIDA_VK_VALIDATION=1, VK_LOADER_LAYERS_DISABLE=~implicit~.

GPU ctest
RTX 5070, 617.42 66/66 passed (queue_proxy 32 s, device_proxy, xs_proxy_mock* pass)
AMD Radeon RDNA2 iGPU (Ryzen 7 9800X3D), 32.0.21042.62 65/66: queue_proxy timed out (1,500 s)

The AMD queue_proxy timeout doesn't look like this PR's. Run alone on the iGPU with nothing else on the GPU, main's queue_proxy_test (bb2e184) also hits a 900 s cap, the same as this branch. Main's log shows vulkan case 8 (real): the child exited with 0x0000008f without a report. In another ctest run of current main on this iGPU it passed in 97 s, so it looks like an existing, flaky problem with the test's child processes on this AMD driver. I'll look into it separately. No validation messages in any run.

AI-assisted (Claude Code). No game files.

@AimLogin

Copy link
Copy Markdown
Contributor

@quackottu, a heads-up for later, nothing needed now: #1795 (draft) adds an Xbox-ABI allocator proxy at device slot 9. It touches neither device slot 12 nor anything in your list proxy, so it doesn't conflict with #1325.

Why it matters for your list proxy: today slot 9 wraps only the Vulkan layer's allocators, whose CommandAllocator::from() resolves the proxy in CreateCommandList and Reset. On the host PC runtime it hands the allocator out unwrapped, because a real d3d12.dll list would take a proxy for its own allocator. Once both PRs are in, your list proxy is what can lift that restriction:

  1. Device slot 12 CreateCommandList(node, type, allocator, pso, riid, out): pass unwrap_object(a3) to the real device. a3 is a register word, so the positions stay as they are, and proxy_real_object() already knows the allocator vtable in Runtime: Xbox-ABI proxy for the command allocator (device slot 9) #1795.
  2. The list's Reset(allocator, pso) (PC slot 10, which is at its PC index in your console map): unwrap a1 the same way before forwarding.
  3. Then slot 9 may wrap host allocators too. In Runtime: Xbox-ABI proxy for the command allocator (device slot 9) #1795 the condition is resolves_allocator_proxies(), and it would also become true when the device's lists are list proxies.

I'm happy to do all of this as a small follow-up stacked on both PRs. Or, if you'd rather, steps 1 and 2 can go into #1325 and I'll do only step 3. Your call, and no rush. #1325 still needs its rebase onto current main either way.

AI-assisted (Claude Code).

@mokkymiah

Copy link
Copy Markdown
Contributor

I rebased this onto current main (ec8ec4c9) in a clean branch, dropping the already-merged #1270 queue/fence commits and replaying only the two list-proxy commits:

https://github.com/mokkymiah/Leonida/tree/test-pr1325-clean

Two things the old branch had only in the merge commit 70379919 were carried over:

  • queue slot 10 ExecuteCommandLists now unwraps the list array with UnwrappedArray (the merge added it, neither list commit has it);
  • proxy_real_object recognises the list vtable.

Two small fixes were needed for current main:

  • list_proxy_real_list was forward-declared inside the anonymous namespace, which gave an internal-linkage reference with no definition (C5046 / LNK2019); it is now declared in rt::d3d12_xs.
  • main added a "several lists in one ExecuteCommandLists, then fewer" block to d3d12_vulkan_device_test that records ClearRenderTargetView with the PC header on a slot-12 list. With slot 12 now returning a console-order proxy, that call lands on an unmapped console slot; the block takes the PC list with use_pc_list, as the other PC-header blocks in the file do, so it still checks the queue replays only the lists it is given.

Tested

Windows 11 x64, NVIDIA GeForce RTX 3070, driver 621.01, Vulkan 1.4.357, LEONIDA_VK_VALIDATION=1, none of the tests read game data. AI-assisted.

  • device_proxy_test: OK (0 failures), including the console-order list proxy through the queue proxy.
  • queue_proxy_test: 3 backend(s) passed.
  • xs_proxy_mock_test: passed.
  • d3d12_debug_markers_test: all checks passed.
  • d3d12_vulkan_device_test: passed with no validation messages ("Vulkan device behind the Xbox-ABI proxy: clears, zero-filled first use, uploads, texture, buffer and BC copies, a resolve, reserved resources, queries, GetCopyableFootprints, GetResourceTiling and CheckFeatureSupport error paths all matched").

The branch is ready to be updated in place if you want to keep this PR, or to open as a replacement.

@mokkymiah

Copy link
Copy Markdown
Contributor

Full-suite result on the rebased branch: all 53 d3d12 ctest tests pass on Windows 11 x64 / NVIDIA GeForce RTX 3070 (driver 621.01, Vulkan 1.4.357) with LEONIDA_VK_VALIDATION=1. Branch updated: https://github.com/mokkymiah/Leonida/tree/test-pr1325-clean

main grew quite a few PC-header tests after this branch, and slot 12 now returns a console-order proxy, so their SetDescriptorHeaps/root-binding/clear/bundle calls landed on unmapped console slots. I added use_pc_list after CreateCommandList in the 13 tests that needed it (present, translated draw, m2 formats/textured, m3 frame, m4 compute, buffer UAV, compute, FSPx, draw including its bundles, MSAA draw, set-0 compute, subgroup). No production change.

A plain main build of the same 53 tests passes 53/53 as well, so these were the only differences. The list-proxy behaviour itself is still exercised through console slots in device_proxy_test and the console-order block of d3d12_vulkan_device_test.

@mokkymiah

Copy link
Copy Markdown
Contributor

Rebased again onto current main (16282101) and re-ran the full d3d12 suite: 53/53 pass on the RTX 3070 with LEONIDA_VK_VALIDATION=1 (the two package-gated tests skip). Branch: https://github.com/mokkymiah/Leonida/tree/test-pr1325-clean

@mokkymiah

Copy link
Copy Markdown
Contributor

@quackottu the clean rebase is still green on current main (f847748c): all 53 d3d12 ctest tests pass on the RTX 3070 with validation, including the tests main added after this branch. If you are not planning to update the PR head, would you be OK with a replacement PR carrying that branch? I have not opened one to avoid duplicating your work. Branch: https://github.com/mokkymiah/Leonida/tree/test-pr1325-clean

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