diff --git a/AGENTS.md b/AGENTS.md index 8b5b46c43..d9b460cc2 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -291,6 +291,39 @@ python3 -m venv out/pe-env and the local `llvm-mc`, `llvm-objcopy` and `libLLVM` paths. CI uses LLVM 15; newer versions may print a different `exp` spelling. +## Run settings for packages + +Start runs of a local package with the shared presets rather than a +hand-written `run.ps1` or `run.sh` line: + +```powershell +.\out\pe-env\Scripts\python.exe -B tools\startup\run_preset.py --package --console x --gpu nvidia +``` + +The launcher asks only for the console (`x` or `s`), the GPU (`nvidia` or `amd`) +and the OS (`win11`, `win10` or `linux`; the host by default). All other +settings come from `tools/startup/run_presets.json`, applied in layers: base, +then OS, console and GPU. `--print` shows the merged settings and the command +without starting anything. See +[Run with the shared presets](docs/startup-runtime.md#run-with-the-shared-presets). + +Keep the presets current. They are only useful while they hold the best +settings on main: + +- When a pull request adds an opt-in switch or setting that helps package runs, + add it to the right layer in the same pull request or in a follow-up. +- When a measured run shows that a preset setting is better, worse or no longer + needed, change it. +- Give each change its evidence in the layer's `why`: commit, host, GPU, + duration, and the counters before and after. +- When a host needs a setting that no layer covers, such as a GPU generation, a + driver or an OS, put it in that host's layer with the run that showed it, and + name the switch in that layer's `why` (the check refuses a GPU difference it + does not name). Do not add a launcher option. +- Leave out switches that main does not read yet, such as one from an open pull + request. +- After editing, run `tests/startup_run_preset_check.py`. + ## Repository map | Path | Purpose | diff --git a/docs/startup-runtime.md b/docs/startup-runtime.md index 8c4a1625f..5bb3c95c8 100644 --- a/docs/startup-runtime.md +++ b/docs/startup-runtime.md @@ -921,6 +921,64 @@ It writes: | `/files.txt` | every file the process opened | | `/translate.txt` | with `-Translate`: one line per shader request translated during the run | +### Run with the shared presets + +`tools/startup/run_preset.py` starts a run with the settings kept in `tools/startup/run_presets.json` +instead of a hand-picked set of switches. It takes three choices and the package root: + +```powershell +.\out\pe-env\Scripts\python.exe -B tools\startup\run_preset.py --package --console x --gpu nvidia +``` + +| Choice | Values | Default | +|---|---|---| +| `--console` | `x` (Series X), `s` (Series S) | required | +| `--gpu` | `nvidia`, `amd` | required | +| `--os` | `win11`, `win10`, `linux` | this host | + +The settings file has a `base` layer and one layer per choice. They apply in the order base, OS, +console, GPU. A later layer overrides an earlier one, and an `env` value of `null` unsets it, also when +the caller's shell set it. Each entry +records why it is there. To change what everyone runs with, change the file and cite the run that +supports the change. Do not add a launcher option for it. `--print` shows the merged switches, the +environment and the command without staging or starting anything. + +The launcher: + +- reads the executable's path from the package's `MicrosoftGame.config`; +- stages the PE files of that executable's folder in `/stage`, hard-linked where the volume + allows and copied otherwise. `run.ps1` and `run.sh` copy the stand-ins next to the executable, so + the package folder itself is never written. A package file named like a stand-in (`xg_xs.dll`, + `GameInput.dll`, ...) is always copied: `Copy-Item -Force` and `cp -f` rewrite an existing file in + place, so through a hard link they would write into the package; +- gives every run an empty storage folder (`/storage`); +- maps the package on its console drive letter with `subst` for the run and removes the mapping + afterwards. A letter that is taken is refused, unless `subst` already maps it onto this package. It + does not use `run.ps1 -MapDrive`: that rewrites only opens that pass through the debugger's file + hooks, and a real-title run with it stayed on its first screens where the same settings on a `subst` + drive went on loading. Under Wine, link `dosdevices/g:` in the prefix yourself; +- turns off the debugger's thread holding (`run.ps1 -SuspendOthers 0`, #3332). With holding on, real + runs on main stopped before the first input poll; a bisect points at #1408. The base layer also + sets `X2W_PROBE_PRECHECK=0` (#3313), because title runs always start under the debugger. On the + same 420 s input it raised translated draws from 162,303 to 1,142,089; +- hides the title's own window (`X2W_HIDE_TITLE_WINDOW=1`, see [Output window and fallback diagnostics](#output-window-and-fallback-diagnostics)) + once presents reach the output window, so only the output window stays on screen; +- starts `run.ps1`, or `run.sh` on Linux, then prints `tools/startup/triage_run.py` for the run's logs. + +Runs go to `out/startup/runs/