From a29b083bbe7afe9c2b4571f54c3dec0380201337 Mon Sep 17 00:00:00 2001 From: Alyssa Rosenzweig Date: Tue, 17 Aug 2021 16:45:17 +0000 Subject: [PATCH] panfrost: Prefer batch->resources to rsrc->users This expresses the semantic of the flush only applying to batches within the context, not globally, in line with OpenGL's multithreading rules. Signed-off-by: Alyssa Rosenzweig Cc: mesa-stable Part-of: (cherry picked from commit e98aa5541307b28804858c126e1c878c08714bb3) Conflicts: src/gallium/drivers/panfrost/pan_job.c --- .pick_status.json | 2 +- src/gallium/drivers/panfrost/pan_job.c | 18 +++++++++++++----- 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/.pick_status.json b/.pick_status.json index 7a42b7e7088..d5f5c3228b7 100644 --- a/.pick_status.json +++ b/.pick_status.json @@ -1156,7 +1156,7 @@ "description": "panfrost: Prefer batch->resources to rsrc->users", "nominated": true, "nomination_type": 0, - "resolution": 0, + "resolution": 1, "main_sha": null, "because_sha": null }, diff --git a/src/gallium/drivers/panfrost/pan_job.c b/src/gallium/drivers/panfrost/pan_job.c index a434470c8cb..e8fa8de4e2a 100644 --- a/src/gallium/drivers/panfrost/pan_job.c +++ b/src/gallium/drivers/panfrost/pan_job.c @@ -291,12 +291,16 @@ panfrost_batch_update_access(struct panfrost_batch *batch, /* Flush users if required */ if (writes || ((writer != NULL) && (writer != batch))) { unsigned i; - BITSET_FOREACH_SET(i, rsrc->track.users, PAN_MAX_BATCHES) { + foreach_batch(ctx, i) { + struct panfrost_batch *batch = &ctx->batches.slots[i]; + /* Skip the entry if this our batch. */ if (i == batch_idx) continue; - panfrost_batch_submit(&ctx->batches.slots[i], 0, 0); + /* Submit if it's a user */ + if (_mesa_set_search(batch->resources, rsrc)) + panfrost_batch_submit(batch, 0, 0); } } @@ -943,9 +947,13 @@ panfrost_flush_batches_accessing_rsrc(struct panfrost_context *ctx, struct panfrost_resource *rsrc) { unsigned i; - BITSET_FOREACH_SET(i, rsrc->track.users, PAN_MAX_BATCHES) { - panfrost_batch_submit(&ctx->batches.slots[i], - ctx->syncobj, ctx->syncobj); + foreach_batch(ctx, i) { + struct panfrost_batch *batch = &ctx->batches.slots[i]; + + if (!_mesa_set_search(batch->resources, rsrc)) + continue; + + panfrost_batch_submit(batch, ctx->syncobj, ctx->syncobj); } assert(!BITSET_COUNT(rsrc->track.users));