Mesa (main): panfrost: Move the polygon list init logic to pan_cmdstream.c
GitLab Mirror
gitlab-mirror at kemper.freedesktop.org
Thu Aug 26 08:52:45 UTC 2021
Module: Mesa
Branch: main
Commit: 8a058a91903ae5c65c0735049b889cb7d84b65cb
URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=8a058a91903ae5c65c0735049b889cb7d84b65cb
Author: Boris Brezillon <boris.brezillon at collabora.com>
Date: Wed Jul 28 11:09:49 2021 +0200
panfrost: Move the polygon list init logic to pan_cmdstream.c
This logic is Midgard specific and we need move the
panfrost_scoreboard_initialize_tiler() call to a per-arch file so
we can make panfrost_scoreboard_initialize_tiler a per-arch function.
Signed-off-by: Boris Brezillon <boris.brezillon at collabora.com>
Reviewed-by: Alyssa Rosenzweig <alyssa.rosenzweig at collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/12551>
---
src/gallium/drivers/panfrost/pan_cmdstream.c | 61 ++++++++++++++++++++++++++++
src/gallium/drivers/panfrost/pan_job.c | 58 +-------------------------
src/gallium/drivers/panfrost/pan_screen.h | 3 ++
3 files changed, 65 insertions(+), 57 deletions(-)
diff --git a/src/gallium/drivers/panfrost/pan_cmdstream.c b/src/gallium/drivers/panfrost/pan_cmdstream.c
index 2f8a95742d4..d951b2709ef 100644
--- a/src/gallium/drivers/panfrost/pan_cmdstream.c
+++ b/src/gallium/drivers/panfrost/pan_cmdstream.c
@@ -3541,6 +3541,66 @@ context_init(struct pipe_context *pipe)
pipe->get_sample_position = panfrost_get_sample_position;
}
+#if PAN_ARCH <= 5
+
+/* Returns the polygon list's GPU address if available, or otherwise allocates
+ * the polygon list. It's perfectly fast to use allocate/free BO directly,
+ * since we'll hit the BO cache and this is one-per-batch anyway. */
+
+static mali_ptr
+batch_get_polygon_list(struct panfrost_batch *batch)
+{
+ struct panfrost_device *dev = pan_device(batch->ctx->base.screen);
+
+ if (!batch->tiler_ctx.midgard.polygon_list) {
+ bool has_draws = batch->scoreboard.first_tiler != NULL;
+ unsigned size =
+ panfrost_tiler_get_polygon_list_size(dev,
+ batch->key.width,
+ batch->key.height,
+ has_draws);
+ size = util_next_power_of_two(size);
+
+ /* Create the BO as invisible if we can. In the non-hierarchical tiler case,
+ * we need to write the polygon list manually because there's not WRITE_VALUE
+ * job in the chain (maybe we should add one...). */
+ bool init_polygon_list = !has_draws && (dev->quirks & MIDGARD_NO_HIER_TILING);
+ batch->tiler_ctx.midgard.polygon_list =
+ panfrost_batch_create_bo(batch, size,
+ init_polygon_list ? 0 : PAN_BO_INVISIBLE,
+ PIPE_SHADER_VERTEX,
+ "Polygon list");
+ panfrost_batch_add_bo(batch, batch->tiler_ctx.midgard.polygon_list,
+ PIPE_SHADER_FRAGMENT);
+
+ if (init_polygon_list) {
+ assert(batch->tiler_ctx.midgard.polygon_list->ptr.cpu);
+ uint32_t *polygon_list_body =
+ batch->tiler_ctx.midgard.polygon_list->ptr.cpu +
+ MALI_MIDGARD_TILER_MINIMUM_HEADER_SIZE;
+
+ /* Magic for Mali T720 */
+ polygon_list_body[0] = 0xa0000000;
+ }
+
+ batch->tiler_ctx.midgard.disable = !has_draws;
+ }
+
+ return batch->tiler_ctx.midgard.polygon_list->ptr.gpu;
+}
+#endif
+
+static void
+init_polygon_list(struct panfrost_batch *batch)
+{
+#if PAN_ARCH <= 5
+ mali_ptr polygon_list = batch_get_polygon_list(batch);
+ panfrost_scoreboard_initialize_tiler(&batch->pool.base,
+ &batch->scoreboard,
+ polygon_list);
+#endif
+}
+
void
GENX(panfrost_cmdstream_screen_init)(struct panfrost_screen *screen)
{
@@ -3554,6 +3614,7 @@ GENX(panfrost_cmdstream_screen_init)(struct panfrost_screen *screen)
screen->vtbl.preload = preload;
screen->vtbl.context_init = context_init;
screen->vtbl.init_batch = init_batch;
+ screen->vtbl.init_polygon_list = init_polygon_list;
pan_blitter_init(dev, &screen->blitter.bin_pool.base,
&screen->blitter.desc_pool.base);
diff --git a/src/gallium/drivers/panfrost/pan_job.c b/src/gallium/drivers/panfrost/pan_job.c
index 8ce736b94eb..8099cdee598 100644
--- a/src/gallium/drivers/panfrost/pan_job.c
+++ b/src/gallium/drivers/panfrost/pan_job.c
@@ -373,54 +373,6 @@ panfrost_batch_create_bo(struct panfrost_batch *batch, size_t size,
return bo;
}
-/* Returns the polygon list's GPU address if available, or otherwise allocates
- * the polygon list. It's perfectly fast to use allocate/free BO directly,
- * since we'll hit the BO cache and this is one-per-batch anyway. */
-
-static mali_ptr
-panfrost_batch_get_polygon_list(struct panfrost_batch *batch)
-{
- struct panfrost_device *dev = pan_device(batch->ctx->base.screen);
-
- assert(!pan_is_bifrost(dev));
-
- if (!batch->tiler_ctx.midgard.polygon_list) {
- bool has_draws = batch->scoreboard.first_tiler != NULL;
- unsigned size =
- panfrost_tiler_get_polygon_list_size(dev,
- batch->key.width,
- batch->key.height,
- has_draws);
- size = util_next_power_of_two(size);
-
- /* Create the BO as invisible if we can. In the non-hierarchical tiler case,
- * we need to write the polygon list manually because there's not WRITE_VALUE
- * job in the chain (maybe we should add one...). */
- bool init_polygon_list = !has_draws && (dev->quirks & MIDGARD_NO_HIER_TILING);
- batch->tiler_ctx.midgard.polygon_list =
- panfrost_batch_create_bo(batch, size,
- init_polygon_list ? 0 : PAN_BO_INVISIBLE,
- PIPE_SHADER_VERTEX,
- "Polygon list");
- panfrost_batch_add_bo(batch, batch->tiler_ctx.midgard.polygon_list,
- PIPE_SHADER_FRAGMENT);
-
- if (init_polygon_list) {
- assert(batch->tiler_ctx.midgard.polygon_list->ptr.cpu);
- uint32_t *polygon_list_body =
- batch->tiler_ctx.midgard.polygon_list->ptr.cpu +
- MALI_MIDGARD_TILER_MINIMUM_HEADER_SIZE;
-
- /* Magic for Mali T720 */
- polygon_list_body[0] = 0xa0000000;
- }
-
- batch->tiler_ctx.midgard.disable = !has_draws;
- }
-
- return batch->tiler_ctx.midgard.polygon_list->ptr.gpu;
-}
-
struct panfrost_bo *
panfrost_batch_get_scratchpad(struct panfrost_batch *batch,
unsigned size_per_thread,
@@ -781,7 +733,6 @@ panfrost_batch_submit(struct panfrost_context *ctx,
{
struct pipe_screen *pscreen = ctx->base.screen;
struct panfrost_screen *screen = pan_screen(pscreen);
- struct panfrost_device *dev = pan_device(pscreen);
int ret;
/* Nothing to do! */
@@ -794,14 +745,7 @@ panfrost_batch_submit(struct panfrost_context *ctx,
panfrost_batch_to_fb_info(batch, &fb, rts, &zs, &s, false);
screen->vtbl.preload(batch, &fb);
-
- if (!pan_is_bifrost(dev)) {
- mali_ptr polygon_list = panfrost_batch_get_polygon_list(batch);
-
- panfrost_scoreboard_initialize_tiler(&batch->pool.base,
- &batch->scoreboard,
- polygon_list);
- }
+ screen->vtbl.init_polygon_list(batch);
/* Now that all draws are in, we can finally prepare the
* FBD for the batch (if there is one). */
diff --git a/src/gallium/drivers/panfrost/pan_screen.h b/src/gallium/drivers/panfrost/pan_screen.h
index 198f33b26db..ca09836ac54 100644
--- a/src/gallium/drivers/panfrost/pan_screen.h
+++ b/src/gallium/drivers/panfrost/pan_screen.h
@@ -76,6 +76,9 @@ struct panfrost_vtable {
/* Device-dependent initialization of a panfrost_batch */
void (*init_batch)(struct panfrost_batch *batch);
+
+ /* Initialize the polygon list */
+ void (*init_polygon_list)(struct panfrost_batch *);
};
struct panfrost_screen {
More information about the mesa-commit
mailing list