After voidopcode/vilocity ccb27fd (GPL-3.0): in its night walks with every frame looked at, the merge of the
title's bytes into copies in the card's memory under the flights' writes was what tore moving cars, trailers and
people into big flat triangles for single frames (3 of 1,322 frames merged, 0 of 1,032 settled; 0 of 2,331 in a
longer walk); the same merge into copies in the PC's memory was not; and the merge made a frame 16 ms shorter there.
LEONIDA_MERGE_CARD_COPIES=0 (and LEONIDA_MERGE_PC_COPIES=0; both A/B-able, on by default) settles that kind of
copy in Shadow::merge_under_writes, with its own reason in the stale-reason log.
AI-assisted (Claude). Tested on an RTX 4060 Ti (driver 616.64): builds with and without diagnostics; its cost and
the tears to be measured in game.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A Lua mod for in-game gates and A/Bs: it presses Enter through the title's menus only once frames
have moved on since the last press, shows control by holding W (the player must walk 1 to 30 m in
3 s; more is the title placing the player, which it waits out without a press), then stands still
(idle) or walks a fixed loop (roam). It logs GATE PRESS/PROBE/CONTROL/MARK/SHOT/FAIL lines with
distances only, never a position. It ships disabled; a run enables a copy with LEONIDA_MODS and
needs LEONIDA_GAME_ACTIONS=1 for the player's position.
The logic is in driver.lua and takes the calls it uses as an argument, so leonida-lua's tests run
it on a stub with a simulated clock: menus, control, roam, no position, no control, a jump.
test_docs_repo_paths failed: docs/measuring_fps.md named scripts/game-gate.ps1, which only #2782 adds.
Name the game gate's run folders instead, here and in the tool's docstring.
test_docs_cli_flags read the -SeriesS -NoFrameGen inside -PlayArgs '...'
in the fenced command as flags of game-gate.ps1. The block now shows a
placeholder, and the text gives the example.
LEONIDA_COPY_BACK brings back only textures the title fills; a texture the card renders to or an upscale writes
(the black world of DLSS on Series X) is not copied back, so the lead of a placed view in its memory, filled from
title memory the card never wrote, is looked for in every run now.
AI-assisted (Claude). Tested on an RTX 4060 Ti (driver 616.64): builds with diagnostics.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
AI-assisted (Claude). Tested on an RTX 4060 Ti (driver 616.64), Ryzen 5 7600X: runs d246 to d251.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
docs/measuring_fps.md tells how to read an A/B (neighbouring pairs, the
effect with its standard error, ABBA after a throwaway run), but the
scripts it named were never in the repository, and testers' two-run
verdicts turned out to be noise.
`abba` takes runs in the order they ran (folders of scripts/game-gate.ps1
or logs), one value a run (its world median frame time: frames within a
run are not independent), pairs neighbouring runs and gives the mean
difference with its standard error and a 95 % t interval, the median of the
differences and how many agree in sign. It needs at least 4 pairs, as many
with A first as with B first, so a linear drift cancels; with 3 runs a side
it fits the side and a linear trend instead. It says "B faster" or "B
slower" only when the interval leaves 0 out and all pairs but one agree.
Gate runs that did not PASS are left out with their pair.
`phases` does the same inside one LEONIDA_AB run, per switch, for the
median frame time and the `A/B counters` line, leaving out pairs of blocks
whose draws a frame differ by more than a tenth. `plan` prints a balanced
order. Numbers only, never log text.
Testers ran in-game gates and A/Bs by hand on five machines, each with
their own launcher wrapper and log parsers, and lost runs to consoles and
key files. scripts/game-gate.ps1 runs leonida.exe through the checkout's
play-d3d12.ps1 and writes one folder per run: run.json, launch.ps1, the
-DryRun settings, the F1 settings file, the launcher's output (the
precompile lines nobody kept), the runtime's log, events.jsonl and a copy
of the tester's data template (their own saves are never touched). It
stops the game with WM_SYSCOMMAND/SC_CLOSE (the runtime's own end: suspend,
pipeline cache saved) once -WorldSeconds were spent in the world, on a
STOP file or after -MaxMinutes, and kills it only 60 s later; it keeps the
game's exit code. `start` runs the same detached (created through CIM, so
an agent's or console's end does not end it); `stop` asks a run to end.
tools/game_gate.py (standard library) reads the folder into
summary.json (leonida-gate-summary/1): build, card, settings (the run's
settings line, no paths), precompile counts, time to the world (two frame
lines with 500 draws or more, cutscenes included), when the pipeline
cache went warm (60 s with nothing being made), fps from the presents
(median, p5, frame p95, end median, the first second under 2 frames, the
longest gap with no frame), crashes by kind (device lost, panic, fault by
module kind), exit, stop and a verdict: PASS needs 300 s in the world,
no device loss, panic or fault, no gap over 10 s, alive at the stop. The
testers' answers to a draft on the bridge are folded in. Its tests use
synthetic logs and check that the runtime still writes what it reads.
The frame-rate line averages five seconds, and what a player feels as a stutter is single long frames. With
LEONIDA_FRAME_TIMES=<file> each present's number and time (microseconds since 1970) is appended as a line
"<frame> <us>", a second's worth at a time, without recording any picture.
AI-assisted (Claude). Tested on an RTX 4060 Ti (driver 616.64): builds with diagnostics.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
For the black world of DLSS on Series X: the first three upscales log the output's title memory and every title
texture whose memory overlaps it (resource::textures_overlapping), through which later passes may read what the
upscale wrote into the output's host copy alone.
AI-assisted (Claude). Tested on an RTX 4060 Ti (driver 616.64): builds with and without diagnostics.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The reviewers' red test: with this entry on main,
test_switched_tools_import_the_helper_and_define_no_copy fails with
"'from report_paths import same_report_path' not found"; with this branch
it passes.
`unspill` decodes the fields and the effects of every instruction to find scalars
parked in VGPR lanes, though most programs have no `v_writelane_b32` or
`v_readlane_b32`; it now returns at once for those. The scan itself is unchanged
for the rest (`unspill_scan`).
`members` (the register sets `rename` walks for every block) stepped through all
513 registers testing a bit each; it now takes the set bits a word at a time, and
`rename` sizes each block's live-out list once.
Measured on a full-archive `leonida translate` (mimalloc build, 16 threads, four
interleaved pairs against main): CPU 655.2 s -> 645.7 s (-1.5 %, three pairs of
four lower), wall unchanged within noise (median 50.0 s vs 49.9 s). The DXIL of
all 25 689 programs is identical to main's (blake3 of each, five runs).
New test: `unspill` leaves a list with no lane save or restore alone, and finds
the same parks as the scan for lists that have them; it fails if the early-out
skips a list that has one.
AI-assisted: Claude Sonnet 5.5
Co-authored-by: Cursor <cursoragent@cursor.com>
The unit tests of settings_line could only fail on main by not building.
This one runs the built binary on a title that does not exist, with two
LEONIDA_ settings, one a folder, and reads its log: on main there is no
settings line and it fails by assertion; with the change the line names
both settings and shows the folder only by its length.
LEONIDA_AB compares switch settings by turns in one run, but its phase
lines carried only frame times, the card's idle time and the submitting
thread's work: an A/B could not split by arm the time spent changing memory
protections, refreshing, or waiting. The frame lines' counters (watch's
ASKS and FAULT_ASKS, host's SPLIT) were emptied with swap(0) by the frame
line, which runs on its own thread at its own pace, so a phase could not
read them.
They are now running totals, never reset; no writer changes. The frame
line takes what came since its last take (ab::take, a fetch_max on a
second array, so two takers never count the same amount twice) and prints
the same numbers. Each A/B phase snapshots the totals where it reads the
card's idle time and logs one more line, "A/B counters phase N bits b:",
with each counter that moved, per frame, named next to its array
(nanoseconds as ms). Diagnostics builds only, as before.
leonida-shader's build script hashed every .rs file of the crate, its
*_tests.rs modules included, into LEONIDA_SHADER_SOURCE_HASH, and since
0baa9278c that hash is part of the shader cache key
(translation_fingerprint). A pull request that only adds a translator test
made every player and tester translate all shaders again at the next start
and make their early pipelines again, which 69837e53a had ruled out for
leonida-gpu's own fingerprint. The switch-name scan in the same script also
put the switches only tests read (LEONIDA_DIFF_ONLY, LEONIDA_EMIT_DUMP,
LEONIDA_CONSOLE_DXC, LEONIDA_PROBE) into the key.
The build script now leaves *_tests.rs out of both. Each of those modules
is declared under a cfg with test, so none changes what the translator
emits. Three portable tests: the hash recomputed without the test modules
equals the built one; test-only switches are out of the key and the
translator's own are in; every `mod *_tests;` is test-only.
AI-assisted (Claude). Tested on an RTX 4060 Ti (driver 616.64), Ryzen 5 7600X: tours d240 to d242 against d233.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A tester could not show from a run's log that a switch was on. `leonida
run` now logs one line, under the `settings` target, with every LEONIDA_
variable present, sorted, as NAME=value. A value with any character other
than letters, digits, space and ._,:+=*- (a folder, which names the user,
a file, a command line) shows only its length, so posted logs carry no
path; one longer than 120 characters is cut. Names that came from an older
VICTORY_ name say so. `LEONIDA_LOG=warn,settings=info` keeps the line on
its own.
It says what a run was started with, not that the code read it.
`Bools::ite` kept every result in a hash map. A result depends on its
triple alone, and the nodes made on the way to it stay in the diagram, so
a result that is asked for again after it was dropped finds those nodes and
makes none: the table can forget without the diagram changing. It is now a
set-associative table of four 16-byte entries to a cache line (the newest
of a set first), which doubles, keeping what it holds, while the diagram
has more nodes than it has entries. A lookup touches one line, and nothing
is rehashed as the table grows.
`Bools::mk` also makes a new node with one probe of its table (`entry`)
where it looked the key up and then inserted it.
Measured on a full-archive `leonida translate` (16 threads, mimalloc
build), four interleaved pairs against main: wall 47.1 s -> 41.2 s, CPU
(user + kernel) 654 s -> 574 s. The blake3 of every emitted DXIL (25,689
programs, 15,799 distinct) is the same as main's in all four runs. On the
system heap the same pairs show no change (six pairs, CPU +0.5 %).
Tests: the table keeps the newest of a set and forgets the rest, grows to
its limit and keeps what it holds, and a diagram whose table holds four
entries gives the same nodes, in the same places, as one with room for
all, and every function holds where the one it stands for does.
AI-assisted: Claude Sonnet 5.5
Co-authored-by: Cursor <cursoragent@cursor.com>
merzleckeier measured it on CachyOS: --skip-existing --jobs 1 left 0 of 3
existing outputs alone, --skip-existing --jobs 2 rewrote 3 of 3. The submit call
passed export_bank four arguments where the serial call passed five, so the
flag never crossed into the pool. The unit test above it calls export_bank
directly - the function, not the CLI - which is why the plumbing was not
covered; the new test runs the tool as a subprocess for --jobs 1 and 2, freezes
an output, and carries its own control (the same command without the flag must
rewrite the frozen file).
The NVIDIA driver compiles DXIL under fast math and may fold a float compare's NaN case away. The title's NaN
guards are such compares (v_cmp_u_f32 x, x; v_cmp_neq_f32 x, x), lowered to fcmp uno / une; a NaN that passes
one reaches the temporal filters, where it spreads as black blocks that grow frame by frame. Every
v_cmp_*_f32 / _f16 but f and tru now tests both operands with the integer check is_nan_f32 already used
(|x| > the bits of infinity): ordered compares are the ordered compare and no NaN, unordered ones the ordered
compare of their sense or a NaN, o and u the NaN test itself, so no unordered fcmp is left. The NaN of
v_cvt_u16_f16 / v_cvt_i16_f16 is found the same way, and so are the NaN and infinity tests of the scrub of
colours and image stores (LEONIDA_NAN_SCRUB), which were unordered compares too. LEONIDA_NAN_EXACT=0: as
before. The shader cache keys on the switch (translation_fingerprint).
Ported from voidopcode/vilocity 598050b (INFIERNOXIII, GPL-3.0-or-later; after the Whiplash-NVIDIA team's
nan_exact), written into Leonida's lower.rs; the scrubs are ours.
Test: float_compares_with_nan_on_the_device (the fourteen compares other than f and tru against quiet,
signalling and negative NaNs, infinities and signed zeros, on the RTX 4060 Ti and WARP; f and tru are left out:
WARP's device is removed at a dispatch of an fcmp false). The existing NaN tests (v_cmp_lg, med3, the 16-bit
conversions, the scrub's integer bits, division fixup) pass with the switch on. docs/switches.md made again.
AI-assisted (Claude). Tested on an RTX 4060 Ti (driver 616.64) and WARP: the named tests above.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Each list of a standing frame's operations given the queue it was submitted to, and each operation weighed by its
kind's card time in a timing run: the drawing queues about 50 ms, the compute queue 1.6 ms. Running the compute
queue beside the drawing one, as the console does, could overlap no more than that.
AI-assisted (Claude). Tested on an RTX 4060 Ti (driver 616.64), Ryzen 5 7600X: run d239 against timing run d183.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
By turns of 4 s standing at 1440 lines with no frame limit (run d237, LEONIDA_FG_TURNS): the frame +5.82 +-0.43 ms
by medians, p90 +10.25, the card +6.76, with DLSS 4's generator (nvngx_dlssg 310.9.16).
AI-assisted (Claude). Tested on an RTX 4060 Ti (driver 616.64), Ryzen 5 7600X: runs d236, d237.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Shaders clamp a sampler index to 2,047 (leonida-shader emit/shader.rs:
"not the bound heap's own count, which a title heap smaller than 2,048
would need"), but HostHeap::new made a sampler heap with exactly the
title's count. With a title sampler heap of fewer than 2,048 samplers, an
index between its count and 2,047 (a number read from memory the host has
not got yet) read past the end of the host heap.
A host sampler heap now always has 2,048 slots; fill_null already makes
every slot a null point sampler, so the slots past the title's count read
as that. The title's own count is kept (up to 2,048): unlike the sibling
tree's version, slot 2,047 is not taken from a title heap that uses it,
since any clamped index now lands inside the heap anyway.
Test: sampler_heaps_have_every_slot_the_shaders_can_reach (a 16-sampler
title heap gets 2,048 host slots and keeps count 16; a 2,048 one keeps
2,048). On main it fails: the 16-sampler heap has 16 slots.
After ESAT's fix in the sibling VIctory tree (TaynanGT/Vice-Tay dd67ae7,
GPL-3.0).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The start (fg::wanted, read once) went through the A/B pick, so a run whose first phase had LEONIDA_FG_TURNS off
never started Streamline (run d236 measured nothing). The pick now changes only the amount at each present.
AI-assisted (Claude). Tested on an RTX 4060 Ti (driver 616.64): builds with and without diagnostics.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>