Skip to content

d3d12_xs: serve the runtime's 93 GUID data exports - #3675

Open
kotorvr wants to merge 2 commits into
ItsNotRexed:mainfrom
kotorvr:claude/d3d12-xs-iid-data
Open

kotorvr wants to merge 2 commits into
ItsNotRexed:mainfrom
kotorvr:claude/d3d12-xs-iid-data

Conversation

@kotorvr

@kotorvr kotorvr commented Nov 22, 2026

Copy link
Copy Markdown
Contributor

Claim (new item, no ID assigned yet)

AI-assisted (Claude Code). I ran everything under "Tested" on Windows.

Problem

docs/d3d12_xs_surface.md §2.2 lists 93 GUID data exports of the console d3d12_xs.dll (IID_ID3D12Device, DXGI_DEBUG_ALL, IID_ID3D12ConsDmaCommandList, ...). A title linked against the console import library imports them: the import address table slot then holds the address of a GUID, not of a function.

The shim table in runtime/shims/d3d12_xs.cpp has four function names and no data. Loader::resolve finds no shim, no bundled module and no host d3d12_xs.dll, and binds the import to the unimplemented-import thunk. The title reads the first 16 bytes of that thunk's code as its interface id. Nothing is ever called, so LEONIDA_UNIMPLEMENTED=stop does not fire and fail changes nothing; the first symptom would be a QueryInterface logging an unknown IID far from the cause.

Reproduced on main with a fixture DLL that imports three of them and is loaded by rt::Loader: all three bind as Unimplemented.

What is not known: whether the executable imports any. The package's own DLLs import none (the six console imports in docs/runtime_imports.md are all functions). This is a wrong answer waiting behind an import that may or may not exist, cheap to close before the executable arrives; it is not a crash I reproduced with a real title.

Change

  • runtime/shims/d3d12_xs_guids.inc (new, generated): one line per GUID, in ordinal order. tools/d3d12_xs_surface.py --inc PATH writes it (UTF-8, LF, by the tool itself, not a shell redirect) from the table that tool already holds and checks against the Windows SDK headers (83 standard values) and SCARAB's published list (10 console-only values, GPL-3.0, facts only; see the doc's §4). No value is new to the repository.
  • runtime/shims/d3d12_xs.cpp defines the 93 GUIDs from that file and registers each by name in the shim registry. The loader needs no change: a registry entry is an address, and for a data import the address of the data is what the slot must hold (the loader already binds module-to-module data imports, tiny_exported_value in pe_loader_test).
  • They are served by name only. 34 of the 93 ordinals are derived from an ordering rule in the doc, not read from the runtime, so an import by ordinal stays unserved and visible in --dry-run.
  • tests/test_d3d12_xs_surface.py regenerates the file with --inc and fails when the committed bytes differ.
  • docs/d3d12_xs_surface.md §2.2 says what Leonida serves.

Test

pe_loader_test takes a third fixture, tiny_iid.dll, linked against a stub d3d12_xs.dll whose GUIDs are zero (it lives in fixtures/stubs, so the loader cannot bind it as a bundled module). The test loads it through rt::Loader and checks, for a standard IID, a debug GUID and a console-only IID, that the import is Binding::Shim and that the 16 bytes the title would read are the expected GUID. The expected values are written out in the test, not taken from the table under test.

Tested

