Skip to content

d3d12_xs: the title's queue slots 16 and 17 with a fence are Signal and Wait (RT-QUEUE-SIGNAL) - #430

Merged
aslan2142 merged 7 commits into
ProjectLeonida:mainfrom
Mumogg:queue-slots16-17-signal
Nov 25, 2026
Merged

aslan2142 merged 7 commits into
ProjectLeonida:mainfrom
Mumogg:queue-slots16-17-signal

Conversation

@Mumogg

@Mumogg Mumogg commented Nov 24, 2026

Copy link
Copy Markdown
Contributor

Claimed in #14 as RT-QUEUE-SIGNAL. Depends on: the stack up to #427 (their commits come first here; this pull request is the last commit). The change is in the queue proxy and its test, next to #403's.

What and why

The same kind of bug as #403, one slot over.

Queue slots 16 and 17 are GetTimestampFrequency(UINT64*) and GetClockCalibration(UINT64*, UINT64*) on the PC; both write through their first argument. The retail title calls queue slot 16 with one of its fences and a value: the shape of Signal(fence, value). On the console queue Signal and Wait sit two later than on the PC, at 16 and 17, as the frequency getter does at 18.

main forwarded the call by number, so the PC frequency getter wrote the frequency over the first 8 bytes of the fence proxy: its vtable pointer. The title's next call on that fence then went through a null pointer.

How I found it: at the fault the register that should hold the fence's vtable held 1,000,000,000, the frequency the layer answers; and the object the title was calling was a queue/fence/allocator proxy at an address I had logged.

The change: the title's call (set_console_caller) whose first argument is a fence proxy goes to the PC Signal or Wait with the real fence. A host caller keeps the PC getters, and so does a title call whose first argument is no object of this proxy, which cannot be a Signal.

Written by me. The slot order is the console queue's of old PR 2490 (Nolan Cotter), which detects the layout at run time; this is one rule for main's queue proxy.

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, #387 and #428 applied on top for the boot runs (they are not in this branch).

--run Ends with
without this a call through a null pointer from the title, on the fence it had just passed to queue slot 16
with this later: XboxID3D12Fence::Slot12 unsupported, then the title writes through a null pointer

Both runs create 50,450 pipeline states. The next stop is fence slot 12, a console method one past ID3D12Fence1 that returns a pointer the title reads; refused, the title dereferences the error code. 5ac4deaa2 (TreXito) is the piece for it and I will try it next.

Tests under Wine: xs_proxy_mock_test passes with the new case (both slots with a fence reach the mock queue's slots 14 and 15 with the real fence; the fence proxy's first word is unchanged; the non-fence call and the host call reach slot 16). queue_proxy_test passes on the Vulkan backend.

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

Mumogg and others added 6 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
…zed and created without it (stand-in)

The console allows ALLOW_DEPTH_STENCIL | ALLOW_UNORDERED_ACCESS on a texture; the PC runtime refuses the pair and
slot 25 answered UINT64_MAX for it. pc_resource_flags drops the UAV bit from depth-stencil textures (slot 25 through
pc_resource_desc, and slot 76). Their UAV views then write no descriptor.

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

Adapted to main by Mumogg: the conflict is with b4d1ba1, which is applied before it here: slot 25 keeps that
commit's scoped cleaning, and this one adds the flag rule and its log line.
…nd Wait

Queue slots 16 and 17 are GetTimestampFrequency(UINT64*) and GetClockCalibration(UINT64*, UINT64*) on the PC:
both write through their first argument. The retail title calls slot 16 with one of its fences and a value, the
shape of Signal(fence, value). On the console queue Signal and Wait sit two later than on the PC, at 16 and 17,
as the frequency getter does at 18. Forwarded by number, the call wrote the frequency over the first word of
the fence proxy, its vtable pointer; the title's next call on that fence went through a null pointer.

The title's call (set_console_caller) whose first argument is a fence proxy now goes to the PC Signal or Wait
with the real fence. A host caller keeps the PC getters, and so does a title call whose first argument is no
object of this proxy, which cannot be a Signal.

Same family as the slot 18 change: the console queue order of old PR 2490 (Nolan Cotter), as one rule for
main's queue proxy. xs_proxy_mock_test: both slots with a fence reach the mock queue's slots 14 and 15 with the
real fence, the fence proxy's first word is unchanged, and the non-fence and host calls reach slot 16.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01HxBQf4pXH8PWpC5oZsM4bt
@Mumogg
Mumogg force-pushed the queue-slots16-17-signal branch from feabc36 to 028a414 Compare November 24, 2026 09:54
@Dezmonius

Copy link
Copy Markdown
Contributor

Independent native Windows check of RT-QUEUE-SIGNAL. Windows 10 22H2 (19045), MSVC 19.51.36256, Windows SDK 10.0.26100, Ninja Release, RTX 5070 / NVIDIA 610.88.

  • A/B with the same xs_proxy_mock_test source: parent 89fdb83e0 fails the new slot-16 routing assertion, while PR head 028a414fa passes, including the slot-17 routing, unchanged fence vtable and host getter controls.
  • Stock queue_proxy_test passed on all three backends: native D3D12/WARP, native D3D12/RTX 5070, and Vulkan/RTX 5070 with Khronos validation 1.4.369 enabled.
  • A local extension of queue_proxy_test called Xbox slots 16/17 on the real queue proxy. Slot 16 completed a signal, slot 17 held a subsequent queue signal until a CPU signal released the wait, and the fence vtable stayed unchanged. This passed on all three backends. The real-device extension was run on the PR head only.

Synthetic data only; no game files or retail boot. AI-assisted (Codex).

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 5129be1 into ProjectLeonida:main Nov 25, 2026
2 of 5 checks passed
@aslan2142

Copy link
Copy Markdown
Collaborator

Merged, after merging main into it (6ed716a99). Thanks. Only the test is left of this; main took the routing from #984/#939 in its own form:

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.

5 participants