[Mesa-dev] [PATCH v3 03/25] panfrost: Stop passing a ctx to functions being passed a batch
Alyssa Rosenzweig
alyssa at rosenzweig.io
Thu Sep 5 19:54:54 UTC 2019
Reviewed-by: Alyssa Rosenzweig <alyssa at rosenzweig.io>
On Thu, Sep 05, 2019 at 09:41:28PM +0200, Boris Brezillon wrote:
> The context can be retrieved from batch->ctx.
>
> Signed-off-by: Boris Brezillon <boris.brezillon at collabora.com>
> Alyssa Rosenzweig <alyssa.rosenzweig at collabora.com>
> Reviewed-by: Daniel Stone <daniels at collabora.com>
> ---
> Changes in v3:
> * Collect R-bs
>
> Changes in v2:
> * s/panfrost_job_get_batch_for_fbo/panfrost_get_batch_for_fbo/
> * s/panfrost_job_batch/panfrost_batch/g
> ---
> src/gallium/drivers/panfrost/pan_context.c | 6 +++---
> src/gallium/drivers/panfrost/pan_drm.c | 2 +-
> src/gallium/drivers/panfrost/pan_job.c | 25 +++++++++++++---------
> src/gallium/drivers/panfrost/pan_job.h | 11 ++++------
> 4 files changed, 23 insertions(+), 21 deletions(-)
>
> diff --git a/src/gallium/drivers/panfrost/pan_context.c b/src/gallium/drivers/panfrost/pan_context.c
> index ce895822014d..292de7fe132c 100644
> --- a/src/gallium/drivers/panfrost/pan_context.c
> +++ b/src/gallium/drivers/panfrost/pan_context.c
> @@ -180,7 +180,7 @@ panfrost_clear(
> struct panfrost_context *ctx = pan_context(pipe);
> struct panfrost_batch *batch = panfrost_get_batch_for_fbo(ctx);
>
> - panfrost_batch_clear(ctx, batch, buffers, color, depth, stencil);
> + panfrost_batch_clear(batch, buffers, color, depth, stencil);
> }
>
> static mali_ptr
> @@ -907,7 +907,7 @@ panfrost_emit_for_draw(struct panfrost_context *ctx, bool with_vertex_data)
> SET_BIT(ctx->fragment_shader_core.unknown2_4, MALI_NO_MSAA, !msaa);
> }
>
> - panfrost_batch_set_requirements(ctx, batch);
> + panfrost_batch_set_requirements(batch);
>
> if (ctx->occlusion_query) {
> ctx->payloads[PIPE_SHADER_FRAGMENT].gl_enables |= MALI_OCCLUSION_QUERY | MALI_OCCLUSION_PRECISE;
> @@ -1329,7 +1329,7 @@ panfrost_submit_frame(struct panfrost_context *ctx, bool flush_immediate,
> struct pipe_fence_handle **fence,
> struct panfrost_batch *batch)
> {
> - panfrost_batch_submit(ctx, batch);
> + panfrost_batch_submit(batch);
>
> /* If visual, we can stall a frame */
>
> diff --git a/src/gallium/drivers/panfrost/pan_drm.c b/src/gallium/drivers/panfrost/pan_drm.c
> index 768d9602eee7..040cb1368e4e 100644
> --- a/src/gallium/drivers/panfrost/pan_drm.c
> +++ b/src/gallium/drivers/panfrost/pan_drm.c
> @@ -355,7 +355,7 @@ panfrost_drm_force_flush_fragment(struct panfrost_context *ctx,
> ctx->last_fragment_flushed = true;
>
> /* The job finished up, so we're safe to clean it up now */
> - panfrost_free_batch(ctx, ctx->last_batch);
> + panfrost_free_batch(ctx->last_batch);
> }
>
> if (fence) {
> diff --git a/src/gallium/drivers/panfrost/pan_job.c b/src/gallium/drivers/panfrost/pan_job.c
> index f136ccb97fcd..0d19c2b4c5cd 100644
> --- a/src/gallium/drivers/panfrost/pan_job.c
> +++ b/src/gallium/drivers/panfrost/pan_job.c
> @@ -54,11 +54,13 @@ panfrost_create_batch(struct panfrost_context *ctx)
> }
>
> void
> -panfrost_free_batch(struct panfrost_context *ctx, struct panfrost_batch *batch)
> +panfrost_free_batch(struct panfrost_batch *batch)
> {
> if (!batch)
> return;
>
> + struct panfrost_context *ctx = batch->ctx;
> +
> set_foreach(batch->bos, entry) {
> struct panfrost_bo *bo = (struct panfrost_bo *)entry->key;
> panfrost_bo_unreference(ctx->base.screen, bo);
> @@ -195,18 +197,20 @@ panfrost_flush_jobs_writing_resource(struct panfrost_context *panfrost,
> prsc);
> if (entry) {
> struct panfrost_batch *batch = entry->data;
> - panfrost_batch_submit(panfrost, job);
> + panfrost_batch_submit(job);
> }
> #endif
> /* TODO stub */
> }
>
> void
> -panfrost_batch_submit(struct panfrost_context *ctx, struct panfrost_batch *batch)
> +panfrost_batch_submit(struct panfrost_batch *batch)
> {
> + assert(batch);
> +
> + struct panfrost_context *ctx = batch->ctx;
> int ret;
>
> - assert(batch);
> panfrost_scoreboard_link_batch(batch);
>
> bool has_draws = batch->last_job.gpu;
> @@ -232,9 +236,10 @@ panfrost_batch_submit(struct panfrost_context *ctx, struct panfrost_batch *batch
> }
>
> void
> -panfrost_batch_set_requirements(struct panfrost_context *ctx,
> - struct panfrost_batch *batch)
> +panfrost_batch_set_requirements(struct panfrost_batch *batch)
> {
> + struct panfrost_context *ctx = batch->ctx;
> +
> if (ctx->rasterizer && ctx->rasterizer->base.multisample)
> batch->requirements |= PAN_REQ_MSAA;
>
> @@ -336,13 +341,13 @@ pan_pack_color(uint32_t *packed, const union pipe_color_union *color, enum pipe_
> }
>
> void
> -panfrost_batch_clear(struct panfrost_context *ctx,
> - struct panfrost_batch *batch,
> +panfrost_batch_clear(struct panfrost_batch *batch,
> unsigned buffers,
> const union pipe_color_union *color,
> double depth, unsigned stencil)
> -
> {
> + struct panfrost_context *ctx = batch->ctx;
> +
> if (buffers & PIPE_CLEAR_COLOR) {
> for (unsigned i = 0; i < PIPE_MAX_COLOR_BUFS; ++i) {
> if (!(buffers & (PIPE_CLEAR_COLOR0 << i)))
> @@ -386,7 +391,7 @@ panfrost_flush_jobs_reading_resource(struct panfrost_context *panfrost,
>
> if (_mesa_set_search(batch->bos, rsc->bo)) {
> printf("TODO: submit job for flush\n");
> - //panfrost_batch_submit(panfrost, job);
> + //panfrost_batch_submit(job);
> continue;
> }
> }
> diff --git a/src/gallium/drivers/panfrost/pan_job.h b/src/gallium/drivers/panfrost/pan_job.h
> index a0020efb617c..7e0b7b3f314e 100644
> --- a/src/gallium/drivers/panfrost/pan_job.h
> +++ b/src/gallium/drivers/panfrost/pan_job.h
> @@ -123,8 +123,7 @@ struct panfrost_batch *
> panfrost_create_batch(struct panfrost_context *ctx);
>
> void
> -panfrost_free_batch(struct panfrost_context *ctx,
> - struct panfrost_batch *batch);
> +panfrost_free_batch(struct panfrost_batch *batch);
>
> struct panfrost_batch *
> panfrost_get_batch(struct panfrost_context *ctx,
> @@ -149,18 +148,16 @@ panfrost_flush_jobs_reading_resource(struct panfrost_context *panfrost,
> struct pipe_resource *prsc);
>
> void
> -panfrost_batch_submit(struct panfrost_context *ctx, struct panfrost_batch *batch);
> +panfrost_batch_submit(struct panfrost_batch *batch);
>
> void
> -panfrost_batch_set_requirements(struct panfrost_context *ctx,
> - struct panfrost_batch *batch);
> +panfrost_batch_set_requirements(struct panfrost_batch *batch);
>
> mali_ptr
> panfrost_batch_get_polygon_list(struct panfrost_batch *batch, unsigned size);
>
> void
> -panfrost_batch_clear(struct panfrost_context *ctx,
> - struct panfrost_batch *batch,
> +panfrost_batch_clear(struct panfrost_batch *batch,
> unsigned buffers,
> const union pipe_color_union *color,
> double depth, unsigned stencil);
> --
> 2.21.0
More information about the mesa-dev
mailing list