mirror of
https://gitlab.winehq.org/wine/vkd3d.git
synced 2025-09-12 18:50:22 -07:00
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:
committed by
Alexandre Julliard
parent
8df3bfc5c2
commit
9e997c6db6
@@ -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)
|
void vkd3d_gpu_va_allocator_free(struct vkd3d_gpu_va_allocator *allocator, D3D12_GPU_VIRTUAL_ADDRESS address)
|
||||||
{
|
{
|
||||||
struct vkd3d_gpu_va_allocation *allocation;
|
struct vkd3d_gpu_va_allocation *allocation;
|
||||||
|
unsigned int index;
|
||||||
int rc;
|
int rc;
|
||||||
|
|
||||||
if ((rc = pthread_mutex_lock(&allocator->mutex)))
|
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,
|
allocation = bsearch(&address, allocator->allocations, allocator->allocation_count,
|
||||||
sizeof(*allocation), vkd3d_gpu_va_allocation_compare);
|
sizeof(*allocation), vkd3d_gpu_va_allocation_compare);
|
||||||
if (allocation && allocation->base == address)
|
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);
|
pthread_mutex_unlock(&allocator->mutex);
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user