Skip to content

d3d12_xs: forward console list slot 70 to OMSetDepthBounds (typed thunk); document unnamed list slots - #9678

Closed
KkelebekK wants to merge 8 commits into
ProjectLeonida:mainfrom
KkelebekK:xs-list-depth-bounds
Closed

KkelebekK wants to merge 8 commits into
ProjectLeonida:mainfrom
KkelebekK:xs-list-depth-bounds

Conversation

@KkelebekK

Copy link
Copy Markdown

Claimed in the coordination issue as: #8683 (comment)

Depends on: #2490. ListProxy only exists there, so this branch is based on its current head (084c8bd09). This PR's own diff is the one commit on top, 471dd0b8f ("d3d12_xs: forward console list slot 70 to PC OMSetDepthBounds with a typed thunk"). Until #2490 lands, GitHub shows #2490's commits here too.

What and why

Slot 70 was silently swallowed. #2490's console-to-PC list map has no entry for console slot 70. ListProxy records the call and returns 0, and the real list never sees it. From a static read of the retail executable, slot 70 is ID3D12GraphicsCommandList1::OMSetDepthBounds(FLOAT Min, FLOAT Max):

  • the caller passes only this and two floats (XMM1 = Min, XMM2 = Max);
  • it is called right after every OMSetRenderTargets.

A typed thunk is needed. On the Windows x64 ABI the two floats travel in XMM1/XMM2. The generic all-uint64_t list_slot<Slot> thunk reads RDX/R8 and never forwards the XMM registers, so mapping the slot alone is not enough. This is the same problem #7880 solves for ClearDepthStencilView, and this PR follows #7880's approach:

  • console_to_pc_list_slot(70) returns PC slot 62 (ID3D12GraphicsCommandList1).
  • A typed WINAPI thunk, list_om_set_depth_bounds(ListProxy*, FLOAT, FLOAT), is installed over slot 70 in fill_list_vtable, after the fold, the same way d3d12_xs: translate title-owned CPU descriptor handles in ListProxy and preserve ClearDepthStencilView FLOAT Depth #7880 installs its slot-51 thunk. It records the call (the first-call log shows the float bits) and forwards both floats to the real list's PC slot 62.
  • If the real list stops before ID3D12GraphicsCommandList1 (60 slots), the call is dropped with a one-time warning. The method is void, so there is no E_NOTIMPL to return.

The two PRs both add a line to fill_list_vtable and a typed slot to the list mocks. Whichever lands second has a one-line merge there; the changes do not overlap in meaning.

Docs (docs/d3d12_xs_console_abi.md §5.3):

  • slot 70 in the method table;
  • a new table of list slots that are measured but not yet named: 71, 72, 74, 75, 126, 131, 132, 142 and 146. It gives argument shapes and call counts only. Readings marked "hypothesis" are guesses, not measurements.

None of these slots is forwarded by this PR except 70. 146 was already routed to Barrier by #2490.

Tested

Linux, Wine 11.21 (a separate, freshly created test prefix), clang-cl/lld-link cross build against the MSVC CRT and Windows SDK from xwin. No GPU and no game data needed.

xs_proxy_mock_test gets a new check_depth_bounds. The list mocks now take PC slot 62 typed (mock_om_set_depth_bounds(Mock*, FLOAT, FLOAT)), so the test sees the floats as the real list would. It checks:

  • on a full-chain list, console slot 70 reaches PC slot 62 with Min/Max intact, on the first call (the one that is logged) and on later calls, for (0.125, 0.875), the default (0, 1) and an inverted (0.75, 0.25);
  • PC slots 61, 63 and 70 of the real list are not hit;
  • list_slot_hits(70) counts every call;
  • on a list that answers only ID3D12GraphicsCommandList (60 slots), the call is recorded and dropped, and nothing reaches the mock;
  • references are balanced afterwards.
Build xs_proxy_mock_test under Wine
#2490 as it is, with this PR's test fails: xs_proxy_mock line 1012: real->calls[62] == 1 && real->depth_bounds_min == 0.125f && real->depth_bounds_max == 0.875f. The first-call log shows slot 70 receiving 0x0 0x0 in place of the floats.
this PR PASS: xs_proxy_mock: console list slot 70 reaches PC OMSetDepthBounds with Min/Max intact; a list without ID3D12GraphicsCommandList1 drops it … xs_proxy_mock_test: PASS (9 allocations refused on purpose)
  • ctest -R 'xs_proxy_mock|fsr_dispatch': all six xs_proxy_mock* tests pass (plain, --fail-virtualalloc, --fail-virtualprotect, --fail-veh, --env-slots, --env-slots-invalid). fsr_dispatch reports itself as skipped here.
  • The full runtime build (917 steps) completes with no warnings from d3d12_xs_device.cpp.

