1
0
mirror of https://github.com/doitsujin/dxvk.git synced 2024-11-29 01:24:11 +01:00
This commit is contained in:
Philip Rebohle 2024-10-24 16:41:25 +02:00
parent 6bdc9f3b3d
commit 45b0f13dd6

View File

@ -2136,7 +2136,6 @@ namespace dxvk {
return;
DxvkAllocationModes mode(
DxvkAllocationMode::NoAllocation,
DxvkAllocationMode::NoFallback);
// Iterate over the chunk's allocation list and look up resources
@ -2164,11 +2163,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);
@ -2265,7 +2282,7 @@ namespace dxvk {
void DxvkMemoryAllocator::performTimedTasks() {
static constexpr auto Interval = std::chrono::milliseconds(500u);
static constexpr auto Interval = std::chrono::milliseconds(50u);
// This function shouldn't be called concurrently, so checking and
// updating the deadline is fine without taking the global lock