Skip to content

d3d12_xs: console-ABI command lists, upload arena, PC-list fixture path - #2490

Closed
NolanCotter wants to merge 7 commits into
ProjectLeonida:mainfrom
NolanCotter:main
Closed

NolanCotter wants to merge 7 commits into
ProjectLeonida:mainfrom
NolanCotter:main

Conversation

@NolanCotter

Copy link
Copy Markdown
Contributor

Summary

Follow-up batch after #1912 (claim: #1902 (comment)). 12 commits, all new files or small self-contained changes; no game data.

Runtime / loader

  • runtime/shims/registry.cpp: console ordinal-import classification — xaudio2_9.dll!#1 (XAudio2Create) and gameinput.dll!#1 (GameInputCreate) classify as HRESULT so unimplemented imports report E_NOTIMPL instead of faking success (+ unimplemented_policy_test checks)
  • runtime/src/pe_loader.cpp: fix — unregistered imports on shim-owned DLLs (xgameruntime, gameinput, ...) could bind to the host namesake (the live PC Gaming Services runtime). They now follow the pseudo-handle path and go unimplemented. + docs/import_routing.md (bind order, owns_dll, per-DLL outcome)

Docs

  • docs/console_libraries.md: catalogue of the console-DLL surface (d3d12_xs, xg_xs, AcpHal, dstorage_xs, chad/xapu/xcrdapi, ...) and per-module shim status
  • stale section/symbol reference fixes across docs
  • docs/hello_pixels.md + index rows
  • i18n: German + Italian community quickstarts (@NolanCotter maintainer)

Tools

  • tools/import_inventory.py: stdlib PE32+ import parser — maps dll!function / ordinal imports to shim-layer coverage per module (mirrors registry.cpp classification); 18 tests
  • tools/hello_pixels.py: package-free complement to first_light — assembles hand-written SPIR-V (spirv-as only), draws a generated quad through VKH_DRAW_MESH, writes PPM+PNG, --check oracle verifies coverage + probe pixels against the pattern's closed form

Tests (~1,400 lines): test_hello_pixels, test_import_inventory, test_run_gpu_tests_helpers, test_make_game_shader_state, test_viewer_serve additions, test_spirv_interface, test_wave64_halves_operands, and semantic fixtures for s_cmpk_* / s_wqm_b32 / ALU / f16-transcendental ops.

