- docs/running.md: add Recommended variables (all platforms) table covering async submit/compile, compile-pool sizing, warm-up throttling, heap sizing, input, and telemetry/fault variables on main; update RX 7900 XTX RADV recipe and Reporting section - runtime/README.md: document LEONIDA_CLWB_PATCH (runtime/src/cpu_emulation.h) - AGENTS.md: add port_ctl.py (scripts/port_ctl.py) to numpy/Pillow exception list - d3d12/docs/replay.md: fix nonexistent --looks flag reference to --flow - docs/port_plan.md, docs/port_status.md, docs/ultrawide.md, docs/victory_gap_gpu.md, docs/victory_gap_media.md: fix typos (chad_dsp.cpp -> chad.cpp, VIctory tests/fidelityfx.rs -> crates/victory-hle/tests/fidelityfx.rs) and clearly mark unmerged-branch paths (runtime/ ultrawide, frame_step.h, media_foundation.cpp, gameinput_xinput.cpp, d3d12_xs_exports_test.cpp, pipeline_queue.h -> pipeline_wait.h) - tests/test_docs_cli_flags.py: scan .rs sources and clap #[arg(long)] struct fields for d3d12/docs/*.md flags, treat cargo/git-filter-repo flags as foreign, and add docs/port_plan.md to OTHER_PROJECTS AI-assisted: Antigravity (Gemini 4 Neon). Verified: 13/13 tests/test_docs_*.py pass and scripts/check_no_game_data.py clean.
8.8 KiB
Guide for coding agents
Read this before changing anything here. CONTRIBUTING.md has the rules for every contributor and docs/design.md the formats and the translator's runtime contract; this file adds what an agent tends to get wrong.
What this is
A port template for the Xbox Series build of GTA VI, built on the player's PC from their own copy:
make_game.py carves and translates the shaders (RDNA2 → SPIR-V), exports the assets and builds runtime/, a PE
loader that maps the game's executable and resolves its imports to shims. Nothing of the game is in the repository.
Where things are
- The notes under
docs/record measured formats, indexed by docs/README.md;docs/design.mdis the one quoted most. scripts/holds the GPU/Wine test runners (run_gpu_tests.py,run_wine_tests.py), the translator suite runnerrun_semantic_tests.py,check_no_game_data.py(see the first hard rule below) and PowerShell build helpers.viewer/is the map viewer:index.htmlplusserve.py, a local-only server for the exported world.third_party/holds therpf9-explorersubmodule (tools/rpf9dumpneedsgit submodule update --init), the vendoredxtaskqueuethexgameruntimeshim links and the vendoredbcpack-rsrANS decoder of the BCPack calibration tools.game/xbox-1.0.2.1.jsonis the per-file size and SHA-256 manifest of the Xbox package — hashes only, no game content.tests/semantic/is the translator regression suite; a new translator rule comes with a small hand-written.asmfixture there.
Hard rules
- No game data, ever: no archives, executables, carved files, shaders in any form (DXBC, FSSM, disassembly,
SPIR-V), textures, audio, or logs and reports that quote them, in commits, issues, pull requests or test
fixtures. A test that needs a shader builds its input by hand or reads it from the user's work folder.
python -I scripts/check_no_game_data.py <path> ...reads the first bytes of the files you name, so it catches a renamed file the extension check in CI misses. - No keys, decryption or protection workarounds. If a format turns out to be encrypted, write that down in
docs/design.mdand stop there. - Nothing online: no Xbox Live or Rockstar services or domains.
- Fix, don't disable: a shader the translator rejects gets a rule, not a skip list. A new rule goes into the
contract table in
docs/design.mdwith how it was confirmed (a GPU test, a Mesa/LLVM reference, or a count over the corpus).
Claim before you start
-
Work is claimed in the coordination issue before a pull request is opened: the open issue titled "Coordinating who works on what". It moves to a new issue when the thread gets long, so look it up instead of using an old number:
gh issue list -R ubiquitarianism/leonida --state open --search "Coordinating who works on what in:title"With no
ghauth, the search link in CONTRIBUTING.md works in a browser; say so when you cannot read the claims at all rather than guessing that a thing is unclaimed.Check its tables and the open pull requests first. If someone has claimed the item or has a pull request for it, stop and tell the user instead of writing it a second time.
-
Put the item ID from that issue in the pull request, and
Depends on: #Nfor every pull request yours builds on. -
Found work you won't do yourself (a bug, a missing method, a stale doc, a follow-up of your own pull request)? Post it in the coordination issue as
finding: <one line>, followed by where it is (file and line), why it matters, and whether it needs game files or particular hardware. The coordinator checks it and lists it for others. -
For the D3D12 → Vulkan layer (
runtime/shims/d3d12_*,runtime/src/vulkan_*), also read docs/d3d12_vulkan.md and the open pull requests: most of that work builds on a few of them. The page that tracked it, #313, was in the original repository and is gone. -
The original repository (
ItsNotRexed/Leonida) went private on 23 November 2026. A#Nwritten before that is an old number and links nowhere: do not cite one as if it could be read, and do not runghagainst that repository. The old open issues are indexed by title in #18 and the old open pull requests are kept asold-pr/<old number>branches (#17).
Before you guess, look
- The format or behaviour may already be measured in
docs/design.md. Quote the file and offset a claim comes from, or call it a hypothesis. - Count over the whole corpus, not a sample: a rule that holds for 400 shaders can fail on the other 26 000.
Test without the game first
None of these need game files. Most run in seconds - the translator suite takes a few minutes (465 files and 6 108 tests in 297 s on 16 cores on Windows 11) and the two builds longer - so run one translator test file while you iterate and the whole suite once before the pull request:
python -m compileall -q make_game.py tools tests
python -I make_game.py --help
python -I scripts/run_semantic_tests.py tests/semantic # translator suite, one file per core; no LLVM, SPIR-V tools or GPU needed
python -m unittest discover -s tests/semantic -p test_<name>.py # one translator test file
python -I tests/test_<name>.py # standalone standard-library unit test
node --test tests/test_viewer_streaming.cjs # viewer streaming; needs Node 22+
dotnet build tools/rpf9dump/rpf9dump.csproj -c Release
cmake -S runtime -B runtime/build; cmake --build runtime/build --config RelWithDebInfo
ctest --test-dir runtime/build -C RelWithDebInfo --output-on-failure
gta6rt and the shims are Windows-only, so Linux and macOS configure the portable subset of the runtime tests. The
runtime tests that need the retail package read LEONIDA_GAME_DIR (and LEONIDA_MOVIE) and print SKIP when
unset; loader_test writes small PE images to %TEMP%\leonida_loader_test, which antivirus can block.
For pytest-based tests (the test files with import pytest, or no __main__ block: they fail to import under
python -I), use a virtual environment and install the pinned dependencies in
tests/requirements.txt. From the repository root, run python -m pytest with the
test file you want to check.
python -m pip install -r tests/requirements.txt
python -m pytest tests/test_user_sgpr_census.py
With a work folder already built, a translator change is checked on a slice before the full run, and the result is compared with the run before it:
python -I tools/rdna2spirv.py <work>/shaders/dxbc/disasm --out <scratch> --limit 200
python -I tools/rdna2spirv.py <work>/shaders/dxbc/disasm --out <scratch> --shard 0/8 # one of 8 parallel slices
Shard runs write index.part*.json; merge them into index.json with --merge. Report translated and
spirv-val-valid counts before and after; a change that lowers either is a regression.
Runtime traps
- No
thread_localwith a destructor ingta6rt.exe. It makes the loader register a thread-exit callback with the shared C runtime, which accepts one per process; the title's own registration then fails and the title aborts with0xC0000409before its first frame. Keep per-thread scratch in the thread's own frame (a worker's loop) or in a plain-datathread_local. - A console method that returns a struct by value takes a hidden return pointer as its first argument (RCX)
and
thisin RDX, as MSVC does for COM methods returning structs (GetCustomHeapProperties,GetDesc-style slots); a proxy that reads RCX asthisfaults on a null vtable.
Conventions
- Python tools run with
python -Iand use only the standard library unless a file says otherwise; the exceptions are the texture, model and control tools that import numpy or Pillow:bc_feature.py,amd_swizzle.py,tile_probe.py,swizzle_search.py,tex_export.py,tex_mode_probe.py,calibrated_texture.py,world_grid_atlas.py,port_ctl.py,tex_headers.pyandskinned_glb.py(the last two fall back to the standard library when numpy is absent). - A text file a tool writes names its line ending -
open(path, "w", encoding="utf-8", newline="\n")- so the same input gives the same bytes on every platform;tests/test_text_write_line_endings.pycatches a writer that forgets. - Keep
make_game.pyworking on Windows first: paths throughos.path, no bash in the build. - In the pull request, say that it was AI-assisted, what you tested and on which GPU and driver.
- How agents share results, ask each other for a test on a machine they do not have and say how sure a claim is: docs/agent_collaboration.md.