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

Author: Paulo Zanoni <[email protected]>
Date:   Wed Oct 25 15:37:32 2023 -0700

anv/trtt: add struct anv_trtt_batch_bo and pass it around

For now it just wraps the bo and size, so there's really no value to
having it. In the next commit we'll add more elements to the struct.

Reviewed-by: Lionel Landwerlin <[email protected]>
Signed-off-by: Paulo Zanoni <[email protected]>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/25512>

---

 src/intel/vulkan/anv_batch_chain.c      | 20 ++++++++++----------
 src/intel/vulkan/anv_gem_stubs.c        |  2 +-
 src/intel/vulkan/anv_kmd_backend.h      |  4 ++--
 src/intel/vulkan/anv_private.h          |  5 +++++
 src/intel/vulkan/i915/anv_batch_chain.c |  8 ++++----
 src/intel/vulkan/i915/anv_batch_chain.h |  3 ++-
 src/intel/vulkan/xe/anv_batch_chain.c   |  4 ++--
 src/intel/vulkan/xe/anv_batch_chain.h   |  3 ++-
 8 files changed, 28 insertions(+), 21 deletions(-)

diff --git a/src/intel/vulkan/anv_batch_chain.c 
b/src/intel/vulkan/anv_batch_chain.c
index 35896db00bb..4ecd3075b5e 100644
--- a/src/intel/vulkan/anv_batch_chain.c
+++ b/src/intel/vulkan/anv_batch_chain.c
@@ -1705,28 +1705,28 @@ anv_queue_submit_trtt_batch(struct 
anv_sparse_submission *submit,
    struct anv_device *device = queue->device;
    VkResult result = VK_SUCCESS;
 
-   uint32_t batch_size = align(batch->next - batch->start, 8);
+   struct anv_trtt_batch_bo trtt_bbo;
+   trtt_bbo.size = align(batch->next - batch->start, 8);
 
-   struct anv_bo *batch_bo;
-   result = anv_bo_pool_alloc(&device->batch_bo_pool, batch_size, &batch_bo);
+   result = anv_bo_pool_alloc(&device->batch_bo_pool, trtt_bbo.size,
+                              &trtt_bbo.bo);
    if (result != VK_SUCCESS)
       return result;
 
-   memcpy(batch_bo->map, batch->start, batch_size);
+   memcpy(trtt_bbo.bo->map, batch->start, trtt_bbo.size);
 #ifdef SUPPORT_INTEL_INTEGRATED_GPUS
    if (device->physical->memory.need_flush)
-      intel_flush_range(batch_bo->map, batch_size);
+      intel_flush_range(trtt_bbo.bo->map, trtt_bbo.size);
 #endif
 
    if (INTEL_DEBUG(DEBUG_BATCH)) {
-      intel_print_batch(queue->decoder, batch_bo->map, batch_bo->size,
-                        batch_bo->offset, false);
+      intel_print_batch(queue->decoder, trtt_bbo.bo->map, trtt_bbo.bo->size,
+                        trtt_bbo.bo->offset, false);
    }
 
-   result = device->kmd_backend->execute_trtt_batch(submit, batch_bo,
-                                                    batch_size);
+   result = device->kmd_backend->execute_trtt_batch(submit, &trtt_bbo);
 
-   anv_bo_pool_free(&device->batch_bo_pool, batch_bo);
+   anv_bo_pool_free(&device->batch_bo_pool, trtt_bbo.bo);
 
    return result;
 }
diff --git a/src/intel/vulkan/anv_gem_stubs.c b/src/intel/vulkan/anv_gem_stubs.c
index 38d20b41381..195ddee1278 100644
--- a/src/intel/vulkan/anv_gem_stubs.c
+++ b/src/intel/vulkan/anv_gem_stubs.c
@@ -67,7 +67,7 @@ stub_execute_simple_batch(struct anv_queue *queue, struct 
anv_bo *batch_bo,
 
 static VkResult
 stub_execute_trtt_batch(struct anv_sparse_submission *submit,
-                        struct anv_bo *batch_bo, uint32_t batch_size)
+                        struct anv_trtt_batch_bo *trtt_bbo)
 {
    return VK_ERROR_UNKNOWN;
 }
diff --git a/src/intel/vulkan/anv_kmd_backend.h 
b/src/intel/vulkan/anv_kmd_backend.h
index 363cfded5f5..372dc31d8e2 100644
--- a/src/intel/vulkan/anv_kmd_backend.h
+++ b/src/intel/vulkan/anv_kmd_backend.h
@@ -39,6 +39,7 @@ struct anv_queue;
 struct anv_query_pool;
 struct anv_utrace_submit;
 struct anv_sparse_submission;
