Skip to content

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

Open
NolanCotter wants to merge 2 commits into
ItsNotRexed:mainfrom
NolanCotter:main
Open

NolanCotter wants to merge 2 commits into
ItsNotRexed: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
Contributor

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
Contributor

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

@NolanCotter

Copy link
Copy Markdown
Contributor Author

@gertify both addressed — and a clarification on which head you ran:

  • Markers: the docs/fssm_crosscheck.md / docs/README.md conflict markers were real on the old head 92e7a043 — that's why the maintainer reverted. This PR was rebased and re-scoped after the revert: head is now 446a1549 (the console-ABI slice only) + 04276510. fssm_crosscheck.md was dropped entirely (it duplicated content run_wine_tests: reject malformed CTest inventories before launching #2479 already documented on main) and docs/README.md was repaired — git grep '^<<<<<<<' over the whole tree at this head finds nothing.
  • LEONIDA_D3D12_LISTS undocumented: real failure, fixed in 04276510 — the variable is now named in docs/d3d12_xs_console_abi.md §5.3 where the two list layouts are defined. unittest discover -s tests -p 'test_docs_*.py' is 33/33 OK on this head.

@Kam471 Kam471 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.

Superseded by #5731 + #5732:

  • #5731 reworks the loader host-binding fix and module identity. At 2e0f1a297 it passes 8/8 loader ctest — including run_tiny_frame (OK), the regression that caused this PR to be reverted — plus loader 90 checks, unimplemented_policy 105, pe_loader_bounds 54. A static import of xgameruntime.dll!XErrorReport now reports UNIMPLEMENTED instead of binding the System32 namesake, and GetModuleFileNameW(NULL) returns the mapped guest path.
  • #5732 is the tooling half (import_inventory, hello_pixels), stacked on #5731.

Recommend closing this in favor of the two slices; the reverted history is preserved in the commits.

@NolanCotter

Copy link
Copy Markdown
Contributor Author

@Kam471 this one isn't superseded — it's the third slice of the split. Per the maintainer's request the original PR became three pieces:

Current diff vs 561b65a83: 32 files, +1391/−71 — all console-ABI, zero overlap with the two split PRs (you can check: git diff --name-only lists no pe_loader/library_loader/registry/tools files). Closing it would drop the upload arena, the console command-list proxy, and PresentX — the largest chunk of the original PR. It's kept on this PR deliberately so the ~dozen hardware verifications in the comments above stay attached to the code they verified.

Happy to retitle again if the current title doesn't make the slice scope clear enough — what would help?

@CryingLaughing

Copy link
Copy Markdown
Contributor

Native RTX 4080 retest of the split console ABI at 04276510 on Windows 11 build 26200, NVIDIA 621.01, MSVC 19.44 RelWithDebInfo and Khronos validation 1.4.357. run_tiny_frame, queue_proxy, d3d12_com, and the four xs_proxy_mock CTests passed (7/7). A direct gta6rt --run --trace-d3d12 run with LEONIDA_D3D12_LISTS=pc bound D3D12XboxCreateDevice to the shim, logged 19 contiguous successful/called trace entries, and read back all 32 expected clear-colour pixels. The trace includes ClearRenderTargetView followed by Close ok, submission and fence completion. The loader reported exit 0 with zero Vulkan validation errors. Synthetic fixture only. AI-assisted with Codex.

@NolanCotter

Copy link
Copy Markdown
Contributor Author

@CryingLaughing thanks — that's the first full trace verification on the split slice specifically, and it confirms the console-ABI work stands alone after the rebase: ClearRenderTargetView → Close ok → submission → fence completion with zero validation errors, plus all 32 clear-colour pixels read back. 7/7 console tests on top of that closes the RTX 4080 coverage at this head.

@shipped-it

Copy link
Copy Markdown

Tested the new head 04276510 (post-rebase/split slice) on Linux (Arch), Wine 11.20 under Xvfb, GPU AMD RX 7900 XTX (RADV NAVI31): clang-cl 23.1.3 + lld-link 23.1.5 cross-build against xwin SDK 10.0.26100, ctest through Wine.

  • Build clean. Targeted ctest (-R "tiny|proxy|loader|queue|device|unimplemented|mods|code_hooks|draw|present|compute", 56 tests): 49/56 pass. The 7 failures (vk_queue, vk_presenter_sync, d3d12_present, xbox_present, device_proxy, device_proxy_trace, run_tiny_game_abort_exit_codes) all fail identically on origin/main @ 561b65a83 built in the same environment (headless Wine) — no regressions from this PR.
  • run_tiny_frame passes at this head (0.21 s) — the exact failure that got the old head reverted (console slot 48 vs PC ClearRenderTargetView); check_tiny_frame.py now sets LEONIDA_D3D12_LISTS=pc. xs_proxy_mock ×4, queue_proxy, unimplemented_policy all pass.
  • @gertify's two findings at 92e7a043 are fixed at this head: git grep '^<<<<<<<' over the tree is clean, and unittest discover -s tests -p "test_docs_*.py" runs 33 tests OK; LEONIDA_D3D12_LISTS is documented at docs/d3d12_xs_console_abi.md:175.

