diff options
| author | NotRexed <therealnothingfn@gmail.com> | 2026-11-27 16:21:23 -0500 |
|---|---|---|
| committer | NotRexed <therealnothingfn@gmail.com> | 2026-11-27 16:21:23 -0500 |
| commit | d06b2be257568d8336a166c01bb46ef9ae41455d (patch) | |
| tree | 32f723b43632b4fa091d49d72d537ab29c5c4fc7 /runtime/test/cpp_unwind_test.cpp | |
| parent | 6d40be2b88a60f8cba77799c654c203fa8d5aafa (diff) | |
Read backs: a list's read-back buffers are kept for the next read backs of their sizes (LEONIDA_READ_BACK_POOL=0: as before)
What was slow: a read back is recorded into a buffer of ours in read-back
memory. There are two kinds: a texture the title copies into a buffer of its
own (`list::read_back`), and a texture shaders wrote that the title reads on
the CPU, copied when the list closes (`texback`, from `HostList::close`).
Each buffer was a committed resource made for the one copy, on the thread
that records or closes the list, and released when the list was reset. In
the CPU profile of 2026-11-27 (Series X profile, about 9,500 draws a frame)
`Host::read_back_buffer` was 5 % of the running time of the threads that
record lists, and `HostList::close` 5 % of the submitting thread's.
What changes: with the switch a read-back buffer is made in whole 64 KiB
(`read_back_size`; a buffer of its own takes whole 64 KiB of the card's
address space either way). When a list is reset or dropped its buffers go to
a table (`give_read_backs`, from `Deferred`'s drop), and
`Host::read_back_buffer` takes one of the size from there before it makes
one. The table is the one the scratch chunks already use (`Spare`); it keeps
64 MiB at most (16 MiB on a PC with little memory) and is emptied when host
memory is pressured, with the spare scratch chunks.
Why a buffer in the table is nobody's: a list's read-backs are read when its
submission has run (`read_backs`, which copies the texels out under the
list's lock), a list is reset only after its last submission finished, and a
buffer goes to the table only then, and only if the list's reference to it
is the last one (`sole`: the count the resource itself gives). One made
without the switch (an A/B run) is not kept.
What differs with it on, besides who makes the buffers: the bytes of a
buffer its copy does not write (the padding of rows) are what the buffer
held before, not zeros; nothing of ours reads them. A frame-rate line says
how many were made, taken, kept and let go.
LEONIDA_READ_BACK_POOL: on unless 0; a diagnostics build turns it on and off
while the title runs (LEONIDA_AB=<seconds>,LEONIDA_READ_BACK_POOL).
Leonida's own, from its profile; no other project's code.
Checked: `cargo check --profile diag -p leonida --features diagnostics,mimalloc`
and without `diagnostics` (the 10 and 18 warnings of leonida-gpu from before,
none new). New tests `host::read_back_pool_tests`: the sizes; and, on the
host's card, a list's buffer is not the next read back's while the list
holds it, is the next one's of its size once the list is reset, once, and is
not kept if something else still names it. Also run: `late_tests`,
`texback::`, `spare::` (7 passed). Not run in the game.
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Diffstat (limited to 'runtime/test/cpp_unwind_test.cpp')
0 files changed, 0 insertions, 0 deletions