vkd3d: Remove old entries in GPU VA allocator.

The "allocations" array is filled with unused entries when D3D12 buffers
are destroyed. The majority of entries might be unused after running for
a while. Remove the entry when VA is freed in order to prevent
accumulation of unused entries. This makes destroying D3D12 buffers more
expensive.

Signed-off-by: Józef Kucia <jkucia@codeweavers.com>
Signed-off-by: Henri Verbeet <hverbeet@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Józef Kucia 2019-08-05 18:03:40 +02:00 committed by Alexandre Julliard
parent 8df3bfc5c2
commit 9e997c6db6
1 changed files with 10 additions and 1 deletions

View File

@ -1895,6 +1895,7 @@ void *vkd3d_gpu_va_allocator_dereference(struct vkd3d_gpu_va_allocator *allocato
void vkd3d_gpu_va_allocator_free(struct vkd3d_gpu_va_allocator *allocator, D3D12_GPU_VIRTUAL_ADDRESS address)
{
struct vkd3d_gpu_va_allocation *allocation;
unsigned int index;
int rc;
if ((rc = pthread_mutex_lock(&allocator->mutex)))
@ -1906,7 +1907,15 @@ void vkd3d_gpu_va_allocator_free(struct vkd3d_gpu_va_allocator *allocator, D3D12
allocation = bsearch(&address, allocator->allocations, allocator->allocation_count,
sizeof(*allocation), vkd3d_gpu_va_allocation_compare);
if (allocation && allocation->base == address)
allocation->ptr = NULL;
{
index = allocation - allocator->allocations;
--allocator->allocation_count;
if (index != allocator->allocation_count)
{
memmove(&allocator->allocations[index], &allocator->allocations[index + 1],
(allocator->allocation_count - index) * sizeof(*allocation));
}
}
pthread_mutex_unlock(&allocator->mutex);
}