AI-assisted (omp coding assistant).

@NolanCotter

Copy link
Copy Markdown
Contributor Author

@shipped-it the strict same-environment A/B is what this slice needed — 7/7 Wine failures identical on origin/main rules out any regression, and run_tiny_frame passing at 04276510 closes the loop on the revert-triggering slot-48 failure in the same environment family that originally saw it. Thanks for confirming both of gertify's findings land at this head.

NolanCotter added a commit to NolanCotter/Leonida that referenced this pull request Nov 23, 2026
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>
@NolanCotter

Copy link
Copy Markdown
Contributor Author

Rebased onto current main f6c6d11e — head is now fbfe45d6 (same 32-file console-ABI slice, +1391/−71). One textual conflict: upstream added --queue-test-settings env handling in check_tiny_frame.py where LEONIDA_D3D12_LISTS=pc is set; both kept. Verified: xs_proxy_mock_test PASS and queue_proxy_test runs through the child-runner section that fails identically on unmodified main under headless Wine (pre-existing env limit), test_docs_*.py 33/33 OK, no conflict markers. The rebase also sits cleanly with upstream's #5110 queue-sharing work — d3d12_xs.cpp auto-merged and the mock suite exercises it.

NolanCotter and others added 2 commits November 23, 2026 07:21
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>
@NolanCotter

Copy link
Copy Markdown
Contributor Author

Rebased again onto 338f242a — head 2abf0cd9. One conflict: upstream's 9c5b3a1b README dedup vs our status row — resolved keeping upstream's cleaned table plus the [console ABI] link. Docs tests 33/33 OK, no markers.

@devnull34 devnull34 left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Verified at head 2abf0cd on Windows 11 with MSVC 19.44 on AMD Radeon RX 7900 GRE (RDNA3, gfx1100):

  • Build: Clean compile and link for targets xs_proxy_mock_test and queue_proxy_test with 0 warnings/errors.
  • xs_proxy_mock_test.exe: PASS (9 allocations refused on purpose). Verified console-shaped list ABI (160-slot vtable, cursor pinning, dispatch/extras forwarding), bump arena AllocateUploadMemory bounds checking, and queue detection.
  • queue_proxy_test.exe: PASS (3 backend(s) passed: Vulkan device proxy, queues, fences in both release orders, no leaks, copies through queue proxy read back intact, residency unwrapped).
  • Formatting: git diff --check 338f242..HEAD is clean with no trailing whitespace or leftover conflict markers.

No retail game files or keys used.

AI-assisted verification.

@thehollowedone

Copy link
Copy Markdown

Independent native Windows 11 check of 2abf0cd9. RTX 3080 Ti, NVIDIA 621.35, MSVC 19.44, Vulkan SDK 1.4.363.0.

The stock run_tiny_frame test passed using the PC command-list path. All 32 pixels read back as RGBA (64, 128, 191, 255). Khronos core and synchronization validation reported zero errors. A focused d3d12_com run also passed the clear and readback and valid bundle cases. Both runs used synthetic inputs.

AI-assisted.

NolanCotter added a commit to NolanCotter/Leonida that referenced this pull request Nov 23, 2026
Shim-owned modules (xgameruntime, gameinput, d3d12_xs, xmem) no longer
bind to their real System32 namesakes in resolve() or forwarded
exports — an unregistered console import now ends unimplemented
instead of reaching a host Gaming Services call. LoadLibrary's
file-name rule keys imports so "TestShim", "testshim.dll." and
"testshim.dll" hit the same shim.

registry gains the ordinal classes: gameinput ItsNotRexed#1 and xaudio2_9
(ItsNotRexed#1, and host-only ItsNotRexed#8-ItsNotRexed#10) classify as HResult.

GetModuleHandle(nullptr) answers with the mapped main image and
GetModuleFileNameA/W answer for bundled modules' stored paths
(Win32 spelling, Z: under Wine) through two new BundledModuleOps.
loader_test pins the name-rule binding; unimplemented_policy_test
pins the ordinal classes.

Split from ItsNotRexed#2490 (first of three). AI-assisted. Tested on the build
host under Wine/clang-cl: loader_test 88/0, unimplemented_policy_test
96/0.

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

@devnull34 thanks — first queue_proxy PASS on the post-rebase head (2abf0cd9) on RDNA3 native Windows, with the three-backend check and leak accounting clean. That covers the upstream #5110 queue-sharing merge this slice now sits on.

@NolanCotter

Copy link
Copy Markdown
Contributor Author

@thehollowedone thanks — another clean native pass on 2abf0cd9, this time Ampere (3080 Ti) with validation layers zero. That's the PC-list path through run_tiny_frame plus d3d12_com clears/bundles confirmed on the rebased head.

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.