venus: refactor buffer cache related bits

Simplify returns and reorder inits.

Signed-off-by: Yiwei Zhang <zzyiwei@chromium.org>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/23916>
This commit is contained in:
Yiwei Zhang
2023-06-28 16:00:11 -07:00
committed by Marge Bot
parent 432ffaf10a
commit 1e17234260
4 changed files with 9 additions and 16 deletions

View File

@@ -46,7 +46,7 @@ vn_buffer_get_max_buffer_size(struct vn_physical_device *physical_dev)
: safe_max_buffer_size;
}
VkResult
void
vn_buffer_cache_init(struct vn_device *dev)
{
dev->buffer_cache.max_buffer_size =
@@ -55,8 +55,6 @@ vn_buffer_cache_init(struct vn_device *dev)
simple_mtx_init(&dev->buffer_cache.mutex, mtx_plain);
util_sparse_array_init(&dev->buffer_cache.entries,
sizeof(struct vn_buffer_cache_entry), 64);
return VK_SUCCESS;
}
static void

View File

@@ -67,7 +67,7 @@ vn_buffer_create(struct vn_device *dev,
const VkAllocationCallbacks *alloc,
struct vn_buffer **out_buf);
VkResult
void
vn_buffer_cache_init(struct vn_device *dev);
void

View File

@@ -487,13 +487,9 @@ vn_device_init(struct vn_device *dev,
mtx_init(&pool->mutex, mtx_plain);
}
result = vn_buffer_cache_init(dev);
if (result != VK_SUCCESS)
goto out_memory_pool_fini;
result = vn_device_feedback_pool_init(dev);
if (result != VK_SUCCESS)
goto out_buffer_cache_fini;
goto out_memory_pool_fini;
result = vn_feedback_cmd_pools_init(dev);
if (result != VK_SUCCESS)
@@ -503,6 +499,8 @@ vn_device_init(struct vn_device *dev,
if (result != VK_SUCCESS)
goto out_cmd_pools_fini;
vn_buffer_cache_init(dev);
/* This is a WA to allow fossilize replay to detect if the host side shader
* cache is no longer up to date.
*/
@@ -516,9 +514,6 @@ out_cmd_pools_fini:
out_feedback_pool_fini:
vn_device_feedback_pool_fini(dev);
out_buffer_cache_fini:
vn_buffer_cache_fini(dev);
out_memory_pool_fini:
for (uint32_t i = 0; i < ARRAY_SIZE(dev->memory_pools); i++)
vn_device_memory_pool_fini(dev, i);
@@ -594,6 +589,8 @@ vn_DestroyDevice(VkDevice device, const VkAllocationCallbacks *pAllocator)
if (!dev)
return;
vn_buffer_cache_fini(dev);
for (uint32_t i = 0; i < dev->queue_count; i++)
vn_queue_fini(&dev->queues[i]);
@@ -601,8 +598,6 @@ vn_DestroyDevice(VkDevice device, const VkAllocationCallbacks *pAllocator)
vn_device_feedback_pool_fini(dev);
vn_buffer_cache_fini(dev);
for (uint32_t i = 0; i < ARRAY_SIZE(dev->memory_pools); i++)
vn_device_memory_pool_fini(dev, i);

View File

@@ -38,8 +38,6 @@ struct vn_device {
struct vn_device_memory_pool memory_pools[VK_MAX_MEMORY_TYPES];
struct vn_buffer_cache buffer_cache;
struct vn_feedback_pool feedback_pool;
/* feedback cmd pool per queue family used by the device
@@ -50,6 +48,8 @@ struct vn_device {
struct vn_queue *queues;
uint32_t queue_count;
struct vn_buffer_cache buffer_cache;
};
VK_DEFINE_HANDLE_CASTS(vn_device,
base.base.base,