Skip to content

Commit

Permalink
frog
Browse files Browse the repository at this point in the history
  • Loading branch information
doitsujin committed Oct 24, 2024
1 parent 662cfd4 commit 3df3a10
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions src/dxvk/dxvk_memory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2146,11 +2146,29 @@ namespace dxvk {
}
}

static uint32_t lastDefrag = 0u;


void DxvkMemoryAllocator::pickDefragChunk(
DxvkMemoryType& type) {
auto& pool = type.devicePool;

if (pool.chunks.size() == 0)
return;

for (uint32_t i = 1; i <= pool.chunks.size(); i++) {
auto index = (lastDefrag + i) % pool.chunks.size();

if (pool.chunks[index].canMove && pool.pageAllocator.pagesUsed(index)) {
pool.nextDefragChunk = index;
pool.pageAllocator.killChunk(index);
lastDefrag = index;
return;
}
}

return;

// Only engage defragmentation at all if we have a significant
// amount of memory wasted, or if we're under memory pressure.
auto heapStats = getMemoryStats(type.heap->index);
Expand Down

0 comments on commit 3df3a10

Please sign in to comment.