On a device where each listed import costs every submission (RADV with a dma-buf source), a
guest RAM's chunks are a few long dma-bufs (2.7 GiB on the Radeon 780M and RX 7900 XTX), and
the first object over a chunk not imported imported it on its own thread: 660 to 692 ms, at
the first object over each chunk and again at a released chunk's next use. A copy over such a
chunk (copy_from_host_ram, copy_to_host_ram) did the same on the encoding thread.
Now the chunk's import is off the caller's path:
- On a listed device the device's thread (listed_chunks, in place of release_idle) imports each
chunk an object or copy asked for (ChunkSlot::asked, RamOnDevice::next_asked), and still
releases idle chunks. The object, and every object over the chunk until the import is done,
is bound in an import of its own run alone (RamOnDevice::run_alone), as on a device that
imports ahead; those after lie in the chunk.
- A buffer's (not a heap's) run import is releasable as a no-copy buffer's own import is
(host_residency.rs, AgainFrom::RamRun): released while idle, its address never handed out,
and at its next blit bound in the chunk's import where that is made and lays the bytes as the
run's did, else in its run's own import again; never the chunk's import nor a wait for one.
This holds on every device whose objects take run imports.
- A copy over a chunk not imported imports each of its ranges of that chunk alone (ranges less
than 2 MiB apart joined, at most copy::MOST_ALONE = 16), held by its command buffer, while the
device's thread imports the chunk (RamOnDevice::for_copy); more ranges than that, or where an
object's run would not be imported alone, the chunk as before.
Tests: the listed device test now checks the first object's run import, the thread's import of
the asked chunk, the holders in the chunk, the runs' release while idle and the rebind in the
chunk at the next blit, the chunks' release, and a copy over a released chunk taking its run
alone. The AHEAD copy window test expects the copy past the window to import its page alone.
Unit tests: next_asked's choice, alone_ranges' joins.
Docs: host_ram.rs, host_residency.rs, host_ram/copy.rs module docs, use_host_ram,
HostMemory::with_runs, WorkCounts::run_imports_live, FAST-PATHS.md, HOWTO.md.
(cherry picked from commit f80468eb4afac1e30f14fd99e1af06b67622a1a1)