How XSEmu runs a console game

An Xbox Series console is, underneath, an x64 PC with an AMD RDNA2 GPU. XSEmu uses that: it runs the game’s own code natively and only replaces what Windows doesn’t have. The two hard parts are the console’s libraries and its graphics.

The whole picture

XSEmu run maps the game’s executable and DLLs into its own process and starts them. From then on, every request the game makes lands in one of three places.

The game’s EXE and DLLsNative x64 code, mapped into the XSEmu process by its PE loader and run on your CPU

Calls a console library

HLE replacementskernelx, XGameRuntime, GameInput, XAudio2, Bink and more
Or, by namethe game’s own DLL, the Windows DLL of the same name, or a logged stub
WindowsReal Windows exports, and Gaming Services for what XCL doesn’t implement

Opens G:, GAME:, S: or T:

Virtual file systemConsole paths mapped to folders on your PC. DirectStorage reads go through it too, then zlib and BCPack.
Game folderOnly ever read, never changed
Title data folderThe write overlay, saves, S:\ and T:\, caches and logs

Draws through d3d12_xs.dll

D3D12.X layerConsole device slots, descriptor heaps, command lists and PresentX become PC D3D12
Shader recompilerRDNA2 to HLSL to DXIL, with three disk caches
PC D3D12, your driver, your GPUTiled console textures converted to PC layouts on the way
Replaced by XCLTranslated or passed throughYour PC

The loader and the console libraries

The PE loader handles everything a Windows loader would: relocations, imports by name and by ordinal, delay-loads, TLS callbacks and exception tables. Each import then goes to one of four places, decided when the game loads.

Console libraries such as kernelx, XGameRuntime, GameInput and XAudio2 are reimplemented in Rust undercrates/xcl/src/hle. Functions that behave the same as on Windows go straight to the real Windows export, and anything not implemented yet becomes a stub that logs the call. After a run, logs\report.json lists every stub the game called, so gaps are easy to find.

The game sees an offline Xbox user, local saves and its own storage. XGameRuntime functions XCL doesn’t implement are forwarded to Gaming Services, which is why Gaming Services is a requirement.

Where each import of a game goes when XSEmu loads it
ImportXCL replacementThe game’s own DLLWindows DLLLogged stub
kernelx.dllXMemAllocTitle memory, threads, modules, console info.
XCL replacement
xgameruntime.dllXUserAddAsyncAn offline user, saves and storage. What XCL doesn’t implement goes to Gaming Services.
XCL replacement
d3d12_xs.dllD3D12CreateDeviceConsole D3D12.X becomes real PC D3D12 objects.
XCL replacement
xcrdapi.dllDirectStorageReads through the virtual file system and unpacks zlib and BCPack.
XCL replacement
GameInput.dllGameInputCreateYour XInput controller, or keyboard and mouse as a gamepad.
XCL replacement
xaudio2_9.dllXAudio2CreateWindows XAudio2, with XMA2 decoded in Rust.
XCL replacement
Engine.dllshipped with the gameLoaded from the game folder and run as it is.
The game’s own DLL
ucrtbase.dllmemcpyBehaves the same on Windows, so the real export is used.
Windows DLL
anything elsenot implementedA stub that logs the call to report.json so it can be found and filled in.
Logged stub
Every import resolves at load time. The game’s code itself is never translated: it runs on your CPU as the x64 code it already is.

Files, saves and DirectStorage

Consoles address storage by drive letters a PC doesn’t have. The virtual file system maps them, and keeps your game folder untouched.

G: and GAME:
Map to the game folder, which is only ever read. Every write lands in an overlay instead.
S:\ and T:\
The console’s persistent local storage and its temp drive, kept in the title’s own data folder.
DirectStorage
The console’s xcrdapi.dll reads through the file system and decompresses zlib and BCPack data straight into title memory.
BCPack tables
BCPack needs a table file that isn’t part of the repository or the release. Without it, those textures stay undecoded.

Console shaders, rebuilt for your GPU.

Xbox Series games ship their shaders as RDNA2 machine code, with no DXIL a PC driver could use. XSEmu’s recompiler turns every vertex, pixel, compute, geometry and mesh program into HLSL, and a compiler turns that into DXIL.

