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

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.

5 participants