=?UTF-8?Q?J=C3=B3zef=20Kucia=20?=: vkd3d: Remove old entries in GPU VA allocator.
Alexandre Julliard
julliard at winehq.org
Tue Aug 6 17:39:38 CDT 2019
Module: vkd3d
Branch: master
Commit: 9e997c6db6375766a058ae95727d0ae4eb469bdb
URL: https://source.winehq.org/git/vkd3d.git/?a=commit;h=9e997c6db6375766a058ae95727d0ae4eb469bdb
Author: Józef Kucia <jkucia at codeweavers.com>
Date: Mon Aug 5 18:03:40 2019 +0200
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 at codeweavers.com>
Signed-off-by: Henri Verbeet <hverbeet at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>
---
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 cb70578..dc0fa0a 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);
}
More information about the wine-cvs
mailing list