+struct anv_trtt_batch_bo;
 
 enum anv_vm_bind_op {
    ANV_VM_BIND,
@@ -79,8 +80,7 @@ struct anv_kmd_backend {
                                     uint32_t batch_bo_size,
                                     bool is_companion_rcs_batch);
    VkResult (*execute_trtt_batch)(struct anv_sparse_submission *submit,
-                                  struct anv_bo *batch_bo,
-                                  uint32_t batch_size);
+                                  struct anv_trtt_batch_bo *trtt_bbo);
    VkResult (*queue_exec_locked)(struct anv_queue *queue,
                                  uint32_t wait_count,
                                  const struct vk_sync_wait *waits,
diff --git a/src/intel/vulkan/anv_private.h b/src/intel/vulkan/anv_private.h
index 7a870fdf793..1db938569ab 100644
--- a/src/intel/vulkan/anv_private.h
+++ b/src/intel/vulkan/anv_private.h
@@ -1595,6 +1595,11 @@ struct anv_device_astc_emu {
     VkPipeline pipeline;
 };
 
+struct anv_trtt_batch_bo {
+   struct anv_bo *bo;
+   uint32_t size;
+};
+
 struct anv_device {
     struct vk_device                            vk;
 
diff --git a/src/intel/vulkan/i915/anv_batch_chain.c 
b/src/intel/vulkan/i915/anv_batch_chain.c
index 7b0e161f93f..9c65e4e3165 100644
--- a/src/intel/vulkan/i915/anv_batch_chain.c
+++ b/src/intel/vulkan/i915/anv_batch_chain.c
@@ -981,7 +981,7 @@ fail:
 
 VkResult
 i915_execute_trtt_batch(struct anv_sparse_submission *submit,
-                        struct anv_bo *batch_bo, uint32_t batch_size)
+                        struct anv_trtt_batch_bo *trtt_bbo)
 {
    struct anv_queue *queue = submit->queue;
    struct anv_device *device = queue->device;
@@ -1020,7 +1020,7 @@ i915_execute_trtt_batch(struct anv_sparse_submission 
*submit,
          goto out;
    }
 
-   result = anv_execbuf_add_bo(device, &execbuf, batch_bo, NULL, 0);
+   result = anv_execbuf_add_bo(device, &execbuf, trtt_bbo->bo, NULL, 0);
    if (result != VK_SUCCESS)
       goto out;
 
@@ -1035,7 +1035,7 @@ i915_execute_trtt_batch(struct anv_sparse_submission 
*submit,
       .buffers_ptr = (uintptr_t) execbuf.objects,
       .buffer_count = execbuf.bo_count,
       .batch_start_offset = 0,
-      .batch_len = batch_size,
+      .batch_len = trtt_bbo->size,
       .flags = I915_EXEC_HANDLE_LUT | I915_EXEC_NO_RELOC | exec_flags,
       .rsvd1 = context_id,
       .rsvd2 = 0,
@@ -1053,7 +1053,7 @@ i915_execute_trtt_batch(struct anv_sparse_submission 
*submit,
    /* TODO: we can get rid of this wait once we can properly handle the buffer
     * lifetimes.
     */
-   result = anv_device_wait(device, batch_bo, INT64_MAX);
+   result = anv_device_wait(device, trtt_bbo->bo, INT64_MAX);
    if (result != VK_SUCCESS) {
       result = vk_device_set_lost(&device->vk,
                                   "trtt anv_device_wait failed: %m");
diff --git a/src/intel/vulkan/i915/anv_batch_chain.h 
b/src/intel/vulkan/i915/anv_batch_chain.h
index 37d55a62b6b..fc799582828 100644
--- a/src/intel/vulkan/i915/anv_batch_chain.h
+++ b/src/intel/vulkan/i915/anv_batch_chain.h
@@ -36,6 +36,7 @@ struct anv_cmd_buffer;
 struct anv_query_pool;
 struct anv_utrace_submit;
 struct anv_sparse_submission;
+struct anv_trtt_batch_bo;
 
 VkResult
 i915_queue_exec_trace(struct anv_queue *queue,
@@ -46,7 +47,7 @@ i915_execute_simple_batch(struct anv_queue *queue, struct 
anv_bo *batch_bo,
 
 VkResult
 i915_execute_trtt_batch(struct anv_sparse_submission *submit,
-                        struct anv_bo *batch_bo, uint32_t batch_size);
+                        struct anv_trtt_batch_bo *trtt_bbo);
 
 VkResult
 i915_queue_exec_locked(struct anv_queue *queue,
diff --git a/src/intel/vulkan/xe/anv_batch_chain.c 
b/src/intel/vulkan/xe/anv_batch_chain.c
index ad71f8acf9a..3c28b908014 100644
--- a/src/intel/vulkan/xe/anv_batch_chain.c
+++ b/src/intel/vulkan/xe/anv_batch_chain.c
@@ -185,7 +185,7 @@ xe_exec_print_debug(struct anv_queue *queue, uint32_t 
cmd_buffer_count,
 
 VkResult
 xe_execute_trtt_batch(struct anv_sparse_submission *submit,
-                      struct anv_bo *batch_bo, uint32_t batch_size)
+                      struct anv_trtt_batch_bo *trtt_bbo)
 {
    struct anv_queue *queue = submit->queue;
    struct anv_device *device = queue->device;
@@ -215,7 +215,7 @@ xe_execute_trtt_batch(struct anv_sparse_submission *submit,
       .exec_queue_id = queue->exec_queue_id,
       .num_syncs = xe_syncs_count,
       .syncs = (uintptr_t)xe_syncs,
-      .address = batch_bo->offset,
+      .address = trtt_bbo->bo->offset,
       .num_batch_buffer = 1,
    };
 
diff --git a/src/intel/vulkan/xe/anv_batch_chain.h 
b/src/intel/vulkan/xe/anv_batch_chain.h
index d3bd8232607..06e8968bc53 100644
--- a/src/intel/vulkan/xe/anv_batch_chain.h
+++ b/src/intel/vulkan/xe/anv_batch_chain.h
@@ -35,13 +35,14 @@ struct anv_cmd_buffer;
 struct anv_query_pool;
 struct anv_utrace_submit;
 struct anv_sparse_submission;
+struct anv_trtt_batch_bo;
 
 VkResult
 xe_execute_simple_batch(struct anv_queue *queue, struct anv_bo *batch_bo,
                         uint32_t batch_bo_size, bool is_companion_rcs_batch);
 VkResult
 xe_execute_trtt_batch(struct anv_sparse_submission *submit,
-                      struct anv_bo *batch_bo, uint32_t batch_size);
+                      struct anv_trtt_batch_bo *trtt_bbo);
 
 VkResult
 xe_queue_exec_locked(struct anv_queue *queue,

Reply via email to