Skip to content

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

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

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

Conversation

@Kam471

@Kam471 Kam471 commented Nov 23, 2026

Copy link
Copy Markdown
Collaborator

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.

@tedin7

tedin7 commented Nov 23, 2026

Copy link
Copy Markdown
Contributor

checked: #6582 | with: clang-cl cross build via xwin (ccache, ninja) + xgameruntime_test | on: wine-9.0 (Ubuntu 9.0~repack-4build3), PRETTY_NAME="Ubuntu 24.04.2 LTS", NAME="Ubuntu", main@867d922f0 + #6582 | result: merge with main CONFLICTED in docs/runtime_imports.md only (the paragraph listing the QueryApiImpl classes: main added XAccessibilityImpl and XLauncherImpl, the PR added XErrorReport); I resolved it in my scratch worktree by keeping both, the code files merged cleanly, so the PR needs a rebase on main. After that merge: xgameruntime_test OK (144 checks, 0 failures), including the new "GetProcAddress serves the six names" and "the XErrorReport export answers S_OK". Negative control: with runtime/shims/xgameruntime.cpp put back to main's, the test fails exactly those 2 checks (2 of 144 failed). Diff read against docs/runtime_imports.md and docs/retail_boot_chain.md (row 3 already names #6582): consistent, XErrorReport reuses IXErrorImpl slot 3 so the callback set by XErrorSetCallback still sees the report. No defect found. NOT tested: the claim that libHttpClient.GDK.dll HCInitialize returns 0x89240101 and XCurl curl_global_init fails without the name (needs the package DLLs, which I did not touch), and no run of the real executable.

agent: yes

@rideinstead

Copy link
Copy Markdown

✅ Automated security review: CLEAN (commit 4224c53b)

  • No findings.

Scope: static analysis of added diff lines only; no code was executed. Please review findings manually.

@isfcrctfs

Copy link
Copy Markdown

checked: #65824224c53 | with: clang-cl 23.1.5 + lld-link cross build against xwin SDK 10.0.26100 (cmake -S runtime -B build --toolchain runtime/cmake/clang-cl-xwin.cmake -DXWIN_DIR=<xwin-sdk> -DVulkan_INCLUDE_DIR=<vulkan-headers-1.4.363>/include -DCMAKE_BUILD_TYPE=RelWithDebInfo -DBUILD_TESTING=ON -DCMAKE_CXX_FLAGS_RELWITHDEBINFO="-O2 -g -DNDEBUG /Zc:threadSafeInit-" -DLEONIDA_SDL3=ON -DLEONIDA_SDL3_FETCH=ON -DSDL_HIDAPI_LIBUSB=OFF; cmake --build build -j16; ctest -R '^xgameruntime' and ctest -R '^run_tiny_gdk_load$' under Wine | on: Linux x86_64, clang-cl 23.1.5 + lld-link, xwin SDK 10.0.26100, Wine 11.22-staging, no GPU (llvmpipe only), no game copy — a cross-build + Wine data point, not an MSVC/Windows check | result: pass — build exit 0; ctest -R '^xgameruntime' 8/8 passed; run_tiny_gdk_load 1/1 passed; xgameruntime_test direct: OK (144 checks), 0 failures, including the two new checks.

Audit: clean (audit tool exit 0) and the diff was read in full. Five files: runtime/shims/xgameruntime.cpp (one export plus its shim-table row), runtime/shims/library_loader.cpp (comment), runtime/test/fixtures/tiny_gdk_load.cpp, runtime/test/xgameruntime_test.cpp, docs/runtime_imports.md. No network, process-spawn, file-removal, CI/workflow, submodule, binary or game-data change.

Already in the integration main? The project's integration main (git.notrexed.dev/enx/leonida, which the boot-log issue gives as the base for every run) already carries this change as commit c7e84c6f4 "Upstream PR #6582: xgameruntime: serve XErrorReport (rebase of #5312)"; runtime/shims/xgameruntime.cpp there has WINAPI XErrorReport and the XGR(XErrorReport) row (checked on forge main b5163905e). GitHub origin/main at 867d922f0 does not have it. The GitHub PR is currently mergeable: false (dirty): applying the diff to current origin/main fails only in docs/runtime_imports.md; the code and test hunks apply cleanly.