Windows 11 (build 26200), MSVC 19.44.35222, Visual Studio's CMake and ctest 3.31.6 with Ninja, RelWithDebInfo, built by scripts/build_runtime.ps1. Base f847748c (main). Windows SDK 10.0.26100.0.

  • pe_loader_test with the new fixture on main's d3d12_xs.cpp: 6 failures of 86 (each of the three imports is Unimplemented, and each read is not the GUID). With the change: OK, 86 checks.
  • ctest --test-dir runtime/build -C RelWithDebInfo with LEONIDA_GAME_DIR set: 140 run, 134 passed, 6 skipped, 0 failed (gameinput is disabled, no SDL3 here). NVIDIA GeForce RTX 4090, driver 32.0.16.2114, for the Vulkan tests in that run; this change needs no GPU.
  • python tools/d3d12_xs_surface.py --check --sdk: PASS, 83/83 standard GUIDs match the SDK. python -m pytest tests/test_d3d12_xs_surface.py: 8 passed, 1 skipped (the SCARAB cross-check, which needs a checkout); tests/test_docs_links.py: 5 passed. python -I on tests/test_docs_repo_paths.py, test_docs_list_items.py, test_docs_design_rows.py, test_docs_links.py: OK.
  • The C++ results above are from the first commit. The second commit changes only the tool's --inc option, the pytest, and two comment lines at the top of the .inc; the Python tests were rerun on it, the C++ was not rebuilt.
  • No game data: the GUIDs are Windows SDK values and ten published console IIDs already in tools/d3d12_xs_surface.py.

Overlap: #2098 adds function exports to the same shim table (different lines); #3520 edits tools/d3d12_xs_surface.py and its doc section on the four command-list IIDs that are not exported, which this does not serve either.

🤖 Generated with Claude Code

kotorvr and others added 2 commits November 22, 2026 21:11
A title linked against the console import library imports its interface ids from
d3d12_xs.dll as data: the import address table slot holds the address of a GUID.
The shim table had four function names and no data, so such an import fell through
to the unimplemented-import thunk and the title would read 16 bytes of thunk code
as its IID. Nothing is called, so LEONIDA_UNIMPLEMENTED=stop never fired.

The 93 names (docs/d3d12_xs_surface.md section 2.2) are now served by name from
runtime/shims/d3d12_xs_guids.inc, which tools/d3d12_xs_surface.py --inc writes from
the table it already checks against the Windows SDK; a pytest check fails when the
file and the tool differ. Ordinals are not served: 34 of them are derived.

pe_loader_test loads a fixture DLL that imports three of the GUIDs (a standard IID,
a debug GUID, a console-only IID) and checks the binding and the bytes read.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
A shell redirect of the tool's output gave CRLF on Windows and UTF-16 from
PowerShell 5.1, so the documented command did not reproduce the committed file.
--inc now takes the path and names its encoding and line ending; the pytest
regenerates the file and compares bytes.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>

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

ccd8aef on Windows: 86 loader checks passed. Three distinct PE data imports resolved and returned expected 16-byte GUIDs. Extended synthetic registry check (187 total) verified stable read-only addresses for all 93 names and executable memory for four functions. SDK 10.0.26100.0 independently confirmed 83 standard GUIDs, ten console values traced to the SCARAB-derived table. CPU only, AI-assisted.

@Maraco91

Copy link
Copy Markdown

Tested ccd8aef on Windows 11, MSVC 19.42 (VS 2022 Build Tools), Windows SDK 10.0.28000.0, NVIDIA RTX 3080 Ti, driver 616.56: pass

  • scripts\build_runtime.ps1: builds clean, including the two new fixture DLLs.
  • ctest -R pe_loader: passes.
  • Full ctest: 132 of 132 pass (the same 8 skipped and 1 disabled as on main here).
  • python -I tests/test_d3d12_xs_surface.py: OK, and under pytest 8 passed, 1 skipped (SCARAB, SCARAB_REF not set). The committed runtime/shims/d3d12_xs_guids.inc is byte-identical to what --inc writes on Windows, so the LF handling holds on a checkout made here.
  • Negative control: with runtime/shims/d3d12_xs.cpp restored to main and everything else kept, pe_loader_test ends "FAILED (86 checks, 6 failures)": for each of IID_ID3D12Device, DXGI_DEBUG_ALL and IID_ID3D12ConsDmaCommandList the import is reported -> Unimplemented and the read through it is wrong. That is the reproduction the description gives for main.

