[v2,20/37] panfrost: Add FBO BOs to batch->bos earlier

Submitted by Boris Brezillon on Sept. 16, 2019, 9:36 a.m.

Details

Message ID 20190916093715.32203-21-boris.brezillon@collabora.com
State Accepted
Commit 0eec73a800fb87b691df21ba9482db1317c744d3
Headers show
Series "panfrost: Support batch pipelining" ( rev: 1 ) in Mesa

Not browsing as part of any series.

Commit Message

Boris Brezillon Sept. 16, 2019, 9:36 a.m.
If we want the batch dependency tracking to work correctly we must
make sure all BOs are added to the batch->bos set early enough. Adding
FBO BOs when generating the fragment job is clearly to late. Add a
panfrost_batch_add_fbo_bos helper and call it in the clear/draw path.

Signed-off-by: Boris Brezillon <boris.brezillon@collabora.com>
---
 src/gallium/drivers/panfrost/pan_context.c  |  2 ++
 src/gallium/drivers/panfrost/pan_fragment.c |  3 ---
 src/gallium/drivers/panfrost/pan_job.c      | 13 +++++++++++++
 src/gallium/drivers/panfrost/pan_job.h      |  2 ++
 4 files changed, 17 insertions(+), 3 deletions(-)

Patch hide | download patch | download mbox

diff --git a/src/gallium/drivers/panfrost/pan_context.c b/src/gallium/drivers/panfrost/pan_context.c
index c5139a21f9a3..34bc6e41218d 100644
--- a/src/gallium/drivers/panfrost/pan_context.c
+++ b/src/gallium/drivers/panfrost/pan_context.c
@@ -160,6 +160,7 @@  panfrost_clear(
         struct panfrost_context *ctx = pan_context(pipe);
         struct panfrost_batch *batch = panfrost_get_batch_for_fbo(ctx);
 
+        panfrost_batch_add_fbo_bos(batch);
         panfrost_batch_clear(batch, buffers, color, depth, stencil);
 }
 
@@ -879,6 +880,7 @@  panfrost_emit_for_draw(struct panfrost_context *ctx, bool with_vertex_data)
         struct panfrost_batch *batch = panfrost_get_batch_for_fbo(ctx);
         struct panfrost_screen *screen = pan_screen(ctx->base.screen);
 
