Skip to content

xgameruntime: serve XErrorReport (rebase of #5312) - #6582

Open
Kam471 wants to merge 1 commit into
ItsNotRexed:mainfrom
Kam471:assist-5312-rebased
Open

Kam471 wants to merge 1 commit into
ItsNotRexed:mainfrom
Kam471:assist-5312-rebased

Conversation

@Kam471

@Kam471 Kam471 commented Nov 23, 2026

Copy link
Copy Markdown
Contributor

Rebase of #5312 for current main (the original head is conflicting). Original author: @dracbat; authorship is preserved. Branch Kam471:assist-5312-rebased, one commit on 1cc6e3c12.

xgameruntime.lib's thunks GetProcAddress XErrorReport from xgameruntime.dll. Without it, the GDK clients refuse the runtime: HCInitialize(NULL) -> 0x89240101, curl_global_init(3) -> 2, curl_easy_init() -> NULL.

Tested on the rebase base:

  • ctest -R '^xgameruntime': 8/8
  • run_tiny_gdk_load: 1/1
  • GDK probe against the package DLLs: XErrorReport non-NULL and S_OK; HCInitialize(NULL) = 0; curl_global_init(3) = 0; curl_easy_init() non-NULL
  • git diff --check clean; git merge-tree vs main exits 0.

The only conflicts were main's newer class lists in docs/runtime_imports.md and the class-list comment; both are kept, with the XErrorReport text added.

libHttpClient.GDK.dll and XCurl.dll reach the GDK runtime through
xgameruntime.lib's thunks: LoadLibraryW("xgameruntime.dll"), then
GetProcAddress of InitializeApiImpl, InitializeApiImplEx,
InitializeApiImplEx2, QueryApiImpl, UninitializeApiImpl and XErrorReport.
The shims served only the first five. Without XErrorReport the thunks
refuse the runtime before they call any initializer: under gta6rt --run,
HCInitialize returned 0x89240101 (E_GAMERUNTIME_DLL_NOT_FOUND) and
curl_global_init returned CURLE_FAILED_INIT.

XErrorReport is now served by the function behind IXErrorImpl slot 3, so
a report reaches the XErrorSetCallback callback either way.
xgameruntime_test and the tiny_gdk_load fixture check all six names and
that a report through the export reaches the callback.

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

hazben commented Nov 23, 2026

Copy link
Copy Markdown

Tested 4224c53b145ea9e68eb579817d772fe7276b943a (one commit on main 1cc6e3c12) on NVIDIA GeForce RTX 4070 SUPER (Ada), driver 621.14, Windows 11 (build 26200): pass. AI-assisted run, no game files.

  • Build: MSVC 14.44 (VS 2022), Ninja, RelWithDebInfo, Vulkan SDK 1.4.363.0, fresh build folder. Targets: gta6rt, tiny_gdk_load and the five xgameruntime_* tests. They compile and link. MSVC printed 5 warnings, none on a line this PR changes (xgameruntime_test.cpp lines 750, 770, 831 and 866, and xgameruntime_gamesave_test.cpp line 293).
  • ctest -R "^xgameruntime|^run_tiny_gdk_load$": 9/9 passed normally and 9/9 with LEONIDA_VK_VALIDATION=1. These tests print no Vulkan device line, so the GPU makes no difference here.
    • xgameruntime: PASS GetProcAddress serves the six names xgameruntime.lib looks up (five entry points and XErrorReport), PASS the XErrorReport export answers S_OK, xgameruntime_test: OK (144 checks)
    • run_tiny_gdk_load: the fixture run directly as the check script runs it (gta6rt --run tiny_gdk_load.exe -- host-shim-probe) prints [rt] xgameruntime: XErrorReport(0x80004005, tiny_gdk_load), then tiny_gdk_load: PASS and game exited with code 0
    • The user, gamesave, store and offline tests, which this PR does not change, still pass: 0 of 42 checks failed, 56 checks, 0 failures, 22 checks, 0 failures and 29 checks, 0 failures.
  • Negative control: I put main's runtime/shims/xgameruntime.cpp back in the PR tree and rebuilt. The PR's tests then fail: FAIL GetProcAddress serves the six names xgameruntime.lib looks up (five entry points and XErrorReport), FAIL the XErrorReport export answers S_OK (xgameruntime_test: 2 of 144 checks failed), and tiny_gdk_load: FAIL XErrorReport (0x0000007f), which is ERROR_PROC_NOT_FOUND. After I restored the PR's file and rebuilt, both tests passed again.
  • Full ctest, because xgameruntime.cpp is built into gta6rt: of 260 tests (gameinput disabled, no SDL3), 248 passed, 11 skipped and 1 failed normally. With validation, 248 passed, 10 skipped and 2 failed (vk_sync_validation runs only with validation on). The other skips are shader_library_corpus, the four Bink tests, fsr_dispatch, bvh_builder, d3d12_rgb9e5_rtv, d3d12_boot_movie and d3d12_first_light. All 8 xgameruntime* tests and all 16 run_tiny_* tests passed in both runs. Both failures also happen without this PR: each failed again when re-run alone, and main 1cc6e3c12, built in a separate worktree, fails both the same way:
    • d3d12_indirect_dispatch_count, in both runs: count 0 update 1: host 6/10, layer 0/0, expected 6/10 (d3d12_indirect_dispatch_count_test: its compute fixture reads the root UAV at s4:s5 (D3D-448 layout) #5792 is the open PR for that test).
    • vk_queue, with validation only: line 394: d.validation_errors() == 0, backlog: 256 submits, 63 command buffers allocated (cap 64), 3 waits timed out, validation errors: 10. The messages are synchronization WRITE_AFTER_WRITE hazards between vkCmdCopyBuffer submits on one queue. Without validation, vk_queue passes.
  • Python, from the PR tree: tests/test_gdk_runtime_calls.py ran 22 tests, OK. tests/test_docs_repo_paths.py (3), tests/test_docs_links.py (7) and tests/test_docs_env_vars.py (4) all report OK with the PR's docs/runtime_imports.md changes. git diff --check origin/main...HEAD printed nothing.

Not covered: the GDK probe against the package's libHttpClient.GDK.dll and XCurl.dll (HCInitialize, curl_global_init, curl_easy_init), because it needs the game files. So this run shows the shim serves XErrorReport, but not that the real thunks now accept the runtime. No Wine, Linux or Windows 10 run.

@Stalkerino

Copy link
Copy Markdown

Verified the export change from 4224c53b1 on CachyOS x86-64 with Wine 11.22 and a clang-cl/xwin build. All nine selected loader and GDK tests passed, including run_tiny_gdk_load. The synthetic caller resolves XErrorReport by name and the registered error callback receives its report.

I also compared two local startup runs on the same integration branch and Wine prefix, with the same experimental CPU-side XMem backing in both runs. Before this change the lookup of XErrorReport failed. With this change the lookup succeeds and execution reaches InitializeApiImplEx2. Startup later stops at a different point, before rendering. The GPU was disabled for this comparison.

@sneylol

sneylol commented Nov 23, 2026

Copy link
Copy Markdown

Tested 4224c53 against the retail exe: needed for boot.

The exe's runtime init looks up QueryApiImpl, the InitializeApiImpl* entry points, UninitializeApiImpl and XErrorReport on xgameruntime.dll, and returns E_GAMERUNTIME_DLL_NOT_FOUND if any of them is missing. Without this PR, the loader logs GetProcAddress(xgameruntime.dll, XErrorReport): not served and WinMain exits with 0x89240101. With it, InitializeApiImplEx2(gdk=10002, gs=7901, mode=0x2) succeeds. xgameruntime and loader tests pass.

Windows 11 26200, AMD RX 9070 XT, MSVC 14.44, Windows SDK 10.0.26100, own Xbox 1.0.2.1 package (with game_scarlett_master.exe). gta6rt --run with --overlay, inspected under cdb. Outcomes only; no game data, RVAs or traces.

AI-assisted (Claude Code).

@quackottu

Copy link
Copy Markdown
Contributor

Tested on the retail engine game_scarlett_master.exe (120,181,760 bytes, 1.0.2.1) under gta6rt --run, RTX 5070 / Windows 11, main 1cc6e3c + this PR + the other boot PRs named below. Outcomes only.

Needed and confirmed. WinMain's xgameruntime.lib stub requires XErrorReport to resolve and otherwise returns 0x89240101 and hits an int3 (exe+0x5a91c21). With this PR: InitializeApiImplEx2(gdk=10002, gs=7901, mode=0x2) succeeds and the title proceeds to DirectStorage (xcrdapi.dll!DStorageGetFactory, next blocker).

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

Hardware & Environment

  • Host: Windows 11 Build 26300 x64
  • CPU/GPU: AMD Ryzen / AMD Radeon RX 7900 GRE (16 GB VRAM)
  • Toolchain: MSVC 19.44 (Visual Studio 2022), CMake 4.4, Windows SDK 10.0.26100.0

Verification Summary

Targets compiled with MSVC 19.44 and verified natively:

  1. **\xgameruntime_test.exe**:

    • Passed with all 144 checks OK.
    • Verified resolution of all six GDK thunk names (\InitializeApiImpl, \InitializeApiImplEx, \InitializeApiImplEx2, \QueryApiImpl, \UninitializeApiImpl, and \XErrorReport).
    • Verified \XErrorReport\ export returns \S_OK\ and routes through to \XErrorSetCallback.
  2. \ iny_gdk_load\ Fixture & \gta6rt\ Runner:

    • Rebuilt \gta6rt.exe\ and ran
      un_tiny_gdk_load\ test under runtime loader.
    • Dynamic command line matching and run-time module resolution with \XErrorReport\ verified.
  3. CTest Suite:

    • All 9 xgameruntime tests passed (100%):
      • \xgameruntime: Passed (0.04s)
      • \xgameruntime_user: Passed (0.01s)
      • \xgameruntime_gamesave: Passed (0.03s)
      • \xgameruntime_store: Passed (0.01s)
      • \xgameruntime_offline: Passed (0.01s)
      • \xgameruntime_offline_hdr: Passed (0.01s)
      • \xgameruntime_user_gamertag: Passed (0.01s)
      • \xgameruntime_user_gamertag_long: Passed (0.01s)

      • un_tiny_gdk_load: Passed (0.08s)
  4. Hygiene & Compliance:

    • Clean-room compliant: zero game data or proprietary files used or referenced.
    • \git diff HEAD~1..HEAD --check: Clean (0 whitespace/formatting defects).

LGTM!

ASTROWwwW pushed a commit to ASTROWwwW/Leonida that referenced this pull request Nov 23, 2026
…(rebase of ItsNotRexed#5312)

Author: Kam471

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01UkEUa9YfGQH4p9g1Guw9gq
@ElsCiber

Copy link
Copy Markdown

Independent Windows + NVIDIA check of 4224c53b (base main 1cc6e3c1): pass on the synthetic tests. AI-assisted.

  • GPU: NVIDIA GeForce GTX 1660 SUPER (Turing, subgroup 32), driver 621.14, Vulkan 1.4.357

  • CPU: AMD Ryzen 5 3600; OS: Windows 11 Pro 26300

  • Build: MSVC (VS Build Tools 2022) + Ninja, RelWithDebInfo, Windows SDK 10.1.26100.7705, Vulkan SDK 1.4.363.0

  • ctest -R "xgameruntime|tiny_gdk|pe_loader|module_names": 13/13, including run_tiny_gdk_load.

  • Full ctest -j 4: 248/250. Both failures are also on main 1cc6e3c1 in the same run: d3d12_indirect_dispatch_count (d3d12_indirect_dispatch_count fails on main since #4312: cs_indirect_dispatch_count.comp still reads its root UAV from s0:s1 #6162), and d3d12_bindless_churn_validated, which failed once on both trees under -j 4 and then passed 3/3 alone.

I didn't run the GDK probe against the package DLLs, because that needs game files.

@Marukooh

Marukooh commented Nov 23, 2026 •

Copy link
Copy Markdown
Contributor

Independent retail startup comparison on CachyOS x86-64, Wine 11.22, clang-cl 23.1.5/xwin 0.10.0 SDK 10.0.26100, Release, RTX 5070 Ti / NVIDIA 620.73.04. Tested offline on my local 1.0.2.1 package with Vulkan enabled.

On the combined TLS + memory build, the synthetic xmem (156 checks), loader TLS, tiny-game TLS and TLS clone cleanup tests passed. The /GA fixture's positive slot-zero checks pass, with the already-reported Wine failure in its missing-temp negative case.

Outcomes only; all traces stayed local. AI-assisted (Codex).

Follow-up: the runtime parts of #4348 at 45c39cf6 reduced unimplemented imports from 22 to 21 on this stack. The subsequent offline run stopped at the same breakpoint as the XErrorReport build, before calling the DirectStorage factory. The 270/272 synthetic result reproduced the two guard-page timing failures already reported on #4348.

IAmNotSiob added a commit to IAmNotSiob/Leonida that referenced this pull request Nov 23, 2026

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

approve :) merged onto current main (one doc paragraph conflicted: kept main's XAccessibilityImpl/XLauncherImpl, your XErrorReport text) at IAmNotSiob:xerr-check. win10 VM, RTX 6000, MSVC: xgameruntime and run_tiny_gdk_load pass (the export reaches the XErrorSetCallback callback). the 7 failing tests on that box are d3d12/gameinput ones, the same set it fails without this pr. retail boot chain stop 3. AI-assisted (Claude Code).

@jtrudeau1530

Copy link
Copy Markdown

Independent retail-startup comparison on Arch Linux / Wine 11.18, clang-cl 23.1.6 + xwin SDK 10.0.26100, RelWithDebInfo, Vulkan and SDL3 enabled. RX 7900 XT / RADV Mesa 26.2.3; GPU work was not reached.

Base: main 8575d36 + #6919 36936f3 + #4313 28ea6b971. Before this PR, startup records five XMemVirtualAlloc attribute events, reports XErrorReport as not served, and hits a breakpoint.

With #6582 head 4224c53b145ea9e68eb579817d772fe7276b943a added (local integration revision e86f4b4baad9a9e94ef103361f57f72759eeb841), startup gets past that missing export and reaches InitializeApiImplEx2. Its next failure is Wine's builtin GameInputCreate stub, confirmed with the ginput trace channel, followed by the title's breakpoint. This run exits 3 within the 30-second bound.

The executable and matching PDB were built by a cooperating local tester from a frozen source snapshot; I independently verified all 747 tracked runtime/xtaskqueue files against the integration revision, copied the runtime artifacts with hashes, and ran both comparisons in the same private Wine prefix with networking disabled and the original package read-only. The only merge conflict for this checkpoint was the documented class-list paragraph; no code conflict or local runtime patch.

Adding #4348 alone to that checkpoint still reaches the same Wine GameInput stub. The existing ordinal-alias fix #7216 is being tested separately, so no DirectStorage or device progress is claimed from these runs. No game data or raw traces attached. AI-assisted.

@Roberto0953

Copy link
Copy Markdown
Contributor

@Kam471, the conflict with main is one paragraph of docs/runtime_imports.md: since this branch, main added XAccessibilityImpl and XLauncherImpl to the list of classes QueryApiImpl serves. I merged main 042c5f378 into your head and kept both: main's list, and your sentence on XErrorReport before it. Nothing else changed.

Branch: Roberto0953:rebase/6582-on-042c5f378 (61e858745). Your commits are untouched, and the merge sits on top of them, so git pull https://github.com/Roberto0953/Leonida rebase/6582-on-042c5f378 fast-forwards your branch.

Checked on Windows 11, i7-14700K, MSVC 14.44 RelWithDebInfo:

  • xgameruntime_test: OK (144 checks). CTest run_tiny_gdk_load: passed.
  • tests/test_docs_table_rows.py: OK. tests/test_docs_links.py fails on one link in docs/dev-tools.md, and it fails the same way on main 042c5f378.
  • Retail 1.0.2.1 executable (own copy), stacked with the other RT-5 PRs: without this PR, --run logs GetProcAddress(xgameruntime.dll, XErrorReport): not served and stops at the title's assert. With it, the title goes on to DStorageGetFactory (runtime: console DirectStorage (DStorageGetFactory) with file-to-memory reads #4348). This agrees with the "needed for boot" results above.

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

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.