Mesa (main): panfrost: Split "flush writer" from "flush accessing"
GitLab Mirror
gitlab-mirror at kemper.freedesktop.org
Tue Jul 6 19:10:18 UTC 2021
Module: Mesa
Branch: main
Commit: 5100c42cbbb035714c0179a198e4f078839c0423
URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=5100c42cbbb035714c0179a198e4f078839c0423
Author: Alyssa Rosenzweig <alyssa at collabora.com>
Date: Fri May 28 18:23:37 2021 -0400
panfrost: Split "flush writer" from "flush accessing"
Since writers are counted in the accessor set, the old implementation
had a redundant flush in the "flush accessing" case. To fix, split the
two modes into separate functions, removing the redundancy and offering
a much more ergonomic API.
Signed-off-by: Alyssa Rosenzweig <alyssa at collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/11077>
---
src/gallium/drivers/panfrost/pan_cmdstream.c | 2 +-
src/gallium/drivers/panfrost/pan_context.c | 2 +-
src/gallium/drivers/panfrost/pan_job.c | 16 ++++++++--------
src/gallium/drivers/panfrost/pan_job.h | 7 +++++--
src/gallium/drivers/panfrost/pan_resource.c | 14 +++++++-------
5 files changed, 22 insertions(+), 19 deletions(-)
diff --git a/src/gallium/drivers/panfrost/pan_cmdstream.c b/src/gallium/drivers/panfrost/pan_cmdstream.c
index 0293293db80..7e7062ec74f 100644
--- a/src/gallium/drivers/panfrost/pan_cmdstream.c
+++ b/src/gallium/drivers/panfrost/pan_cmdstream.c
@@ -1132,7 +1132,7 @@ panfrost_map_constant_buffer_cpu(struct panfrost_context *ctx,
if (rsrc) {
panfrost_bo_mmap(rsrc->image.data.bo);
- panfrost_flush_batches_accessing_rsrc(ctx, rsrc, false);
+ panfrost_flush_writer(ctx, rsrc);
panfrost_bo_wait(rsrc->image.data.bo, INT64_MAX, false);
return rsrc->image.data.bo->ptr.cpu + cb->buffer_offset;
diff --git a/src/gallium/drivers/panfrost/pan_context.c b/src/gallium/drivers/panfrost/pan_context.c
index c0d398484a4..95f3f7ee222 100644
--- a/src/gallium/drivers/panfrost/pan_context.c
+++ b/src/gallium/drivers/panfrost/pan_context.c
@@ -1821,7 +1821,7 @@ panfrost_get_query_result(struct pipe_context *pipe,
case PIPE_QUERY_OCCLUSION_COUNTER:
case PIPE_QUERY_OCCLUSION_PREDICATE:
case PIPE_QUERY_OCCLUSION_PREDICATE_CONSERVATIVE:
- panfrost_flush_batches_accessing_rsrc(ctx, rsrc, false);
+ panfrost_flush_writer(ctx, rsrc);
panfrost_bo_wait(rsrc->image.data.bo, INT64_MAX, false);
/* Read back the query results */
diff --git a/src/gallium/drivers/panfrost/pan_job.c b/src/gallium/drivers/panfrost/pan_job.c
index c0cacaacb58..6c2938df162 100644
--- a/src/gallium/drivers/panfrost/pan_job.c
+++ b/src/gallium/drivers/panfrost/pan_job.c
@@ -905,21 +905,20 @@ panfrost_flush_all_batches(struct panfrost_context *ctx)
}
}
-/* We always flush writers. We might also need to flush readers */
-
void
-panfrost_flush_batches_accessing_rsrc(struct panfrost_context *ctx,
- struct panfrost_resource *rsrc,
- bool flush_readers)
+panfrost_flush_writer(struct panfrost_context *ctx,
+ struct panfrost_resource *rsrc)
{
if (rsrc->track.writer) {
panfrost_batch_submit(rsrc->track.writer, ctx->syncobj, ctx->syncobj);
rsrc->track.writer = NULL;
}
+}
- if (!flush_readers)
- return;
-
+void
+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],
@@ -927,6 +926,7 @@ panfrost_flush_batches_accessing_rsrc(struct panfrost_context *ctx,
}
assert(!BITSET_COUNT(rsrc->track.users));
+ rsrc->track.writer = NULL;
}
void
diff --git a/src/gallium/drivers/panfrost/pan_job.h b/src/gallium/drivers/panfrost/pan_job.h
index aca798f547e..2e5af79d73c 100644
--- a/src/gallium/drivers/panfrost/pan_job.h
+++ b/src/gallium/drivers/panfrost/pan_job.h
@@ -174,8 +174,11 @@ panfrost_flush_all_batches(struct panfrost_context *ctx);
void
panfrost_flush_batches_accessing_rsrc(struct panfrost_context *ctx,
- struct panfrost_resource *rsrc,
- bool flush_readers);
+ struct panfrost_resource *rsrc);
+
+void
+panfrost_flush_writer(struct panfrost_context *ctx,
+ struct panfrost_resource *rsrc);
void
panfrost_batch_adjust_stack_size(struct panfrost_batch *batch);
diff --git a/src/gallium/drivers/panfrost/pan_resource.c b/src/gallium/drivers/panfrost/pan_resource.c
index 199608c1c1d..41ce9ff5ada 100644
--- a/src/gallium/drivers/panfrost/pan_resource.c
+++ b/src/gallium/drivers/panfrost/pan_resource.c
@@ -843,11 +843,11 @@ panfrost_ptr_map(struct pipe_context *pctx,
/* TODO: Eliminate this flush. It's only there to determine if
* we're initialized or not, when the initialization could come
* from a pending batch XXX */
- panfrost_flush_batches_accessing_rsrc(ctx, rsrc, true);
+ panfrost_flush_batches_accessing_rsrc(ctx, rsrc);
if ((usage & PIPE_MAP_READ) && BITSET_TEST(rsrc->valid.data, level)) {
pan_blit_to_staging(pctx, transfer);
- panfrost_flush_batches_accessing_rsrc(ctx, staging, true);
+ panfrost_flush_batches_accessing_rsrc(ctx, staging);
panfrost_bo_wait(staging->image.data.bo, INT64_MAX, false);
}
@@ -876,7 +876,7 @@ panfrost_ptr_map(struct pipe_context *pctx,
* to flush and split the frame in two.
*/
- panfrost_flush_batches_accessing_rsrc(ctx, rsrc, false);
+ panfrost_flush_writer(ctx, rsrc);
panfrost_bo_wait(bo, INT64_MAX, false);
create_new_bo = true;
@@ -919,7 +919,7 @@ panfrost_ptr_map(struct pipe_context *pctx,
/* Allocation failed or was impossible, let's
* fall back on a flush+wait.
*/
- panfrost_flush_batches_accessing_rsrc(ctx, rsrc, true);
+ panfrost_flush_batches_accessing_rsrc(ctx, rsrc);
panfrost_bo_wait(bo, INT64_MAX, true);
}
}
@@ -929,10 +929,10 @@ panfrost_ptr_map(struct pipe_context *pctx,
/* No flush for writes to uninitialized */
} else if (!(usage & PIPE_MAP_UNSYNCHRONIZED)) {
if (usage & PIPE_MAP_WRITE) {
- panfrost_flush_batches_accessing_rsrc(ctx, rsrc, true);
+ panfrost_flush_batches_accessing_rsrc(ctx, rsrc);
panfrost_bo_wait(bo, INT64_MAX, true);
} else if (usage & PIPE_MAP_READ) {
- panfrost_flush_batches_accessing_rsrc(ctx, rsrc, false);
+ panfrost_flush_writer(ctx, rsrc);
panfrost_bo_wait(bo, INT64_MAX, false);
}
}
@@ -1100,7 +1100,7 @@ panfrost_ptr_unmap(struct pipe_context *pctx,
panfrost_bo_reference(prsrc->image.data.bo);
} else {
pan_blit_from_staging(pctx, trans);
- panfrost_flush_batches_accessing_rsrc(pan_context(pctx), pan_resource(trans->staging.rsrc), true);
+ panfrost_flush_batches_accessing_rsrc(pan_context(pctx), pan_resource(trans->staging.rsrc));
}
}
More information about the mesa-commit
mailing list