Tested

  • python -m compileall -q make_game.py tools tests ✅
  • test_hello_pixels 9 ✅ · test_import_inventory 18 ✅ · test_run_gpu_tests_helpers 25 ✅ · test_make_game_shader_state 40 ✅ · test_viewer_serve 38 ✅ · test_spirv_interface 28 ✅ · test_wave64_halves_operands 23 ✅
  • python -m unittest discover -s tests/semantic — 1,694 tests OK (incl. new fixtures; expected values verified against the translator's own interpreter)
  • hello_pixels end-to-end: Mesa llvmpipe (LLVM 20.1.2), Vulkan 1.3.275, Linux — 512×512 draw, 100% coverage, all probes pass
  • test_i18n_index, test_docs_links ✅

Caveat: the registry.cpp / pe_loader.cpp changes are Windows-only C++ and were not compiled locally (Linux box) — same situation as the #1912 classifier change that adriaespii verified on MSVC. CI or a Windows check appreciated.

AI assistance

Written with AI assistance (Devin + delegated workers); all test expectations verified by execution, not hand-trust.

Checklist

  • Claimed in the coordination issue
  • No game data, keys, or protection bypasses
  • Tests added for new behavior
  • AI assistance disclosed

@umnitus

umnitus commented Nov 22, 2026

Copy link
Copy Markdown

Tested hello_pixels at 9213603 on RTX 3060 12 GB, NVIDIA 621.14, Vulkan 1.4.357, Windows 11 26H2: pass.

Ran python -B -I tools/hello_pixels.py --work --harness <same-commit-vk_harness.exe> --size 512 --run --check. Exit 0. The GPU framebuffer had 262,144/262,144 covered pixels, all seven reference probes passed, and the raw, PPM and PNG outputs were written. The harness was built with llvm-mingw Clang 23.1.6 from the tested commit. AI-assisted verification.

@adriaespii

Copy link
Copy Markdown
Contributor

Tested 9213603d on AMD Radeon RX 9070 (RDNA4), AMD driver 26.10.1 (Vulkan 1.4.359), Windows 11 Pro 24H2, MSVC 19.44 (Visual Studio 2022 Community):

Windows MSVC Build & Runtime Tests

  • Compiles cleanly on Windows with MSVC 19.44: all 46 build targets linked with 0 errors/warnings.
  • unimplemented_policy_test.exe: 101 checks passed, 0 failed (including ordinal 1 classification checks for xaudio2_9.dll and gameinput.dll).
  • Full CTest suite (ctest --test-dir runtime/build): 110/110 passed (100%), 0 failed, 6 skipped, 1 disabled.

Real Hardware Verification (hello_pixels.py)

  • Tested tools/hello_pixels.py --work <dir> --run --check end-to-end at both 256×256 and 512×512:
    • Device: AMD Radeon RX 9070 (subgroup 32..64)
    • Active extensions: VK_KHR_shader_fma, VK_KHR_fragment_shader_barycentric, VK_EXT_fragment_shader_interlock, VK_KHR_maintenance8
    • Rendered image.raw, image.ppm, and image.png with 100% test pattern coverage and all probe pixels matching closed-form predictions.

Python Test Suites

  • python -m compileall -q make_game.py tools tests: OK
  • python -m unittest discover -s tests/semantic: 2590/2590 passed (OK)
  • Unit test modules:
    • tests/test_hello_pixels.py: 9/9 passed
    • tests/test_import_inventory.py: 18/18 passed
    • tests/test_run_gpu_tests_helpers.py: 25/25 passed
    • tests/test_make_game_shader_state.py: 40/40 passed (2 skipped)
    • tests/test_viewer_serve.py: 38/38 passed (2 skipped)
    • tests/test_wave64_halves_operands.py: 23/23 passed

Note on tests/test_spirv_interface.py

In tests/test_spirv_interface.py:146, test_64_bit_vectors_may_span_two_locations fails:

spirv_interface.InterfaceError: a 64-bit vector spanning two locations needs Component 0

This is because commit 461218a6 on main tightened location_masks to reject 64-bit vectors that start on a non-zero component and span across locations (component + slots > 4 and component). For dvec2 (slots = 4) starting at component = 2, it now correctly throws InterfaceError per the Vulkan specification. Updating line 146 to expect the exception resolves it:

        with self.assertRaisesRegex(spv.InterfaceError, "Component 0"):
            dvec2.location_masks(2)

No game data used.

AI-assisted.

@NolanCotter

Copy link
Copy Markdown
Contributor Author

Fixed in defa3f19 — test_64_bit_vectors_may_span_two_locations now expects InterfaceError("Component 0") for dvec2.location_masks(2), matching 461218a6. test_spirv_interface.py: 28/28 pass.

Thanks @umnitus (RTX 3060/Windows) and @adriaespii (RX 9070/MSVC + llvmpipe) for the hardware runs — the MSVC clean build and 110/110 CTest covers the uncompiled-locally caveat.

@CharlyRien

Copy link
Copy Markdown

Code review of the loader and inventory parts (AI-assisted), checked at defa3f1, with synthetic PE images and the repo's loader_test on Windows 11 23H2 (RTX 3090 machine). Nothing was pushed.

1. The host-binding fix is bypassed when the import's DLL name has no .dll (or ends in a dot) (proved). runtime/src/pe_loader.cpp resolve() keys on lower(dll) only. resolve_forwarder (a few lines above it) appends .dll, and library_loader.cpp's module_name() appends it and strips a trailing dot.

  • So for an import from GameInput or gameinput.dll., both shims::find and the new owns_dll gate miss. LoadLibraryExA then adds .dll itself and binds the real System32 module.
  • Loader cases added to loader_test.cpp in a private copy, with a test SHIM_TABLE {"gameinput.dll","GameInputCreate"} and the real gameinput.dll present in System32:
    import gameinput.dll   !DllCanUnloadNow -> Unimplemented owns_dll=1
    import GameInput       !GameInputCreate -> Host  owns_dll=0   (slot = host gameinput base + 0x6f10)
    import GameInput       !DllCanUnloadNow -> Host  owns_dll=0
    import GameInput       !#2              -> Host
    import gameinput.dll.  !DllCanUnloadNow -> Host
    forwarder GameInput.DllCanUnloadNow     -> Unimplemented
    
  • The registered shim is skipped too. That part predates this PR, but the new owns_dll gate inherits it. docs/import_routing.md says static imports match the GetProcAddress path, and here they don't.
  • Fix: normalise the key in resolve() the same way resolve_forwarder / module_name() do. Linkers always write .dll, so this needs a hand-made or hostile image, but it's a one-line fix.

2. tools/import_inventory.py's classify port disagrees with registry.cpp (proved). The PR adds "#1" as HRESULT for xaudio2_9(redist).dll and gameinput.dll in registry.cpp, but not in the Python port, whose docstring says it mirrors it. Result: classify("xaudio2_9.dll", "#1") and classify("gameinput.dll", "#1") give other in Python, while the C++ test expects HResult.

3. The inventory ignores delay-load imports (proved). It reads only data directory 1. The loader binds directory 13 eagerly. An image whose only import is a delay import of xgameruntime.dll!XUserAddAsync gives an empty inventory.

4. The inventory and the loader stop the descriptor table at different points (proved). The loader stops at the first descriptor with Name == 0, but the tool keeps going and reads string_at(0), the MZ header, as a DLL name:

descriptors kernel32 / Name=0 / xmem  ->  [('kernel32.dll','Sleep'), ('mz','Sleep'), ('xmem.dll','XMemAlloc')]

The loader binds only the first. An unreadable name is also skipped silently, where the loader throws.

5. The report's "unimplemented thunk" column counts host-bound imports (proved). Every unregistered import goes there, including kernel32.dll!Sleep and api-ms-win-core-synch-l1-2-0.dll!Sleep, which the loader binds to the host: total 3 … implemented 0, unimplemented thunk 3. On the real executable, that would greatly overstate what is missing, which is the number this tool exists to give.

6. MAX_ENTRIES doesn't bound the work (proved). The cap is per table (65,536 descriptors × 65,536 thunks), and shared thunk tables aren't deduplicated. A 529 KB file with 64 descriptors sharing one table took 94.5 s, gave 4,194,240 entries and peaked at 613 MiB. A global cap, or deduplicating by thunk RVA, would make the "stops a malformed image" comment true.

7. (reasoned) Ordinal 1 of the host xaudio2_9.dll is XAudio2Create (checked against System32), but I couldn't confirm it for xaudio2_9redist.dll. Host ordinals 8–10 (XAudio2CreateV2_9, …WithVersionInfo, …WithSharedContexts) also return HRESULT and stay other.

Checked and found correct, for normal .dll names:

  • The owns_dll gate in resolve() and resolve_forwarder: unregistered names and ordinals on an owned DLL go to Unimplemented, registered names go to Shim, and case is ignored.
  • Forwarders by name and by #N into owned modules never reach Host.
  • IMAGE_ORDINAL64 masking and the hint/name +2 offset, in both C++ and Python.
  • The forwarder #N parse rejects values over 0xFFFF and non-digits.
  • The PR's own tests pass: loader_test, unimplemented_policy_test and test_import_inventory. None of them covers items 1–6.

@NolanCotter

Copy link
Copy Markdown
Contributor Author

All addressed in ffdcef4 (and 8c91167 adds a console-ABI doc). Thanks for the thorough pass — every one of these reproduced.

1. resolve() DLL-name normalisation — fixed. New dll_key() in pe_loader.cpp applies the same file-name rule module_name() / resolve_forwarder use (lower, trailing . dropped, .dll added when no extension), and both resolve() and resolve_forwarder() key on it. loader_test covers it: imports naming TestShim and testshim.dll. now bind the shim.

2. classify parity — #1 added to the xaudio2_9/xaudio2_9redist and gameinput branches in the Python port; test cases added.

3. Delay imports — directory 13 is now read (IMAGE_DELAYLOAD_DESCRIPTOR, RvaBased/IAT/INT checks matching bind_imports's throws). Fixture test included.

4. Table termination — the descriptor loop now stops at Name == 0 exactly like the loader, and unreadable descriptor/thunk names raise PeFormatError instead of silently skipping.

5. Host vs thunk — the report now mirrors the routing order: registered → implemented; unregistered on a shim-owned DLL → unimplemented thunk; anything else → host (owns_dll ported: the 8 host DLLs and api-ms-*/ext-ms-* exclusions). kernel32.dll!Sleep and the api-ms imports no longer inflate the missing count.

6. MAX_ENTRIES bound — thunk tables deduplicate by lookup-table RVA (your 64-descriptor case now walks the table once) plus a global MAX_TOTAL_ENTRIES cap that raises on a malformed image.

7. xaudio2_9 ordinals — #8–#10 added for xaudio2_9.dll only (the verified System32 table), registry.cpp and Python port both; xaudio2_9redist.dll stays other until its ordinal table is confirmed. New checks in unimplemented_policy_test.

Verified: test_import_inventory.py 24/24; cross-built on clang-cl 20 + xwin, loader_test 69 checks / 0 failed, unimplemented_policy_test 96 checks / 0 failed under Wine.

Generated with Devin

@Flyander Flyander left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Checked at 249b7065ddb4db971e318d195da6eec96a2265ff. The existing test_import_inventory.py suite passes (24 tests), but two synthetic PE/list-input cases expose report mismatches with the loader:

  1. Shared lookup-table RVA drops later descriptors. I built a synthetic PE with gameinput.dll and other.dll descriptors pointing to the same lookup table containing GameInputCreate. pe_imports() returns only [('gameinput.dll', 'GameInputCreate')]; the second descriptor is omitted because seen_tables skips the RVA before associating its symbols with that descriptor's DLL. Loader::bind_imports() calls bind_thunks(dll, ...) for each descriptor, so it resolves each DLL's IAT separately. This hides a real import association and can produce the wrong per-DLL binding/coverage report. Please cache parsed symbols per lookup RVA, then emit them for each descriptor DLL, while keeping a bound on total work/output. The current test_shared_thunk_table_is_walked_once encodes the incomplete one-DLL result and should assert both associations.

  2. DLL-name normalization differs from the loader. parse_import_lines(['GameInput!GameInputCreate']) produces ('gameinput', 'GameInputCreate'); summarize() reports other/host, although pe_loader.cpp::dll_key('GameInput') resolves to gameinput.dll, where this import is registered and classified HRESULT. The PE path likewise only lowercases DLL names. Please apply the loader's dll_key normalization to report comparison/classification keys (and add cases for a bare name and a trailing dot).

@ray3242

ray3242 commented Nov 22, 2026

Copy link
Copy Markdown
Collaborator

At a6dff5bd, the newly added tests/test_make_game_shader_state.py fails against this PR's own make_game.py, both on this head and on its merge with main: 19 failures, all in this module (19 failed, 132 passed, 501 subtests passed across the files the PR touches).

  • :144, :148, :152 call make_game.disassembly_matches(...), and other cases call make_game.clear_shader_disassembly(...). Neither function exists in make_game.py at this head (grep -c gives 0) or on main, so every one of these cases raises AttributeError.
  • Running the module against main's make_game.py gives the same AttributeError.

The tests look like they were written against an older shader-stage API. Pointing them at the current make_game helpers, or dropping the file if those paths are already covered elsewhere, would fix it. The shim and loader changes aren't affected.

AI-assisted (Devin); Linux, Python 3.12.16, no GPU or game files.

NolanCotter added a commit to NolanCotter/Leonida that referenced this pull request Nov 23, 2026
…s per DLL

Review findings on ItsNotRexed#2490: descriptors sharing one lookup table lost the
later DLL's association (the walk was deduplicated before the DLL was
attached), and names like "GameInput" or "gameinput.dll." reported as a
"gameinput" host module while the loader keys them gameinput.dll.

Lookup tables now parse once per RVA into a name cache and emit per
descriptor, matching the loader's per-IAT binding; the emitted pair
count stays under MAX_TOTAL_ENTRIES. DLL names go through a port of
pe_loader.cpp's dll_key (basename, lower, one trailing dot dropped,
.dll added when there is no extension) at both input boundaries and in
summarize(), so the report groups and routes on the loader's key.

