Mesa (main): panfrost: Pass a memory pool to pan_blit_ctx_init()

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Mon Jul 5 05:56:28 UTC 2021


Module: Mesa
Branch: main
Commit: dea0c4ddd879b87c6fdf552e8c9dfbf6b3d09279
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=dea0c4ddd879b87c6fdf552e8c9dfbf6b3d09279

Author: Boris Brezillon <boris.brezillon at collabora.com>
Date:   Wed Jun  2 09:44:51 2021 +0200

panfrost: Pass a memory pool to pan_blit_ctx_init()

Pass a memory pool to pan_blit_ctx_init() instead of creating a new pool.
Useful for Vulkan since the descriptor pool is at the command buffer
level and is thus shared by all blit batches. Doing this will save us a
BO ownership transfer.

Signed-off-by: Boris Brezillon <boris.brezillon at collabora.com>
Reviewed-by: Alyssa Rosenzweig <alyssa at collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/11695>

---

 src/gallium/drivers/panfrost/pan_blit.c | 13 ++++++++-----
 src/panfrost/lib/pan_blitter.c          | 20 +++++++-------------
 src/panfrost/lib/pan_blitter.h          |  5 +----
 3 files changed, 16 insertions(+), 22 deletions(-)

diff --git a/src/gallium/drivers/panfrost/pan_blit.c b/src/gallium/drivers/panfrost/pan_blit.c
index 78da23a4918..6baa69c6633 100644
--- a/src/gallium/drivers/panfrost/pan_blit.c
+++ b/src/gallium/drivers/panfrost/pan_blit.c
@@ -89,9 +89,9 @@ panfrost_u_blitter_blit(struct pipe_context *pipe,
 
 static void
 panfrost_blit_add_ctx_bos(struct panfrost_batch *batch,
-                          struct pan_blit_context *ctx)
+                          struct pan_pool *blit_pool)
 {
-        util_dynarray_foreach(&ctx->pool.bos, struct panfrost_bo *, bo) {
+        util_dynarray_foreach(&blit_pool->bos, struct panfrost_bo *, bo) {
                 panfrost_batch_add_bo(batch, *bo,
                                       PAN_BO_ACCESS_SHARED |
                                       PAN_BO_ACCESS_READ |
@@ -241,8 +241,11 @@ panfrost_blit(struct pipe_context *pipe,
         }
 
         struct pan_blit_context bctx;
+        struct pan_pool blit_pool;
 
-        pan_blit_ctx_init(dev, &pinfo, &bctx);
+        panfrost_pool_init(&blit_pool, NULL, dev, 0, 4096, "Blitter pool",
+                           false, true);
+        pan_blit_ctx_init(dev, &pinfo, &blit_pool, &bctx);
         do {
                 if (bctx.dst.cur_layer < 0)
                         continue;
@@ -279,7 +282,7 @@ panfrost_blit(struct pipe_context *pipe,
                 }
 
                 panfrost_batch_add_fbo_bos(batch);
-                panfrost_blit_add_ctx_bos(batch, &bctx);
+                panfrost_blit_add_ctx_bos(batch, &blit_pool);
                 batch->draws = draw_flags;
                 batch->resolve = draw_flags;
                 batch->minx = minx;
@@ -301,5 +304,5 @@ panfrost_blit(struct pipe_context *pipe,
                 ctx->batch = NULL;
         } while (pan_blit_next_surface(&bctx));
 
-        pan_blit_ctx_cleanup(&bctx);
+        panfrost_pool_cleanup(&blit_pool);
 }
diff --git a/src/panfrost/lib/pan_blitter.c b/src/panfrost/lib/pan_blitter.c
index 61ffb505191..1bc9b9dadf3 100644
--- a/src/panfrost/lib/pan_blitter.c
+++ b/src/panfrost/lib/pan_blitter.c
@@ -1344,10 +1344,10 @@ pan_preload_fb(struct pan_pool *pool,
 void
 pan_blit_ctx_init(struct panfrost_device *dev,
                   const struct pan_blit_info *info,
+                  struct pan_pool *blit_pool,
                   struct pan_blit_context *ctx)
 {
         memset(ctx, 0, sizeof(*ctx));
-        panfrost_pool_init(&ctx->pool, NULL, dev, 0, 65536, "Blitter pool", false, true);
 
         ctx->z_scale = (float)(info->dst.end.z - info->dst.start.z + 1) /
                        (info->src.end.z - info->src.start.z + 1);
@@ -1440,17 +1440,17 @@ pan_blit_ctx_init(struct panfrost_device *dev,
 
         if (pan_is_bifrost(dev)) {
                 ctx->textures =
-                        pan_blitter_emit_bifrost_textures(&ctx->pool, nviews, sview_ptrs);
+                        pan_blitter_emit_bifrost_textures(blit_pool, nviews, sview_ptrs);
                 ctx->samplers =
-                        pan_blitter_emit_bifrost_sampler(&ctx->pool, info->nearest);
+                        pan_blitter_emit_bifrost_sampler(blit_pool, info->nearest);
         } else {
                 ctx->textures =
-                        pan_blitter_emit_midgard_textures(&ctx->pool, nviews, sview_ptrs);
+                        pan_blitter_emit_midgard_textures(blit_pool, nviews, sview_ptrs);
                 ctx->samplers =
-                        pan_blitter_emit_midgard_sampler(&ctx->pool, info->nearest);
+                        pan_blitter_emit_midgard_sampler(blit_pool, info->nearest);
         }
 
-        ctx->vpd = pan_blitter_emit_viewport(&ctx->pool,
+        ctx->vpd = pan_blitter_emit_viewport(blit_pool,
                                              minx, miny, maxx, maxy);
 
         float dst_rect[] = {
@@ -1461,16 +1461,10 @@ pan_blit_ctx_init(struct panfrost_device *dev,
         };
 
         ctx->position =
-                panfrost_pool_upload_aligned(&ctx->pool, dst_rect,
+                panfrost_pool_upload_aligned(blit_pool, dst_rect,
                                              sizeof(dst_rect), 64);
 }
 
-void
-pan_blit_ctx_cleanup(struct pan_blit_context *ctx)
-{
-        panfrost_pool_cleanup(&ctx->pool);
-}
-
 bool
 pan_blit_next_surface(struct pan_blit_context *ctx)
 {
diff --git a/src/panfrost/lib/pan_blitter.h b/src/panfrost/lib/pan_blitter.h
index ebe8620ed6a..4064717ab83 100644
--- a/src/panfrost/lib/pan_blitter.h
+++ b/src/panfrost/lib/pan_blitter.h
@@ -57,7 +57,6 @@ struct pan_blit_info {
 };
 
 struct pan_blit_context {
-        struct pan_pool pool;
         mali_ptr rsd, vpd;
         mali_ptr textures;
         mali_ptr samplers;
@@ -95,11 +94,9 @@ pan_preload_fb(struct pan_pool *desc_pool,
 void
 pan_blit_ctx_init(struct panfrost_device *dev,
                   const struct pan_blit_info *info,
+                  struct pan_pool *blit_pool,
                   struct pan_blit_context *ctx);
 
-void
-pan_blit_ctx_cleanup(struct pan_blit_context *ctx);
-
 bool
 pan_blit_next_surface(struct pan_blit_context *ctx);
 



More information about the mesa-commit mailing list