Mesa (main): anv: implement DEBUG_SYNC

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Tue Apr 19 08:02:40 UTC 2022


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

Author: Lionel Landwerlin <lionel.g.landwerlin at intel.com>
Date:   Tue Feb 22 10:38:05 2022 +0200

anv: implement DEBUG_SYNC

Signed-off-by: Lionel Landwerlin <lionel.g.landwerlin at intel.com>
Reviewed-by: Jordan Justen <jordan.l.justen at intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/15950>

---

 src/intel/vulkan/anv_batch_chain.c | 18 ++++++++++++++++++
 src/intel/vulkan/anv_private.h     |  3 +++
 src/intel/vulkan/anv_queue.c       | 11 +++++++++++
 3 files changed, 32 insertions(+)

diff --git a/src/intel/vulkan/anv_batch_chain.c b/src/intel/vulkan/anv_batch_chain.c
index 38251c74225..24765f4706f 100644
--- a/src/intel/vulkan/anv_batch_chain.c
+++ b/src/intel/vulkan/anv_batch_chain.c
@@ -2143,6 +2143,15 @@ anv_queue_exec_locked(struct anv_queue *queue,
          goto error;
    }
 
+   if (queue->sync) {
+      result = anv_execbuf_add_sync(device, &execbuf,
+                                    queue->sync,
+                                    true /* is_signal */,
+                                    0 /* signal_value */);
+      if (result != VK_SUCCESS)
+         goto error;
+   }
+
    if (cmd_buffer_count) {
       result = setup_execbuf_for_cmd_buffers(&execbuf, queue,
                                              cmd_buffers,
@@ -2258,6 +2267,15 @@ anv_queue_exec_locked(struct anv_queue *queue,
    if (ret)
       result = vk_queue_set_lost(&queue->vk, "execbuf2 failed: %m");
 
+   if (queue->sync) {
+      VkResult result = vk_sync_wait(&device->vk,
+                                     queue->sync, 0,
+                                     VK_SYNC_WAIT_COMPLETE,
+                                     UINT64_MAX);
+      if (result != VK_SUCCESS)
+         result = vk_queue_set_lost(&queue->vk, "sync wait failed");
+   }
+
    struct drm_i915_gem_exec_object2 *objects = execbuf.objects;
    for (uint32_t k = 0; k < execbuf.bo_count; k++) {
       if (anv_bo_is_pinned(execbuf.bos[k]))
diff --git a/src/intel/vulkan/anv_private.h b/src/intel/vulkan/anv_private.h
index caa463f6958..f2044208de9 100644
--- a/src/intel/vulkan/anv_private.h
+++ b/src/intel/vulkan/anv_private.h
@@ -1098,6 +1098,9 @@ struct anv_queue {
 
    uint32_t                                  exec_flags;
 
+   /** Synchronization object for debug purposes (DEBUG_SYNC) */
+   struct vk_sync                           *sync;
+
    struct intel_ds_queue *                   ds;
 };
 
diff --git a/src/intel/vulkan/anv_queue.c b/src/intel/vulkan/anv_queue.c
index 93d835c68cb..ffdd111686d 100644
--- a/src/intel/vulkan/anv_queue.c
+++ b/src/intel/vulkan/anv_queue.c
@@ -41,6 +41,14 @@ anv_queue_init(struct anv_device *device, struct anv_queue *queue,
    if (result != VK_SUCCESS)
       return result;
 
+   if (INTEL_DEBUG(DEBUG_SYNC)) {
+      result = vk_sync_create(&device->vk,
+                              &device->physical->sync_syncobj_type,
+                              0, 0, &queue->sync);
+      vk_queue_finish(&queue->vk);
+      return result;
+   }
+
    queue->vk.driver_submit = anv_queue_submit;
 
    queue->device = device;
@@ -58,5 +66,8 @@ anv_queue_init(struct anv_device *device, struct anv_queue *queue,
 void
 anv_queue_finish(struct anv_queue *queue)
 {
+   if (queue->sync)
+      vk_sync_destroy(&queue->device->vk, queue->sync);
+
    vk_queue_finish(&queue->vk);
 }



More information about the mesa-commit mailing list