Skip to content

Runtime: offline xgameruntime shim, part 1 (XGameRuntime, XSystem, XTaskQueue, XAsync) - #257

Closed
IAmNotSiob wants to merge 0 commit into
ItsNotRexed:mainfrom
IAmNotSiob:gdk-runtime
Closed

IAmNotSiob wants to merge 0 commit into
ItsNotRexed:mainfrom
IAmNotSiob:gdk-runtime

Conversation

@IAmNotSiob

Copy link
Copy Markdown
Contributor

Part 1 of the offline xgameruntime shim claimed in #156 (a.k.a. the big beautiful pull request).

What and why

Every GDK title calls XGameRuntimeInitialize before anything else and builds its async work on XTaskQueue/XAsync. If those imports are unimplemented, the executable stops long before it reaches D3D12. runtime/README.md listed "the xgameruntime surface" as not done. This adds the part a title needs first, ahead of the executable.

  • runtime/shims/xgameruntime.cpp: an xgameruntime.dll shim table with
    • XGameRuntimeInitialize/XGameRuntimeUninitialize, reference counted
    • XSystemGetDeviceType → XboxScarlettAnaconda (Series X). LEONIDA_DEVICE_TYPE=<0..8> overrides it
    • XSystemGetConsoleId → a fixed 39-byte placeholder (XSystemConsoleIdBytes)
    • all 23 XTaskQueue*/XAsync* functions
  • third_party/xtaskqueue/: Microsoft's MIT-licensed XTaskQueue/XAsync from microsoft/libHttpClient Source/Task, copied unmodified at c5007fd (byte-identical, checked with cmp), with its licence and a README. Only the task queue is copied, no HTTP stack. Files rather than a submodule, so submodule update --recursive doesn't pull libHttpClient's own submodules.
  • runtime/shims/xtaskqueue/pch.h: stands in for libHttpClient's pch.h (which includes the whole HTTP stack) with the few macros and error codes Source/Task uses.
  • runtime/test/xgameruntime_test.cpp (CTest xgameruntime): resolves every function through rt::shims::find, like the loader binds imports, and runs a title-style boot. The steps are init, device and console queries, a queue with thread-pool work and completions dispatched by hand from the "game loop" thread, the process queue, a custom XAsyncBegin provider through XAsyncSchedule/XAsyncComplete/XAsyncGetResult, and balanced uninitialize.
  • Docs: docs/related_projects.md entry (MIT, code use under a compatible licence), README Credits, runtime/README.md current limits.

Nothing goes online. No game data.

Tested

Not built with MSVC yet. I don't have Visual Studio here, so the Windows CI job is the first MSVC build. Cross-built with MinGW-w64 GCC 13 and run under Wine 9.0: xgameruntime_test passes all 21 checks, repeated runs with no failures, and our files are warning-free at -Wall -Wextra.

Open points

  • The DLL name xgameruntime.dll is the PC GDK's. Until the console executable's import table is seen, it's an assumption. A different name means registering the same functions under it.
  • XSystemDeviceType values and XSystemConsoleIdBytes (39) come from Microsoft's public GDK documentation. Verify once the executable exists.
  • Part 2: XUser (one silent local offline user), XGameSave (a local folder), XPackage (the game folder).

Checklist

  • No game data, keys or decryption (CONTRIBUTING.md), including in logs or reports quoted here.
  • Third-party code: MIT, licence kept with the files, recorded in docs/related_projects.md.

@IAmNotSiob

Copy link
Copy Markdown
Contributor Author

Closing note: this was merged as 36bc120 (merge commit 345465a). A follow-up commit for the C4996 getenv warning landed on the branch around the same time and conflicted with 83d0637, which fixed the same line with GetEnvironmentVariableA. I dropped it from the branch, so nothing here is left unmerged. Part 2 is #279.

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.

1 participant