[PATCH vkd3d 5/6] vkd3d: Remove old entries in GPU VA allocator.
From: Józef Kucia <jkucia(a)codeweavers.com> 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(a)codeweavers.com> --- libs/vkd3d/device.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/libs/vkd3d/device.c b/libs/vkd3d/device.c index cb70578e9f4c..dc0fa0aaf885 100644 --- a/libs/vkd3d/device.c +++ b/libs/vkd3d/device.c @@ -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); } -- 2.21.0
participants (2)
-
Henri Verbeet -
Józef Kucia