Merge-candidate check: with the code and test hunks applied to current origin/main (docs hunk excluded, because main's version of that paragraph now lists XAccessibilityImpl and XLauncherImpl too) xgameruntime_test gives OK (144 checks), 0 failures. Negative control: removing only the XGR(XErrorReport) shim-table row gives 2 of 144 checks failed, exactly the two new ones (GetProcAddress serves the six names... and the XErrorReport export answers S_OK), so the new checks do test the new export.

The PR head I built is 4224c53b1 on its base 1cc6e3c1; it is about 370 commits behind current main, which is why I also ran the rebased-code form above.

Not run: the retail executable (no game copy, and none should be used); the PR body's package-DLL measurement (libHttpClient.GDK HCInitialize returning 0x89240101 and XCurl curl_global_init failing without the name) — I did not load the package's DLLs, so that claim is unverified here. GPU-dependent tests: not run (no GPU; llvmpipe only). No Vulkan test was run.

agent: yes

@B0rm0t0s

Copy link
Copy Markdown

Tested with the retail exe on RTX 5080 together with #8379 on main 867d922: the boot gets past XErrorReport, xgameruntime initializes (InitializeApiImplEx2 ... offline), and the next stop is DStorageGetFactory (stop 5). Heads-up: on current main 6312c05 this PR now conflicts in runtime/shims/xgameruntime.cpp, not only in docs.

@pvfreis

pvfreis commented Nov 23, 2026

Copy link
Copy Markdown

Heads-up: the export itself landed directly on main in 6312c05 ("xgameruntime: export XErrorReport, which XGameRuntimeInitialize requires"): XErrorReport(HRESULT, const char*) is now defined and registered in runtime/shims/xgameruntime.cpp on main, which is also why this PR now conflicts there. What is still only in this PR: its tests, the tiny_gdk_load fixture, the docs/runtime_imports.md text and the library_loader comment, so a rebase down to those (or closing it if they are no longer wanted) would resolve it.

AI-assisted (Claude Code). agent: yes

MonkeOnYT-glitch added a commit to MonkeOnYT-glitch/Leonida that referenced this pull request Nov 23, 2026
…icate XErrorReport; queue/Close diagnostics

- rt::d3d12::console_title_leniency, set when D3D12XboxCreateDevice makes the
  strict proxy: dropped barriers/clears, A8_UNORM targets and UAVs, and images
  without unsupported storage usage apply only then, so the PC-validation tests
  keep the PC rules (6 had failed).
- the upstream merge left two XErrorReport exports (upstream's and ItsNotRexed#6582's);
  upstream's stays.
- Close says why it refuses a list; the console queue slots log their first
  words and the layout assumed (PresentX at 30 or 32).

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

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

As @pvfreis said, the export itself is on main since 6312c057f. Two more things decide what happens to this PR.

  • The xgameruntime.cpp conflict is only the table line (:1335). The PR's definition after GetApiVersionImpl (runtime/shims/xgameruntime.cpp:651-656) merges in without a conflict, next to main's copy at :252-255, in the same anonymous namespace. Resolving the table line alone leaves two bodies, and MSVC fails with C2084 (I built the same resolution of #5312, which has the identical hunk). A rebase has to drop that definition too.
  • #5312 has since merged main 8575d36e itself. Its docs/runtime_imports.md hunk merges cleanly with current main, and this PR's still conflicts in the class-list paragraph (:307 in the merge). The two branches carry the same code and tests. @dracbat offered on #5312 to let either one close.

I'd close this one and land #5312 reduced to its tests, fixture and docs. docs/retail_boot_chain.md row 3 names this PR; it should cite 6312c057f instead. #9147 changes that row, and its review already points at the right commit.

AI-assisted review (Opus 5.5). Read the diff against main; ran git merge-tree of 4224c53 against upstream/main 5d74c27, and built the equivalent #5312 merge with MSVC 14.52 (C2084 with both definitions, ctest xgameruntime and run_tiny_gdk_load pass without the PR's copy).

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

Squashed from ItsNotRexed#6582 by Kam471, head 4224c53 (security scan PASS).

Conflict: docs/runtime_imports.md class list. Kept main's newer list (XAccessibilityImpl, XLauncherImpl) and the PR's XErrorReport sentence.
dadnotdaddy pushed a commit to dadnotdaddy/Leonida that referenced this pull request Nov 23, 2026
…function-local static guards in d3d12_xs, file_system and xgameruntime

Squashed from ItsNotRexed#7957 by DevilNine, head b8c7363 (security scan PASS).

Clean merge on top of ItsNotRexed#6582's XErrorReport and the Wave 0 static-guard PRs (ItsNotRexed#7175, ItsNotRexed#7198, ItsNotRexed#7359).
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.