Mesa (main): anv: Add a helper to add a BO to the batch list without a reloc

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Tue Jun 8 23:09:30 UTC 2021


Module: Mesa
Branch: main
Commit: 9802a0d7ca67b74436e041d7e2792f19d034a92c
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=9802a0d7ca67b74436e041d7e2792f19d034a92c

Author: Jason Ekstrand <jason at jlekstrand.net>
Date:   Thu Aug  6 22:46:12 2020 -0500

anv: Add a helper to add a BO to the batch list without a reloc

The relocation list currently serves two purposes.  One is for
relocations on older non-softpin platforms.  The second is to keep track
of driver-managed BOs which are used by the given command buffer.  We
going to need a mechanism to add BOs to the command buffer without doing
a relocation into the batch.

Reviewed-by: Lionel Landwerlin <lionel.g.landwerlin at intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/11236>

---

 src/intel/vulkan/anv_batch_chain.c | 32 +++++++++++++++++++++-----------
 src/intel/vulkan/anv_private.h     |  4 ++++
 2 files changed, 25 insertions(+), 11 deletions(-)

diff --git a/src/intel/vulkan/anv_batch_chain.c b/src/intel/vulkan/anv_batch_chain.c
index 35fb2182d42..51f78f71d12 100644
--- a/src/intel/vulkan/anv_batch_chain.c
+++ b/src/intel/vulkan/anv_batch_chain.c
@@ -175,6 +175,25 @@ anv_reloc_list_grow_deps(struct anv_reloc_list *list,
 
 #define READ_ONCE(x) (*(volatile __typeof__(x) *)&(x))
 
+VkResult
+anv_reloc_list_add_bo(struct anv_reloc_list *list,
+                      const VkAllocationCallbacks *alloc,
+                      struct anv_bo *target_bo)
+{
+   assert(!target_bo->is_wrapper);
+   assert(target_bo->flags & EXEC_OBJECT_PINNED);
+
+   uint32_t idx = target_bo->gem_handle;
+   VkResult result = anv_reloc_list_grow_deps(list, alloc,
+                                              (idx / BITSET_WORDBITS) + 1);
+   if (unlikely(result != VK_SUCCESS))
+      return result;
+
+   BITSET_SET(list->deps, idx);
+
+   return VK_SUCCESS;
+}
+
 VkResult
 anv_reloc_list_add(struct anv_reloc_list *list,
                    const VkAllocationCallbacks *alloc,
@@ -192,17 +211,8 @@ anv_reloc_list_add(struct anv_reloc_list *list,
    assert(unwrapped_target_bo->gem_handle > 0);
    assert(unwrapped_target_bo->refcount > 0);
 
-   if (unwrapped_target_bo->flags & EXEC_OBJECT_PINNED) {
-      assert(!target_bo->is_wrapper);
-      uint32_t idx = unwrapped_target_bo->gem_handle;
-      VkResult result = anv_reloc_list_grow_deps(list, alloc,
-                                                 (idx / BITSET_WORDBITS) + 1);
-      if (unlikely(result != VK_SUCCESS))
-         return result;
-
-      BITSET_SET(list->deps, unwrapped_target_bo->gem_handle);
-      return VK_SUCCESS;
-   }
+   if (unwrapped_target_bo->flags & EXEC_OBJECT_PINNED)
+      return anv_reloc_list_add_bo(list, alloc, unwrapped_target_bo);
 
    VkResult result = anv_reloc_list_grow(list, alloc, 1);
    if (result != VK_SUCCESS)
diff --git a/src/intel/vulkan/anv_private.h b/src/intel/vulkan/anv_private.h
index 0a955b09eae..0086a80afe4 100644
--- a/src/intel/vulkan/anv_private.h
+++ b/src/intel/vulkan/anv_private.h
@@ -1523,6 +1523,10 @@ VkResult anv_reloc_list_add(struct anv_reloc_list *list,
                             uint32_t offset, struct anv_bo *target_bo,
                             uint32_t delta, uint64_t *address_u64_out);
 
+VkResult anv_reloc_list_add_bo(struct anv_reloc_list *list,
+                               const VkAllocationCallbacks *alloc,
+                               struct anv_bo *target_bo);
+
 struct anv_batch_bo {
    /* Link in the anv_cmd_buffer.owned_batch_bos list */
    struct list_head                             link;



More information about the mesa-commit mailing list