diff options
author | Bas Nieuwenhuizen <[email protected]> | 2018-12-31 11:34:32 +0100 |
---|---|---|
committer | Chia-I Wu <[email protected]> | 2019-03-11 10:01:41 -0700 |
commit | e3a9b0792325f849246baab73cf19c51f2238122 (patch) | |
tree | 37776bb21dfaa2cb5b1ae4503d267c4b46fda9cb /src/freedreno/vulkan/tu_cmd_buffer.c | |
parent | 48b65201a6cf7a0b93dad94b4986c5dfc49c69ef (diff) |
turnip: Implement a slow bo list
Diffstat (limited to 'src/freedreno/vulkan/tu_cmd_buffer.c')
-rw-r--r-- | src/freedreno/vulkan/tu_cmd_buffer.c | 50 |
1 files changed, 50 insertions, 0 deletions
diff --git a/src/freedreno/vulkan/tu_cmd_buffer.c b/src/freedreno/vulkan/tu_cmd_buffer.c index 60002a0a708..e8835a0aa32 100644 --- a/src/freedreno/vulkan/tu_cmd_buffer.c +++ b/src/freedreno/vulkan/tu_cmd_buffer.c @@ -29,6 +29,51 @@ #include "vk_format.h" +static void +tu_bo_list_init(struct tu_bo_list *list) +{ + list->count = list->capacity = 0; + list->handles = NULL; +} + +static void +tu_bo_list_destroy(struct tu_bo_list *list) +{ + free(list->handles); +} + +static void +tu_bo_list_reset(struct tu_bo_list *list) +{ + list->count = 0; +} + +static uint32_t +tu_bo_list_add(struct tu_bo_list *list, + const struct tu_bo *bo) +{ + uint32_t handle = bo->gem_handle; + for (uint32_t i = 0; i < list->count; ++i) { + if (list->handles[i] == handle) + return i; + } + + if (list->count == list->capacity) { + uint32_t new_capacity = MAX2(2 * list->count, 16); + uint32_t *new_handles = realloc(list->handles, new_capacity * sizeof(uint32_t)); + if (!new_handles) + return ~0; + list->handles = new_handles; + list->capacity = new_capacity; + } + + uint32_t ret = list->count; + list->handles[list->count] = handle; + ++list->count; + + return ret; +} + const struct tu_dynamic_state default_dynamic_state = { .viewport = { @@ -199,6 +244,8 @@ tu_create_cmd_buffer(struct tu_device *device, cmd_buffer->queue_family_index = TU_QUEUE_GENERAL; } + tu_bo_list_init(&cmd_buffer->bo_list); + *pCommandBuffer = tu_cmd_buffer_to_handle(cmd_buffer); list_inithead(&cmd_buffer->upload.list); @@ -214,6 +261,7 @@ tu_cmd_buffer_destroy(struct tu_cmd_buffer *cmd_buffer) for (unsigned i = 0; i < VK_PIPELINE_BIND_POINT_RANGE_SIZE; i++) free(cmd_buffer->descriptors[i].push_set.set.mapped_ptr); + tu_bo_list_destroy(&cmd_buffer->bo_list); vk_free(&cmd_buffer->pool->alloc, cmd_buffer); } @@ -222,6 +270,8 @@ tu_reset_cmd_buffer(struct tu_cmd_buffer *cmd_buffer) { cmd_buffer->record_result = VK_SUCCESS; + tu_bo_list_reset(&cmd_buffer->bo_list); + for (unsigned i = 0; i < VK_PIPELINE_BIND_POINT_RANGE_SIZE; i++) { cmd_buffer->descriptors[i].dirty = 0; cmd_buffer->descriptors[i].valid = 0; |