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 | |
parent | 48b65201a6cf7a0b93dad94b4986c5dfc49c69ef (diff) |
turnip: Implement a slow bo list
Diffstat (limited to 'src/freedreno/vulkan')
-rw-r--r-- | src/freedreno/vulkan/tu_cmd_buffer.c | 50 | ||||
-rw-r--r-- | src/freedreno/vulkan/tu_private.h | 30 |
2 files changed, 58 insertions, 22 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; diff --git a/src/freedreno/vulkan/tu_private.h b/src/freedreno/vulkan/tu_private.h index 4f2a14a3dd1..e884b2cd8db 100644 --- a/src/freedreno/vulkan/tu_private.h +++ b/src/freedreno/vulkan/tu_private.h @@ -403,12 +403,6 @@ struct tu_queue VkDeviceQueueCreateFlags flags; }; -struct tu_bo_list -{ - unsigned capacity; - pthread_mutex_t mutex; -}; - struct tu_device { VK_LOADER_DATA _loader_data; @@ -431,11 +425,6 @@ struct tu_device mtx_t shader_slab_mutex; struct tu_device_extension_table enabled_extensions; - - /* Whether the driver uses a global BO list. */ - bool use_global_bo_list; - - struct tu_bo_list bo_list; }; struct tu_bo @@ -715,6 +704,13 @@ enum tu_cmd_buffer_status TU_CMD_BUFFER_STATUS_PENDING, }; +struct tu_bo_list +{ + uint32_t count; + uint32_t capacity; + uint32_t *handles; +}; + struct tu_cmd_buffer { VK_LOADER_DATA _loader_data; @@ -740,19 +736,9 @@ struct tu_cmd_buffer struct tu_cmd_buffer_upload upload; - uint32_t scratch_size_needed; - uint32_t compute_scratch_size_needed; - uint32_t esgs_ring_size_needed; - uint32_t gsvs_ring_size_needed; - bool tess_rings_needed; - bool sample_positions_needed; + struct tu_bo_list bo_list; VkResult record_result; - - /** - * Whether a query pool has been resetted and we have to flush caches. - */ - bool pending_reset_query; }; bool |