Mesa (staging/21.3): iris: Check for cross-batch flushing whenever a buffer is newly written.

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Thu Nov 18 19:01:41 UTC 2021


Module: Mesa
Branch: staging/21.3
Commit: 87309ea5c23ea138f37c0d3849a9fad15bbe04b4
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=87309ea5c23ea138f37c0d3849a9fad15bbe04b4

Author: Kenneth Graunke <kenneth at whitecape.org>
Date:   Mon Nov 15 19:08:55 2021 -0800

iris: Check for cross-batch flushing whenever a buffer is newly written.

We need to perform cross-batch flushing if any batch writes to a BO
while others refer to it.  We checked this case when recording a new
BO in the list which we'd never seen before.  However, we neglected to
handle the case when we already read from a BO, but then began writing
to it.  That new write may provoke a conflict between existing reads
in other batches, so we need to re-check the cross-batch flushing.

Caught by Piglit's copyteximage when forcing blits and copies to use
a new IRIS_BATCH_BLITTER that isn't upstream yet.  But this bug could
be provoked by render/compute work today...we just hadn't noticed it.

Fixes: b21e916a628 ("iris: Combine iris_use_pinned_bo and add_exec_bo")
Reviewed-by: Paulo Zanoni <paulo.r.zanoni at intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/13808>
(cherry picked from commit 6e909849349062985fe279296bfb0eb3c94b494c)

---

 .pick_status.json                     | 2 +-
 src/gallium/drivers/iris/iris_batch.c | 9 ++++++---
 2 files changed, 7 insertions(+), 4 deletions(-)

diff --git a/.pick_status.json b/.pick_status.json
index 1a9cad4d73f..9e65b60ff96 100644
--- a/.pick_status.json
+++ b/.pick_status.json
@@ -445,7 +445,7 @@
         "description": "iris: Check for cross-batch flushing whenever a buffer is newly written.",
         "nominated": true,
         "nomination_type": 1,
-        "resolution": 0,
+        "resolution": 1,
         "main_sha": null,
         "because_sha": "b21e916a6280f9aee5353c0dd4c6bcebb947496d"
     },
diff --git a/src/gallium/drivers/iris/iris_batch.c b/src/gallium/drivers/iris/iris_batch.c
index 9008f2263c2..fafe70e7b6b 100644
--- a/src/gallium/drivers/iris/iris_batch.c
+++ b/src/gallium/drivers/iris/iris_batch.c
@@ -298,8 +298,9 @@ flush_for_cross_batch_dependencies(struct iris_batch *batch,
    if (batch->measure && bo == batch->measure->bo)
       return;
 
-   /* This is the first time our batch has seen this BO.  Before we use it,
-    * we may need to flush and synchronize with other batches.
+   /* When a batch uses a buffer for the first time, or newly writes a buffer
+    * it had already referenced, we may need to flush other batches in order
+    * to correctly synchronize them.
     */
    for (int b = 0; b < ARRAY_SIZE(batch->other_batches); b++) {
       struct iris_batch *other_batch = batch->other_batches[b];
@@ -357,8 +358,10 @@ iris_use_pinned_bo(struct iris_batch *batch,
 
    if (existing_index != -1) {
       /* The BO is already in the list; mark it writable */
-      if (writable)
+      if (writable && !BITSET_TEST(batch->bos_written, existing_index)) {
          BITSET_SET(batch->bos_written, existing_index);
+         flush_for_cross_batch_dependencies(batch, bo, writable);
+      }
 
       return;
    }



More information about the mesa-commit mailing list