Texture slab pools: budgeted defrag to release freed-but-not-drained blocks (deferred) #593

Open
opened 2026-10-09 04:27:44 +00:00 by sky_line · 0 comments
Owner

Follow-up to #587 (size-class texture slab pools), deferred because the slack is acceptable.

Measured (2026-10-09, heavy sim, RTX 5090)

  • Classes 92/180/352/700/1392 KiB.
  • With the VMA full-insertion-sort fix (fullest block first), settled numbers: pools 89% occupied, about 275 MB slack. Medium classes 91% / about 160 MB stranded; the 1392K class is 94% / 79 MB, the 352K class 82% / about 65 MB.
  • Blocks are released when a region is left (148 -> 118 blocks on teleport).
  • The remaining slack is freed-but-not-drained capacity. When textures drop resolution or lose demand in bulk, the frees are spread across blocks, so no block empties. The space is reused when demand returns, but stays reserved until then.

Design (only when it pays)

  • Trigger: a class holding more than ~64 MB of free slots for more than ~10–20 s, or VRAM ladder pressure, or after a region drop.
  • Move: take images out of the emptiest blocks of a class into free slots in fuller blocks. Equal-size slots, so no packing problem.
    • GPU image copy (all mips) into a new allocation from the same class.
    • Rewrite the texture's bindless descriptor slot (update-after-bind); the slot index stays the same.
    • Free the old image after its frame fence.
  • Skip: images with uploads, sharpen or re-encode in flight; media textures; anything holding the VkImage/VkImageView directly (UI, FX inputs, probe/snapshot bindings).
  • Budget: a few images or MB per frame. Release emptied blocks immediately.

Done when

  • Per-class stranded memory drops below ~16 MB within a short time after a bulk drop, or under pressure.
  • No visual glitches.
  • No device lost; validation layers clean.
Follow-up to #587 (size-class texture slab pools), deferred because the slack is acceptable. ## Measured (2026-10-09, heavy sim, RTX 5090) - Classes 92/180/352/700/1392 KiB. - With the VMA full-insertion-sort fix (fullest block first), settled numbers: pools 89% occupied, about 275 MB slack. Medium classes 91% / about 160 MB stranded; the 1392K class is 94% / 79 MB, the 352K class 82% / about 65 MB. - Blocks are released when a region is left (148 -> 118 blocks on teleport). - The remaining slack is **freed-but-not-drained** capacity. When textures drop resolution or lose demand in bulk, the frees are spread across blocks, so no block empties. The space is reused when demand returns, but stays reserved until then. ## Design (only when it pays) - **Trigger:** a class holding more than ~64 MB of free slots for more than ~10–20 s, or VRAM ladder pressure, or after a region drop. - **Move:** take images out of the emptiest blocks of a class into free slots in fuller blocks. Equal-size slots, so no packing problem. - GPU image copy (all mips) into a new allocation from the same class. - Rewrite the texture's bindless descriptor slot (update-after-bind); the slot index stays the same. - Free the old image after its frame fence. - **Skip:** images with uploads, sharpen or re-encode in flight; media textures; anything holding the VkImage/VkImageView directly (UI, FX inputs, probe/snapshot bindings). - **Budget:** a few images or MB per frame. Release emptied blocks immediately. ## Done when - Per-class stranded memory drops below ~16 MB within a short time after a bulk drop, or under pressure. - No visual glitches. - No device lost; validation layers clean.
sky_line added this to the Slipstream project 2026-10-09 04:27:44 +00:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
sky_line/Slipstream#593
No description provided.