Files
metal2vulkan/crates
Anees Iqbal 2daafe221e Memory: plain blocks made smaller where their making is slow
On RADV a block of plain memory (allocated with no export: the blocks of images, of heaps, of
buffers that declare their padding unobserved) shares the reservation of the process's buffer
objects, and its vkAllocateMemory holds every submission of the process while the kernel fills
its pages. On a Radeon 780M with the kernel's page pools empty, a 64 MiB block took 8.9 to 9.6 ms
at the median on a quiet host and up to 23.1 ms (slowest 30.4 ms) with its free memory in single
pages, and a texture made every frame left 13 to 33 turnarounds of 8 ms or more a phase (the
slowest 42.3 ms).

Now a making of such a block that took longer than MAKING_BOUND (8 ms, half a frame at 60 Hz)
makes the device's later pooled blocks of plain memory the largest power of two that making's
rate makes within the bound, at least 16 MiB (Memory::plain_block_made); a placement larger than
such a block takes a pooled block of the power of two that holds it (up to half of BLOCK_BYTES,
past which it is dedicated as before). The size is never made larger again. Exportable blocks
keep 64 MiB: each is a buffer object of its own reservation, whose making holds nothing.

Each made Block records how long its making took (Block::took, zero for imports); add_block
feeds the plain ones to plain_block_made. place, keep_room, ready_if_growing, ready_ahead and
sweep_stale size a pool's blocks through pooled_bytes, and add_ready takes the size of the block
it adds.

tests::plain_blocks: the size rule and the pooled block sizes on the bookkeeping alone, and on a
device told of a slow making, 1 MiB textures in 16 MiB blocks and 20 MiB ones in 32 MiB blocks.
tests::reclaim_submit_bench: an images arm (a 1024x1024 texture a frame) and a mixed one (with
2560x1440 and 3840x2160 textures), the blocks of images made, pooled and dedicated, and the plain
block size reached.

(cherry picked from commit 0bec0583b042c1f2c05b98e97d080e6426d13619)
2026-11-09 12:29:02 -08:00
..