The values, checked against a different SDK than the one the tool's table names: python -I tools/d3d12_xs_surface.py --check --sdk --require-sdk with only Windows SDK 10.0.28000.0 installed gives "83/83 standard GUIDs match ...\Include\10.0.28000.0\um" and "PASS: 116 slots (23 functions + 93 GUID data), 83 standard + 10 console GUIDs". The 10 console-only values I could not check against anything here.

No blocker found.

AI-assisted (Claude Code); synthetic fixtures only, no game files.

@requiemsnkrp

Copy link
Copy Markdown

Tested ccd8aef1 (merged onto main f847748c) on NVIDIA GeForce RTX 3060, driver 32.0.16.1714, Windows 11, MSVC 19.51, Vulkan SDK 1.4.363.0: pass.

  • pe_loader (with LEONIDA_VK_VALIDATION=1): PASS d3d12_xs.dll!IID_ID3D12Device is bound by the shim registry (Binding::Shim), same for IID_ID3D12ConsDmaCommandList and DXGI_DEBUG_ALL, plus PASS and the title reads DXGI_DEBUG_ALL through it; pe_loader ... Passed 0.21 sec, pe_loader_bounds ... Passed 0.34 sec.
  • python tests/test_d3d12_xs_surface.py: exit 0, ok (SCARAB cross-check skipped: SCARAB_REF is not set, so the 10 console-only values were not cross-checked here).
  • Full ctest (-E "present|swapchain|frame_pacer"): 100% tests passed, 0 tests failed out of 127 (8 skipped/disabled, same as main: shader_library_corpus, bink_decode, fsr_dispatch, bvh_builder, bink_audio, gameinput, d3d12_rgb9e5_rtv, d3d12_first_light).

AI-assisted (Claude). No game files.

@FaKL-Code

Copy link
Copy Markdown
Contributor

