diff options
-rw-r--r-- | src/freedreno/vulkan/tu_cmd_buffer.c | 28 | ||||
-rw-r--r-- | src/freedreno/vulkan/tu_device.c | 13 | ||||
-rw-r--r-- | src/freedreno/vulkan/tu_private.h | 18 |
3 files changed, 35 insertions, 24 deletions
diff --git a/src/freedreno/vulkan/tu_cmd_buffer.c b/src/freedreno/vulkan/tu_cmd_buffer.c index 4600f1ffa2f..d58e8e1bd0f 100644 --- a/src/freedreno/vulkan/tu_cmd_buffer.c +++ b/src/freedreno/vulkan/tu_cmd_buffer.c @@ -35,13 +35,13 @@ void tu_bo_list_init(struct tu_bo_list *list) { list->count = list->capacity = 0; - list->handles = NULL; + list->bo_infos = NULL; } void tu_bo_list_destroy(struct tu_bo_list *list) { - free(list->handles); + free(list->bo_infos); } void @@ -50,27 +50,39 @@ tu_bo_list_reset(struct tu_bo_list *list) list->count = 0; } +/** + * \a flags consists of MSM_SUBMIT_BO_FLAGS. + */ uint32_t tu_bo_list_add(struct tu_bo_list *list, - const struct tu_bo *bo) + const struct tu_bo *bo, + uint32_t flags) { uint32_t handle = bo->gem_handle; for (uint32_t i = 0; i < list->count; ++i) { - if (list->handles[i] == handle) + if (list->bo_infos[i].handle == handle) { + list->bo_infos[i].flags |= flags; return i; + } } + /* grow list->bo_infos if needed */ 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) + 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; - list->handles = new_handles; + list->bo_infos = new_bo_infos; list->capacity = new_capacity; } uint32_t ret = list->count; - list->handles[list->count] = handle; + list->bo_infos[list->count] = (struct drm_msm_gem_submit_bo) { + .flags = flags, + .handle = bo->gem_handle, + .presumed = bo->iova, + }; ++list->count; return ret; diff --git a/src/freedreno/vulkan/tu_device.c b/src/freedreno/vulkan/tu_device.c index d5533028a62..f0c70f4f811 100644 --- a/src/freedreno/vulkan/tu_device.c +++ b/src/freedreno/vulkan/tu_device.c @@ -1178,8 +1178,8 @@ tu_QueueSubmit(VkQueue _queue, struct tu_cs *cs = &cmdbuf->cs; for (unsigned i = 0; i < cs->entry_count; ++i, ++entry_idx) { cmds[entry_idx].type = MSM_SUBMIT_CMD_BUF; - cmds[entry_idx].submit_idx = - tu_bo_list_add(&bo_list, cs->entries[i].bo); + cmds[entry_idx].submit_idx = tu_bo_list_add( + &bo_list, cs->entries[i].bo, MSM_SUBMIT_BO_READ); cmds[entry_idx].submit_offset = cs->entries[i].offset; cmds[entry_idx].size = cs->entries[i].size; cmds[entry_idx].pad = 0; @@ -1188,13 +1188,6 @@ tu_QueueSubmit(VkQueue _queue, } } - struct drm_msm_gem_submit_bo bos[bo_list.count]; - for (unsigned i = 0; i < bo_list.count; ++i) { - bos[i].flags = MSM_SUBMIT_BO_READ | MSM_SUBMIT_BO_WRITE; - bos[i].handle = bo_list.handles[i]; - bos[i].presumed = 0; - } - uint32_t flags = MSM_PIPE_3D0; if (last_submit) { flags |= MSM_SUBMIT_FENCE_FD_OUT; @@ -1203,7 +1196,7 @@ tu_QueueSubmit(VkQueue _queue, struct drm_msm_gem_submit req = { .flags = flags, .queueid = queue->msm_queue_id, - .bos = (uint64_t)(uintptr_t)bos, + .bos = (uint64_t)(uintptr_t) bo_list.bo_infos, .nr_bos = bo_list.count, .cmds = (uint64_t)(uintptr_t)cmds, .nr_cmds = entry_count, diff --git a/src/freedreno/vulkan/tu_private.h b/src/freedreno/vulkan/tu_private.h index 31f9d23fa4c..c2552330cb8 100644 --- a/src/freedreno/vulkan/tu_private.h +++ b/src/freedreno/vulkan/tu_private.h @@ -51,6 +51,7 @@ #include "vk_alloc.h" #include "vk_debug_report.h" +#include "drm/msm_drm.h" #include "tu_descriptor_set.h" #include "tu_extensions.h" @@ -708,14 +709,19 @@ struct tu_bo_list { uint32_t count; uint32_t capacity; - uint32_t *handles; + struct drm_msm_gem_submit_bo *bo_infos; }; -void tu_bo_list_init(struct tu_bo_list *list); -void tu_bo_list_destroy(struct tu_bo_list *list); -void tu_bo_list_reset(struct tu_bo_list *list); -uint32_t tu_bo_list_add(struct tu_bo_list *list, - const struct tu_bo *bo); +void +tu_bo_list_init(struct tu_bo_list *list); +void +tu_bo_list_destroy(struct tu_bo_list *list); +void +tu_bo_list_reset(struct tu_bo_list *list); +uint32_t +tu_bo_list_add(struct tu_bo_list *list, + const struct tu_bo *bo, + uint32_t flags); struct tu_cs_entry { |