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

Manually merged
github merged 7 commits from gh-pr/430/head into gh-pr/430/base 2026-11-26 08:59:40 +00:00
Owner

@⁠Mumogg on GitHub · 2026-11-24 05:05 UTC · original
Mumogg:queue-slots16-17-signal → main · +21 −1 · 1 files · 7 commits · merged 2026-11-25 03:46 UTC

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** on GitHub · 2026-11-24 05:05 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/430) `Mumogg:queue-slots16-17-signal` → `main` · +21 −1 · 1 files · 7 commits · merged 2026-11-25 03:46 UTC 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.com/claude-code) https://claude.ai/code/session_01HxBQf4pXH8PWpC5oZsM4bt
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, 2be25cee2), 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 <[email protected]>
Claude-Session: https://claude.ai/code/session_01HxBQf4pXH8PWpC5oZsM4bt
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 afb14d56c6)

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 <[email protected]>
Claude-Session: https://claude.ai/code/session_01HxBQf4pXH8PWpC5oZsM4bt
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 0aba6c361 (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 <[email protected]>
Claude-Session: https://claude.ai/code/session_01HxBQf4pXH8PWpC5oZsM4bt
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 <[email protected]>
(cherry picked from commit 4a86034367)

Adapted to main by Mumogg: the conflict is with b4d1ba179, 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.
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 <[email protected]>
Claude-Session: https://claude.ai/code/session_01HxBQf4pXH8PWpC5oZsM4bt
Everything below this rung (#414, #416, #427) and the rung's own routing are in
main already, through #984 and #939, in main's form; what is left of #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 #414; main's list proxy already
  translates the CPU handles of console list slots 50 to 54 (#416) and
  drops unordered access from a depth-stencil texture at slot 76 (#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 #414, as #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 (#427).
- runtime/test/xs_proxy_mock_test.cpp: main's file, which already has
  check_list_cpu_handles (#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: #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 <[email protected]>
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 08:59:38 +00:00
github manually merged commit 6ed716a99a into gh-pr/430/base 2026-11-26 08:59:40 +00:00
Author
Owner

@⁠Dezmonius on GitHub · 2026-11-24 13:51 UTC · original

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).

**@⁠Dezmonius** on GitHub · 2026-11-24 13:51 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/430#issuecomment-7133447848) 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).
Author
Owner

@⁠aslan2142 on GitHub · 2026-11-25 03:46 UTC · original

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:

  • Claim: RT-QUEUE-SIGNAL, valid, before this PR.
  • Kept from main: queue slots 16/17 with a fence go to Signal/Wait through main's layout detection (any caller), which also marks the newer queue layout and so moves the PresentX slot.
  • Kept from this PR: your test, ported to main's rule: with a fence, slot 16 reaches PC Signal and slot 17 reaches PC Wait, both with the real fence, the PC getters are never called and the fence proxy's vtable pointer is unchanged. Slot 17 had no test on main. The host-caller and no-fence expectations are dropped, because main answers those calls S_OK once the layout is detected.
  • Windows suite under Wine (llvmpipe and an RDNA2 iGPU): xs_proxy_mock passes on both and fails when slot 17 is sent to Signal; the full suite shows no test going from pass to fail.
  • The rest of the ladder: this merge also marks #414, #416 and #427 as merged, since their commits come with it; their content is in main already (notes on each). #432, #428 and #602 are carried as well.
  • Checked on main bfef489cb + 6ed716a99: it merges cleanly; the semantic suite passes (487 files, 6,279 tests, 0 files failed); the 14 docs and writer tests pass; check_no_game_data.py is clean on the 1 changed files.

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

**@⁠aslan2142** on GitHub · 2026-11-25 03:46 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/430#issuecomment-7152226885) 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: - **Claim:** `RT-QUEUE-SIGNAL`, valid, before this PR. - **Kept from `main`:** queue slots 16/17 with a fence go to Signal/Wait through `main`'s layout detection (any caller), which also marks the newer queue layout and so moves the PresentX slot. - **Kept from this PR:** your test, ported to `main`'s rule: with a fence, slot 16 reaches PC Signal and slot 17 reaches PC Wait, both with the real fence, the PC getters are never called and the fence proxy's vtable pointer is unchanged. Slot 17 had no test on `main`. The host-caller and no-fence expectations are dropped, because `main` answers those calls `S_OK` once the layout is detected. - **Windows suite under Wine (llvmpipe and an RDNA2 iGPU):** `xs_proxy_mock` passes on both and fails when slot 17 is sent to Signal; the full suite shows no test going from pass to fail. - **The rest of the ladder:** this merge also marks #414, #416 and #427 as merged, since their commits come with it; their content is in `main` already (notes on each). #432, #428 and #602 are carried as well. - **Checked on `main` `bfef489cb` + `6ed716a99`:** it merges cleanly; the semantic suite passes (487 files, 6,279 tests, 0 files failed); the 14 docs and writer tests pass; `check_no_game_data.py` is clean on the 1 changed files. AI-assisted (Claude Code, Claude Opus 5.5).
This discussion has been locked. Commenting is limited to contributors.
No description provided.