+        panfrost_batch_add_fbo_bos(batch);
         panfrost_attach_vt_framebuffer(ctx);
 
         if (with_vertex_data) {
diff --git a/src/gallium/drivers/panfrost/pan_fragment.c b/src/gallium/drivers/panfrost/pan_fragment.c
index 2b6ffd841fe9..00ff363a1bba 100644
--- a/src/gallium/drivers/panfrost/pan_fragment.c
+++ b/src/gallium/drivers/panfrost/pan_fragment.c
@@ -42,9 +42,6 @@  panfrost_initialize_surface(
         struct panfrost_resource *rsrc = pan_resource(surf->texture);
 
         rsrc->slices[level].initialized = true;
-
-        assert(rsrc->bo);
-        panfrost_batch_add_bo(batch, rsrc->bo);
 }
 
 /* Generate a fragment job. This should be called once per frame. (According to
diff --git a/src/gallium/drivers/panfrost/pan_job.c b/src/gallium/drivers/panfrost/pan_job.c
index cc0db3e440a1..5b9a51325c3b 100644
--- a/src/gallium/drivers/panfrost/pan_job.c
+++ b/src/gallium/drivers/panfrost/pan_job.c
@@ -144,6 +144,19 @@  panfrost_batch_add_bo(struct panfrost_batch *batch, struct panfrost_bo *bo)
         _mesa_set_add(batch->bos, bo);
 }
 
+void panfrost_batch_add_fbo_bos(struct panfrost_batch *batch)
+{
+        for (unsigned i = 0; i < batch->key.nr_cbufs; ++i) {
+                struct panfrost_resource *rsrc = pan_resource(batch->key.cbufs[i]->texture);
+                panfrost_batch_add_bo(batch, rsrc->bo);
+        }
+
+        if (batch->key.zsbuf) {
+                struct panfrost_resource *rsrc = pan_resource(batch->key.zsbuf->texture);
+                panfrost_batch_add_bo(batch, rsrc->bo);
+        }
+}
+
 struct panfrost_bo *
 panfrost_batch_create_bo(struct panfrost_batch *batch, size_t size,
                          uint32_t create_flags)
diff --git a/src/gallium/drivers/panfrost/pan_job.h b/src/gallium/drivers/panfrost/pan_job.h
index b1351b902bd2..3474a102f5a4 100644
--- a/src/gallium/drivers/panfrost/pan_job.h
+++ b/src/gallium/drivers/panfrost/pan_job.h
@@ -124,6 +124,8 @@  panfrost_batch_init(struct panfrost_context *ctx);
 void
 panfrost_batch_add_bo(struct panfrost_batch *batch, struct panfrost_bo *bo);
 
+void panfrost_batch_add_fbo_bos(struct panfrost_batch *batch);
+
 struct panfrost_bo *
 panfrost_batch_create_bo(struct panfrost_batch *batch, size_t size,
                          uint32_t create_flags);

Comments

R-b

On Mon, Sep 16, 2019 at 11:36:58AM +0200, Boris Brezillon wrote:
> If we want the batch dependency tracking to work correctly we must
> make sure all BOs are added to the batch->bos set early enough. Adding
> FBO BOs when generating the fragment job is clearly to late. Add a
> panfrost_batch_add_fbo_bos helper and call it in the clear/draw path.
> 
> Signed-off-by: Boris Brezillon <boris.brezillon@collabora.com>
> ---
>  src/gallium/drivers/panfrost/pan_context.c  |  2 ++
>  src/gallium/drivers/panfrost/pan_fragment.c |  3 ---
>  src/gallium/drivers/panfrost/pan_job.c      | 13 +++++++++++++
>  src/gallium/drivers/panfrost/pan_job.h      |  2 ++
>  4 files changed, 17 insertions(+), 3 deletions(-)
> 
> diff --git a/src/gallium/drivers/panfrost/pan_context.c b/src/gallium/drivers/panfrost/pan_context.c
> index c5139a21f9a3..34bc6e41218d 100644
> --- a/src/gallium/drivers/panfrost/pan_context.c
> +++ b/src/gallium/drivers/panfrost/pan_context.c
> @@ -160,6 +160,7 @@ panfrost_clear(
>          struct panfrost_context *ctx = pan_context(pipe);
>          struct panfrost_batch *batch = panfrost_get_batch_for_fbo(ctx);
>  
> +        panfrost_batch_add_fbo_bos(batch);
>          panfrost_batch_clear(batch, buffers, color, depth, stencil);
>  }
>  
> @@ -879,6 +880,7 @@ panfrost_emit_for_draw(struct panfrost_context *ctx, bool with_vertex_data)
>          struct panfrost_batch *batch = panfrost_get_batch_for_fbo(ctx);
>          struct panfrost_screen *screen = pan_screen(ctx->base.screen);
>  
> +        panfrost_batch_add_fbo_bos(batch);
>          panfrost_attach_vt_framebuffer(ctx);
>  
>          if (with_vertex_data) {
> diff --git a/src/gallium/drivers/panfrost/pan_fragment.c b/src/gallium/drivers/panfrost/pan_fragment.c
> index 2b6ffd841fe9..00ff363a1bba 100644
> --- a/src/gallium/drivers/panfrost/pan_fragment.c
> +++ b/src/gallium/drivers/panfrost/pan_fragment.c
> @@ -42,9 +42,6 @@ panfrost_initialize_surface(
>          struct panfrost_resource *rsrc = pan_resource(surf->texture);
>  
>          rsrc->slices[level].initialized = true;
> -
> -        assert(rsrc->bo);
> -        panfrost_batch_add_bo(batch, rsrc->bo);
>  }
>  
>  /* Generate a fragment job. This should be called once per frame. (According to
> diff --git a/src/gallium/drivers/panfrost/pan_job.c b/src/gallium/drivers/panfrost/pan_job.c
> index cc0db3e440a1..5b9a51325c3b 100644
> --- a/src/gallium/drivers/panfrost/pan_job.c
> +++ b/src/gallium/drivers/panfrost/pan_job.c
> @@ -144,6 +144,19 @@ panfrost_batch_add_bo(struct panfrost_batch *batch, struct panfrost_bo *bo)
>          _mesa_set_add(batch->bos, bo);
>  }
>  
> +void panfrost_batch_add_fbo_bos(struct panfrost_batch *batch)
> +{
> +        for (unsigned i = 0; i < batch->key.nr_cbufs; ++i) {
> +                struct panfrost_resource *rsrc = pan_resource(batch->key.cbufs[i]->texture);
> +                panfrost_batch_add_bo(batch, rsrc->bo);
> +        }
> +
> +        if (batch->key.zsbuf) {
> +                struct panfrost_resource *rsrc = pan_resource(batch->key.zsbuf->texture);
> +                panfrost_batch_add_bo(batch, rsrc->bo);
> +        }
> +}
> +
>  struct panfrost_bo *
>  panfrost_batch_create_bo(struct panfrost_batch *batch, size_t size,
>                           uint32_t create_flags)
> diff --git a/src/gallium/drivers/panfrost/pan_job.h b/src/gallium/drivers/panfrost/pan_job.h
> index b1351b902bd2..3474a102f5a4 100644
> --- a/src/gallium/drivers/panfrost/pan_job.h
> +++ b/src/gallium/drivers/panfrost/pan_job.h
> @@ -124,6 +124,8 @@ panfrost_batch_init(struct panfrost_context *ctx);
>  void
>  panfrost_batch_add_bo(struct panfrost_batch *batch, struct panfrost_bo *bo);
>  
> +void panfrost_batch_add_fbo_bos(struct panfrost_batch *batch);
> +
>  struct panfrost_bo *
>  panfrost_batch_create_bo(struct panfrost_batch *batch, size_t size,
>                           uint32_t create_flags);
> -- 
> 2.21.0