diff options
author | Bas Nieuwenhuizen <[email protected]> | 2020-03-24 17:59:26 +0100 |
---|---|---|
committer | Marge Bot <[email protected]> | 2020-04-27 18:01:24 +0000 |
commit | cbeda7f78e36caa7e4ca775bd848e1c8d38ee5d7 (patch) | |
tree | fc1b6b28ae0b5cfd119e7ad5ca01442a71834ac4 /src/amd/vulkan/radv_device.c | |
parent | 9a61f2a8a9ca17e2d53dded9c1c490c890aa4a74 (diff) |
radv: Add WSI buffers to BO list only if they can be used.
Also reverse the BO list removal loop. This way typical WSI usage
should find the entry in O(active swapchains) iterations, which
should not be a performance issues. Tested with Doom(2106) which
found the entry in 1 iteration every time.
Acked-by: Jason Ekstrand <[email protected]>
Reviewed-by: Samuel Pitoiset <[email protected]>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/4306>
Diffstat (limited to 'src/amd/vulkan/radv_device.c')
-rw-r--r-- | src/amd/vulkan/radv_device.c | 20 |
1 files changed, 12 insertions, 8 deletions
diff --git a/src/amd/vulkan/radv_device.c b/src/amd/vulkan/radv_device.c index b51d7325df8..c34674d0904 100644 --- a/src/amd/vulkan/radv_device.c +++ b/src/amd/vulkan/radv_device.c @@ -2231,8 +2231,8 @@ radv_bo_list_finish(struct radv_bo_list *bo_list) pthread_mutex_destroy(&bo_list->mutex); } -static VkResult radv_bo_list_add(struct radv_device *device, - struct radeon_winsys_bo *bo) +VkResult radv_bo_list_add(struct radv_device *device, + struct radeon_winsys_bo *bo) { struct radv_bo_list *bo_list = &device->bo_list; @@ -2261,8 +2261,8 @@ static VkResult radv_bo_list_add(struct radv_device *device, return VK_SUCCESS; } -static void radv_bo_list_remove(struct radv_device *device, - struct radeon_winsys_bo *bo) +void radv_bo_list_remove(struct radv_device *device, + struct radeon_winsys_bo *bo) { struct radv_bo_list *bo_list = &device->bo_list; @@ -2273,7 +2273,9 @@ static void radv_bo_list_remove(struct radv_device *device, return; pthread_mutex_lock(&bo_list->mutex); - for(unsigned i = 0; i < bo_list->list.count; ++i) { + /* Loop the list backwards so we find the most recently added + * memory first. */ + for(unsigned i = bo_list->list.count; i-- > 0;) { if (bo_list->list.bos[i] == bo) { bo_list->list.bos[i] = bo_list->list.bos[bo_list->list.count - 1]; --bo_list->list.count; @@ -5241,9 +5243,11 @@ static VkResult radv_alloc_memory(struct radv_device *device, mem->type_index = mem_type_index; } - result = radv_bo_list_add(device, mem->bo); - if (result != VK_SUCCESS) - goto fail; + if (!wsi_info) { + result = radv_bo_list_add(device, mem->bo); + if (result != VK_SUCCESS) + goto fail; + } *pMem = radv_device_memory_to_handle(mem); |