diff options
author | Rafael Antognolli <[email protected]> | 2018-12-13 08:06:48 -0800 |
---|---|---|
committer | Rafael Antognolli <[email protected]> | 2019-01-17 15:08:08 -0800 |
commit | 11a5d4620ba289d3b438524862e0f04df0e421b4 (patch) | |
tree | 06807752ed5bd49d5e108a2c8e1773824fe0d431 /src | |
parent | f874604f45b5fd7a46453a37f99d7c6717c8a4f6 (diff) |
anv: Split code to add BO dependencies to execbuf.
This part of the anv_execbuf_add_bo() code is totally independent of the
BO being added. Let's split it out, so we can reuse it later.
v3: rename to anv_execbuf_add_bo_set (Jason).
Reviewed-by: Jason Ekstrand <[email protected]>
Diffstat (limited to 'src')
-rw-r--r-- | src/intel/vulkan/anv_batch_chain.c | 62 |
1 files changed, 39 insertions, 23 deletions
diff --git a/src/intel/vulkan/anv_batch_chain.c b/src/intel/vulkan/anv_batch_chain.c index ff615bca01d..1b92994a052 100644 --- a/src/intel/vulkan/anv_batch_chain.c +++ b/src/intel/vulkan/anv_batch_chain.c @@ -1036,6 +1036,12 @@ _compare_bo_handles(const void *_bo1, const void *_bo2) } static VkResult +anv_execbuf_add_bo_set(struct anv_execbuf *exec, + struct set *deps, + uint32_t extra_flags, + const VkAllocationCallbacks *alloc); + +static VkResult anv_execbuf_add_bo(struct anv_execbuf *exec, struct anv_bo *bo, struct anv_reloc_list *relocs, @@ -1124,36 +1130,46 @@ anv_execbuf_add_bo(struct anv_execbuf *exec, } } - if (relocs->deps && relocs->deps->entries > 0) { - const uint32_t entries = relocs->deps->entries; - struct anv_bo **bos = - vk_alloc(alloc, entries * sizeof(*bos), - 8, VK_SYSTEM_ALLOCATION_SCOPE_COMMAND); - if (bos == NULL) - return vk_error(VK_ERROR_OUT_OF_HOST_MEMORY); + return anv_execbuf_add_bo_set(exec, relocs->deps, extra_flags, alloc); + } - struct anv_bo **bo = bos; - set_foreach(relocs->deps, entry) { - *bo++ = (void *)entry->key; - } + return VK_SUCCESS; +} - qsort(bos, entries, sizeof(struct anv_bo*), _compare_bo_handles); +/* Add BO dependencies to execbuf */ +static VkResult +anv_execbuf_add_bo_set(struct anv_execbuf *exec, + struct set *deps, + uint32_t extra_flags, + const VkAllocationCallbacks *alloc) +{ + if (!deps || deps->entries <= 0) + return VK_SUCCESS; - VkResult result = VK_SUCCESS; - for (bo = bos; bo < bos + entries; bo++) { - result = anv_execbuf_add_bo(exec, *bo, NULL, extra_flags, alloc); - if (result != VK_SUCCESS) - break; - } + const uint32_t entries = deps->entries; + struct anv_bo **bos = + vk_alloc(alloc, entries * sizeof(*bos), + 8, VK_SYSTEM_ALLOCATION_SCOPE_COMMAND); + if (bos == NULL) + return vk_error(VK_ERROR_OUT_OF_HOST_MEMORY); - vk_free(alloc, bos); + struct anv_bo **bo = bos; + set_foreach(deps, entry) { + *bo++ = (void *)entry->key; + } - if (result != VK_SUCCESS) - return result; - } + qsort(bos, entries, sizeof(struct anv_bo*), _compare_bo_handles); + + VkResult result = VK_SUCCESS; + for (bo = bos; bo < bos + entries; bo++) { + result = anv_execbuf_add_bo(exec, *bo, NULL, extra_flags, alloc); + if (result != VK_SUCCESS) + break; } - return VK_SUCCESS; + vk_free(alloc, bos); + + return result; } static VkResult |