mirror of
https://github.com/tangerineturtle1/NX2navi.git
synced 2026-11-20 01:49:59 -04:00
Add texture compaction behind NX2NAVI_TEX_COMPACT, off by default.
With the setting on, textures no shader sampled for ten seconds are copied on the GPU out of the emptiest allocator blocks into the holes of fuller ones, so the emptied blocks go back to the driver. A pass starts when the free space inside the device-local blocks reaches NX2NAVI_TEX_COMPACT_MIN_MB (one block under VRAM pressure) and the block table has blocks that hold nothing but such textures, with room elsewhere for what moves. It takes at most four textures and NX2NAVI_TEX_COMPACT_FRAME_MB a frame, and none in a frame that loads an area, already made or uploaded textures, or follows a long one. A released texture the size cap would drop is dropped instead of moved. Only a texture whose image holds what the game's memory holds moves: uploaded, never written by the GPU, single sampled, not depth. The entry takes the new image under the texture lock and its address generation moves, so every slot, pool descriptor and memo resolves again. The old image and its views stay until the texture pool has taken every set of its ring and the GPU is past the submissions recorded until then, as a retired texture's do. Each pass logs what it moved and dropped, the blocks and bytes given back, and the time it took. A block emptied of textures that the allocator keeps is left alone for ten minutes, and a pass that gave nothing back doubles the wait. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
This commit is contained in:
@@ -774,6 +774,14 @@ typedef struct {
|
||||
uint64_t sparse_bytes, sparse_listed, emptiable_bytes, emptiable_move, emptiable_drop;
|
||||
} VkTexHoles;
|
||||
void vk_texture_holes(const VkBlockRow *other, int nother, VkTexHoles *h);
|
||||
// Texture compaction (NX2NAVI_TEX_COMPACT; vk_texture.c "the pass"): idle textures move out of sparsely used blocks
|
||||
// so that the blocks go back to the driver. vk_mem_census asks at each present whether the holes are due a look
|
||||
// and, when they are, hands over the VRAM mirrors' rows for the plan; the allocator's free callback reports each
|
||||
// device memory it gives back (vk_headroom.c on_free; any thread).
|
||||
int vk_texture_compact_on(void);
|
||||
int vk_texture_compact_due(void);
|
||||
void vk_texture_compact_plan(const VkBlockRow *other, int nother);
|
||||
void vk_texture_block_freed(uint64_t mem);
|
||||
void vk_texture_want_room(uint64_t bytes); // a VRAM mirror that did not fit: idle textures make that much room
|
||||
int vk_texture_commit_low(void); // the system's commit was low at the last check (vk_texture.c)
|
||||
// vk_mem_vram's device-local use less the free space inside VMA's blocks (vk_memory.c), for the evictions
|
||||
|
||||
Reference in New Issue
Block a user