summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKenneth Graunke <kenneth@whitecape.org>2021-11-15 19:08:55 -0800
committerEric Engestrom <eric@engestrom.ch>2021-12-01 18:55:45 +0000
commit1b90272e16c8b590e8eb73c8b72240206fc08eb4 (patch)
tree521f90a4e94f440e8c123eae315f11e7da34e32d
parenta3dd8c974e30ebe5a8cfd412277525e1c6d4c7b2 (diff)
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@intel.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/13808> (cherry picked from commit 6e909849349062985fe279296bfb0eb3c94b494c)
-rw-r--r--.pick_status.json2
-rw-r--r--src/gallium/drivers/iris/iris_batch.c9
2 files changed, 7 insertions, 4 deletions
diff --git a/.pick_status.json b/.pick_status.json
index 952a2b94712..a0dea85f785 100644
--- a/.pick_status.json
+++ b/.pick_status.json
@@ -2839,7 +2839,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;
}