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.

@Silliana

Copy link
Copy Markdown

Measured in a local integration on main 9f53c50: with this merged, xgameruntime.dll resolves XErrorReport through the shim registry and the package's own libHttpClient/XCurl initialisation gets past the E_GAMERUNTIME_DLL_NOT_FOUND stop, so the run reaches device creation.

This is a rebase of #5312, which serves the same five entry points plus XErrorReport. #5312 is the duplicate; suggest it closes and any unique test coverage moves here.

No action requested beyond marking the duplicate - the shim side is unchanged either way.

@DavidM1911

Copy link
Copy Markdown

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

  • Full ctest: 105/105 passed, 0 failed (skips are the usual game-file-gated ones), including xgameruntime, xgameruntime_test additions and run_tiny_gdk_load.
  • Independent confirmation of the premise on the retail exe: on main-equivalent runtime the title's xgameruntime.lib init thunk resolves six names — QueryApiImpl, InitializeApiImpl, InitializeApiImplEx, InitializeApiImplEx2, XErrorReport, UninitializeApiImpl — and treats the missing XErrorReport (GetProcAddress → NULL) as fatal: the thunk returns a failing HRESULT and the title takes its deliberate int3 path before InitializeApiImplEx2 is ever called. With the export served (local experiment), the same path proceeds: InitializeApiImplEx2 runs, QueryApiImpl serves the threading/networking/user classes, and boot continues to the next documented stop. Matches docs/retail_boot_chain.md row 3.

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

@KevinPratap

Copy link
Copy Markdown

Tested 4224c53b1 on RTX 4050 Laptop (NVIDIA 592.82), Windows 11, MSVC 14.44 RelWithDebInfo, LEONIDA_D3D12=vulkan, own 1.0.2.1 copy, gta6rt --run with outbound network blocked: pass.

Merged onto main dde82f27e with #4313. Before it, the loader logged GetProcAddress(xgameruntime.dll, XErrorReport): not served and the title hit a fatal assert just past its entry point. With it, InitializeApiImplEx2 succeeds (offline) and the run reaches the next stop, DStorageGetFactory (#4348).

The only conflict is the xgameruntime.cpp paragraph in docs/runtime_imports.md. Since this branch, main added XAccessibilityImpl and XLauncherImpl to that paragraph's class list, so a rebase should keep them alongside the XErrorReport sentence.

Traces stay local; no addresses or game data here. AI-assisted (Claude Code).

@shayderrr shayderrr left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Summary

The offline xgameruntime shim now exports the sixth name the package's GDK thunks resolve: XErrorReport(HRESULT, const char*), implemented as error_report(nullptr, hr, message) — the same function as IXErrorImpl slot 3 — and registered in SHIM_TABLE. The docs, library_loader.cpp comment, tiny_gdk_load.cpp fixture, and xgameruntime_test.cpp all move from five to six names; the fixture sets XErrorSetCallback through XErrorImpl and asserts the export reaches that callback.

Why merge

Without XErrorReport, libHttpClient.GDK.dll and XCurl.dll refuse the runtime before any initializer (0x89240101 / CURLE_FAILED_INIT), so adding it is required for those DLLs to boot offline.

Verdict: Approve

@shayderrr

Copy link
Copy Markdown
Collaborator

Summary

The offline xgameruntime shim now exports the sixth name the package's GDK thunks resolve: XErrorReport(HRESULT, const char*), implemented as error_report(nullptr, hr, message) — the same function as IXErrorImpl slot 3 — and registered in SHIM_TABLE. The docs, library_loader.cpp comment, tiny_gdk_load.cpp fixture, and xgameruntime_test.cpp all move from five to six names; the fixture sets XErrorSetCallback through XErrorImpl and asserts the export reaches that callback.

Why merge

Without XErrorReport, libHttpClient.GDK.dll and XCurl.dll refuse the runtime before any initializer (0x89240101 / CURLE_FAILED_INIT), so adding it is required for those DLLs to boot offline.

Verdict: Approve

@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 3 (GetProcAddress(xgameruntime.dll, XErrorReport) was the last line before the fatal int3). Only docs/runtime_imports.md conflicts with current main.

AI-assisted test run.

@SirKingg

Copy link
Copy Markdown
Contributor

Independent Windows Sandbox integration check of 4224c53b1 with TLS PR #8379 at a9085b661 (network disabled; package and executable read-only; fresh overlay per run). I applied this PR's code and test hunks in a temporary comparison checkout; its documentation hunk was excluded because it conflicts with the newer baseline.

  • TLS-only: 2/2 runs stopped at a missing XErrorReport lookup with 0x80000003.
  • Combined: 2/2 runs passed --dry-run and --init, reported the offline runtime initializer, no longer logged the missing lookup, and reached a different guest breakpoint (0x80000003). No D3D12 calls were recorded. The next breakpoint's cause is not established.
  • Windows 11 / MSVC 2022 / RelWithDebInfo: xgameruntime, run_tiny_gdk_load, loader_tls_index0, and run_tiny_tls_ga CTests passed (4/4).

Only counts and error classes are shared; traces stay local. AI-assisted.

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.