Mesa (main): iris: implement inter-context busy-tracking

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Tue Feb 1 00:55:29 UTC 2022


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

Author: Paulo Zanoni <paulo.r.zanoni at intel.com>
Date:   Fri Jan 28 15:11:49 2022 -0800

iris: implement inter-context busy-tracking

Previously, no buffers were ever marked as EXEC_OBJECT_ASYNC so the
Kernel would ensure dependency tracking for us. After we implemented
explicit busy tracking in commit 89a34cb8450a, only the external
objects kept relying on the Kernel's implicit tracking and Iris did
inter-batch busy tracking, meaning we lost inter-screen and
inter-context synchronization. This seemed fine to me since, as far as
I understdood, it is the duty of the application to synchronize itself
against multiple screens and contexts.

The problem here is that applications were actually relying on the old
behavior where the Kernel guarantees synchronization, so 89a34cb8450a
can be seen as a regression. This commit addresses the inter-context
synchronization case.

v2: Rebase after the changes from a90a1f15a7c8. This new version is
significantly different.

Cc: mesa-stable (see the backport in MR !14783)
References: https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/14783
Closes: https://gitlab.freedesktop.org/mesa/mesa/-/issues/5731
Closes: https://gitlab.freedesktop.org/mesa/mesa/-/issues/5812
Fixes: 89a34cb8450a ("iris: switch to explicit busy tracking")
References: a90a1f15a7c8 ("iris: Create an IRIS_BATCH_BLITTER for using the BLT command streamer")
Tested-by: Konstantin Kharlamov <hi-angel at yandex.ru> (v1)
Reviewed-by: Kenneth Graunke <kenneth at whitecape.org>
Signed-off-by: Paulo Zanoni <paulo.r.zanoni at intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/14505>

---

 src/gallium/drivers/iris/iris_batch.c | 30 ++++++++----------------------
 1 file changed, 8 insertions(+), 22 deletions(-)

diff --git a/src/gallium/drivers/iris/iris_batch.c b/src/gallium/drivers/iris/iris_batch.c
index 45c1cad579a..83397812d58 100644
--- a/src/gallium/drivers/iris/iris_batch.c
+++ b/src/gallium/drivers/iris/iris_batch.c
@@ -831,36 +831,22 @@ update_bo_syncobjs(struct iris_batch *batch, struct iris_bo *bo, bool write)
    struct iris_bo_screen_deps *bo_deps = &bo->deps[screen->id];
    int batch_idx = batch->name;
 
-   /* Someday if IRIS_BATCH_COUNT increases to 4, we could do:
-    *
-    *   int other_batch_idxs[IRIS_BATCH_COUNT - 1] = {
-    *      (batch_idx + 1) & 3,
-    *      (batch_idx + 2) & 3,
-    *      (batch_idx + 3) & 3,
-    *   };
-    */
-   STATIC_ASSERT(IRIS_BATCH_COUNT == 3);
-   int other_batch_idxs[IRIS_BATCH_COUNT - 1] = {
-      (batch_idx ^ 1) & 1,
-      (batch_idx ^ 2) & 2,
-   };
-
    /* Make our batch depend on additional syncobjs depending on what other
     * batches have been doing to this bo.
+    *
+    * We also look at the dependencies set by our own batch since those could
+    * have come from a different context, and apps don't like it when we don't
+    * do inter-context tracking.
     */
-   for (unsigned i = 0; i < ARRAY_SIZE(other_batch_idxs); i++) {
-      unsigned other_batch_idx = other_batch_idxs[i];
-
+   for (unsigned i = 0; i < IRIS_BATCH_COUNT; i++) {
       /* If the bo is being written to by others, wait for them. */
-      if (bo_deps->write_syncobjs[other_batch_idx])
-         move_syncobj_to_batch(batch,
-                               &bo_deps->write_syncobjs[other_batch_idx],
+      if (bo_deps->write_syncobjs[i])
+         move_syncobj_to_batch(batch, &bo_deps->write_syncobjs[i],
                                I915_EXEC_FENCE_WAIT);
 
       /* If we're writing to the bo, wait on the reads from other batches. */
       if (write)
-         move_syncobj_to_batch(batch,
-                               &bo_deps->read_syncobjs[other_batch_idx],
+         move_syncobj_to_batch(batch, &bo_deps->read_syncobjs[i],
                                I915_EXEC_FENCE_WAIT);
    }
 



More information about the mesa-commit mailing list