RDNA2machine code from the game
s_mov_b32m0, s20v_interp_p1_f32v2, v0, attr0.xv_interp_p2_f32v2, v1, attr0.xv_interp_p1_f32v3, v0, attr0.yv_interp_p2_f32v3, v1, attr0.ys_load_dwordx8s[4:11], s[2:3], 0x00s_load_dwordx4s[12:15], s[2:3], 0x20s_waitcntlgkmcnt(0)image_samplev[4:7], v[2:3], s[4:11], s[12:15]s_waitcntvmcnt(0)v_mul_f32v4, s16, v4expmrt0 v4, v5, v6, v7 done vms_endpgm
HLSLsimplified; the real output keeps every register
Texture2D<float4> t0 : register(t0);SamplerState s0 : register(s0);cbuffer cb0 : register(b0){    float4 c[8];}; float4 main(float4 pos : SV_Position,            float2 uv : TEXCOORD0)    : SV_Target0{    float4 v4 = t0.Sample(s0, uv);    v4.x *= c[4].x;    return v4;}
DXILa container your driver accepts
SFI0
shader features
ISG1
2 inputs
OSG1
1 output
PSV0
pipeline state
HASH
9f3c…e1a0
DXIL
ps_6_6, LLVM bitcode

Each step is cached on disk

  1. Translated cache

    The DXIL of each console program, keyed by its bytes, its stage, the translator’s sources and the DXC build.

  2. DXIL cache

    Keyed by the HLSL, the XCL version, the compiler and the shader profile. A new translator means new keys, never stale code.

  3. Driver blob cache

    Your driver’s own compile, kept when it took 250 ms or more. A different driver or GPU simply compiles again.

  4. Pipeline manifest

    Every pipeline the game made, as console shaders plus a description, so warm-up can rebuild them all before the next run.

The game never waits for the compiler

A game creates thousands of pipelines while it loads, and one compile takes from 0.2 seconds to several. So when a pipeline isn’t cached yet, the game gets a stand-in at once and the real one is built on a background worker.

If the game binds it early, the bind waits up to 3 seconds and the build jumps the queue. Once a frame has waited a second in total, draws with unbuilt pipelines are skipped until they’re ready. Compute work always waits, because a skipped dispatch could leave the game in the wrong state.

Making console GPU code fit a PC GPU

The console’s GPU and a PC’s don’t always agree on how work is shaped. Two differences matter most, and both have design notes in the repository.

Wave64 on 32-lane GPUs

Console programs often run 64 threads in lockstep. NVIDIA cards run only 32 in D3D12. On those GPUs, compute programs run packed: each host lane holds the registers of two console lanes, i and i + 32, and wave-wide operations combine both halves. GPUs that can run 64-lane waves keep the native path.

Read the wave64 note

Mesh shaders, natively

Console geometry often runs as NGG programs. XSEmu translates them into real PC mesh shaders (Shader Model 6.6), so a mesh draw is one host call with the game’s own group counts. A two-pass compute fallback covers what the native form can’t hold. That’s why mesh shader support is a requirement.

Read the mesh shader note

Warm-up in child processes

A large compile can hold more than a gigabyte in the driver and doesn’t always give it back. So warm-up runs its compiles in child processes: memory returns when each child exits, and a driver crash costs only the pipelines that child had in flight.

Read the warm-up note

The launcher and XSEmu.exe

XSEmu Launcher is a Qt 6 app in C++. XSEmu.exe stays a separate program: the launcher starts it, places the game’s window inside its own, and talks to it over a named pipe in JSON lines. A warm-up reports its progress the same way.

The launcher runs one XSEmu process tree at a time, either a game or a warm-up, and refuses to start a second. Everything XSEmu reads from the environment is a run profile in Settings, so what the launcher does is always something you could type yourself.

Read the launcher protocol

What the launcher runs
# a game, inside the launcher window
XSEmu.exe run --host-hwnd 0x2A0B4C --control-pipe xsemu-4120-1 "D:\Games\Your Game"

# a warm-up, reporting progress as JSON
XSEmu.exe warm-up --progress-json

Where it comes from

XSEmu started from XCL at commit f311ca5 and keeps merging XCL’s general fixes. Credit for the loader, the runtime shims, the recompiler and the test suite goes to ivall and the XCL contributors. The design spec, the handoff notes and the contribution guide in the repository come from upstream XCL too.