summaryrefslogtreecommitdiffstats
path: root/src/intel/vulkan/anv_device.c
diff options
context:
space:
mode:
authorJason Ekstrand <[email protected]>2019-02-26 18:05:34 -0600
committerJason Ekstrand <[email protected]>2019-04-19 19:56:42 +0000
commit83b943cc2f2408087795ee2bd984477a1749a530 (patch)
tree3738c9ebfa9d4a5107675ddd8b5f7714ae4a1609 /src/intel/vulkan/anv_device.c
parenta9241edfa3ed1ccf9b5635d1313d88e532d46cd5 (diff)
anv: Make all VkDeviceMemory BOs resident permanently
We spend a lot of time in the driver adding things to hash sets to track residency. The reality is that a properly built Vulkan app uses large memory objects and sub-allocates from them. In a typical frame, most of if not all of those allocations are going to be resident for the entire frame so we're really not saving ourselves much by tracking fine-grained residency. Just throwing everything in the validation list does make it a little bit more expensive inside the kernel to walk the list and ensure that all our VA is in order. However, without relocations, the overhead of that is pretty small. If we ever do run into a memory pressure situation where the fine- grained residency could even potentially help, we would likely be swapping one page out to make room for another within the draw call and performance is totally lost at that point. We're better off swapping out other apps and just letting ours run a whole frame. Reviewed-by: Lionel Landwerlin <[email protected]> Reviewed-by: Caio Marcelo de Oliveira Filho <[email protected]>
Diffstat (limited to 'src/intel/vulkan/anv_device.c')
-rw-r--r--src/intel/vulkan/anv_device.c28
1 files changed, 10 insertions, 18 deletions
diff --git a/src/intel/vulkan/anv_device.c b/src/intel/vulkan/anv_device.c
index 991ca50f7dd..2af09d4f122 100644
--- a/src/intel/vulkan/anv_device.c
+++ b/src/intel/vulkan/anv_device.c
@@ -2005,6 +2005,8 @@ VkResult anv_CreateDevice(
high_heap->size;
}
+ list_inithead(&device->memory_objects);
+
/* As per spec, the driver implementation may deny requests to acquire
* a priority above the default priority (MEDIUM) if the caller does not
* have sufficient privileges. In this scenario VK_ERROR_NOT_PERMITTED_EXT
@@ -2118,9 +2120,6 @@ VkResult anv_CreateDevice(
if (device->info.gen >= 10)
anv_device_init_hiz_clear_value_bo(device);
- if (physical_device->use_softpin)
- device->pinned_buffers = _mesa_pointer_set_create(NULL);
-
anv_scratch_pool_init(device, &device->scratch_pool);
anv_queue_init(device, &device->queue);
@@ -2211,9 +2210,6 @@ void anv_DestroyDevice(
anv_queue_finish(&device->queue);
- if (physical_device->use_softpin)
- _mesa_set_destroy(device->pinned_buffers, NULL);
-
#ifdef HAVE_VALGRIND
/* We only need to free these to prevent valgrind errors. The backing
* BO will go away in a couple of lines so we don't actually leak.
@@ -2698,6 +2694,10 @@ VkResult anv_AllocateMemory(
}
success:
+ pthread_mutex_lock(&device->mutex);
+ list_addtail(&mem->link, &device->memory_objects);
+ pthread_mutex_unlock(&device->mutex);
+
*pMem = anv_device_memory_to_handle(mem);
return VK_SUCCESS;
@@ -2789,6 +2789,10 @@ void anv_FreeMemory(
if (mem == NULL)
return;
+ pthread_mutex_lock(&device->mutex);
+ list_del(&mem->link);
+ pthread_mutex_unlock(&device->mutex);
+
if (mem->map)
anv_UnmapMemory(_device, _mem);
@@ -3324,12 +3328,6 @@ VkResult anv_CreateBuffer(
buffer->usage = pCreateInfo->usage;
buffer->address = ANV_NULL_ADDRESS;
- if (buffer->usage & VK_BUFFER_USAGE_SHADER_DEVICE_ADDRESS_BIT_EXT) {
- pthread_mutex_lock(&device->mutex);
- _mesa_set_add(device->pinned_buffers, buffer);
- pthread_mutex_unlock(&device->mutex);
- }
-
*pBuffer = anv_buffer_to_handle(buffer);
return VK_SUCCESS;
@@ -3346,12 +3344,6 @@ void anv_DestroyBuffer(
if (!buffer)
return;
- if (buffer->usage & VK_BUFFER_USAGE_SHADER_DEVICE_ADDRESS_BIT_EXT) {
- pthread_mutex_lock(&device->mutex);
- _mesa_set_remove_key(device->pinned_buffers, buffer);
- pthread_mutex_unlock(&device->mutex);
- }
-
vk_free2(&device->alloc, pAllocator, buffer);
}