diff --git a/src/gallium/drivers/panfrost/pan_job.c b/src/gallium/drivers/panfrost/pan_job.c index 67f7b66ed3a..a59a9a92290 100644 --- a/src/gallium/drivers/panfrost/pan_job.c +++ b/src/gallium/drivers/panfrost/pan_job.c @@ -257,12 +257,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); } } @@ -867,10 +871,14 @@ panfrost_flush_batches_accessing_rsrc(struct panfrost_context *ctx, const char *reason) { unsigned i; - BITSET_FOREACH_SET(i, rsrc->track.users, PAN_MAX_BATCHES) { + foreach_batch(ctx, i) { + struct panfrost_batch *batch = &ctx->batches.slots[i]; + + if (!_mesa_set_search(batch->resources, rsrc)) + continue; + perf_debug_ctx(ctx, "Flushing user due to: %s", reason); - panfrost_batch_submit(&ctx->batches.slots[i], - ctx->syncobj, ctx->syncobj); + panfrost_batch_submit(batch, ctx->syncobj, ctx->syncobj); } assert(!BITSET_COUNT(rsrc->track.users));