Tested ccd8aef (merged onto main f847748) on NVIDIA GeForce RTX 4060 Ti, driver 610.88 (32.0.16.1088), Windows 11 26200, MSVC 14.51.36231 (VS 2026), Vulkan SDK 1.4.363.0, Windows SDK 10.0.26100.0: pass

  • Merges cleanly; no new compiler warnings against main.
  • ctest: 131 of 131 pass (same 8 skips as main). Loader test passes; validation run: 52 tests clean (2 skipped, as on main).
  • pe_loader -V: "OK (86 checks)"; the fixture's GUID imports bind as Binding::Shim (for example IID_ID3D12ConsDmaCommandList -> Shim). pe_loader_bounds: 50 checks pass.
  • python -I tools/d3d12_xs_surface.py --check --sdk --require-sdk: "83/83 standard GUIDs match" the 10.0.26100.0 headers; "116 slots (23 functions + 93 GUID data)".
  • --inc regenerated into a scratch folder is byte-identical to the committed runtime/shims/d3d12_xs_guids.inc. tests/test_d3d12_xs_surface.py passes (the SCARAB cross-check skipped: no SCARAB_REF here, so the 10 console-only values weren't checked).
  • Main has moved since (aa2988c); git merge-tree merges this head with it cleanly. I didn't rebuild on it.

AI-assisted (Claude).

@erickbobd

Copy link
Copy Markdown
Contributor

Confirmed an actual executable import covered by this PR, AI-assisted with Codex.

The local Series Minecraft Preview executable imports d3d12_xs.dll!IID_ID3D12Device as data. In the pre-change integration it was classified as UNIMPLEMENTED; with snapshot ccd8aef17e82cb5d39b2fa924746cf598350ae85, the binding is Shim and the package-wide unresolved count drops from 13 to 12. This supplies EXE evidence for the case that the PR description could previously only reproduce synthetically.

Validation on the same worktree:

  • A saved pre-change loader binds all three tiny_iid data imports as unimplemented; the updated loader binds all three as shims.
  • pe_loader passes its checks of the actual GUID bytes read through the fixture imports, alongside the Runtime: the mapped executable's module identity (GetModuleHandle/Ex, GetModuleFileName, GetProcAddress) #2075 identity checks.
  • pe_loader, run_tiny_game and run_tiny_tls_ga: 3/3 CTests passed.
  • tools/d3d12_xs_surface.py --check --sdk --require-sdk: 83/83 standard GUIDs match Windows SDK 10.0.26100.0.
  • The portable surface test script passes, including regeneration of the 93-entry table. The optional SCARAB checkout check was skipped.

The local title stack also needs #4313, #2075 and the direct XErrorReport(HRESULT, const char*) export from #5312 (forwarding to error_report(nullptr, hr, message) plus the table entry). It includes merged #4551, #4239's activation objects and only #3476's analytics class. The strict run still stops at xmem.dll!XMemTransferMemory, before reaching D3D12. Thus this confirms the data-import correction, not rendering or gameplay.

Environment: Windows 11 build 26200, MSVC 14.51, Ninja RelWithDebInfo, RTX 5070 Ti / driver 617.14. Offline functional testing; no GPU performance measurements or game artifacts.

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

Reviewed head ccd8aef17e82cb5d39b2fa924746cf598350ae85. Windows 11 26200, MSVC 19.44.35207, Ninja, RelWithDebInfo, Vulkan 1.4.363.

Rebased onto 561b65a83 in a scratch worktree. Green after the fix below: pe_loader 1/1 (86 checks), pytest tests/test_d3d12_xs_surface.py 9 passed 1 skipped; 93 data exports, 83 checked against SDK headers, 10 console-only. Red: reverting runtime/shims/d3d12_xs.cpp only gives 6 pe_loader failures (an imported GUID reads thunk bytes).

Blocker: it does not apply or build on main as-is. Three conflicts (docs/d3d12_xs_surface.md, runtime/CMakeLists.txt, tests/test_d3d12_xs_surface.py); after resolving them the build stops with multiple rules generate fixtures/stubs/RelWithDebInfo/d3d12_xs.dll, because main now builds d3d12_xs_stub into that folder with the same OUTPUT_NAME. Moving the new d3d12_xs_iid_stub output to fixtures/stubs/iid/ (one line) builds and passes all of the above. I did not push that change.

Verdict: content correct, needs the rebase plus that one-line output-dir fix. First-frame relevant: an unserved imported GUID binds to the unimplemented-import thunk, so the title reads code bytes as its interface id. No duplicate in the open list; #4500 touches the d3d12_xs proxy but not its data exports.

@erickbobd

Copy link
Copy Markdown
Contributor

Integration note for ccd8aef1, merged locally onto main 8575d36e together with other open PRs.

When the configure finds Vulkan headers, main builds tiny_frame and its d3d12_xs_stub, which writes d3d12_xs.dll to fixtures/stubs/$<CONFIG>. This PR's d3d12_xs_iid_stub has the same OUTPUT_NAME d3d12_xs and the same folder, so Ninja refuses the build tree before compiling anything:

ninja: error: build.ninja: multiple rules generate fixtures/stubs/RelWithDebInfo/d3d12_xs.dll

Giving the iid stub its own folder (fixtures/stubs_iid/$<CONFIG> for both RUNTIME_OUTPUT_DIRECTORY and ARCHIVE_OUTPUT_DIRECTORY) fixes it here. Nothing else refers to that path, the stub still stays out of tiny_iid's folder, and pe_loader (with the tiny_iid argument) passes in the full ctest run.

The PR also conflicts with current main in docs/d3d12_xs_surface.md, runtime/CMakeLists.txt, runtime/shims/d3d12_xs.cpp (next to #6792's configure_virtual_memory) and tests/test_d3d12_xs_surface.py. Each one resolved by keeping both sides.

Windows 11 26200, MSVC 14.51, Ninja RelWithDebInfo, Vulkan SDK 1.4.363.0, RTX 5070 Ti / NVIDIA 617.14. Synthetic fixtures only, no game files. AI-assisted (Claude Code).

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.

7 participants