upleb.uk

Public git repos — served from a NIP-34 GRASP relay at git.upleb.uk

summaryrefslogtreecommitdiff
path: root/docs/boot.md
diff options
context:
space:
mode:
authorOreoFR <tony37160@hotmail.fr>2026-11-30 11:29:46 +0100
committerOreoFR <tony37160@hotmail.fr>2026-11-30 11:29:46 +0100
commitca71fd7f5c04ca3ec269fd3983e7201ac3344b8b (patch)
treec92cfb77f76f7fd422f7efefcc8468526384af17 /docs/boot.md
parente76cabc17a7400d6ab73da0e2689554b182df52a (diff)
parent012b79a6787cd47d31dcf023eb2b67a1eac6d77f (diff)
Merge remote-tracking branch 'origin/main' into reprise-1837
Diffstat (limited to 'docs/boot.md')
-rw-r--r--docs/boot.md163
1 files changed, 150 insertions, 13 deletions
diff --git a/docs/boot.md b/docs/boot.md
index 2b7186e30..688d91dd1 100644
--- a/docs/boot.md
+++ b/docs/boot.md
@@ -28,8 +28,15 @@ DllMain/TLS results, exceptions with their stack frames, the exit, and the D3D12
28per method. When `XboxPresentation` logs its teardown `[rt] present: pacing summary ...` line (BL-6), the D3D12 28per method. When `XboxPresentation` logs its teardown `[rt] present: pacing summary ...` line (BL-6), the D3D12
29summary also reports the frame count, interval count, target interval, mean and drift against target, `p50`/`p95`/`p99` 29summary also reports the frame count, interval count, target interval, mean and drift against target, `p50`/`p95`/`p99`
30frame times, and `p50`/`p95`/`p99` origin-to-present latencies (and includes the numeric `frame_pacing` object in 30frame times, and `p50`/`p95`/`p99` origin-to-present latencies (and includes the numeric `frame_pacing` object in
31`--json` and `--counts-only`). The remaining `[rt]` lines in the same stderr log carry the device parameters, feature 31`--json` and `--counts-only`).
32ids and warnings; the summary leaves them as a count, so grep `^\[rt\]` for those. 32
33The same report counts shader translation lookup failures by stage. For builds with `LEONIDA_STUB_PIPELINES`,
34the highest logged creation milestone gives a lower bound on stub pipelines created. The runtime can create a
35pipeline without ever drawing with it. If the presenter logged capture measurements, the report counts black and
36nonblack readbacks. On older builds, a positive mean establishes color, while three rounded zero means leave the
37capture inconclusive. A successful `PresentX` call alone gives no pixel measurement. To share just the counters,
38run `python -I tools/boot_trace.py --d3d12 d3d12.log --counts-only`. For device parameters, feature IDs and other
39warnings, inspect the original stderr locally.
33 40
34For `xmem_physical_pages`, the shim records the first request for each distinct attribute word. The text and 41For `xmem_physical_pages`, the shim records the first request for each distinct attribute word. The text and
35JSON summaries list the API, raw attribute word, requested page count and caller for the first `--limit` 42JSON summaries list the API, raw attribute word, requested page count and caller for the first `--limit`
@@ -95,17 +102,31 @@ Useful switches:
95 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.
96* `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
97 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
98 `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).
99* `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
100 `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.
101 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
102 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_SKIP_ASSERTS=N` steps over up to N int3 in guest code, with or without `--trace`, and prints each one
113 as `[rt] LEONIDA_SKIP_ASSERTS: int3 at <module>+0x... stepped over (k of N)`; the next one after N ends the run as
114 before. An int3 in a host module is never stepped over. The same caveat: each skipped address is a finding
115 ([runtime/README.md](../runtime/README.md), "Guest asserts").
103* `LEONIDA_STUB_PIPELINES=1` creates a pipeline whose translated shader is missing (no shader library, or no entry 116* `LEONIDA_STUB_PIPELINES=1` creates a pipeline whose translated shader is missing (no shader library, or no entry
104 for its program) as a no-op stub instead of failing `CreateGraphicsPipelineState` / `CreateComputePipelineState`. 117 for its program) as a stub instead of failing `CreateGraphicsPipelineState` / `CreateComputePipelineState`.
105 The stub is never registered, so `SetPipelineState` binds no PSO and its draws and dispatches are no-ops (D3D-482). 118 A graphics pipeline with a vertex stage (MVP-GPU-04) is a real Vulkan pipeline built from the built-in stages in
106 Diagnostic only, like `LEONIDA_SKIP_INT3`: it follows a boot past every pipeline the title creates without 119 `runtime/src/stub_pipeline.h` and registered like any other, so its draws run through replay (render targets,
107 translating or running a game shader, so nothing the title draws reaches the screen. Each stub is logged with a 120 layouts, push constants) and the validation layer. Its vertex stage puts every vertex outside the clip volume, so
108 power-of-two count. 121 the draw changes no pixel. `LEONIDA_STUB_PIPELINES=color` makes every three vertices a triangle over the viewport
122 and writes magenta (1 to an integer target) to each render target, so the passes that are stubbed show on screen.
123 The cover needs a triangle topology (a point or line draw marks only its points or lines) and stays inside the
124 scissor rectangle; the title's culling, wireframe fill, sample mask, depth and stencil tests, blending and logic op
125 are off for it, and its write mask is kept. A compute or mesh stub is never registered: `SetPipelineState` binds no
126 executable pipeline and its dispatches and mesh draws are not recorded (D3D-482). A mesh draw with another device's
127 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
128 creates without translating or running a game shader. Each stub is logged with a power-of-two count.
129 `d3d12_stub_pipelines_test` and `d3d12_stub_draw_test` cover it.
109* During `--run` on Vulkan, the runtime paints the package shell splash when the title shows its window. The first 130* During `--run` on Vulkan, the runtime paints the package shell splash when the title shows its window. The first
110 direct queue presents it on the window's swapchain. Startup clears keep the splash visible until the first 131 direct queue presents it on the window's swapchain. Startup clears keep the splash visible until the first
111 non-black output replaces it. The runtime reads `ShellVisuals/SplashScreenImage` from 132 non-black output replaces it. The runtime reads `ShellVisuals/SplashScreenImage` from
@@ -116,13 +137,82 @@ Useful switches:
116 diagnostic). 137 diagnostic).
117* `LEONIDA_DEVICE_FAULT=1` enables Vulkan device-loss diagnostics and checkpoints where available. The first 138* `LEONIDA_DEVICE_FAULT=1` enables Vulkan device-loss diagnostics and checkpoints where available. The first
118 observed loss prints a `[rt] device-fault:` report to stderr. 139 observed loss prints a `[rt] device-fault:` report to stderr.
140* `LEONIDA_IO_TRACE=<file>` writes one line for every read the title asks for (`runtime/shims/io_trace.h`):
141 - `ds`: a DirectStorage request, with its file, file offset, source and destination sizes, zlib and BCPack, and the
142 request's name;
143 - `rf`: a ReadFile, ReadFileEx or ReadFileScatter on a disk file, with its path, offset and size.
144
145 Each line starts with the local time, as the `mem-probe` lines do. Each line is flushed at once and the file can be
146 read while the game runs, so the last reads before a crash or a device loss name what the title was loading.
147* `LEONIDA_TITLE_HUD=1` shows live counters in the title bar of the window the title presents in
148 (`runtime/shims/title_hud.h`). It updates twice a second with:
149 - the frame rate and the average and worst frame time from PresentX, or, when no frame came in that half
150 second, how long since the last one (a hang reads "0 fps, no frame for 12.5 s");
151 - the process's private memory (its commit charge; Wine fills only `PagefileUsage`, which is the same figure)
152 and working set;
153 - its GPU memory: in use and the budget over the device-local heaps, and in use in the other heaps, read from
154 the Vulkan device through `VK_EXT_memory_budget`. Without that extension it falls back to DXGI's
155 `QueryVideoMemoryInfo`, which reads 0 under Wine; with neither the field reads `VRAM n/a`, not a false 0.
156 Both memory figures and their text come from `runtime/src/memory_figures.h`, which the dev overlay shows too;
157 - the graphics and compute pipelines created, and the seconds spent in `vkCreate*Pipelines` in the last half
158 second. A pipeline compiled in the frame shows up there as a hitch. This needs `LEONIDA_MEM_PROBE`; without it
159 the field reads `PSO -`.
160 - the time since the first present.
161
162 A thread of its own sets the text with `SendMessageTimeout`, so a busy window thread never holds a present.
163* `LEONIDA_DEV_OVERLAY=1` (Windows) shows what the runtime is doing in a small click-through window over the top left
164 corner of the title's window, while that window is in front (`runtime/src/dev_overlay.h`): frames and submissions a
165 second, where a submission's CPU time goes, the phase that is running now and for how long, pipeline builds in
166 flight, indirect draws emitted and skipped, cores, free RAM, and the same private memory and GPU memory figures as
167 `LEONIDA_TITLE_HUD` (`VRAM n/a` without `VK_EXT_memory_budget`). The device publishes its GPU memory figure, and
168 the overlay and the HUD read it at most once per half second. The rates cover the last two seconds. It has its own
169 thread, so it also counts while the title presents nothing, and it is in no capture. `LEONIDA_TITLE_HUD` shows frame
170 times and compile times in the title bar instead; both can be on.
119* `DISABLE_RTSS_LAYER=1` and `DISABLE_VULKAN_OBS_CAPTURE=1` when MSI Afterburner or OBS is installed; their 171* `DISABLE_RTSS_LAYER=1` and `DISABLE_VULKAN_OBS_CAPTURE=1` when MSI Afterburner or OBS is installed; their
120 implicit layers add swapchain usage that shows up as validation errors ([testing.md](testing.md), "Known 172 implicit layers add swapchain usage that shows up as validation errors ([testing.md](testing.md), "Known
121 problems"). 173 problems").
122* `--overlay DIR` sends the guest's writes to DIR instead of the default `<game-dir>\overlay` (useful when the 174* `--overlay DIR` sends the guest's writes to DIR instead of the default `<game-dir>\overlay` (useful when the
123 package drive is read-only); the package itself is never written. Set `LEONIDA_WRITE_DIR` to override that folder 175 package drive is read-only); the package itself is never written. Set `LEONIDA_WRITE_DIR` to override that folder
124 for one run (it wins over `--overlay`). For a fresh first-run profile, also set `LEONIDA_SAVE_DIR` to a separate 176 for one run (it wins over `--overlay`). For a fresh first-run profile, also set `LEONIDA_SAVE_DIR` to a separate
125 empty directory for the local game-save provider. 177 empty directory for the local game-save provider. The title's `T:` drive (its temporary drive,
178 where it writes its crash dump `T:\<guid>.dmp` and crash log) is a folder of each process's own inside the overlay,
179 `<overlay>\.gta6rt-temp\<YYYYMMDD-HHMMSS-mmm>-pid<id>` (the process's start time in UTC and its id).
180 The folder is reserved with a create-only `CreateDirectoryW` when `gta6rt` starts the title (or on the first `T:`
181 call): when that name already exists, as after a reused process id in the same millisecond, it takes `-2`, `-3`,
182 ... (up to 1000 names), so a run never writes into a folder that existed before it. The startup line names it
183 (`console paths: GAME: -> ..., writes -> ..., T: -> ...`).
184 Folders of earlier runs are kept, so a run's crash files can be read after it stops; delete them by hand. With
185 one folder for every run, a `CREATE_NEW` of a name an earlier run had left failed with `ERROR_FILE_EXISTS` (80)
186 and no report landed (old upstream issue 7913).
187
188### Under Wine on Linux
189
190The prefix has to supply a `d3d12.dll` that exports `D3D12SerializeVersionedRootSignature`, because the executable
191imports it. Wine's own `d3d12.dll` does not answer that export for the runtime's shim, and the failure is quiet:
192the D3D12 trace ends at about 1,658 calls, the startup trace ends in an access violation inside the executable,
193and the one line that names the cause is
194`[rt] d3d12_xs: host d3d12.dll has no D3D12SerializeVersionedRootSignature`. The run never reaches
195`CreateRootSignature`.
196
197Copying the DLLs a Proton prefix installs is not enough on its own: Wine keeps preferring its own copy next to
198them. Name them in the overrides.
199
200```bash
201GE=$HOME/GE-Proton11-13-x86_64/files/lib/wine
202cp "$GE/vkd3d-proton/x86_64-windows/d3d12.dll" \
203 "$GE/vkd3d-proton/x86_64-windows/d3d12core.dll" \
204 "$GE/dxvk/x86_64-windows/dxgi.dll" "$WINEPREFIX/drive_c/windows/system32/"
205export WINEDLLOVERRIDES="d3d12,d3d12core,dxgi=n,b"
206export LEONIDA_D3D12=vulkan
207export LEONIDA_SHADERS='Z:\path\to\shaders\spirv'
208wine ./gta6rt.exe --run 'Z:\path\to\game_scarlett_master.exe' --game-dir 'Z:\path\to\the\package' \
209 --trace /tmp/boot.jsonl --trace-d3d12
210```
211
212With those three DLLs and the override, the same prefix reaches the frame loop: about 1.4 million D3D12 calls in
21390 s, no exception, `PresentX ready`, against 1,658 calls and an access violation without them, measured on Wine
21411.13 (GE-Proton 11-13) with an RDNA2 iGPU. A prefix that Proton itself created already carries these files and
215needs no override.
126 216
127## 3. Triage order 217## 3. Triage order
128 218
@@ -179,7 +269,7 @@ order. It maps each question to the event to look for; it does not answer them.
179 269
180| # | Question | Signal in the first trace | 270| # | Question | Signal in the first trace |
181|---|---|---| 271|---|---|---|
182| 1 | `D3D12XboxCreateDevice` 24-word params and flags | first `D3D12XboxCreateDevice` in the D3D12 trace; the shim prints the 24 words as an `[rt]` line in the same log, with or without `--trace-d3d12` (grep `^\[rt\]`); accept unknown flags | 272| 1 | `D3D12XboxCreateDevice` 0x50-byte params and flags | first `D3D12XboxCreateDevice` in the D3D12 trace; the shim prints the twenty dwords as an `[rt]` line in the same log, with or without `--trace-d3d12` (grep `^\[rt\]`); accept unknown flags. The struct is 0x50 bytes (20 dwords), not 24 words: at the single retail call site it is a stack local of a `0x228` frame whose saved `xmm6` begins at `+0x200`, and three 32-byte stores zero it up to `+0x4F`. Only `+0x00 = 0x00020004`, `+0x08 = 0x00100000`, `+0x28 = 1` and `+0x3C = 0x20` are fixed; `+0x20` and `+0x24` carry two bytes of launch state and `+0x30`-`+0x4F` stay zero. Adapter is null, the IID is `{5405C344-D457-444E-B4DD-2366E45AEE39}` |
183| 2 | Xbox device/heap/queue/command-list slots | queue, fence and allocator method names in the D3D12 trace; device slots past the PC vtable print an `[rt] d3d12_xs: device slot …` line instead and record nothing; compare with the SDK vtable | 273| 2 | Xbox device/heap/queue/command-list slots | queue, fence and allocator method names in the D3D12 trace; device slots past the PC vtable print an `[rt] d3d12_xs: device slot …` line instead and record nothing; compare with the SDK vtable |
184| 3 | Root signature → `s0..s31` | `CreateRootSignature`, `SetGraphicsRootSignature`, then the shader's user-SGPR reads; mask `0x03000000` on a copy | 274| 3 | Root signature → `s0..s31` | `CreateRootSignature`, `SetGraphicsRootSignature`, then the shader's user-SGPR reads; mask `0x03000000` on a copy |
185| 4 | Descriptor bytes and heap increments | first `CreateShaderResourceView`/`CreateSampler` and the first draw; dump the heap bytes and compare with the T#/S# parser | 275| 4 | Descriptor bytes and heap increments | first `CreateShaderResourceView`/`CreateSampler` and the first draw; dump the heap bytes and compare with the T#/S# parser |
@@ -192,7 +282,7 @@ order. It maps each question to the event to look for; it does not answer them.
192| 11 | `CheckFeatureSupport` answers | the call's `ok`/`failed` and the `[rt]` feature-id line; the answer itself is not logged yet | 282| 11 | `CheckFeatureSupport` answers | the call's `ok`/`failed` and the `[rt]` feature-id line; the answer itself is not logged yet |
193| 12 | Async compute / copy queues | queue creation and cross-queue fences | 283| 12 | Async compute / copy queues | queue creation and cross-queue fences |
194| 13 | 144-byte push constants | device creation `[rt]` line; `push_constants_need_fallback` when the device reports fewer | 284| 13 | 144-byte push constants | device creation `[rt]` line; `push_constants_need_fallback` when the device reports fewer |
195| 14 | Two code-base stages in one PSO | PSO creation log; the index metadata (`uses_code_base`) | 285| 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) |
196| 15 | `ExecuteIndirect` signatures | `CreateCommandSignature` and `ExecuteIndirect` calls | 286| 15 | `ExecuteIndirect` signatures | `CreateCommandSignature` and `ExecuteIndirect` calls |
197| 16 | UAV counters and typed buffer formats | UAV descs and V# format logs; formats outside `Gen.FORMATS` read 0 | 287| 16 | UAV counters and typed buffer formats | UAV descs and V# format logs; formats outside `Gen.FORMATS` read 0 |
198| 17 | Upload/readback resources reaching shaders | `CreateCommittedResource` heap types and the VB/IB/descriptor that points at one | 288| 17 | Upload/readback resources reaching shaders | `CreateCommittedResource` heap types and the VB/IB/descriptor that points at one |
@@ -211,7 +301,54 @@ order. It maps each question to the event to look for; it does not answer them.
211 does not affect these outcomes. 301 does not affect these outcomes.
212* `exit` is the game's own code, not the loader's. A crash after the first frame is the next layer question. 302* `exit` is the game's own code, not the loader's. A crash after the first frame is the next layer question.
213 303
214## 6. Limits 304## 6. Which pull requests a stop depends on
305
306A stop is only comparable with someone else's when both name the same base, the same pull requests in the same
307order, and a shader library made by the same translator. `tools/boot_matrix.py` makes that one row per named set:
308
309```powershell
310python -I tools\boot_matrix.py merge --base origin/main --fetch origin --out $matrix `
311 --set main= --set rt5=445 --set rt5-plus=445,565
312# check out or export boot-matrix/rt5 where you build, then, per set:
313python -I tools\boot_matrix.py run $matrix --set rt5 --tree $tree --exe $exe --game-dir $pkg `
314 --shaders $work\shaders\spirv --build
315python -I tools\boot_matrix.py report $matrix
316```
317
318* `merge` only runs git (`merge-tree --write-tree`, `commit-tree`): no checkout, nothing from a pull request runs.
319 A PR that `scripts/merge_check.py` finds already on the base is skipped (also one merged and then reverted there:
320 git merges an ancestor as a no-op, so revert the revert on a branch and give it as `N:REF`); one that conflicts
321 with an earlier PR in the set is skipped too (its files are listed in `matrix.json`, and whether it conflicts with
322 the base itself or only with the PRs before it). Each set becomes the branch `boot-matrix/<set>`; an empty set
323 (`main=`) is the base alone, the row to compare the others with. A set's branch that is checked out in the
324 repository stops the merge before anything is written.
325* `run` first checks that the tree holds the set's head: `merge` writes the blob id of every file of that head to
326 `<matrix>/<set>/files.json`, and a tree that lacks one of them or holds other content stops the run (exit 2) before
327 anything is built. CRLF line ends count as the same file; files the head does not have (a build folder) are not
328 looked at. It then builds `runtime/` in the tree, in a build folder of the head's own
329 (`runtime/build-boot-matrix-<head>`, so an earlier set's binary is never reused), or takes `--gta6rt`: such a run
330 is recorded as built `prebuilt (unverified)`, since nothing shows which source the binary came from. It runs
331 `--run --trace --trace-d3d12` with `LEONIDA_D3D12=vulkan` and stops the process tree at `--timeout` (600 s). Each
332 run gets a fresh `LEONIDA_SAVE_DIR`, and a fresh overlay unless `--overlay` names one, so what an earlier run wrote
333 cannot change it. The traces stay in `<matrix>/<set>/runN/`; `result.json` has the stop, the D3D12 call count, the
334 last call and the run's options (`--env` names, timeout, overlay, configuration).
335* The `Shaders` column compares the library's `translation_sources.sha256` (written by `make_game.py`) with the
336 same digest over the tree: `stale` means the library came from another translator, a common reason a stop does
337 not reproduce.
338* `report` prints the Markdown table (or `--json`), with the newest run of each set's current head. Both pass on
339 only a fixed list of fields, each checked for the form it should have: the base and the heads as commits, set
340 names, each PR's number, status and why it was skipped, the build and shader state, the stop's kind, exit or
341 exception code, module+RVA and access kind, the counts, the run's options (`LEONIDA_*` names, others counted) and
342 the last D3D12 call as number, label and outcome. A label of the shape the runtime writes
343 (`ID3D12Device::CreateFence`, `Xbox CreatePlacedResourceX (device slot 133)`) is shown whole, one with free text
344 after its name is cut to the name, anything else is `(other)`; an outcome, exception code or access kind of
345 another form is `other`, and a location outside every known module is `unmapped`. The refs given for the base and
346 the PRs, merge_check's verdicts, conflicted file names, the access address and the loader's error message (it can
347 name a path) stay in `matrix.json` and `result.json` on your machine. A `last exception` row is the last exception
348 the trace recorded before the process ended; exceptions are logged before handlers run, so it is where to look
349 first, not proof of the cause.
350
351## 7. Limits
215 352
216The retail executable is not in the package, so this page is untested against it; the tool and the trace formats 353The retail executable is not in the package, so this page is untested against it; the tool and the trace formats
217are tested on synthetic fixtures and on `tiny_game` (which has no D3D12 calls). The present slots (Q6) and the 354are tested on synthetic fixtures and on `tiny_game` (which has no D3D12 calls). The present slots (Q6) and the