[Mesa-dev] [PATCH v3 13/25] panfrost: Allow testing if a specific batch is targeting a scanout FB

Alyssa Rosenzweig alyssa at rosenzweig.io
Thu Sep 5 20:47:41 UTC 2019


R-b

On Thu, Sep 05, 2019 at 09:41:38PM +0200, Boris Brezillon wrote:
> Rename panfrost_is_scanout() into panfrost_batch_is_scanout(), pass it
> a batch instead of a context and move the code to pan_job.c.
> 
> With this in place, we can now test if a batch is targeting a scanout
> FB even if this batch is not bound to the context.
> 
> Signed-off-by: Boris Brezillon <boris.brezillon at collabora.com>
> ---
>  src/gallium/drivers/panfrost/pan_context.c | 20 +-------------------
>  src/gallium/drivers/panfrost/pan_context.h |  3 ---
>  src/gallium/drivers/panfrost/pan_job.c     | 18 ++++++++++++++++++
>  src/gallium/drivers/panfrost/pan_job.h     |  3 +++
>  src/gallium/drivers/panfrost/pan_mfbd.c    |  3 +--
>  5 files changed, 23 insertions(+), 24 deletions(-)
> 
> diff --git a/src/gallium/drivers/panfrost/pan_context.c b/src/gallium/drivers/panfrost/pan_context.c
> index f0cd8cdb12ea..e34f5757b1cf 100644
> --- a/src/gallium/drivers/panfrost/pan_context.c
> +++ b/src/gallium/drivers/panfrost/pan_context.c
> @@ -152,24 +152,6 @@ panfrost_emit_mfbd(struct panfrost_context *ctx, unsigned vertex_count)
>          return framebuffer;
>  }
>  
> -/* Are we currently rendering to the screen (rather than an FBO)? */
> -
> -bool
> -panfrost_is_scanout(struct panfrost_context *ctx)
> -{
> -        /* If there is no color buffer, it's an FBO */
> -        if (ctx->pipe_framebuffer.nr_cbufs != 1)
> -                return false;
> -
> -        /* If we're too early that no framebuffer was sent, it's scanout */
> -        if (!ctx->pipe_framebuffer.cbufs[0])
> -                return true;
> -
> -        return ctx->pipe_framebuffer.cbufs[0]->texture->bind & PIPE_BIND_DISPLAY_TARGET ||
> -               ctx->pipe_framebuffer.cbufs[0]->texture->bind & PIPE_BIND_SCANOUT ||
> -               ctx->pipe_framebuffer.cbufs[0]->texture->bind & PIPE_BIND_SHARED;
> -}
> -
>  static void
>  panfrost_clear(
>          struct pipe_context *pipe,
> @@ -2397,7 +2379,7 @@ panfrost_set_framebuffer_state(struct pipe_context *pctx,
>           */
>  
>          struct panfrost_batch *batch = panfrost_get_batch_for_fbo(ctx);
> -        bool is_scanout = panfrost_is_scanout(ctx);
> +        bool is_scanout = panfrost_batch_is_scanout(batch);
>          bool has_draws = batch->last_job.gpu;
>  
>          /* Bail out early when the current and new states are the same. */
> diff --git a/src/gallium/drivers/panfrost/pan_context.h b/src/gallium/drivers/panfrost/pan_context.h
> index 586b6d854b6c..02552ed23de2 100644
> --- a/src/gallium/drivers/panfrost/pan_context.h
> +++ b/src/gallium/drivers/panfrost/pan_context.h
> @@ -315,9 +315,6 @@ panfrost_flush(
>          struct pipe_fence_handle **fence,
>          unsigned flags);
>  
> -bool
> -panfrost_is_scanout(struct panfrost_context *ctx);
> -
>  mali_ptr panfrost_sfbd_fragment(struct panfrost_context *ctx, bool has_draws);
>  mali_ptr panfrost_mfbd_fragment(struct panfrost_context *ctx, bool has_draws);
>  
> diff --git a/src/gallium/drivers/panfrost/pan_job.c b/src/gallium/drivers/panfrost/pan_job.c
> index 56aab13d7d5a..0f7e139f1a64 100644
> --- a/src/gallium/drivers/panfrost/pan_job.c
> +++ b/src/gallium/drivers/panfrost/pan_job.c
> @@ -374,6 +374,24 @@ panfrost_batch_intersection_scissor(struct panfrost_batch *batch,
>          batch->maxy = MIN2(batch->maxy, maxy);
>  }
>  
> +/* Are we currently rendering to the screen (rather than an FBO)? */
> +
> +bool
> +panfrost_batch_is_scanout(struct panfrost_batch *batch)
> +{
> +        /* If there is no color buffer, it's an FBO */
> +        if (batch->key.nr_cbufs != 1)
> +                return false;
> +
> +        /* If we're too early that no framebuffer was sent, it's scanout */
> +        if (!batch->key.cbufs[0])
> +                return true;
> +
> +        return batch->key.cbufs[0]->texture->bind & PIPE_BIND_DISPLAY_TARGET ||
> +               batch->key.cbufs[0]->texture->bind & PIPE_BIND_SCANOUT ||
> +               batch->key.cbufs[0]->texture->bind & PIPE_BIND_SHARED;
> +}
> +
>  void
>  panfrost_batch_init(struct panfrost_context *ctx)
>  {
> diff --git a/src/gallium/drivers/panfrost/pan_job.h b/src/gallium/drivers/panfrost/pan_job.h
> index e885d0b9fbd5..ea832f2c3efe 100644
> --- a/src/gallium/drivers/panfrost/pan_job.h
> +++ b/src/gallium/drivers/panfrost/pan_job.h
> @@ -195,4 +195,7 @@ panfrost_scoreboard_queue_fused_job_prepend(
>  void
>  panfrost_scoreboard_link_batch(struct panfrost_batch *batch);
>  
> +bool
> +panfrost_batch_is_scanout(struct panfrost_batch *batch);
> +
>  #endif
> diff --git a/src/gallium/drivers/panfrost/pan_mfbd.c b/src/gallium/drivers/panfrost/pan_mfbd.c
> index 618ebd3c4a19..c89b0b44a47c 100644
> --- a/src/gallium/drivers/panfrost/pan_mfbd.c
> +++ b/src/gallium/drivers/panfrost/pan_mfbd.c
> @@ -455,9 +455,8 @@ panfrost_mfbd_fragment(struct panfrost_context *ctx, bool has_draws)
>           * The exception is ReadPixels, but this is not supported on GLES so we
>           * can safely ignore it. */
>  
> -        if (panfrost_is_scanout(ctx)) {
> +        if (panfrost_batch_is_scanout(batch))
>                  batch->requirements &= ~PAN_REQ_DEPTH_WRITE;
> -        }
>  
>          /* Actualize the requirements */
>  
> -- 
> 2.21.0


More information about the mesa-dev mailing list