Xbox Series game code, running natively on Windows — on Vulkan.
A from-scratch C++20 runtime. First target: GTA VI (Xbox Series build).
Where we are • How it works • Building • Running • Troubleshooting • Other projects • Credits
Important
keylime contains no game files, keys or console SDK code. You need your own copy of the game. Nothing here downloads or distributes game content.
|
|
|
flowchart LR
A[Boot] --> B[Intro & menu] --> C[World loading] --> D[Opening cutscene] --> E[Gameplay]
style A fill:#16a34a,color:#fff,stroke:#15803d
style B fill:#16a34a,color:#fff,stroke:#15803d
style C fill:#16a34a,color:#fff,stroke:#15803d
style D fill:#d97706,color:#fff,stroke:#b45309
style E fill:#6b7280,color:#fff,stroke:#4b5563
- Retail exe boots natively; archives stream through DirectStorage
- Intro and main menu with all audio
- World loading after the menu, into the opening cutscene
-
ExecuteIndirect(single-argument signatures) and GPU memory waits - Mesh shader dispatches without an amplification shader
- Opening cutscene drawn at 15+ fps
- Amplification shaders, multi-argument
ExecuteIndirect - Gameplay
| Problem | What happens | Status |
|---|---|---|
| New shaders at the cutscene | ~3,000 compute pipelines appear at once; each must be translated and compiled by the driver before the game can continue | Urgent compile queue, compiles start when a list is recorded, keylime precompile, background builds throttled — compiles went from 35–60 s to ~1 s each |
| Translated shaders are big | ~50× more SPIR-V than console code; NVIDIA spends ~25 CPU-seconds per big shader | Control flow is now fully structured (was "run by number"); shrinking the output is next |
| Wrong data from some compute shaders | Stores to addresses gigabytes past any buffer; GPU counters the game waits on are never written; the game traps on bad data (int3) |
Stores outside GPU memory are skipped and logged; root cause being traced |
| Game's GPU watchdog | Ends the game when GPU work takes ~25 s | Its thread is parked instead (KEYLIME_WATCHDOG=1 to disable) |
| Area | State |
|---|---|
| Loader (PE mapping, static TLS redirect, import binding) | 🟢 working |
Kernel, files (G: package, T: temp), memory (xmem, physical pages) |
🟢 working |
| DirectStorage (worker pool, zlib, BCPack) | 🟢 working |
| GameInput (XInput pads, keyboard as a pad) | 🟢 working |
Audio: AcpHal XMA, Opus (xapu), DSP (chad) |
🟢 working (reverb is dry) |
xgameruntime (XUser, XStore, XGameSave, XAsync, …) |
🟡 enough for the menus; some stubs |
| XG texture layouts (AMD addrlib) | 🟢 working |
| GPU objects: device, queues, fences, lists, heaps, resources, views, pipelines | 🟢 working |
| GFX10 decoder and GFX10 → SPIR-V translator | 🟡 every shader seen so far translates; some compute results are wrong |
| Running the game's command lists on Vulkan | 🟡 menus fully; cutscene runs but doesn't draw |
We don't emulate the CPU. The console's x86-64 code runs directly on the host CPU; keylime supplies everything around it — the loader, the console system libraries, and a GPU layer on Vulkan with our own translator from the console's RDNA 2 machine code to SPIR-V.
flowchart TB
subgraph Game["game_scarlett_master.exe (runs natively)"]
G1[Game code]
end
subgraph keylime
L[Loader<br/>PE mapping · TLS · imports]
H[Console libraries<br/>kernel · files · xmem · DirectStorage<br/>GameInput · xgameruntime · audio]
D[D3D12.X on Vulkan<br/>command lists · resources · fences]
T[Shader translator<br/>RDNA 2 GFX10 → SPIR-V]
C[(Shader caches<br/>cache/spirv · pipelines.bin)]
end
V[Vulkan driver → GPU]
G1 --> H
G1 --> D
L --> G1
D --> T --> C --> V
D --> V
| keylime | |
|---|---|
| Graphics API | Vulkan 1.3 / 1.4 |
| Shaders | SPIR-V written directly from GFX10 machine code — no HLSL or DXIL round trip |
| Memory | Title memory imported zero-copy behind a GPU page table (console addresses → wherever the page lives) |
| Descriptors | Real RDNA 2 descriptor words; images and samplers found through a GPU hash table into bindless arrays |
| Queues | Asynchronous, timeline semaphores, no wait after each submission |
| Shader compiles | Never on the game's threads; urgent queue for what a draw or dispatch waits on; two-level disk cache |
| Frame pacing | High-resolution waitable timers |
More detail: docs/translator.md · docs/rdna2-descriptors.md
flowchart LR
A[Console shader<br/>GFX10 code] --> B[Decode] --> C[Structure control flow<br/>ifs · loops · parts] --> D[SPIR-V] --> E{In cache?}
E -- yes --> F[Ready instantly]
E -- no --> G[Quick build ~1 s] --> F
G -.background.-> H[Optimized build] -.swap in.-> F
Needs: Windows 10/11 x64 · Visual Studio 2022 (or Build Tools) with the C++ workload (CMake and Ninja ship with it) · a GPU driver with Vulkan 1.3.
powershell -File tools\build.ps1tools\play.ps1 # live log console + the game
build\keylime.exe run <dir>\game_scarlett_master.exe --execute| Command | What it does |
|---|---|
keylime run <exe> --execute |
Run the game |
keylime precompile <dir> |
Build every compute shader in <dir> (*.bin containers) into the caches; resumable |
keylime imports <exe> |
Map and bind only; list unimplemented functions |
keylime shader <dir|file> [--dis] |
Parse or disassemble console shader containers |
keylime shader <dir> --spirv |
Translate shaders and build them as driver pipelines |
A keyboard stands in for a controller (any XInput pad works too).
| Key | Pad | Key | Pad |
|---|---|---|---|
| Enter | A | Backspace | B |
| Esc | Menu | Tab | View |
| Arrows | D-pad | WASD / IJKL | Left / right stick |
| Q / E | Shoulders | Z / C | Triggers |
F3 toggles the debug panel (fps, frame-time graph, GPU work, shader compiles, VRAM, streaming).
Console games ship shaders as finished AMD machine code, so each one has to be translated to SPIR-V and compiled by the driver once. keylime does that for the whole game up front, like a PC game's "compiling shaders" screen:
tools\build-shader-cache.ps1 # extracts all 26,503 shaders the game ships, compiles the compute onestools/extract_shaders.pypulls every shader out ofshaders.rpf(its records are plain deflate streams even though the pack's table is encrypted);tools/extract_embedded_shaders.pyfinds the ones inside the executable and DLLs (BVH builder, AMD upscaler). Files are named by the same FNV-1a hash the runtime keys its caches by.- The results live in
cache\spirv(our translations) andcache\pipelines.bin(the driver's). - The cache is keyed by
TRANSLATOR_VERSIONinsrc/shader/translate.cpp, not by the build. Rebuilding keylime or changing anything else keeps every shader. Raise the version only for a translation fix that must reach shaders already cached. - An NVIDIA driver update empties the driver's half (as for every PC game); run the script again.
| Variable | Effect |
|---|---|
KEYLIME_TRACE=1 |
Detailed logging |
KEYLIME_OVERLAY=0 |
Start with the debug panel hidden |
KEYLIME_DUMP_SHADERS=<dir> |
Save every shader the game uses (for precompile) |
KEYLIME_KEYS=14:RETURN,30:A |
Scripted key presses at those seconds (testing without a person) |
KEYLIME_SNAPSHOTS=<dir> |
Save some shown frames as BMP files |
KEYLIME_STACKS_AT=<s> |
Log every thread's stack at that second |
KEYLIME_STORE_GUARD=0 |
Don't skip shader stores outside GPU memory |
KEYLIME_DRAW_WAIT_MS=4000 |
How long a frame waits for draw pipelines still compiling before skipping those draws |
KEYLIME_DISPATCH_WAIT_MS=12000 |
The same for compute dispatches |
KEYLIME_BACKLOG_DRAW_WAIT_MS=10 |
The draw wait while more urgent builds are queued than the workers clear in a few seconds |
KEYLIME_BACKLOG_DISPATCH_WAIT_MS=30 |
The same for compute dispatches |
KEYLIME_WATCHDOG=1 |
Let the game's GPU watchdog end the game |
KEYLIME_PROFILE=1 |
Log the GPU time of the heaviest pipelines every 10 s |
KEYLIME_PRECOMPILE_WORKERS=8 |
Driver compiles at once in precompile (each big shader takes gigabytes) |
KEYLIME_FLAT=0 |
Reach title memory through the page table instead of the flat sparse view |
KEYLIME_VALIDATION=1 |
Vulkan validation layers |
| File | What's in it |
|---|---|
logs\keylime.log |
Full log; every 2 s a frame: line (ms per frame, GPU busy, pipeline waits, work run and skipped) and a compile: line |
logs\crash.dmp |
Minidump of an unhandled crash (each distinct fault is also logged once) |
logs\stacks.txt |
Every thread's stack when no frame is shown for 5 s and 20 s, plus what each GPU queue waits on |
cache\used-pipelines.txt |
Pipelines used so far; the next run starts them as soon as the game creates them |
Several projects are working on GTA VI's Xbox build on PC. keylime is in the same family as VIctory and XCL — the console's own x86-64 code runs natively, with the system libraries and GPU replaced around it — but we take a different graphics path: we drive Vulkan and write SPIR-V ourselves, where the others go through Direct3D 12 and DXIL.
| Project | Approach | Scope | Graphics path |
|---|---|---|---|
| keylime | Native runtime, C++20, from scratch | GTA VI first | Vulkan; RDNA 2 → SPIR-V directly |
| VIctory | Compatibility layer, Rust | GTA VI | RDNA 2 → DXIL via DXC |
| victory-fork | VIctory plus rendering and speed fixes | GTA VI | Same as VIctory |
| ztrx | VIctory-based | GTA VI | Same as VIctory |
| XCL | Wine-style compatibility layer | Any Xbox Series game | RDNA 2 → HLSL → DXIL |
| Xbox2Windows | Static recompilation to C++ | Any Xbox Series game | DXIL |
| TuxBox | Native-first layer, tested on Linux via Proton | Any Xbox Series game | Not stated |
| xbox-emulator | Rust runtime (continues TomBox) | Any Xbox Series game | Not stated |
| ScarlettX | Clean-room HLE of the Scarlett OS and GDK | Any Xbox Series game | Not stated |
| OpenScarlett CE | AGPL layer swapping console DLLs for PC ones | Any Xbox Series game | Direct3D 12 |
Other projects' progress is their own reporting.
src/loader.*, src/pe.* mapping and binding the game's images
src/hle/ console system libraries (kernel, files, xmem, dstorage, gameinput, xg)
src/hle/xgr/ xgameruntime (user, store, saves, async, other areas)
src/formats/ BCPack decoder
src/audio/ AcpHal (XMA), xapu (Opus), chad (DSP)
src/gpu/ D3D12.X objects on Vulkan: memory (flat sparse view), images, present
src/gpu/exec.cpp the command executor; its parts in src/gpu/exec/:
queues.inc host queues, GPU waits on memory, submission
pipelines.inc shader modules, caches, compile workers, wait budgets
builder.inc recording a title command list into Vulkan commands
src/shader/ containers, GFX10 decoder, control-flow structuring
src/shader/translate.cpp the RDNA2 -> SPIR-V translator; its parts in src/shader/translate/:
helpers, memory, setup, results, alu, vmem, atomics, image, export, control
third_party/ miniz, libopus, AMD addrlib, Vulkan and SPIR-V headers
tools/ build, play, update, saves, build-shader-cache, shader extractors
keylime is licensed under the GNU GPL v3.0 or later (see LICENSE).
- Many console interface layouts (object slot maps, structure shapes, file formats) were reverse engineered by VIctory (GPL-3.0); we reuse that knowledge and port some of its code (noted in the files concerned).
- Ideas from ztrx, victory-fork (GPL-3.0) and XCL (GPL-2.0) are reimplemented here, not copied: per-stage shader loop caps, the wait comparison codes and mask, type 105 as a dispatch, an indirect work budget, and parking the game's GPU watchdog.
- The XMA decoder follows FFmpeg's
wmaprodec.c(LGPL-2.1-or-later) via VIctory. - Third-party code keeps its own licence: miniz (MIT), libopus (BSD-3-Clause), AMD addrlib from Mesa (MIT), Khronos Vulkan / SPIR-V headers (Apache-2.0 / MIT), GFX10 opcode tables from Mesa's ACO (MIT) and register layouts from Mesa (MIT).
keylime is written with the help of Claude, Anthropic's AI model.
Not affiliated with Microsoft, Rockstar Games or Take-Two Interactive.