The title's programs multiply with v_mul_legacy_f32 (0 x anything = 0): 5,968,915 of them in the 25,734
programs, 13.2 % with a constant against a vector register and 1.1 % against a scalar one. Off the RDNA host every one
became a product, two compares, their or and a select. With the switch, what of the RDNA host's forms holds for any
host's floats goes everywhere: a plain product of two factors known to be finite or with a finite constant that is not
0, and only the finite factor's zero asked where one of two is known finite. A product of a finite factor and a zero
keeps the sign the product gives, as on the RDNA host, instead of +0. Off until measured.
AI-assisted (Claude). Tested on RTX 4060 Ti 16 GB, driver 616.64: a new test runs each form on the card and on WARP
over zeros of both signs, ones, tiny and huge values, infinities and no number, against the spelled-out form (the
same but for a zero's sign), and checks that the forms by a constant and of a saturated value are shorter.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
host.rs is past the size the policy allows (cargo test -p xtask), and the
reaper's tests were some 15 KB of it. They move as they are into
host/reaper_tests.rs, a child module of host like its other files; they
reach host's private items through super, as before.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
With LEONIDA_AHEAD_SPLIT, record_ahead_split made a new OS thread with an
8 MiB stack every frame for the textures' half of the list ahead, chose the
fast cores for it and logged a line, all on the path of the line's thread,
which waits for that half (14,271 such lines in about 2.5 minutes of play on
an RTX 4070 Laptop / Core Ultra 7 155H).
One thread is now kept for it (queue::beside::Kept, made at the first split,
pinned once); each frame's half is handed to it and waited for, with the same
panic and fallback behaviour. LEONIDA_AHEAD_KEPT_THREAD=0 brings back the
per-frame thread, and LEONIDA_AB can switch it. Measured with LEONIDA_AB
every 10 s on that machine (18 steady phases a side): the line's thread stood
2.5 ms a frame for the list ahead with it, 5.2 ms without; the frame median
moved 55.6 -> 54.4 ms, within its spread.
switches.md regenerated (it also picks up two rows main had stale).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
By turns of 4 s standing (run d282, RTX 4060 Ti 16 GB, 96 phases): card scratch on against off with the spare chunks
kept to the card's budget, the frame's median -1.87 +-0.30 ms, means -1.61 +-0.40, the card -1.94 +-0.24 (with the
old pool in d281: -1.15 +-0.36, -0.84 +-0.38, -1.72 +-0.30). Chunks made in the card's memory 19.5 a second against
48, residency waited for 1.0 ms a frame against 3.7; the churn guard never tripped. The switch's notes and the
findings say so.
AI-assisted (Claude). Tested on RTX 4060 Ti 16 GB, driver 616.64: runs d281 and d282.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
test_tool_stdout_encoding.py requires every tool's __main__ to set errors='replace'
on stdout, for a redirected stdout that is a strict ANSI code page under -I. The new
tool did not, so main failed that test on both Linux and Windows.
Same block as ab_control_flow.py and the other tools.
TheGeogeo turned LEONIDA_SCRATCH_CARD off by default (f8ad7e245, #2819) "until the card's spare chunks are kept by
size": the card's pool kept 256 MiB of spare chunks in all, in the order they came, and let go of every chunk given
back past it, so the lists' resets freed chunks the recording threads made again (1,158 a second and 35 ms a frame
of MakeResident on an RTX 3090). Now:
- the card's spare chunks are kept up to a sixteenth of its budget, between 256 MiB and 1 GiB
(LEONIDA_SPARE_CARD_MB=<MB> says it), and when the pool is full those kept longest go, not the one given back
(Spare::give_evicting); LEONIDA_SPARE_CARD_GROW=0 keeps the old pool, LEONIDA_AB can name it;
- a guard sends new chunks to the PC's memory for the rest of the run if more than 1,000 are made in the card's
within 10 s (100 a second; this PC's worst was 48 with the old pool), said once;
- with both, card scratch is on again where the card's budget is 9 GiB or more, as before #2819.
Measured before the change (run d281, RTX 4060 Ti 16 GB, by turns of 4 s standing, the old pool): card scratch on
against off, the frame's median -1.15 +-0.36 ms, the card -1.72 +-0.30, with 48 chunks a second made in the card's
memory and 3.7 ms a frame waited for their residency.
AI-assisted (Claude). Tested on RTX 4060 Ti 16 GB, driver 616.64: cargo check with and without diagnostics, the
two new tests (the default by card and switch, the pool letting the oldest go); in-game A/B to follow.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
indirect.rs declared 'mod asbench' under #[cfg(test)] and indirect/asbench.rs has never
been in the repository, so cargo test --workspace failed with E0583 before running a
single test. cargo build was fine, which is why nothing noticed: only a test build sees
the module, and nothing in this repository runs a test build on d3d12/.
The declaration came in with d87ada391; the file did not. Either it lands or the line
goes, and until then every branch rebased on main cannot run the suite.
The reaper thread's channel had no bound and nothing slowed its senders.
On an RTX 3090 its line grew to hundreds of thousands of things in most
runs; the landed host lists waiting there kept their scratch chunks, and
the runs that were not stopped ended in a device loss as private memory
neared Windows' commit limit, while LEONIDA_REAPER=0 kept memory flat. The lists' scratch was in card
memory; it is in PC memory by default since #2819, where the line should
stay short. This bound is the safety net for LEONIDA_SCRATCH_CARD=1 and
any other cause of a backlog.
Once the line (REAPING) holds LEONIDA_REAPER_LIMIT things (4096 by
default; 0: no bound, as before; LEONIDA_AB can turn it on and off), what
the host is done with is let go of by the thread done with it, as
LEONIDA_REAPER=0 does. land(), bury() and fronts_let_go() go through one
helper (reap), which counts each batch as the reaper thread takes it off;
the check and the count are one atomic step (hand_over),
so the line holds fewer than the bound and one batch however many threads
send. A batch comes off the line also if letting it go panics. The first
time the bound takes hold is logged once; the census memory line counts
what was let go in place (REAPED_IN_PLACE) and says the bound.
Diagnostics only: host lists and preludes made per frame by the title's
threads, the submitting thread and the others, with their time; a SPLIT
slot for preludes made and recorded; HostList::reset split into what the
list held let go and the allocator and list resets.
Claim: D3D12-REAPER-BOUNDED-QUEUE
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Both after ImTaneax's VIctory-RTX3050-4gb, by turns of 4 s in one run standing (d280, 112 phases, RTX 4060 Ti):
LEONIDA_RELAY_EACH the frame's median +0.73 +-0.46 ms, LEONIDA_SUBMIT_FRAMES=3 against 1 +0.60 +-0.46. The card is
the wall here, so the title learning sooner or running further ahead wins nothing. Both stay off.
AI-assisted (Claude). Tested on RTX 4060 Ti 16 GB, driver 616.64: run d280.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A composite queue (XTaskQueueCreateComposite) shares its ports with the
queue they came from. XTaskQueueTerminate drained every task on each of
the queue's ports, so terminating the composite also took the other
queue's pending tasks and ran them as canceled, while that queue was
still open. Each queued task now carries the id of the queue that queued
it, and termination drains only those of the terminated queue; the
others stay queued and run uncanceled on the next dispatch.
Ported from ahmetbagci's fix in Vice-Tay (fa10fa3).
Co-Authored-By: ahmetbagci <6625856+ahmetbagci@users.noreply.github.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The thread that lands what flights wrote took every flight the card had run before it told the title anything:
the title's fence was signalled only after the flights behind its signal had landed too. With the switch it lands up
to and with the first signal of the title's among them. After ImTaneax's VIctory-RTX3050-4gb bd79bb1
(VICTORY_RELAY_EACH, GPL-3.0), where the title polled 32 to 81 ms a frame for the card on a walk and two A/B walks on
a 4 GB laptop card had 5 of 6 comparable pairs faster, -8 ms on average. Off until measured here; LEONIDA_AB can
name it.
AI-assisted (Claude). Tested on RTX 4060 Ti 16 GB, driver 616.64: cargo check with and without diagnostics.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
By turns of 4 s standing (run d279, RTX 4060 Ti) the stage made the frame's median +4.42 +-0.40 ms and the card
+7.64 +-0.68 ms a frame. The batches' clamp passes it was to take away open for the title's indirect dispatches and
vertex draws; the mesh executions only read from batches those had opened (860 opened a frame with the stage, 871
without), so no pass went and each mesh draw paid for the stage. The switch stays, off, with nothing of it made
without it. Also written down: the joined parts measured again (8 against 1, 16 against 8), and the full driver cache
file that made every start compile some 600 pipelines in the game.
AI-assisted (Claude). Tested on RTX 4060 Ti 16 GB, driver 616.64: runs d273 to d279 (A/B by turns, recorded tours).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The test asserted the answer from before LEONIDA_TAKE_BLOCKS in its default arm and failed on main since the switch
went on by default (d920d850d): the page a landing took goes up by the 4 KiB blocks that differ, so nothing of it is
left dirty, and the title's writes after it are one block. A third arm for the switch, as fiestorra found and wrote it
in ubiquitarianism/leonida b9bfae60d.
AI-assisted (Claude). Tested on RTX 4060 Ti 16 GB, driver 616.64: the test with the default, LEONIDA_TAKE_BLOCKS=0 and
LEONIDA_SEND_CHANGED=1, each passing (it failed with the default before).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The launcher notes NVIDIA's cache files its precompile wrote, with their sizes, and makes every pipeline again when
one is gone or smaller at the next start. The note was replaced by the files each precompile touched: one with
nothing to make touched a single file, and a set moved aside since (the 4 GB file of one warm process was full, so
its 600 pipelines were compiled in the game at every start) was no longer looked for: the next start compiled all
4,875 in the game (run d278). Now the files written are noted at their sizes beside those noted before, and the old
note goes only after pipelines were made again.
AI-assisted (Claude). Tested on RTX 4060 Ti 16 GB, driver 616.64: the script parses; run d279 found the moved set
by the restored note and made the pipelines again.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
LEONIDA_MESH_AMPLIFY no longer needs a file: indirect/amplify_dxil.rs holds the stage's container (DXC as_6_6,
signed; the tool refuses an unsigned one, which D3D12 would not take), made by the new standard-library tool from
the Windows SDK's dxc or one named. LEONIDA_MESH_AMPLIFY_DXIL=<file> still takes another build of the stage, to
try one. The bytes are the runtime's own shader, not the title's; the file is text and the game-data check passes.
AI-assisted (Claude). Tested on RTX 4060 Ti 16 GB, driver 616.64: the tool's output is byte for byte the file the
in-game runs d276 to d279 loaded; cargo check with and without diagnostics.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The title's mesh draws are indirect executions of one record each, which its culling passes write:
8,600 a frame standing at the waterside, clamped by 955 batch passes (run d275). A pass is a compute
dispatch of ours between the draws and a wait for it. With the switch, and the stage's code in the file
LEONIDA_MESH_AMPLIFY_DXIL names (DXC's as_6_6 of indirect/amplify.hlsl; the translator's own DXIL writer
does not make it yet), mesh pipelines are made a second time with the stage in front, reading the record
through a root view appended to their root signature, and such executions are DispatchMesh(1, 1, 1) of
that form: X alone, Y and Z as 1, nothing past 65,535 groups, as the batched clamp bounds a mesh record.
Where a batch would have opened for the record, a wait for every earlier shader write is recorded alone.
Mesh shaders declare the stage's 4-byte payload with the switch set (D3D12 refuses the stage in front of
a mesh shader without it; one with it runs without the stage), so with it unset the translations stay.
A benchmark of 9,000 mesh draws on the card (RTX 4060 Ti, driver 616.64; not committed): records clamped
every 9 draws 23.9 ms against 10.8 read as they are, through the stage 10.7 to 11.5. The stage writes
nothing: one that only declared a writable view (for the list's budget) made a wait every 9 draws cost
4.4 ms against 1.1, so the list's budget is not charged for these records (the largest record in 55 runs
asked for 2,828 groups).
AI-assisted (Claude). Tested on RTX 4060 Ti 16 GB, driver 616.64: cargo check with and without
diagnostics, the batch and mesh unit tests, a new test that the payload validates in dxil.dll.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The test branches on LEONIDA_SEND_CHANGED and asserts the pre-TAKE_BLOCKS answer in its
else arm, so it fails on main since TAKE_BLOCKS went on by default in d920d850d:
take_dirty after a landing answers [] for the page the landing took, because that page
went up as the 4 KiB pieces that differed.
A third arm covers the default and the two switches no longer collide. Measured on
main d920d850d, the same test: default ok, TAKE_BLOCKS=0 ok, SEND_CHANGED=1 ok, and the
crate 583 passed 0 failed 53 ignored.
Part of enlighted's D3D12-REAPER-BOUNDED-QUEUE, agreed with them. Card scratch, on by default where the
card's budget is 9 GiB or more and it has a GPU upload heap, churns chunks: SPARE_CARD keeps 256 MiB in all
and gives back an exact size only, so chunks of other sizes are let go in the list resets on the reaper and
made again on the recording threads. The reaper falls behind and the memory it holds piles up. Measured on
an RTX 3090 with a resizable BAR (23 pairs): frame median 64.6 ms with card scratch against 33.3 ms without.
It is off by default until the card's spare chunks are kept by size; LEONIDA_SCRATCH_CARD=1 still puts it
there and LEONIDA_AB still switches it. A card that used to get it says once that it is off now.
switches.md is regenerated for that row.
test_custom_jobs_forwarded_to_shaders asserts fallbacks=() but neutralises only four of the six
runtime_gpu_* probes the shaders stage consults. The two it misses answer False on hardware
tools/vk_subgroup_info.py documents: denorm_flush_to_zero_f32 on NVIDIA Vulkan drivers (VK_FALSE)
and integer_dot_product on a Vulkan 1.2 device such as MoltenVK's. Where a probe answers False,
make_game.py sets the fallback flag unconditionally instead of going through
keep_recorded_fallback(), so the assertion fails with fallbacks=('--no-ftz32',).
Add the two missing patches, the same six-probe list tests/test_make_game_translator_flags.py
already uses.
A verification's only trial said "red does not build" while rustc had crashed (0xC0000005). A side whose
cargo output shows rustc or a build script ending with a Windows crash status, an internal compiler
error or a failed allocation now builds again once, and the report says so; a second crash gives the
verdict `compiler crashed` (exit 1), not `red does not build`. A test binary that crashes stays a test
result.
With the relay the compares of copies in the card's memory were not
counted (copystat::compared said "0 ranges"): each compared range is now
counted when its compare is planned, by the pieces of 64 KiB the card
hashes, so the lines say which ranges take the 10,000 pieces a frame
(3.4 to 4.7 ms of the card, run d263).
AI-assisted (Claude). Tested on RTX 4060 Ti 16 GB, driver 616.64: cargo
check of leonida-gpu with and without diagnostics.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
LEONIDA_TAKE_BLOCKS is on (0 turns it off; LEONIDA_AB can name it). By
turns of 4 s standing at 1080 to 1440 lines, no generated frames (run d271,
106 phases): the frame's median -1.69 +-0.38 ms, means -1.87 +-0.39, p90
-2.48 +-0.68, the card -1.84 +-0.32, the submitting thread -1.87 +-0.31;
10 MB sent up a frame against 27 to 28, the sends with their hash passes
1.3 to 1.8 ms of the card against 2.8 to 3.7.
AI-assisted (Claude). Tested on RTX 4060 Ti 16 GB, driver 616.64: cargo
check of leonida-gpu with and without diagnostics; the shadow test
only_the_blocks_the_title_changed_go_up; run d271.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Testers could not use the gate daily without memory figures, and a memory pile-up took a 3090's Windows
down twice. The parser now reads the runtime's memory line and video memory line (every 5 s in builds with
diagnostics) and writes a memory block: the private bytes at their most and when, the most of them in
physical memory, the least the PC had left to commit and when, the card's video memory in use at its most
and when with the budget then, the seconds over that budget, and the most shared memory in use. The video
memory is what the system counts for the process, so it works on any card. The five runtime strings it reads
join the contract test.
Under Windows PowerShell 5.1 the gate failed in about 2 s without starting the game and without saying
why (reported by a tester). A #Requires -Version 7.0 line makes 5.1 refuse it with a message before
anything runs; docs/game_gate.md says so, and a test keeps the line.
A copy in the card's memory that held a page before takes it, once the
title wrote it, as the pages a landing wrote are taken (Shadow::take_landed):
4 KiB at a time compared with the CPU's side, and only the 4 KiB that
differ go up. Off by default (LEONIDA_TAKE_BLOCKS=1; LEONIDA_AB can name
it), to be measured.
Why: standing, the pages of such copies the title wrote were 26 MB a frame
and the dwords it changed in them 3 MB (run d264); sent whole they were 27
MB a frame over the bus, 3.1 to 3.9 ms of the card with their hash passes
(run d263). Sending only the dwords took the card's part to 1.2 to 1.7 ms
but made 280,000 ranges a frame, 5 ms more of the submitting thread (run
d266); blocks of 4 KiB are few ranges.
AI-assisted (Claude). Tested on RTX 4060 Ti 16 GB, driver 616.64: cargo
check of leonida-gpu with diagnostics; the shadow tests
what_a_landing_wrote_is_not_sent_up_again and
only_the_blocks_the_title_changed_go_up.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Run d267: the submitting thread waits 45 % of its samples; the rest is
spread (refreshes on the wide threads 15 %, the write watch 7.3 %, the
merge under flights' writes 6.4 %, the driver 6.6 %, the planes' presents
5.9 %, the crossings' search 1.2 %). Run d268 with the place fix: no
device error, our lists as before.
AI-assisted (Claude). Tested on RTX 4060 Ti 16 GB, driver 616.64: the runs
named.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
LEONIDA_PICKED_WRITES defaults to stage 1 (declared, not landed). The new
offscreen test discovers a write through a picked view, keeps its flight
in the queue and refreshes the same 64 KiB piece: the GPU's bytes stay,
the CPU's neighbour bytes reach the card, nothing is landed in title
memory. A bounded rescue turns a refresh that waits on the writer into a
failure instead of a hang.
writes_through_picked_views_come_back checks landing, which is stage 2:
its ignore note and assert now ask for LEONIDA_PICKED_WRITES=2 (with =1 it
failed at the landing check on an RX 6800).
texture::digest, which tells whether a guarded texture's memory changed (at every check that is not skipped, and over all of it the first time), was a fold of 64x64-bit multiplications that ran at 23.5 GB/s at every size from 16 KiB to 256 MiB: the multiplications were its limit, not the memory. With AES-NI it is now eight 128-bit lanes of `aesenc` over 128 bytes at a time, each lane through two more rounds on its own before the lanes meet: 139, 121, 108, 114 and 70 GB/s on 16 KiB, 256 KiB, 2 MiB, 32 MiB and 256 MiB (Ryzen 7 7800X3D, best of five, `digest_speeds`). The folded one stays as the fallback. The digests are only compared with each other inside one run and none is written out, so the value may change; which version is used cannot change during a run.
A first version, whose lanes met by one round, had pairs of one-bit changes with the same digest (1,328 in a million with four lanes). `no_two_changes_cancel_in_the_aes_digest` tries pairs of one-bit changes over 520 bytes and 4 KiB of noise and of zeros: none for the real digest and for the folded one, 83 for the eight-lane version met by one round (its negative control).
AI-assisted: Claude Sonnet 5.5
Co-authored-by: Cursor <cursoragent@cursor.com>
HostList::place_copy left the host copy it wrote promoted to COPY_DEST, a
write promotion that holds to the end of the ExecuteCommandLists call: a
root view of the buffer later in the same list (the indirect clamp, a
batch) and the compare sent with the lists could not promote it again (the
debug layer's message 538, "COPY_DEST (promoted from COMMON state) ...
invalid for use as a root shader resource", 369,094 times in one run on an
RTX 5070 there). The destination now goes back to COMMON after the copy,
and where source and destination are one host copy, the source side goes
back to COMMON before it is copied into.
After TaynanGT/Vice-Tay 6ca29bc1 ("place: copies at their place hand their
buffers back to common"), from upstream Belobug#425 by MamaLeVrai
(GPL-3.0-or-later), written into Leonida's place.rs.
AI-assisted (Claude). Tested on RTX 4060 Ti 16 GB, driver 616.64: cargo
check of leonida-gpu with diagnostics; host::place tests.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Run d263 (LEONIDA_OWN_STAMPS=1): the sends with their hash passes 3.1-3.9
ms a frame, the compares behind submissions 3.4-4.7, the copies between
copies 0.02-0.04. LEONIDA_SEND_CHANGED (runs d264, d266): the card -1.95
+-0.16 ms a frame, the submitting thread +5.08 +-0.36, the frame's median
+0.77 +-0.33 ms; a recorded tour with it (d265) had no fault. Off.
switches.md regenerated.
AI-assisted (Claude). Tested on RTX 4060 Ti 16 GB, driver 616.64: the runs
named.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
copy_elements ran a runtime-sized std::memcpy per texel/block (the call is not
inlined), which dominates TitleImageUpload::write on runtime texture refresh.
The per-row element loop is now copy_tiled_row<Into, Width>, chosen by one
switch on format.bytes per row: 1/2/4/8/16 get a constant-size memcpy, every
other size takes the unchanged runtime-size loop. Addresses (row/column tables,
pitches, linear fast path) are untouched, so the bytes written are identical,
including for unaligned pointers and pitches and in both directions.
texel_copy_test compares copy_elements with the original loop over the whole
destination buffer: tiled and linear, mips and tails, arrays, volumes, widths
1/2/4/8/16 plus non-specialized 3/6/12, misaligned buffers and padded pitches.
Either way a refresh of a copy in the card's memory leaves its CPU side as
title memory and its card side as what went up, so the way may change
between submissions. Standing (runs d263 and d264, one start each), only
the changed dwords sent up took the sends and their hash passes on the card
from 3.1-3.9 ms a frame to 1.2-1.7 ms (27 MB sent a frame against 5.5, in
some 280,000 runs), the CPU's copies 15.8 -> 17.7 ms a frame; whether the
picture holds is what turned it off (run tile1-0) and is looked at again.
AI-assisted (Claude). Tested on RTX 4060 Ti 16 GB, driver 616.64: cargo
check of leonida-gpu with diagnostics.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>