upleb.uk

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

summaryrefslogtreecommitdiff
path: root/docs
diff options
context:
space:
mode:
authorMoonEyes <14891700+MoonEyes@users.noreply.github.com>2026-11-30 10:29:56 +0100
committerMoonEyes <14891700+MoonEyes@users.noreply.github.com>2026-11-30 10:29:56 +0100
commit589b2d28fa70c2b5dea1be111d414b68340f8897 (patch)
tree24310ff4549b2d7f2e6716d0ddaf15277b713519 /docs
parent1bb726b30f0708bdbce85eab15966e7ab281e518 (diff)
docs: how to measure the D3D12 runtime's frame rates, and its LEONIDA_* variables
d3d12/docs/findings.md was reachable from d3d12/README.md alone, so a night of runs repeated measurements it already holds. Index it, point AGENTS.md at it, say how to measure (a switch by turns inside one run), and list the variables the runtime names from its own sources: 415 of 669 were in no Markdown file. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Diffstat (limited to 'docs')
-rw-r--r--docs/README.md3
-rw-r--r--docs/measuring_fps.md82
2 files changed, 85 insertions, 0 deletions
diff --git a/docs/README.md b/docs/README.md
index 40e9ad264..4aca8051d 100644
--- a/docs/README.md
+++ b/docs/README.md
@@ -125,6 +125,9 @@ method, scope and caveats. No game data is included.
125 125
126| Document | What it covers | 126| Document | What it covers |
127|---|---| 127|---|---|
128| [measuring_fps.md](measuring_fps.md) | How to measure frame rates of the D3D12 runtime (`d3d12/`): look in the findings first, turn a switch inside one run with `LEONIDA_AB`, separate runs, which log number means what, what to write before reporting a cause. |
129| [d3d12/docs/findings.md](../d3d12/docs/findings.md) | What was measured of the D3D12 runtime's frame on several PCs: where a frame goes, switches by turns with their spread, what was not worth it, picture faults and what they were. |
130| [d3d12/docs/switches.md](../d3d12/docs/switches.md) | The `LEONIDA_*` variables the D3D12 runtime names, made from its sources (`tools/d3d12_switches.py`): how each is read, whether `LEONIDA_AB` can turn it, the sentence of the code's comment. |
128| [launcher.md](launcher.md) | The Leonida Launcher: the desktop window with navigation, a PLAY button, status line and pages; Leonida's own design, no game assets. | 131| [launcher.md](launcher.md) | The Leonida Launcher: the desktop window with navigation, a PLAY button, status line and pages; Leonida's own design, no game assets. |
129| [mod-menu.md](mod-menu.md) | The in-game trainer menu drawn by the D3D12 runtime (`d3d12/`): on by default, `LEONIDA_MENU=0` turns it off; single player only, nothing online. | 132| [mod-menu.md](mod-menu.md) | The in-game trainer menu drawn by the D3D12 runtime (`d3d12/`): on by default, `LEONIDA_MENU=0` turns it off; single player only, nothing online. |
130| [lua-modding.md](lua-modding.md) | Lua 5.4 mods in the D3D12 runtime: a folder in `mods\` with the same `mod.json` the mod manager lists, and a script next to it. | 133| [lua-modding.md](lua-modding.md) | Lua 5.4 mods in the D3D12 runtime: a folder in `mods\` with the same `mod.json` the mod manager lists, and a script next to it. |
diff --git a/docs/measuring_fps.md b/docs/measuring_fps.md
new file mode 100644
index 000000000..e97fe2a9e
--- /dev/null
+++ b/docs/measuring_fps.md
@@ -0,0 +1,82 @@
1# Measuring frame rates of the D3D12 runtime
2
3How to find out whether a change or a switch moves the frame of the Rust D3D12 runtime (`d3d12/`), and how not to fool
4yourself. It is about method; the measurements are in [d3d12/docs/findings.md](../d3d12/docs/findings.md) and the list
5of switches in [d3d12/docs/switches.md](../d3d12/docs/switches.md).
6
7## 1. Look first
8
9Search [findings.md](../d3d12/docs/findings.md) for the switch or the function you have in mind, on a fresh `main`.
10Many switches have been measured there, with the card, the scene, the method and the spread. On the night of
112026-11-29 several runs on two PCs went into `LEONIDA_COPYBACK_ELIDE`, whose entry already said "not usable here".
12
13## 2. Turn the switch inside one run
14
15`LEONIDA_AB=<seconds>,<switch>[,<switch>..]` turns switches on and off every so many seconds while the title runs, so
16both sides are measured in one scene, at one cache temperature, beside the same programs
17([`ab.rs`](../d3d12/crates/leonida-gpu/src/ab.rs)):
18
19- It needs a build with `diagnostics` (the one `d3d12/scripts/build-nvidia.ps1` makes) and more than one second a phase.
20- Up to eight switches; switch number *n* is on in the phases whose number has bit *n*, so every combination comes round.
21- A switch named there no longer goes by its own variable. Only switches the code reads that way follow it; for any
22 other name the phases are logged and nothing changes, so check the name in [switches.md](../d3d12/docs/switches.md)
23 or the code before you believe a "no difference".
24- Not every switch may be turned in play: `findings.md` has one that ends the title (`LEONIDA_ASYNC_SUBMIT`).
25- Each phase ends with a line `A/B phase <n> bits <b> on [...]`: frames, mean, median, p90, draws a frame, the card's
26 idle and busy time a frame and the submitting thread's work a frame. The first second of a phase is left out.
27
28Phases of 3.5 to 4 s worked there. The idle camera goes round views of about 24 s with different draw counts, so phases
29of 15 s measured the views rather than the switch. Standing, `findings.md` cuts the phases into stretches where the draw count
30jumps, leaves out the first phase of a stretch and fits a level for each stretch; walking, it takes the mean of the differences of
31neighbouring phases. Give the effect **with its standard error**. The scripts it names for this (`ab_pair.py`, `ab_eff.py`) are not in
32the repository.
33
34That gave about 0.2 to 0.8 ms of spread for a standing run of some minutes and 1 to 2 ms for a walking one. Two separate
35runs of one setting differed by 7 ms in one of its tables (75.0 and 82.1 ms).
36
37## 3. When only separate runs will do
38
39A change of code, or a switch that cannot be turned in play, needs separate runs:
40
41- The same save for every start. The title rewrites its autosave, so keep a copy and put it back before each start
42 (and the player's own back afterwards).
43- Alternate (A B B A), in one sitting, with a throwaway run first: one PC's first measured run after a warm-up came out slowest
44 in both series it was looked for in (2026-11-30; not explained).
45- After a translator change, or on a new build, play a while first. Until its pipelines are made, a run measures that.
46- The same programs in the background, and nothing heavy beside it: no compiler, no test suite. `findings.md` has one build at 16.2 to 17.3
47 and then 12.8 frames a second; what had changed was the programs that start with Windows.
48- Check every run for the state you think it was in: it reached the world, it did not stay in the menu, it did not end early. A run
49 that stayed in the menu shows 60.
50- With two runs a side, do not claim a difference smaller than the spread between runs of the same side.
51
52## 4. Which number means what
53
54- **Frame time, not only frames a second.** The line `leonida_gpu::host: <n> fps, <ms> ms/frame (...)` counts rendered
55 frames. With frame generation the screen shows more; say which you mean, or measure with `-NoFrameGen`.
56- Report the median and a low percentile, and leave the menu and the loading out.
57- **A sum over all threads is not a part of the frame.** "All threads", "list calls ... ms", the process's CPU time and
58 a whole-process profile add up work that runs side by side. They can exceed the frame many times over.
59- **A thread that waits because it has nothing to do costs nothing.** The relay line says its thread waits "beside the
60 submitting thread"; what other threads lost to it is in the line about *settles*.
61- Draws "left out on purpose" are not missing pipelines; the line gives both counts.
62- The frame stands at the longest of its walls (the card, the submitting thread, the title). Work taken off another one
63 does not show. Cards and CPUs differ: say the card, driver, CPU, memory, profile, resolution, scene and commit.
64
65## 5. Where a frame goes
66
67All in builds with `diagnostics`; each costs something, so do not read frame rates from the same run.
68
69| Tool | What it answers |
70|---|---|
71| `LEONIDA_TIMELINE=<file>` (with `LEONIDA_TIMELINE_AT`, `LEONIDA_TIMELINE_FRAMES`) | A trace of a few frames for `chrome://tracing` or Perfetto, and a text summary with **the chain of work and waits each present came out of**: the tool for "what does the frame wait for". |
72| `LEONIDA_PROFILE=<from>,<to>,<ms>,<file>` (with `LEONIDA_PROFILE_ONLY=<thread name>`) | Stack samples by thread, waits included, from inside the process. Do not name the title's own threads: `findings.md` has a run that ended that way. |
73| `LEONIDA_GPU_TIMING=1` | The commands' time on the card. |
74
75Windows Performance Recorder works too (it needs an administrator). Wait until it says that the trace was saved before you open the file.
76
77## 6. Before you report a cause
78
791. Write the prediction and what would refute it before the run.
802. Say **MEASURED** (with *n*), **READ IN CODE** or **ASSUMED**.
813. Try to refute it: if this were the cause, what else would have to be true? Is it on the submitting thread's chain?
824. Post numbers only: no logs, captures, shader or pipeline names that are not already in the repository, addresses of the title, or other game data.