Files
mandy/docs/game_gate.md
MoonEyes 501b3e6c5c Merge pull request #2805 from TheGeogeo/d3d12-gate-pwsh7
gate: game-gate.ps1 says it needs PowerShell 7 (D3D12-GATE-PWSH7)
2026-12-01 08:50:36 +01:00

8.1 KiB

The in-game gate

One command runs the D3D12 runtime (leonida.exe) in the game for a set time in the world and says PASS, FAIL or ERROR. The same way on every machine. It is what a change to the render path needs before merge ("300 s in the world, no device loss"). It also gives the numbers an A/B compares: one summary.json per run, in one format.

The script is scripts/game-gate.ps1 (Windows, PowerShell 7). The parser is tools/game_gate.py (standard library only). The tests are in tests/test_game_gate.py.

Running it

It needs PowerShell 7 (pwsh). Windows PowerShell 5.1 (powershell.exe) refuses the script with a message before anything runs, from its #Requires -Version 7.0 line.

Build the runtime first (d3d12\scripts\build-nvidia.ps1). The gate refuses to start without d3d12\target\diag\leonida.exe, because the play script would build it inside the timed run.

Make a data template once:

  1. Play to the place the runs should start from.
  2. Let the title save, and close the game cleanly.
  3. Copy <Data>\data\<title id> (its saves and storage) into a folder outside the checkout.

Each run gets a copy of it, so your own saves are never touched. A save is game data: never share or commit it.

pwsh -NoProfile -File scripts\game-gate.ps1 run -Game <game folder> -Data <data folder> -DataTemplate <template> `
    -Name base [-PlayArgs '<play-d3d12.ps1 switches>'] [-More 'LEONIDA_X=1;LEONIDA_KEYS=40:Enter,60:Enter'] [-WorldSeconds 300]
pwsh -NoProfile -File scripts\game-gate.ps1 start <same options>   # detached: returns at once, prints the run folder
pwsh -NoProfile -File scripts\game-gate.ps1 stop -RunDir <run folder>
  • The play script's switches. -PlayArgs passes them on as they are, for example -SeriesS -NoFrameGen.
  • Reaching the world. The gate does not drive the menus. Pass key presses with LEONIDA_KEYS; they are timed from the start of the process, so allow for the precompile.
  • The caches. -Data keeps its caches (cache-2); only the saves are copied. The first start after a translator change translates every shader again: run once before measuring.
  • Ending the run. It stops when the time in the world reaches -WorldSeconds, when a STOP file appears in the run folder (stop), or after -MaxMinutes (45).
  • How it stops. With WM_SYSCOMMAND/SC_CLOSE, the runtime's own end: the title is suspended and the pipeline cache saved. It kills the game only if it has not ended 60 s later.
  • Exit code. 0 PASS, 1 FAIL, 2 ERROR. start exits when the detached run is created.

The run folder (under -RunRoot, by default <Data>\gate-runs, refused inside a checkout) holds:

File What
run.json Name, start time, commit, exe hash, build features, card, driver, options
launch.ps1 How the game was started
settings.txt The play script's -DryRun
leonida-settings.txt The F1 menu file, when there was one (it changes every run, so the summary warns)
launcher.txt The play script's output, with the precompile lines
leonida.log The runtime's log, with LEONIDA_LOG=info,leonida_gpu::frame=debug (one line per present)
events.jsonl What the gate did and saw: the game found, the stop asked for and why, a kill, the exit code
data\ The run's copy of the template, and the runtime's crashes.log
summary.json The result, below

summary.json (leonida-gate-summary/1)

Times are seconds since the run started. The summary holds numbers, switch names and verdicts only. It never holds a path, a user or machine name, or text the title printed. A fault is told by the kind of module it was in, not by its name or address.

Field Meaning
run Name, start time, commit, dirty (a tracked file changed), untracked (how many files git does not track), exe hash (16 hex), build features, card, driver, play arguments, world_seconds
settings The LEONIDA_* settings from the runtime's settings line, as it shows them (folders hidden). Empty, with a warning, from a runtime without that line
precompile From the launcher: shaders in the cache and the seconds that took, pipelines known, made before, to make, made, their seconds and median ms
times.world_at_s The world: the first of two frame lines in a row with 500 draws a frame or more. Cutscenes count: a save that opens on one is in the world. Like every time here, it counts from the gate's start, so the precompile is in it (its seconds are precompile.shaders_s and precompile.made_s)
times.warm_at_s From then on, 60 s in the world with no pipeline being made and no wait for one that ran out. Draws dropped for a pipeline the host never has go on all run long and do not count
times.world_s Seconds from world_at_s to the stop request
fps From the presents, after the first 60 s in the world: frames, median, p5, frame p95 (ms), median of the last 60 s (end_median), the first second with fewer than 2 frames, from 60 s in the world on too (under_2_at_s), the longest gap with no frame presented from the world on (longest_present_gap_s, longest_gap_at_s; on purpose from the world on: a freeze on pipeline compiles comes right after arrival, and 10 s with no frame is what a player sees), draws a frame. Without the present lines (a build without diagnostics), the median and p5 come from the frame lines, with a warning
pipelines Waits that ran out (missed_waits), the most pipelines being made at once
memory Peaks over the whole run, from the runtime's memory line and video memory line (every 5 s; builds with diagnostics only, otherwise source is null): the process's private bytes and when (private_max_mb, private_max_at_s), the most of them in physical memory, the least the PC had left to commit and when, the card's video memory in use at its most and when, with the budget the system gave then (vram_in_use_max_mb, vram_max_at_s, vram_budget_at_max_mb), the seconds spent over that budget, and the most of the PC's memory shared with the card in use. The video memory is what the system counts for this process, less than a tool like nvidia-smi shows for the whole card
crash kind is none, device_lost, panic or fault. It also gives the time, the code, the module kind (runtime, title, driver, system, unknown) and the access (read/write). title_watchdog marks a write at address 0 in the title more than 25 s after the last frame line. count is the number of crashes
exit The game's exit code, and its kind: clean, device_lost (0x887A0005), killed or other
stop Why it was stopped (target, stop_file, timeout, relaunched), whether it was killed, whether the cache was saved, whether the suspend was in time
verdict result, reasons, warnings, min_world_s

The verdict

PASS needs all of these:

  • at least -WorldSeconds (300) in the world;
  • no device loss and no panic;
  • no fault before the stop request;
  • no gap over 10 s with no frame presented once in the world, so a run frozen on a pipeline compile does not pass;
  • the game alive at the stop request: a frame line less than 30 s old.

FAIL comes with one or more reasons:

  • device_lost: a host GPU failure, an out-of-memory command list that did not close, or exit 0x887A0005;
  • panic;
  • fault_before_stop;
  • exited_before_stop;
  • present_gap;
  • world_time_short: the time limit came first;
  • not_alive_at_stop;
  • world_not_reached, when the game ended before reaching the world.

ERROR means the gate could not judge the build:

  • not_started;
  • relaunched: the title restarted itself;
  • stopped_early: a STOP file before the time;
  • world_not_reached, when the game was still in the menus at the time limit.

A crash after the stop request is a warning, except a device loss or a panic, which stay FAIL. A kill, a cache not saved and a late suspend are warnings too.

Not in this version

  • A driver for the menus and a fixed route (a Lua mod).
  • An ABBA runner over several runs.
  • A time series beside the summary (memory, census, reaping queue).
  • A "memory rising" warning.
  • VRAM and RAM peaks.
  • The distance walked.
  • The Vulkan runtime (gta6rt).