Mesa (staging/21.3): iris: Make a helper function for cross-batch dependency flushing
GitLab Mirror
gitlab-mirror at kemper.freedesktop.org
Thu Nov 18 19:01:41 UTC 2021
Module: Mesa
Branch: staging/21.3
Commit: f73ab966219058189c1140796638a2120bb277be
URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=f73ab966219058189c1140796638a2120bb277be
Author: Kenneth Graunke <kenneth at whitecape.org>
Date: Mon Nov 15 19:02:31 2021 -0800
iris: Make a helper function for cross-batch dependency flushing
This should have no functional change, but it's tagged with Fixes
anyway because it's needed for the bug fix in the next patch.
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 76030964a65a527b30bb46f2ff806ddafdd3fc2d)
---
.pick_status.json | 2 +-
src/gallium/drivers/iris/iris_batch.c | 63 ++++++++++++++++++++---------------
2 files changed, 37 insertions(+), 28 deletions(-)
diff --git a/.pick_status.json b/.pick_status.json
index d418b055542..1a9cad4d73f 100644
--- a/.pick_status.json
+++ b/.pick_status.json
@@ -454,7 +454,7 @@
"description": "iris: Make a helper function for cross-batch dependency flushing",
"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 f9a1eed0def..9008f2263c2 100644
--- a/src/gallium/drivers/iris/iris_batch.c
+++ b/src/gallium/drivers/iris/iris_batch.c
@@ -290,6 +290,41 @@ add_bo_to_batch(struct iris_batch *batch, struct iris_bo *bo, bool writable)
MAX2(batch->max_gem_handle, iris_get_backing_bo(bo)->gem_handle);
}
+static void
+flush_for_cross_batch_dependencies(struct iris_batch *batch,
+ struct iris_bo *bo,
+ bool writable)
+{
+ 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.
+ */
+ for (int b = 0; b < ARRAY_SIZE(batch->other_batches); b++) {
+ struct iris_batch *other_batch = batch->other_batches[b];
+ int other_index = find_exec_index(other_batch, bo);
+
+ /* If the buffer is referenced by another batch, and either batch
+ * intends to write it, then flush the other batch and synchronize.
+ *
+ * Consider these cases:
+ *
+ * 1. They read, we read => No synchronization required.
+ * 2. They read, we write => Synchronize (they need the old value)
+ * 3. They write, we read => Synchronize (we need their new value)
+ * 4. They write, we write => Synchronize (order writes)
+ *
+ * The read/read case is very common, as multiple batches usually
+ * share a streaming state buffer or shader assembly buffer, and
+ * we want to avoid synchronizing in this case.
+ */
+ if (other_index != -1 &&
+ (writable || BITSET_TEST(other_batch->bos_written, other_index)))
+ iris_batch_flush(other_batch);
+ }
+}
+
/**
* Add a buffer to the current batch's validation list.
*
@@ -328,33 +363,7 @@ iris_use_pinned_bo(struct iris_batch *batch,
return;
}
- if (!batch->measure || bo != batch->measure->bo) {
- /* 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.
- */
- for (int b = 0; b < ARRAY_SIZE(batch->other_batches); b++) {
- struct iris_batch *other_batch = batch->other_batches[b];
- int other_index = find_exec_index(other_batch, bo);
-
- /* If the buffer is referenced by another batch, and either batch
- * intends to write it, then flush the other batch and synchronize.
- *
- * Consider these cases:
- *
- * 1. They read, we read => No synchronization required.
- * 2. They read, we write => Synchronize (they need the old value)
- * 3. They write, we read => Synchronize (we need their new value)
- * 4. They write, we write => Synchronize (order writes)
- *
- * The read/read case is very common, as multiple batches usually
- * share a streaming state buffer or shader assembly buffer, and
- * we want to avoid synchronizing in this case.
- */
- if (other_index != -1 &&
- (writable || BITSET_TEST(other_batch->bos_written, other_index)))
- iris_batch_flush(other_batch);
- }
- }
+ flush_for_cross_batch_dependencies(batch, bo, writable);
ensure_exec_obj_space(batch, 1);
add_bo_to_batch(batch, bo, writable);
More information about the mesa-commit
mailing list