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

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Wed Nov 17 11:10:30 UTC 2021


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

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>

---

 src/gallium/drivers/iris/iris_batch.c | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/src/gallium/drivers/iris/iris_batch.c b/src/gallium/drivers/iris/iris_batch.c
index 4119d5eb829..da4a9863c99 100644
--- a/src/gallium/drivers/iris/iris_batch.c
+++ b/src/gallium/drivers/iris/iris_batch.c
@@ -302,8 +302,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];
@@ -361,8 +362,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