Not verified

  • No run on Windows, and no GPU check that depth-bounds testing actually takes effect on a real device. The mock checks the ABI forwarding only.
  • That the console method takes no further arguments beyond Min/Max. The caller passes none, but the console declaration itself is not recovered.

AI-assisted (Claude Code).

🤖 Generated with Claude Code

NolanCotter and others added 8 commits November 23, 2026 09:24
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) ItsNotRexed#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>
The console build imports GameInput.dll by ordinal, not by name;
the import binds 'ItsNotRexed#1' and the name-only table misses it, so a
boot fell through to the host GameInput.dll or the unimplemented
thunk instead of the shim (registry.cpp already classifies 'ItsNotRexed#1'
as an HResult name for this DLL).
…typed thunk

Console list slot 70 is ID3D12GraphicsCommandList1::OMSetDepthBounds(FLOAT Min,
FLOAT Max): a static read of the retail caller shows it passing only `this` and
two floats (XMM1 = Min, XMM2 = Max), right after every OMSetRenderTargets. The
console-to-PC map had no entry for 70, so ListProxy recorded the call and
returned 0 without reaching the real list.

Map 70 to PC slot 62 and install a typed WINAPI thunk for it, the way ItsNotRexed#7880
does for ClearDepthStencilView: the all-uint64_t list_slot thunk reads RDX/R8
and never forwards XMM registers, so it cannot carry the floats. A real list
without ID3D12GraphicsCommandList1 (60 slots) drops the call with a one-time
warning; the method is void, so there is no HRESULT to return.

xs_proxy_mock_test gets check_depth_bounds: the list mocks take PC slot 62
typed, and the test checks Min/Max on the first and later calls, no
neighbouring slot hit, and the drop on a GCL-only list.

docs/d3d12_xs_console_abi.md: slot 70 in the method table, and a table of
measured but unnamed list slots (71, 72, 74, 75, 126, 131, 132, 142, 146) with
their argument shapes and call counts only.

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

smowlyy commented Nov 23, 2026

Copy link
Copy Markdown
Contributor

Verified on native Windows 11 (10.0.26300.9974, MSVC 19.44, RelWithDebInfo, Vulkan SDK 1.4.363.0, NVIDIA GeForce RTX 5060 Ti driver 610.88 / Vulkan 1.4.341), PR head 471dd0b8f merged onto main (5d74c2723):

  • python -I scripts/check_no_game_data.py ... (all 34 changed files): clean (exit 0).
  • cmake --build runtime/build --target xs_proxy_mock_test queue_proxy_test d3d12_draw_test --parallel: built cleanly.
  • ctest --test-dir runtime/build -R xs_proxy_mock --output-on-failure: 6/6 passed.
  • LEONIDA_VK_VALIDATION=1 ctest --test-dir runtime/build -R "^(queue_proxy|d3d12_draw)$" --output-on-failure: 2/2 passed (0 validation errors).

AI-assisted.

@OliverMarcusson

Copy link
Copy Markdown

Tested 471dd0b8 (merged cleanly onto main 5d74c272) on NVIDIA GeForce RTX 5070 Ti (driver 621.01, Vulkan 1.4.357), Windows 11 10.0.26200, MSVC 19.44 (RelWithDebInfo, Windows SDK 10.0.26100.0, glslangValidator 16.6.0): pass.

  • ctest -C RelWithDebInfo -R ^(xs_proxy_mock|queue_proxy|xbox_present|d3d12_draw)$: 4/4 PASS
    • xs_proxy_mock: PASS (9 allocations refused on purpose)
    • queue_proxy: PASS (3 backends passed, 8.64 s)
    • xbox_present: PASS (2.46 s)
    • d3d12_draw: PASS (0.31 s)

AI-assisted (Gemini).

@sgonzalez-glitch

Copy link
Copy Markdown

Tested 471dd0b8f (as part of #9516, #9549, #9614, #9653, #9657, #9660, #9678 and #9689 merged together onto main 5d74c2723) on NVIDIA GeForce RTX 2080, driver 621.24 (32.0.16.2124), Windows 11, MSVC 19.44 RelWithDebInfo: pass.

AI-assisted: yes

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.

6 participants