Re: [Mesa-dev] [PATCH v3 08/17] panfrost: Add a panfrost_flush_all_batches() helper
(Still r-b) On Wed, Sep 18, 2019 at 03:24:30PM +0200, Boris Brezillon wrote: > And use it in panfrost_flush() to flush all batches, and not only the > one currently bound to the context. > > We also replace all internal calls to panfrost_flush() by > panfrost_flush_all_batches() ones. > > Signed-off-by: Boris Brezillon > Reviewed-by: Alyssa Rosenzweig > --- > Changes in v3: > * Add missing blank line > * Collect R-b > --- > src/gallium/drivers/panfrost/pan_compute.c | 2 +- > src/gallium/drivers/panfrost/pan_context.c | 23 +++ > src/gallium/drivers/panfrost/pan_job.c | 46 - > src/gallium/drivers/panfrost/pan_job.h | 2 +- > src/gallium/drivers/panfrost/pan_resource.c | 6 +-- > 5 files changed, 64 insertions(+), 15 deletions(-) > > diff --git a/src/gallium/drivers/panfrost/pan_compute.c > b/src/gallium/drivers/panfrost/pan_compute.c > index 4639c1b03c38..036dffbb17be 100644 > --- a/src/gallium/drivers/panfrost/pan_compute.c > +++ b/src/gallium/drivers/panfrost/pan_compute.c > @@ -133,7 +133,7 @@ panfrost_launch_grid(struct pipe_context *pipe, > /* Queue the job */ > panfrost_scoreboard_queue_compute_job(batch, transfer); > > -panfrost_flush(pipe, NULL, PIPE_FLUSH_END_OF_FRAME); > +panfrost_flush_all_batches(ctx, true); > } > > void > diff --git a/src/gallium/drivers/panfrost/pan_context.c > b/src/gallium/drivers/panfrost/pan_context.c > index aad69e3f9991..861b4b621602 100644 > --- a/src/gallium/drivers/panfrost/pan_context.c > +++ b/src/gallium/drivers/panfrost/pan_context.c > @@ -1348,7 +1348,6 @@ panfrost_flush( > unsigned flags) > { > struct panfrost_context *ctx = pan_context(pipe); > -struct panfrost_batch *batch = panfrost_get_batch_for_fbo(ctx); > struct util_dynarray fences; > > /* We must collect the fences before the flush is done, otherwise > we'll > @@ -1356,13 +1355,18 @@ panfrost_flush( > */ > if (fence) { > util_dynarray_init(, NULL); > -panfrost_batch_fence_reference(batch->out_sync); > -util_dynarray_append(, struct panfrost_batch_fence *, > - batch->out_sync); > +hash_table_foreach(ctx->batches, hentry) { > +struct panfrost_batch *batch = hentry->data; > + > +panfrost_batch_fence_reference(batch->out_sync); > +util_dynarray_append(, > + struct panfrost_batch_fence *, > + batch->out_sync); > +} > } > > -/* Submit the frame itself */ > -panfrost_batch_submit(batch); > +/* Submit all pending jobs */ > +panfrost_flush_all_batches(ctx, false); > > if (fence) { > struct panfrost_fence *f = panfrost_fence_create(ctx, > ); > @@ -2321,7 +2325,7 @@ panfrost_set_framebuffer_state(struct pipe_context > *pctx, > } > > if (!is_scanout || has_draws) > -panfrost_flush(pctx, NULL, PIPE_FLUSH_END_OF_FRAME); > +panfrost_flush_all_batches(ctx, true); > else > > assert(!ctx->payloads[PIPE_SHADER_VERTEX].postfix.framebuffer && > > !ctx->payloads[PIPE_SHADER_FRAGMENT].postfix.framebuffer); > @@ -2553,6 +2557,7 @@ panfrost_get_query_result(struct pipe_context *pipe, >union pipe_query_result *vresult) > { > struct panfrost_query *query = (struct panfrost_query *) q; > +struct panfrost_context *ctx = pan_context(pipe); > > > switch (query->type) { > @@ -2560,7 +2565,7 @@ panfrost_get_query_result(struct pipe_context *pipe, > case PIPE_QUERY_OCCLUSION_PREDICATE: > case PIPE_QUERY_OCCLUSION_PREDICATE_CONSERVATIVE: > /* Flush first */ > -panfrost_flush(pipe, NULL, PIPE_FLUSH_END_OF_FRAME); > +panfrost_flush_all_batches(ctx, true); > > /* Read back the query results */ > unsigned *result = (unsigned *) query->transfer.cpu; > @@ -2576,7 +2581,7 @@ panfrost_get_query_result(struct pipe_context *pipe, > > case PIPE_QUERY_PRIMITIVES_GENERATED: > case PIPE_QUERY_PRIMITIVES_EMITTED: > -panfrost_flush(pipe, NULL, PIPE_FLUSH_END_OF_FRAME); > +panfrost_flush_all_batches(ctx, true); > vresult->u64 = query->end - query->start; > break; > > diff --git a/src/gallium/drivers/panfrost/pan_job.c > b/src/gallium/drivers/panfrost/pan_job.c > index 211e48bafd4e..3ccf4bb6b3e9 100644 > --- a/src/gallium/drivers/panfrost/pan_job.c > +++ b/src/gallium/drivers/panfrost/pan_job.c > @@ -856,7 +856,7 @@ panfrost_batch_submit_jobs(struct panfrost_batch *batch) > return ret; > } > >
[Mesa-dev] [PATCH v3 08/17] panfrost: Add a panfrost_flush_all_batches() helper
And use it in panfrost_flush() to flush all batches, and not only the one currently bound to the context. We also replace all internal calls to panfrost_flush() by panfrost_flush_all_batches() ones. Signed-off-by: Boris Brezillon Reviewed-by: Alyssa Rosenzweig --- Changes in v3: * Add missing blank line * Collect R-b --- src/gallium/drivers/panfrost/pan_compute.c | 2 +- src/gallium/drivers/panfrost/pan_context.c | 23 +++ src/gallium/drivers/panfrost/pan_job.c | 46 - src/gallium/drivers/panfrost/pan_job.h | 2 +- src/gallium/drivers/panfrost/pan_resource.c | 6 +-- 5 files changed, 64 insertions(+), 15 deletions(-) diff --git a/src/gallium/drivers/panfrost/pan_compute.c b/src/gallium/drivers/panfrost/pan_compute.c index 4639c1b03c38..036dffbb17be 100644 --- a/src/gallium/drivers/panfrost/pan_compute.c +++ b/src/gallium/drivers/panfrost/pan_compute.c @@ -133,7 +133,7 @@ panfrost_launch_grid(struct pipe_context *pipe, /* Queue the job */ panfrost_scoreboard_queue_compute_job(batch, transfer); -panfrost_flush(pipe, NULL, PIPE_FLUSH_END_OF_FRAME); +panfrost_flush_all_batches(ctx, true); } void diff --git a/src/gallium/drivers/panfrost/pan_context.c b/src/gallium/drivers/panfrost/pan_context.c index aad69e3f9991..861b4b621602 100644 --- a/src/gallium/drivers/panfrost/pan_context.c +++ b/src/gallium/drivers/panfrost/pan_context.c @@ -1348,7 +1348,6 @@ panfrost_flush( unsigned flags) { struct panfrost_context *ctx = pan_context(pipe); -struct panfrost_batch *batch = panfrost_get_batch_for_fbo(ctx); struct util_dynarray fences; /* We must collect the fences before the flush is done, otherwise we'll @@ -1356,13 +1355,18 @@ panfrost_flush( */ if (fence) { util_dynarray_init(, NULL); -panfrost_batch_fence_reference(batch->out_sync); -util_dynarray_append(, struct panfrost_batch_fence *, - batch->out_sync); +hash_table_foreach(ctx->batches, hentry) { +struct panfrost_batch *batch = hentry->data; + +panfrost_batch_fence_reference(batch->out_sync); +util_dynarray_append(, + struct panfrost_batch_fence *, + batch->out_sync); +} } -/* Submit the frame itself */ -panfrost_batch_submit(batch); +/* Submit all pending jobs */ +panfrost_flush_all_batches(ctx, false); if (fence) { struct panfrost_fence *f = panfrost_fence_create(ctx, ); @@ -2321,7 +2325,7 @@ panfrost_set_framebuffer_state(struct pipe_context *pctx, } if (!is_scanout || has_draws) -panfrost_flush(pctx, NULL, PIPE_FLUSH_END_OF_FRAME); +panfrost_flush_all_batches(ctx, true); else assert(!ctx->payloads[PIPE_SHADER_VERTEX].postfix.framebuffer && !ctx->payloads[PIPE_SHADER_FRAGMENT].postfix.framebuffer); @@ -2553,6 +2557,7 @@ panfrost_get_query_result(struct pipe_context *pipe, union pipe_query_result *vresult) { struct panfrost_query *query = (struct panfrost_query *) q; +struct panfrost_context *ctx = pan_context(pipe); switch (query->type) { @@ -2560,7 +2565,7 @@ panfrost_get_query_result(struct pipe_context *pipe, case PIPE_QUERY_OCCLUSION_PREDICATE: case PIPE_QUERY_OCCLUSION_PREDICATE_CONSERVATIVE: /* Flush first */ -panfrost_flush(pipe, NULL, PIPE_FLUSH_END_OF_FRAME); +panfrost_flush_all_batches(ctx, true); /* Read back the query results */ unsigned *result = (unsigned *) query->transfer.cpu; @@ -2576,7 +2581,7 @@ panfrost_get_query_result(struct pipe_context *pipe, case PIPE_QUERY_PRIMITIVES_GENERATED: case PIPE_QUERY_PRIMITIVES_EMITTED: -panfrost_flush(pipe, NULL, PIPE_FLUSH_END_OF_FRAME); +panfrost_flush_all_batches(ctx, true); vresult->u64 = query->end - query->start; break; diff --git a/src/gallium/drivers/panfrost/pan_job.c b/src/gallium/drivers/panfrost/pan_job.c index 211e48bafd4e..3ccf4bb6b3e9 100644 --- a/src/gallium/drivers/panfrost/pan_job.c +++ b/src/gallium/drivers/panfrost/pan_job.c @@ -856,7 +856,7 @@ panfrost_batch_submit_jobs(struct panfrost_batch *batch) return ret; } -void +static void panfrost_batch_submit(struct panfrost_batch *batch) { assert(batch); @@ -904,8 +904,52 @@ out: panfrost_free_batch(batch); +} + +void +panfrost_flush_all_batches(struct panfrost_context *ctx, bool wait) +{ +struct util_dynarray fences, syncobjs; + +if (wait) { +