diff options
| author | MoonEyes <14891700+MoonEyes@users.noreply.github.com> | 2026-11-28 21:42:45 +0100 |
|---|---|---|
| committer | MoonEyes <14891700+MoonEyes@users.noreply.github.com> | 2026-11-28 21:42:45 +0100 |
| commit | 5865220a94f15a9de553c2cb4d07d8bf312d2fcb (patch) | |
| tree | 504db1659f49c49c8a127637a039d90b47534d48 /docs/boot.md | |
| parent | 681dae3a71d425e0924c8d5ba5fd9e31370a2d32 (diff) | |
| parent | 30fc2d68cc509ae9eeb2e39a900dbe1a98b2e745 (diff) | |
Merge main into boot-render-diagnostics (resolve conflict in tools/boot_trace.py)
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Diffstat (limited to 'docs/boot.md')
| -rw-r--r-- | docs/boot.md | 157 |
1 files changed, 144 insertions, 13 deletions
diff --git a/docs/boot.md b/docs/boot.md index 8e62e2534..06b34a11d 100644 --- a/docs/boot.md +++ b/docs/boot.md | |||
| @@ -1,13 +1,9 @@ | |||
| 1 | # First boot: the runbook and the two traces | 1 | # First boot: the runbook and the two traces |
| 2 | 2 | ||
| 3 | **Status: `--dry-run` and `--init` have been run on the retail executable; `--run` has not.** The package in the | 3 | The Windows integration has a dedicated [offline first-run UI profile](first_run_ui.md). The original dry-run |
| 4 | repository's test corpus does not contain `game_scarlett_master.exe` (RT-5); the dry-run on an executable supplied | 4 | and initialization measurements used a separately supplied executable and identified 30 unimplemented imports. |
| 5 | separately maps it and leaves 30 imports unimplemented, and `--init` runs its TLS callbacks and the package DLLs' | 5 | The Winsock shim restricts connections to loopback and the WinHTTP shim refuses outbound requests. Keep retail runs |
| 6 | `DllMain`s without an exception | 6 | offline and traces on the player's machine. [Original import measurements](runtime_imports.md#the-retail-executable-rt-5) |
| 7 | ([`runtime_imports.md`](runtime_imports.md#the-retail-executable-rt-5)), so this page is still the procedure and the | ||
| 8 | trace tool for the first boot. Outbound `ws2_32.dll` and `winhttp.dll` calls are restricted offline by the shims | ||
| 9 | (`ws2_offline.cpp` permits loopback only; `winhttp_offline.cpp` refuses all requests), though running with the network | ||
| 10 | off remains good defence in depth. Nothing here quotes game data; a real trace stays on the player's machine. | ||
| 11 | 7 | ||
| 12 | ## 1. What the first boot produces | 8 | ## 1. What the first boot produces |
| 13 | 9 | ||
| @@ -106,18 +102,106 @@ Useful switches: | |||
| 106 | This switch covers imports only; it does not affect the D3D12 outcomes. | 102 | This switch covers imports only; it does not affect the D3D12 outcomes. |
| 107 | * `LEONIDA_SKIP_CPU_CHECK=1` skips the AVX preflight of `--init` and `--run`, which otherwise exits 4 with one line | 103 | * `LEONIDA_SKIP_CPU_CHECK=1` skips the AVX preflight of `--init` and `--run`, which otherwise exits 4 with one line |
| 108 | naming the missing feature on a host without AVX (a QEMU `qemu64` guest; under Rosetta, set | 104 | naming the missing feature on a host without AVX (a QEMU `qemu64` guest; under Rosetta, set |
| 109 | `ROSETTA_ADVERTISE_AVX=1` instead). The game itself still needs AVX, so this is for the #UD emulation work. | 105 | `ROSETTA_ADVERTISE_AVX=1` instead). The game itself still needs AVX, so this is for the #UD emulation work (see |
| 106 | [cpu_features.md](cpu_features.md#hosts-without-avx) for what works on a host without AVX). | ||
| 110 | * `LEONIDA_SKIP_INT3=1` (with `--trace`) steps over each int3 in guest code and logs it once per address as an | 107 | * `LEONIDA_SKIP_INT3=1` (with `--trace`) steps over each int3 in guest code and logs it once per address as an |
| 111 | `int3_skipped` event, so a boot can be followed past soft asserts (an int3 followed by code that carries on). | 108 | `int3_skipped` event, so a boot can be followed past soft asserts (an int3 followed by code that carries on). It is |
| 109 | read when the trace opens. | ||
| 112 | Diagnostic only: a correct run reaches none, so each skipped address is a finding, not a fix. A failed guest file | 110 | Diagnostic only: a correct run reaches none, so each skipped address is a finding, not a fix. A failed guest file |
| 113 | open is always traced as `file_open_failed` (path, error, caller) when `--trace` is on. | 111 | open is always traced as `file_open_failed` (path, error, caller) when `--trace` is on. |
| 112 | * `LEONIDA_STUB_PIPELINES=1` creates a pipeline whose translated shader is missing (no shader library, or no entry | ||
| 113 | for its program) as a stub instead of failing `CreateGraphicsPipelineState` / `CreateComputePipelineState`. | ||
| 114 | A graphics pipeline with a vertex stage (MVP-GPU-04) is a real Vulkan pipeline built from the built-in stages in | ||
| 115 | `runtime/src/stub_pipeline.h` and registered like any other, so its draws run through replay (render targets, | ||
| 116 | layouts, push constants) and the validation layer. Its vertex stage puts every vertex outside the clip volume, so | ||
| 117 | the draw changes no pixel. `LEONIDA_STUB_PIPELINES=color` makes every three vertices a triangle over the viewport | ||
| 118 | and writes magenta (1 to an integer target) to each render target, so the passes that are stubbed show on screen. | ||
| 119 | The cover needs a triangle topology (a point or line draw marks only its points or lines) and stays inside the | ||
| 120 | scissor rectangle; the title's culling, wireframe fill, sample mask, depth and stencil tests, blending and logic op | ||
| 121 | are off for it, and its write mask is kept. A compute or mesh stub is never registered: `SetPipelineState` binds no | ||
| 122 | executable pipeline and its dispatches and mesh draws are not recorded (D3D-482). A mesh draw with another device's | ||
| 123 | stub, and a draw with another implementation's PSO, are still recording errors. Diagnostic only, like `LEONIDA_SKIP_INT3`: it follows a boot past every pipeline the title | ||
| 124 | creates without translating or running a game shader. Each stub is logged with a power-of-two count. | ||
| 125 | `d3d12_stub_pipelines_test` and `d3d12_stub_draw_test` cover it. | ||
| 126 | * During `--run` on Vulkan, the runtime paints the package shell splash when the title shows its window. The first | ||
| 127 | direct queue presents it on the window's swapchain. Startup clears keep the splash visible until the first | ||
| 128 | non-black output replaces it. The runtime reads `ShellVisuals/SplashScreenImage` from | ||
| 129 | `MicrosoftGame.Config` or `SplashScreen/Image` from `appxmanifest.xml`, preserves the image's aspect ratio and | ||
| 130 | uses the same swapchain for PresentX. A surface without readback hands off at the first title present. | ||
| 131 | Set `LEONIDA_PACKAGE_SPLASH=0` to disable the splash. | ||
| 114 | * `LEONIDA_VK_VALIDATION=1` enables the Khronos validation layer with the Vulkan backend (startup overhead; it is a | 132 | * `LEONIDA_VK_VALIDATION=1` enables the Khronos validation layer with the Vulkan backend (startup overhead; it is a |
| 115 | diagnostic). | 133 | diagnostic). |
| 134 | * `LEONIDA_DEVICE_FAULT=1` enables Vulkan device-loss diagnostics and checkpoints where available. The first | ||
| 135 | observed loss prints a `[rt] device-fault:` report to stderr. | ||
| 136 | * `LEONIDA_TITLE_HUD=1` shows live counters in the title bar of the window the title presents in | ||
| 137 | (`runtime/shims/title_hud.h`). It updates twice a second with: | ||
| 138 | - the frame rate and the average and worst frame time from PresentX, or, when no frame came in that half | ||
| 139 | second, how long since the last one (a hang reads "0 fps, no frame for 12.5 s"); | ||
| 140 | - the process's private memory (its commit charge; Wine fills only `PagefileUsage`, which is the same figure) | ||
| 141 | and working set; | ||
| 142 | - its GPU memory: in use and the budget over the device-local heaps, and in use in the other heaps, read from | ||
| 143 | the Vulkan device through `VK_EXT_memory_budget`. Without that extension it falls back to DXGI's | ||
| 144 | `QueryVideoMemoryInfo`, which reads 0 under Wine; with neither the field reads `VRAM n/a`, not a false 0. | ||
| 145 | Both memory figures and their text come from `runtime/src/memory_figures.h`, which the dev overlay shows too; | ||
| 146 | - the graphics and compute pipelines created, and the seconds spent in `vkCreate*Pipelines` in the last half | ||
| 147 | second. A pipeline compiled in the frame shows up there as a hitch. This needs `LEONIDA_MEM_PROBE`; without it | ||
| 148 | the field reads `PSO -`. | ||
| 149 | - the time since the first present. | ||
| 150 | |||
| 151 | A thread of its own sets the text with `SendMessageTimeout`, so a busy window thread never holds a present. | ||
| 152 | * `LEONIDA_DEV_OVERLAY=1` (Windows) shows what the runtime is doing in a small click-through window over the top left | ||
| 153 | corner of the title's window, while that window is in front (`runtime/src/dev_overlay.h`): frames and submissions a | ||
| 154 | second, where a submission's CPU time goes, the phase that is running now and for how long, pipeline builds in | ||
| 155 | flight, indirect draws emitted and skipped, cores, free RAM, and the same private memory and GPU memory figures as | ||
| 156 | `LEONIDA_TITLE_HUD` (`VRAM n/a` without `VK_EXT_memory_budget`). The device publishes its GPU memory figure, and | ||
| 157 | the overlay and the HUD read it at most once per half second. The rates cover the last two seconds. It has its own | ||
| 158 | thread, so it also counts while the title presents nothing, and it is in no capture. `LEONIDA_TITLE_HUD` shows frame | ||
| 159 | times and compile times in the title bar instead; both can be on. | ||
| 116 | * `DISABLE_RTSS_LAYER=1` and `DISABLE_VULKAN_OBS_CAPTURE=1` when MSI Afterburner or OBS is installed; their | 160 | * `DISABLE_RTSS_LAYER=1` and `DISABLE_VULKAN_OBS_CAPTURE=1` when MSI Afterburner or OBS is installed; their |
| 117 | implicit layers add swapchain usage that shows up as validation errors ([testing.md](testing.md), "Known | 161 | implicit layers add swapchain usage that shows up as validation errors ([testing.md](testing.md), "Known |
| 118 | problems"). | 162 | problems"). |
| 119 | * `--overlay DIR` sends the guest's writes to DIR instead of the default `<game-dir>\overlay` (useful when the | 163 | * `--overlay DIR` sends the guest's writes to DIR instead of the default `<game-dir>\overlay` (useful when the |
| 120 | package drive is read-only); the package itself is never written. | 164 | package drive is read-only); the package itself is never written. Set `LEONIDA_WRITE_DIR` to override that folder |
| 165 | for one run (it wins over `--overlay`). For a fresh first-run profile, also set `LEONIDA_SAVE_DIR` to a separate | ||
| 166 | empty directory for the local game-save provider. The title's `T:` drive (its temporary drive, | ||
| 167 | where it writes its crash dump `T:\<guid>.dmp` and crash log) is a folder of each process's own inside the overlay, | ||
| 168 | `<overlay>\.gta6rt-temp\<YYYYMMDD-HHMMSS-mmm>-pid<id>` (the process's start time in UTC and its id). | ||
| 169 | The folder is reserved with a create-only `CreateDirectoryW` when `gta6rt` starts the title (or on the first `T:` | ||
| 170 | call): when that name already exists, as after a reused process id in the same millisecond, it takes `-2`, `-3`, | ||
| 171 | ... (up to 1000 names), so a run never writes into a folder that existed before it. The startup line names it | ||
| 172 | (`console paths: GAME: -> ..., writes -> ..., T: -> ...`). | ||
| 173 | Folders of earlier runs are kept, so a run's crash files can be read after it stops; delete them by hand. With | ||
| 174 | one folder for every run, a `CREATE_NEW` of a name an earlier run had left failed with `ERROR_FILE_EXISTS` (80) | ||
| 175 | and no report landed (old upstream issue 7913). | ||
| 176 | |||
| 177 | ### Under Wine on Linux | ||
| 178 | |||
| 179 | The prefix has to supply a `d3d12.dll` that exports `D3D12SerializeVersionedRootSignature`, because the executable | ||
| 180 | imports it. Wine's own `d3d12.dll` does not answer that export for the runtime's shim, and the failure is quiet: | ||
| 181 | the D3D12 trace ends at about 1,658 calls, the startup trace ends in an access violation inside the executable, | ||
| 182 | and the one line that names the cause is | ||
| 183 | `[rt] d3d12_xs: host d3d12.dll has no D3D12SerializeVersionedRootSignature`. The run never reaches | ||
| 184 | `CreateRootSignature`. | ||
| 185 | |||
| 186 | Copying the DLLs a Proton prefix installs is not enough on its own: Wine keeps preferring its own copy next to | ||
| 187 | them. Name them in the overrides. | ||
| 188 | |||
| 189 | ```bash | ||
| 190 | GE=$HOME/GE-Proton11-13-x86_64/files/lib/wine | ||
| 191 | cp "$GE/vkd3d-proton/x86_64-windows/d3d12.dll" \ | ||
| 192 | "$GE/vkd3d-proton/x86_64-windows/d3d12core.dll" \ | ||
| 193 | "$GE/dxvk/x86_64-windows/dxgi.dll" "$WINEPREFIX/drive_c/windows/system32/" | ||
| 194 | export WINEDLLOVERRIDES="d3d12,d3d12core,dxgi=n,b" | ||
| 195 | export LEONIDA_D3D12=vulkan | ||
| 196 | export LEONIDA_SHADERS='Z:\path\to\shaders\spirv' | ||
| 197 | wine ./gta6rt.exe --run 'Z:\path\to\game_scarlett_master.exe' --game-dir 'Z:\path\to\the\package' \ | ||
| 198 | --trace /tmp/boot.jsonl --trace-d3d12 | ||
| 199 | ``` | ||
| 200 | |||
| 201 | With those three DLLs and the override, the same prefix reaches the frame loop: about 1.4 million D3D12 calls in | ||
| 202 | 90 s, no exception, `PresentX ready`, against 1,658 calls and an access violation without them, measured on Wine | ||
| 203 | 11.13 (GE-Proton 11-13) with an RDNA2 iGPU. A prefix that Proton itself created already carries these files and | ||
| 204 | needs no override. | ||
| 121 | 205 | ||
| 122 | ## 3. Triage order | 206 | ## 3. Triage order |
| 123 | 207 | ||
| @@ -187,7 +271,7 @@ order. It maps each question to the event to look for; it does not answer them. | |||
| 187 | | 11 | `CheckFeatureSupport` answers | the call's `ok`/`failed` and the `[rt]` feature-id line; the answer itself is not logged yet | | 271 | | 11 | `CheckFeatureSupport` answers | the call's `ok`/`failed` and the `[rt]` feature-id line; the answer itself is not logged yet | |
| 188 | | 12 | Async compute / copy queues | queue creation and cross-queue fences | | 272 | | 12 | Async compute / copy queues | queue creation and cross-queue fences | |
| 189 | | 13 | 144-byte push constants | device creation `[rt]` line; `push_constants_need_fallback` when the device reports fewer | | 273 | | 13 | 144-byte push constants | device creation `[rt]` line; `push_constants_need_fallback` when the device reports fewer | |
| 190 | | 14 | Two code-base stages in one PSO | PSO creation log; the index metadata (`uses_code_base`) | | 274 | | 14 | Two code-base stages in one PSO | answered without a trace: the pipeline library pairs the stages, and `tools/pso_code_base_pairs.py` counts 0 of 25,471 (`uses_code_base` per stage comes from the index metadata) | |
| 191 | | 15 | `ExecuteIndirect` signatures | `CreateCommandSignature` and `ExecuteIndirect` calls | | 275 | | 15 | `ExecuteIndirect` signatures | `CreateCommandSignature` and `ExecuteIndirect` calls | |
| 192 | | 16 | UAV counters and typed buffer formats | UAV descs and V# format logs; formats outside `Gen.FORMATS` read 0 | | 276 | | 16 | UAV counters and typed buffer formats | UAV descs and V# format logs; formats outside `Gen.FORMATS` read 0 | |
| 193 | | 17 | Upload/readback resources reaching shaders | `CreateCommittedResource` heap types and the VB/IB/descriptor that points at one | | 277 | | 17 | Upload/readback resources reaching shaders | `CreateCommittedResource` heap types and the VB/IB/descriptor that points at one | |
| @@ -206,7 +290,54 @@ order. It maps each question to the event to look for; it does not answer them. | |||
| 206 | does not affect these outcomes. | 290 | does not affect these outcomes. |
| 207 | * `exit` is the game's own code, not the loader's. A crash after the first frame is the next layer question. | 291 | * `exit` is the game's own code, not the loader's. A crash after the first frame is the next layer question. |
| 208 | 292 | ||
| 209 | ## 6. Limits | 293 | ## 6. Which pull requests a stop depends on |
| 294 | |||
| 295 | A stop is only comparable with someone else's when both name the same base, the same pull requests in the same | ||
| 296 | order, and a shader library made by the same translator. `tools/boot_matrix.py` makes that one row per named set: | ||
| 297 | |||
| 298 | ```powershell | ||
| 299 | python -I tools\boot_matrix.py merge --base origin/main --fetch origin --out $matrix ` | ||
| 300 | --set main= --set rt5=445 --set rt5-plus=445,565 | ||
| 301 | # check out or export boot-matrix/rt5 where you build, then, per set: | ||
| 302 | python -I tools\boot_matrix.py run $matrix --set rt5 --tree $tree --exe $exe --game-dir $pkg ` | ||
| 303 | --shaders $work\shaders\spirv --build | ||
| 304 | python -I tools\boot_matrix.py report $matrix | ||
| 305 | ``` | ||
| 306 | |||
| 307 | * `merge` only runs git (`merge-tree --write-tree`, `commit-tree`): no checkout, nothing from a pull request runs. | ||
| 308 | A PR that `scripts/merge_check.py` finds already on the base is skipped (also one merged and then reverted there: | ||
| 309 | git merges an ancestor as a no-op, so revert the revert on a branch and give it as `N:REF`); one that conflicts | ||
| 310 | with an earlier PR in the set is skipped too (its files are listed in `matrix.json`, and whether it conflicts with | ||
| 311 | the base itself or only with the PRs before it). Each set becomes the branch `boot-matrix/<set>`; an empty set | ||
| 312 | (`main=`) is the base alone, the row to compare the others with. A set's branch that is checked out in the | ||
| 313 | repository stops the merge before anything is written. | ||
| 314 | * `run` first checks that the tree holds the set's head: `merge` writes the blob id of every file of that head to | ||
| 315 | `<matrix>/<set>/files.json`, and a tree that lacks one of them or holds other content stops the run (exit 2) before | ||
| 316 | anything is built. CRLF line ends count as the same file; files the head does not have (a build folder) are not | ||
| 317 | looked at. It then builds `runtime/` in the tree, in a build folder of the head's own | ||
| 318 | (`runtime/build-boot-matrix-<head>`, so an earlier set's binary is never reused), or takes `--gta6rt`: such a run | ||
| 319 | is recorded as built `prebuilt (unverified)`, since nothing shows which source the binary came from. It runs | ||
| 320 | `--run --trace --trace-d3d12` with `LEONIDA_D3D12=vulkan` and stops the process tree at `--timeout` (600 s). Each | ||
| 321 | run gets a fresh `LEONIDA_SAVE_DIR`, and a fresh overlay unless `--overlay` names one, so what an earlier run wrote | ||
| 322 | cannot change it. The traces stay in `<matrix>/<set>/runN/`; `result.json` has the stop, the D3D12 call count, the | ||
| 323 | last call and the run's options (`--env` names, timeout, overlay, configuration). | ||
| 324 | * The `Shaders` column compares the library's `translation_sources.sha256` (written by `make_game.py`) with the | ||
| 325 | same digest over the tree: `stale` means the library came from another translator, a common reason a stop does | ||
| 326 | not reproduce. | ||
| 327 | * `report` prints the Markdown table (or `--json`), with the newest run of each set's current head. Both pass on | ||
| 328 | only a fixed list of fields, each checked for the form it should have: the base and the heads as commits, set | ||
| 329 | names, each PR's number, status and why it was skipped, the build and shader state, the stop's kind, exit or | ||
| 330 | exception code, module+RVA and access kind, the counts, the run's options (`LEONIDA_*` names, others counted) and | ||
| 331 | the last D3D12 call as number, label and outcome. A label of the shape the runtime writes | ||
| 332 | (`ID3D12Device::CreateFence`, `Xbox CreatePlacedResourceX (device slot 133)`) is shown whole, one with free text | ||
| 333 | after its name is cut to the name, anything else is `(other)`; an outcome, exception code or access kind of | ||
| 334 | another form is `other`, and a location outside every known module is `unmapped`. The refs given for the base and | ||
| 335 | the PRs, merge_check's verdicts, conflicted file names, the access address and the loader's error message (it can | ||
| 336 | name a path) stay in `matrix.json` and `result.json` on your machine. A `last exception` row is the last exception | ||
| 337 | the trace recorded before the process ended; exceptions are logged before handlers run, so it is where to look | ||
| 338 | first, not proof of the cause. | ||
| 339 | |||
| 340 | ## 7. Limits | ||
| 210 | 341 | ||
| 211 | The retail executable is not in the package, so this page is untested against it; the tool and the trace formats | 342 | The retail executable is not in the package, so this page is untested against it; the tool and the trace formats |
| 212 | are tested on synthetic fixtures and on `tiny_game` (which has no D3D12 calls). The present slots (Q6) and the | 343 | are tested on synthetic fixtures and on `tiny_game` (which has no D3D12 calls). The present slots (Q6) and the |