summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChia-I Wu <[email protected]>2019-01-17 11:15:21 -0800
committerChia-I Wu <[email protected]>2019-03-11 10:01:41 -0700
commit6c4df43db591367aa2766cec399da1c657245a93 (patch)
treec848d57cd3ed5451660e48fdb27eb4691acc559a
parent7ad01913bd2122c108a51a32aa40cc2b23aed768 (diff)
turnip: add tu_bo_list_merge
tu_bo_list_merge adds an entire list to the current list.
-rw-r--r--src/freedreno/vulkan/tu_cmd_buffer.c47
-rw-r--r--src/freedreno/vulkan/tu_private.h4
2 files changed, 35 insertions, 16 deletions
diff --git a/src/freedreno/vulkan/tu_cmd_buffer.c b/src/freedreno/vulkan/tu_cmd_buffer.c
index d58e8e1bd0f..e14d28e9a1c 100644
--- a/src/freedreno/vulkan/tu_cmd_buffer.c
+++ b/src/freedreno/vulkan/tu_cmd_buffer.c
@@ -53,15 +53,14 @@ tu_bo_list_reset(struct tu_bo_list *list)
/**
* \a flags consists of MSM_SUBMIT_BO_FLAGS.
*/
-uint32_t
-tu_bo_list_add(struct tu_bo_list *list,
- const struct tu_bo *bo,
- uint32_t flags)
+static uint32_t
+tu_bo_list_add_info(struct tu_bo_list *list,
+ const struct drm_msm_gem_submit_bo *bo_info)
{
- uint32_t handle = bo->gem_handle;
for (uint32_t i = 0; i < list->count; ++i) {
- if (list->bo_infos[i].handle == handle) {
- list->bo_infos[i].flags |= flags;
+ if (list->bo_infos[i].handle == bo_info->handle) {
+ assert(list->bo_infos[i].presumed == bo_info->presumed);
+ list->bo_infos[i].flags |= bo_info->flags;
return i;
}
}
@@ -72,20 +71,36 @@ tu_bo_list_add(struct tu_bo_list *list,
struct drm_msm_gem_submit_bo *new_bo_infos = realloc(
list->bo_infos, new_capacity * sizeof(struct drm_msm_gem_submit_bo));
if (!new_bo_infos)
- return ~0;
+ return TU_BO_LIST_FAILED;
list->bo_infos = new_bo_infos;
list->capacity = new_capacity;
}
- uint32_t ret = list->count;
- list->bo_infos[list->count] = (struct drm_msm_gem_submit_bo) {
- .flags = flags,
- .handle = bo->gem_handle,
- .presumed = bo->iova,
- };
- ++list->count;
+ list->bo_infos[list->count] = *bo_info;
+ return list->count++;
+}
- return ret;
+uint32_t
+tu_bo_list_add(struct tu_bo_list *list,
+ const struct tu_bo *bo,
+ uint32_t flags)
+{
+ return tu_bo_list_add_info(list, &(struct drm_msm_gem_submit_bo) {
+ .flags = flags,
+ .handle = bo->gem_handle,
+ .presumed = bo->iova,
+ });
+}
+
+VkResult
+tu_bo_list_merge(struct tu_bo_list *list, const struct tu_bo_list *other)
+{
+ for (uint32_t i = 0; i < other->count; i++) {
+ if (tu_bo_list_add_info(list, other->bo_infos + i) == TU_BO_LIST_FAILED)
+ return VK_ERROR_OUT_OF_HOST_MEMORY;
+ }
+
+ return VK_SUCCESS;
}
const struct tu_dynamic_state default_dynamic_state = {
diff --git a/src/freedreno/vulkan/tu_private.h b/src/freedreno/vulkan/tu_private.h
index c2552330cb8..cce99181e26 100644
--- a/src/freedreno/vulkan/tu_private.h
+++ b/src/freedreno/vulkan/tu_private.h
@@ -712,6 +712,8 @@ struct tu_bo_list
struct drm_msm_gem_submit_bo *bo_infos;
};
+#define TU_BO_LIST_FAILED (~0)
+
void
tu_bo_list_init(struct tu_bo_list *list);
void
@@ -722,6 +724,8 @@ uint32_t
tu_bo_list_add(struct tu_bo_list *list,
const struct tu_bo *bo,
uint32_t flags);
+VkResult
+tu_bo_list_merge(struct tu_bo_list *list, const struct tu_bo_list *other);
struct tu_cs_entry
{