Skip to content

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

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

NolanCotter wants to merge 6 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.

@Hiiva

Hiiva commented Nov 23, 2026

Copy link
Copy Markdown
Contributor

Independent native reproduction of the slot-51 FLOAT forwarding finding in #2490 (comment).

Tested the command-list code from ef9d0759d22e9a88515e7f56854c9db2b6ccc13f, composed over main dde82f27e994337094afc476ded0b1426f6e87e2 with #6964, #6954 and #6953. MSVC 19.44, Windows SDK 10.0.26100, x64 RelWithDebInfo.

A wholly synthetic probe creates a console list through the existing mock device, installs a correctly typed ClearDepthStencilView mock in real slot 47, and calls console slot 51 through the same typed signature:

Call Expected depth Received depth
Direct typed control 0.375 0.375
First proxy call 0.375 0.0
Second proxy call 0.625 0.625

The descriptor handle, flags, stencil, rectangle count and rectangle pointer are all forwarded correctly. The first-call failure is reproducible without any game input. The eight existing mock/WARP CTests still pass, so they do not catch this FLOAT-register path.

This confirms the existing finding on native Windows; no duplicate fix was added.

@DavidM1911

Copy link
Copy Markdown

Tested ef9d075, Windows 11, MSVC 14.50 (VS Build Tools 18), RelWithDebInfo, own 1.0.2.1 copy:

  • Full ctest: 110/110 passed, 0 failed (7 skipped for missing game files, 1 disabled) — includes xs_proxy_mock* (6 variants), unimplemented_policy, pe_loader, loader_tls, dll_thread_calls, all wait_registration_*, and every run_tiny_game*.
  • Retail game_scarlett_master.exe --dry-run: 5 modules mapped, 29 unimplemented imports — same set as main (this PR classifies the console DLLs; serving them is the job of the runtime: bind the 30 console imports the executable actually takes #7132-family stack, so no change expected here). xaudio2_9.dll!#1 and gameinput.dll!#1 classify under the HRESULT policy as described.

AI-assisted. No game files or game-derived bytes in this comment.

@Fran-co-F

Copy link
Copy Markdown

Independent test under Wine (AI-assisted, Claude Code), no game files.

Windows runtime cross-built on Linux (clang-cl 23.1.5 + xwin SDK 10.0.26100, RelWithDebInfo), CTest under Wine 11.17,
AMD Radeon RX 9070 XT (RADV GFX1201, Mesa 26.3.1), Ryzen 7 9800X3D, CachyOS.

  • At f34c71b this PR made d3d12_bindless_churn time out and d3d12_mesh fail at list->Close() == S_OK (5/5 each;
    both pass on that head's merge base). The current head fixes both: they pass with origin/main dde82f2 + this PR.
  • Full CTest with origin/main dde82f2 + this PR: 249/268, exactly the same 19 failures as origin/main alone under
    Wine, so no regression from this PR in this setup. Not run on native Windows.

@AwkGrep256

Copy link
Copy Markdown
Contributor

An AI review of ef9d075 (Claude Code ultrareview, multi-agent with a verification pass; I checked the main claims against the head before posting). Nine findings, most important first:

  1. normal: the M1.5 guest runners weren't given the PC-lists opt-in (d3d12_xs.cpp ~160-168). D3D12XboxCreateDevice now returns console-shaped lists unless LEONIDA_D3D12_LISTS=pc, and only check_tiny_frame.py sets it. runtime/test/run_guest_draw.cmake (~32) and scripts/run_guest_scene.py (~195) don't, so tiny_guest_draw's PC-index calls past slot 26 land on console methods (e.g. PC 28 SetDescriptorHeaps, 30 SetGraphicsRootSignature, 48 ClearRenderTargetView), and d3d12_translated_draw_guest / d3d12_guest_scene fail where the base passes. Fix: set it in both runners.
  2. normal: the upload arena never rewinds (AllocateUploadMemory, list slot 148, ~1431-1477). chunk->used only grows (written at 1461 and 1475, never reset), so per-frame transient uploads add a committed, mapped 8 MB UPLOAD chunk every 8 MB until teardown, and upload_translate's linear scan under the arena mutex gets slower every frame. Suggestion: a fence-tracked ring that resets used once the GPU is done.
  3. normal: PresentX frame tokens (queue_present_x ~1085-1093). The device's WaitFrameEventX (slot 80) hands out tokens from DeviceProxy::frame_next_token, while the fresh XboxPresentation pacer has issued none, so check_present_token refuses every tokened PresentX (E_INVALIDARG). PresentX: device-side WaitFrameEventX and the frame pacer share one token source #7685 (@Cattn) addresses this by sharing one token source.
  4. normal: queue slot 18 before the layout is known (~1180-1187). It goes to GetTimestampFrequency, so a PC-shaped or older-layout GetDesc (e.g. dxgi_com.cpp is_direct_present_queue) gets the 64-bit frequency written over Type/Priority and S_OK in RAX instead of the struct pointer. Suggestion: route it as the frequency only once the newer layout is known.
  5. normal: the PresentX window is never shown or pumped (~1068). CreateWindowExW(…, WS_OVERLAPPEDWINDOW, CW_USEDEFAULT, CW_USEDEFAULT, …) without WS_VISIBLE, and nothing in runtime/shims calls ShowWindow or runs its message loop, so presented frames go to a hidden window (and a shown one would ghost as "not responding"). @rafaelpssz suggested a pump on each PresentX; a dedicated UI thread that owns the window would also let DestroyWindow run on the owning thread.
  6. normal: IASetVertexBuffers / SOSetTargets counts (console 48/49, lines 1738 and 1749). assign(in, in + a2) uses the full 64-bit register as the UINT count; the upper half isn't guaranteed zero by the x64 ABI. Cast to std::uint32_t, as UnwrappedArray::fill does.
  7. nit: the upload-chunk CPU fallback (~1406-1427). When CreateCommittedResource/Map/GetGPUVirtualAddress fails on a real device, the VirtualAlloc buffer's CPU address is recorded as gpu_base and forwarded as a GPU VA to root CBV/SRV/UAV setters and IA/SO views. Suggestion: keep the fallback for mocks and return 0 from AllocateUploadMemory otherwise.
  8. nit: the queue tail's S_OK (~1213-1215). Unmeasured tail slots now answer S_OK without writing their out parameters, where they failed with E_NOTIMPL; e.g. a newer-layout GetClockCalibration (slot 19) before the layout is detected returns uninitialized clocks as success.
  9. nit: teardown and creation of the present state (1037, 72). ~PresentState calls DestroyWindow before its xbox member (presenter/swapchain) is destroyed; reset xbox first. present_state is a plain pointer created lazily without a lock, so two first PresentX calls on one device race (the sibling upload_state uses a compare-exchange for this).

AI-assisted.

@TripleJ160

Copy link
Copy Markdown

@NolanCotter I opened a small PR against your #2490 branch for a reference cycle exposed by the real PresentX queue route on Windows 11 / RTX 5090.

The device proxy owns the presenter, and the presenter retained the proxy. With the new regression alone, the proxy gained a reference and validation reported 29 leaked Vulkan device objects and one leaked surface. With the patch, the reference count check passed, both teardown errors disappeared, and the three focused CTests passed with validation off. The validated presentation test ran the ownership assertion, then took its existing NVIDIA sRGB skip.

I also verified the one-line #7685 integration on top of these two heads. The production queue now accepts the device-issued token while still rejecting the next unissued token. Integration results. Synthetic inputs only. AI-assisted.

@AAyberkU

Copy link
Copy Markdown
Contributor

Follow-up from #7685 (its author asked for the line to land here): once #7685 is in, present_state_for must hand the device's token source to the queue-side presenter. Otherwise every PresentX on the retail title returns E_INVALIDARG, because the title's tokens come from device slot 80 (device->frame_tokens) and the presenter's own pacer never issued any.

state->xbox = std::make_unique<rt::d3d12::XboxPresentation>(std::move(presenter), nullptr, device->frame_tokens);

Measured locally with this PR at ef9d075 plus #7685, #7880 and the other boot PRs: with that one change every PresentX returned S_OK for a 90 s run, about 100 per second. Without it, none did. I can't push to this branch, so here is the line. TripleJ160's integration commit (linked in #7913) carries the same change plus a fix for the presenter/proxy reference cycle.

on: Windows 11, MSVC RelWithDebInfo, RTX 5060 Ti, LEONIDA_D3D12=vulkan. AI-assisted (Claude Code).

@Doffi4

Doffi4 commented Nov 23, 2026

Copy link
Copy Markdown
Contributor

Independent synthetic check of the slot 139 Reset routing from ef9d075. On ramenbellic:boot/retail-stack f61af56 (including its slot 35 list-array unwrapping), I created a wrapped list via device slot 73, submitted it and waited on a fence. Then I reset the allocator and called console list slot 139, recorded new copies/barriers through console list slots 15/26, closed through slot 9, and resubmitted the same proxy through queue slot 35. Without the slot 139 mapping the test stopped after the correct first readback; with the mapping and allocator unwrapping both submissions returned 256/256 expected bytes, with different payloads. Windows x64 MSVC Release, Vulkan on Radeon 780M and RTX 5060 Laptop. This covers actual reset and reuse, not the remaining retail boot stop. Synthetic only; no game data. AI-assisted testing.

ramenbellic added a commit to ramenbellic/Leonida that referenced this pull request Nov 23, 2026
wcd6 added a commit to wcd6/Leonida that referenced this pull request Nov 23, 2026
…s) for the RT-5 boot

# Conflicts:
#	runtime/shims/d3d12_xs_device.cpp
#	runtime/test/xs_proxy_mock_test.cpp
@XIIYAZ

XIIYAZ commented Nov 23, 2026

Copy link
Copy Markdown

Retail boot test (RT-5): own 1.0.2.1 copy, Windows 11, i9-12900KF, RTX 3070 (NVIDIA 617.42), MSVC 2022 RelWithDebInfo, LEONIDA_D3D12=vulkan, gta6rt --run with the network shimmed by #6943. Local integration branch on main dde82f27e with, in order: #6943, #7125, #6010, #7133, #4313, #6582, #4348, #6964, #6953, #6954, #2490, #7218, #7021, #7066, #7110 (+#7078, #6973), #7052. Each PR was merged, rebuilt and the game rerun; the stop named below is the first failure without it and is gone with it. With all of them the run reaches stop 17 of docs/retail_boot_chain.md (#6982) after 1,640 D3D12 calls. Counts and outcomes only; nothing from the executable is quoted.

Result: clears stop 9 (slot 73 asked for the console command-list IID, CreateCommandList failed). With it the run goes from 13 to 1,181 D3D12 calls (all command lists created and closed, GetAdapter, frame interval/events). Conflicts with #6964 in device_slot_overridden and xs_proxy_mock_test.cpp; the union of both works and all proxy tests pass.

AI-assisted test run.

@NolanCotter

Copy link
Copy Markdown
Contributor Author

AAyberkU — noted and queued: state->xbox = std::make_unique<rt::d3d12::XboxPresentation>(std::move(presenter), nullptr, device->frame_tokens); lands on the next rebase after #7685 merges — both halves it needs (device->frame_tokens, the third ctor arg) are #7685's own additions, so it can't compile standalone. Keeping it out of the diff until then avoids stacking the PR on an open dependency; the integration commit in the #7913 thread covers the interim. Thanks for measuring the E_INVALIDARG → S_OK delta — that's exactly what the token-sharing was for.

Doffi4 — thanks for the independent slot-139 check; a reset→record→close→resubmit cycle through queue slot 35 is better coverage than the mock's (it exercises allocator state across Reset). Good to have it confirmed on both a Radeon 780M and RTX hardware.

XIIYAZ — appreciated; stop 9 → stop 17 on a fresh retail run with the current head is the strongest result yet for this slice.

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.