Generated with [Devin](https://devin.ai)

Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
@NolanCotter

Copy link
Copy Markdown
Contributor Author

Addressed in d122c4f7 (rebased onto 2be25cee; PR head is now 425059bd):

1. Shared lookup-table RVA — tables now parse once per RVA into a symbol cache and emit per descriptor, matching the loader's per-IAT binding: your two-descriptor case reports gameinput.dll!GameInputCreate and other.dll!GameInputCreate both. test_shared_thunk_table_reports_each_dll asserts both associations, and MAX_TOTAL_ENTRIES now bounds emitted pairs as well as parse work, so the shared-table malformed image stays stopped.

2. DLL-name normalization — ported pe_loader.cpp::dll_key (basename, lower, one trailing . dropped, .dll added when there's no extension) and applied it at both input boundaries (parse_import_lines, both PE descriptor loops) and inside summarize. GameInput!GameInputCreate now reports gameinput.dll → hresult → implemented; test_unnormalised_names_route_as_their_key, test_descriptor_dll_name_normalises_like_the_loader, and dll_key edge cases cover it.

test_import_inventory.py 32/32 pass.

Also in this push:

  • 879d1fe4 ports test_make_game_shader_state.py to the upstream disassembly-inventory API (disassembly_status / prepare_shader_disassembly) — the rebase had left it calling the removed functions (47/47 pass).
  • fca2064f adds the #1406 sys.stdout.reconfigure(errors="replace") guard to hello_pixels.py (test_tool_stdout_encoding flagged it).
  • 311736ec restores the fssm_crosscheck.md wording for the duplicate-XBCH fix that had already landed.
  • 425059bd restores the test_viewer_serve.py coverage dropped in the rebase, ported to the current raw_request(extra_headers) (48/48 pass).

Real-image check: ran import_inventory.py --pe over all 16 shipped modules from the package (the probe msix payload): 1,557 imports across kernel32/msvcrt/api-ms/winhttp/crypt32/xmem/d3d12_xs/xaudio2_9 and the CRT chain — 0 unimplemented, matching docs/runtime_imports.md's measured claim end-to-end. xmem.dll and d3d12_xs.dll imports classify implemented where the tables serve them.

Generated with Devin

@NolanCotter

Copy link
Copy Markdown
Contributor Author

One more upstream-drift fix on top (fcbe7b7): test_mutations's v_mul_legacy_f32 anchor predated the denormal-flush pass on the translator, so the sabotage was matching zero bytes. Re-anchored on the flushed block; the mutation suite passes again. The other red tests on current main are already covered by open PRs (#3995, #4004, #3885).

@ray3242

ray3242 commented Nov 23, 2026

Copy link
Copy Markdown
Collaborator

@NolanCotter fcbe7b7 duplicates #3883 (claimed in #3796, open since earlier today). It re-anchors the same v_mul_legacy_f32 mutation in tests/semantic/test_mutations.py on the flushed block and keeps the same OpSelect → OpCopyObject sabotage. dcastell1, Tom1419-git and two others have already verified #3883 (Windows, x86 and macOS arm64).

The two edits rewrite the same lines, so whichever lands second conflicts. Could you drop fcbe7b7 from this PR, since it's otherwise about the loader and shims, and leave the anchor to #3883?

@NolanCotter
NolanCotter force-pushed the main branch 2 times, most recently from a8acad0 to 6e81f46 Compare November 23, 2026 00:05
@NolanCotter

Copy link
Copy Markdown
Contributor Author

Update — the console-ABI chain landed on this branch (claim: #3381). The D3D12 side of the ⚠️ table is now structurally complete end to end:

a6dff5bd — console-shaped command lists from device slot 12. CreateCommandList returns a ListProxy with a 160-slot vtable in the measured console order (PC order through 26, console-only extras 27–30, PC chain shifted +4 through 59, EndEvent 60, ExecuteIndirect 61, enhanced Barrier 146 → PC GCL7 80) and the measured console object body at +0x18. The write cursor is pinned at the record limits, so a title's inline record writers always take the vtable path — no console record decoding needed. Unmodelled slots are recorded with their argument words and return 0 without a wrong forward. Reset/ExecuteBundle/SetDescriptorHeaps unwrap allocator/list/heap proxies; queue ExecuteCommandLists unwraps the array.

2be25cee — PresentX + queue layout detection. The two measured queue layouts (older: Signal 14/Wait 15, PresentX 30, SignalX 23; newer: +2 shift, Signal 16/Wait 17, PresentX 32, SignalX 25) are detected by a fence reaching slot 16/17. SignalX forwards as PC Signal; PresentX lazily builds the windowed XboxPresentation core under LEONIDA_VULKAN_DEVICE. Console-only queue methods answer S_OK — frame pacing flows through them — and are never forwarded.

3c048373 / c3f435ec / b70161dc — AllocateUploadMemory (list slot 148) + VA translation. A bump arena of persistently-mapped UPLOAD-heap buffers; the title writes the mapped memory and the six root descriptor setters (console 41–46), IASetIndexBuffer (47), IASetVertexBuffers (48) and SOSetTargets (49, both VAs) translate arena CPU pointers to the chunk's buffer device address in a copied view — the CPU writes land in the same memory the GPU reads. Falls back to private memory when the device can't map a buffer.

a8acad0c — docs: README's Xbox D3D12 row updated (buffer SRVs, root sigs, pipelines, draws, placed resources, 1D textures, swapchain were stale as "missing"); the slot-148 note describes the arena.

Tested (clang-cl 20 + xwin cross-build, Wine)

  • xs_proxy_mock_test — PASS; new check_lists covers creation/unwrap, the pinned cursor, GetDevice, forwarded Dispatch, recorded-not-forwarded extras, slot 148 bump allocation/alignment and the root-SRV/IA/SO VA paths
  • loader_test — 87 checks, 0 failed
  • unimplemented_policy_test — 96 checks, 0 failed

Remaining gaps posted as finding: items in #3381 (list-tail +2 normalization, 32-bit descriptor-table records, PresentX struct layouts).

Written with AI assistance (Devin).

@NolanCotter

Copy link
Copy Markdown
Contributor Author

You're right — I missed #3883 when scanning open PRs for the mutation-anchor fix. Dropped fcbe7b7; the branch is now 425059b's stack rebased onto the shared fork history (current head cf2a45f, which is the collaborator shim/docs work — no test_mutations change from me). Leaving the re-anchor to #3883.

zneel pushed a commit to zneel/Leonida that referenced this pull request Nov 23, 2026
…nd preserve ClearDepthStencilView FLOAT Depth

device slots 17-24, and ItsNotRexed#2490 wraps console-ABI command lists in ListProxy, but
neither wires translate_cpu_handle into the five graphics command-list methods
that consume CPU descriptor handles:
- console slot 50 (PC 46): OMSetRenderTargets (RTV array / single-range + DSV)
- console slot 51 (PC 47): ClearDepthStencilView (DSV handle)
- console slot 52 (PC 48): ClearRenderTargetView (RTV handle)
- console slot 53 (PC 49): ClearUnorderedAccessViewUint (CPU handle; GPU kept)
- console slot 54 (PC 50): ClearUnorderedAccessViewFloat (CPU handle; GPU kept)

Also installs a typed WINAPI thunk for console slot 51 (ClearDepthStencilView):
on the Windows x64 ABI, FLOAT Depth (4th argument) is passed in XMM3 rather than
R9, so the generic all-uint64_t list_slot template dropped/clobbered Depth before
forwarding to the real list.

Adds synthetic mock coverage across all five slots (including single-range RTVs,
null/zero-RTV cases, count > 8 bounds safety, outside-range passthrough, and
XMM3 float preservation) plus an end-to-end WARP/Vulkan GPU clear and readback
check in device_proxy_test.

(cherry picked from commit 0aba6c3)
Raxstreams pushed a commit to Raxstreams/Leonida that referenced this pull request Nov 23, 2026
…its frames in

A GDKX title makes its own top-level Win32 window before its first PresentX, and PresentX names no window: on the PC
the frames belong in that window. Measured on a retail executable: by the first PresentX the process has one visible,
unowned top-level window on a thread of its own, and only hidden windows besides (IME, a driver's dummy window). The
PresentX wiring (ItsNotRexed#2490) built a hidden window of its own instead, so a running title showed a blank window.

find_title_window picks the visible, unowned, non-tool top-level window of the process with the largest client area.
It sends no message: a lookup that read window titles with GetWindowTextW (a WM_GETTEXT sent across threads) stopped
the retail title at its first PresentX, because the title's window thread was not pumping at that moment.

title_window_test makes the windows on a thread that never pumps; the negative control shows a sent WM_GETTEXT times out
there, while the lookup answers at once and skips the larger hidden, owned and tool windows.

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

Copy link
Copy Markdown

Tested 084c8bd09 merged onto main 867d922f0 (clean merge) on NVIDIA GeForce RTX 3060 (driver 616.92), Windows 11 26200, MSVC 14.52 (VS 2026), RelWithDebInfo + Ninja: pass.

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

@bobczan

bobczan commented Nov 23, 2026

Copy link
Copy Markdown

measured: on this stack, adding this PR alone turns a clean stop into a deterministic crash at device slot 15

This is an A/B on one base, so the only difference between the two rows is this PR. Windows 11, MSVC 19.44, RTX 5070,
driver 32.0.16.2124, retail 1.0.2.1, LEONIDA_D3D12=vulkan.

Base: main 6312c057f (the maintainer's TLS-index-0 and XErrorReport commits) + #8461 + #6964 + #8258,
built and run twice per row, 150 s timeout, fresh trace file each run.

Row Runs Result
base, without this PR 2/2 identical d3d12: QueryInterface: unknown IID {c3827890-4024-474c-98cf-645b51dc4874} — a clean stop
base + this PR 2/2 identical access violation immediately after device slot 15 (forwarded) first call

What the crash actually is. I instrumented the device proxy's generic forward for slot 15 and got:

self=… is_proxy=1  slot_count=80  real=<valid>  real_vtable_rva=0x42e028  fn_rva=0x257760

So the dispatch is well-formed: it is our own proxy, the real device and vtable are valid, and the target resolves
(against this build's PDB) to rt::d3d12::Device::GetDescriptorHandleIncrementSize,
runtime/shims/d3d12_vulkan_device.cpp:5955. That method's whole body is return kDescriptorSize; — it cannot
fault
. The trace records the exception as 0xc0000005 with the faulting address 0x0 and an empty stack, i.e.
control transfers to null around the call rather than inside the method body.

My reading, and it is a reading rather than a measurement: slot 15 of the vtable this proxy is calling is being entered
with an interface pointer for the wrong subobject (an adjustor/thunk mismatch on a multiply-inherited object), so the
jump lands on null. This PR rewrites how device-level slots are dispatched, which is where I would look first; the
method itself is not implicated.

What I changed to get this PR to build on that base, so you can reproduce it exactly: two conflicts, both unions —
device_slot_overridden() gained this PR's slot 12 alongside #6964's slot 26, and xs_proxy_mock_test.cpp's check list
kept both sides (check_custom_heap_properties + check_lists/check_signalx_detection/check_list_tail_names).
Nothing in either resolution touches slot 15, the device vtable, or the forward.

I am not touching the PR. Reproducer is deterministic (2/2 both rows), and the probe that names the symbol is the
is_proxy/fn_rva print in the device proxy forward — happy to hand over the exact patch if useful.

Slot numbers, symbol names and outcome only; no game data.

@bobczan

bobczan commented Nov 23, 2026

Copy link
Copy Markdown

Correcting the conclusion of the A/B above — the crash is the next stop, not something this PR introduces.

I ran the same base with #7076 instead of this PR, and got the same result: device slot 15 (forwarded) then a segfault, 2/2. The only difference is that the console list IID is now refused five times before it (this PR and #7076 each let the title get past the command-list stage by different means) rather than once, after which the run previously ended.

So the honest reading is: any PR that carries the title past the command-list stage arrives at device slot 15 and dies there. The A/B I posted showed that this PR reaches the crash earlier than a clean stop, but it did not show that this PR causes it — two different PRs do.

What stays true and useful: the crash is a call through our own device vtable slot 15 that resolves to Device::GetDescriptorHandleIncrementSize (d3d12_vulkan_device.cpp:5955, a return kDescriptorSize; body) yet faults at address 0x0. That is a real frontier stop worth its own issue, and I am filing it rather than blaming a PR.

Sorry for the extra comment; the first conclusion was not supported by the third data point.

@FRaccie

FRaccie commented Nov 23, 2026

Copy link
Copy Markdown

Code read of 084c8bd09 (the code below is unchanged since ef9d0759d). The slot map through console 53, slot 139 → PC Reset with the allocator and PSO unwrapped, the root-VA and IA/SO setters, and the arena guards look right to me. Three points not raised above:

  1. Queue slot 35 is answered S_OK and does nothing (runtime/shims/d3d12_xs_device.cpp:1213-1215). Every console queue slot at or past the 19 PC slots records "console-only" and returns S_OK. @Pipodi measured slot 35 as the title's ExecuteCommandListsX, so with this head the title's frame lists are dropped while the call reports success; the following SignalX is forwarded as a real Signal, so the fence completes and the title moves on with nothing executed. Before this PR the slot was logged and refused with E_NOTIMPL. This is a measured case of the tail-S_OK nit in @AwkGrep256's review (CI: Dependabot for GitHub Actions and the rpf9-explorer submodule #8), and a worse one: whole frames are lost, not only out-parameters. Refusing 35 explicitly, or routing it like queue slot 10 (ExecuteCommandLists(count, lists) through UnwrappedArray), would avoid it.

  2. Console list slots 54-60 are forwarded without a measurement (:1520, if (slot <= 59) return slot - 4;, plus 60 → EndEvent). The measured map stops at 53 → 49, and docs/d3d12_vulkan.md (around lines 3751 and 3847) records console slot 59 as a second indirect/mesh dispatch path, while this forwards it to PC 55 SetPredication. A dispatch arriving there would use its first word as a predication buffer (a bad object pointer on the host runtime; on the layer, predication over a bogus buffer or an invalid list). The file's own rule (comment near 1358) says a wrong forward is worse than a clean refusal, so keeping 54-60 at kListNotForwarded until a trace confirms them seems safer.

  3. The console list vtable has no end guard (:1779, static void* storage[kListSlots], 160 entries). The queue, fence and allocator tables sit at the end of a committed page in a PAGE_NOACCESS reservation with table_overrun_handler naming the slot; the list table doesn't, and the retail title already reaches 131/132/139/148. A call at 160 or above would read past the array and jump to whatever follows it, crashing at an unrelated address with no "list slot N" line. Putting it in the same guarded reservation as get_child_vtable would make that a named stop.

Not run: code read only, no game data.

dadnotdaddy pushed a commit to dadnotdaddy/Leonida that referenced this pull request Nov 23, 2026
…o ExecuteCommandLists

Squashed from ItsNotRexed#7286 by Vadson159, head e925b63 (security scan PASS).

Conflicts with ItsNotRexed#7290 (fence slot 12): the queue and fence slot constants are both kept, the header's queue/fence paragraph names slot 35 and fence slot 12, and the refused-tail loops skip both (queue_slot_overridden, fence slot 12). Reviewers' unwrapping bug (a list proxy reaching ExecuteCommandListsX) does not apply here: command lists are not wrapped in this tree (ItsNotRexed#2490 is not in).
dadnotdaddy pushed a commit to dadnotdaddy/Leonida that referenced this pull request Nov 23, 2026
…load arena, PC-list fixture path

Squashed from ItsNotRexed#2490 by NolanCotter, head ef9d075 (security scan PASS).

Taken at ef9d075, after upstream's revert (57c1753): this head keeps device proxies made by direct callers on PC-shaped lists (the run_tiny_frame regression), maps the console list IID, wraps slot-73 lists, and routes console list slot 139 (Reset) to PC slot 10. Security: prescan no flags, Haiku read PASS; the IID header cites a GPL-3.0 project as a second source for one GUID value measured from the executable (provenance note, no code taken).

Conflicts with Wave 2: the queue proxy keeps ItsNotRexed#7286's ExecuteCommandListsX (slot 35) ahead of this PR's console-layout detection, SignalX and PresentX, and queue_execute_command_lists now unwraps list proxies the way this PR's slot-10 path does (with list proxies in play, ItsNotRexed#7286's early return would have handed the real queue proxies, as ItsNotRexed#7286's reviewers predicted); fence slot 12 (ItsNotRexed#7290) and allocator slot 9 (ItsNotRexed#7949) stay in front of the queue block; device_slot_overridden takes slot 12 with the Wave 2 slots. Tests: queue_proxy_test and the mock's check_tail keep fence slot 12 and expect this PR's S_OK queue tail except overridden slots (35); the mock Kind enum keeps heap and list; the check list takes the union.
dadnotdaddy pushed a commit to dadnotdaddy/Leonida that referenced this pull request Nov 23, 2026
…T depth; list view counts are 32-bit (ItsNotRexed#2490 review)

Console list slot 51 forwarded PC ClearDepthStencilView through the integer thunk: the FLOAT depth travels in XMM3, which that thunk does not declare, and note_list_slot's first-call log clobbered it, so the first clear of each process took depth 0.0 (reproduced by Hiiva on ItsNotRexed#2490). The slot now has a typed WINAPI thunk. IASetVertexBuffers/SOSetTargets (console 48/49) read their UINT count from the low 32 bits of the register, as UnwrappedArray::fill does (review finding 6 on ItsNotRexed#2490).
dadnotdaddy pushed a commit to dadnotdaddy/Leonida that referenced this pull request Nov 23, 2026
…it now unwraps them (ItsNotRexed#7286 x ItsNotRexed#2490)

With ItsNotRexed#2490's list proxies, queue slots 10 and 35 both copy the list array and replace each list proxy by its real list, which reads every entry's vtable. ItsNotRexed#7286's check passed made-up addresses and faulted there; it now passes two readable non-proxy objects and checks that the mock's ExecuteCommandLists received them unchanged (the mock records queue slot 10's array).
dadnotdaddy pushed a commit to dadnotdaddy/Leonida that referenced this pull request Nov 23, 2026
…(out, proxy) on heap slot 8 and queue slot 18

Squashed from ItsNotRexed#8191 by auswhalen999-debug, head fb31ff1 (security scan PASS).

Applied as the PR's own diff (gh pr diff); head fb31ff1 as rescanned. Against ItsNotRexed#2490's queue proxy: the console C-ABI GetDesc check (out in RCX, queue proxy in RDX) runs first in the queue dispatch, before note_child_slot and ItsNotRexed#2490's layout detection, which would otherwise read the caller's buffer as a proxy; a proxy in RCX still takes ItsNotRexed#2490's slot-18 path (newer-layout frequency getter, or PC GetDesc). Mock: Kind keeps heap and list; the heap slot 8 and queue slot 18 GetDesc cases follow the existing heap/queue cases; check_get_desc_c_abi joins the list.
dadnotdaddy pushed a commit to dadnotdaddy/Leonida that referenced this pull request Nov 23, 2026
…namic statics in d3d12_xs, d3d12_xs_device and xgameruntime_offline

Squashed from ItsNotRexed#8178 by piyonchu, head aefa7be (security scan PASS).

Applied as the PR's own diff (gh pr diff). One pattern per file: d3d12_xs.cpp keeps ItsNotRexed#7957's global INIT_ONCE helpers (already on main), so this PR's local-static INIT_ONCE versions there are not taken; d3d12_xs_device.cpp and xgameruntime_offline.cpp take this PR's INIT_ONCE form. The device vtable's INIT_ONCE keeps ItsNotRexed#7078's slot 25/56 struct-return entries (this PR's version predates them), and ItsNotRexed#2490's list vtable gets the same INIT_ONCE form, since lists are made on title threads.
dadnotdaddy pushed a commit to dadnotdaddy/Leonida that referenced this pull request Nov 23, 2026
…ins the older queue layout first (ItsNotRexed#8191 x ItsNotRexed#2490)

ItsNotRexed#8191 was written against a queue proxy without ItsNotRexed#2490's layout detection. With it, an undetected queue answers PC-order slot 18 as the newer layout's frequency getter, which writes 8 bytes and cannot overrun the caller (ItsNotRexed#2490's rule, kept). The check now calls slot 16 with an out pointer first, which pins the older layout, where PC-order slot 18 is GetDesc. The console C-ABI GetDesc path that the retail title takes is unchanged.
@icecreammule277-dot icecreammule277-dot mentioned this pull request Nov 23, 2026
2 tasks
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.