panfrost: Move batch_set_requirements to the CSO
authorAlyssa Rosenzweig <alyssa@rosenzweig.io>
Tue, 18 May 2021 14:00:25 +0000 (10:00 -0400)
committerMarge Bot <eric+marge@anholt.net>
Tue, 18 May 2021 22:51:56 +0000 (22:51 +0000)
Much of the per-draw work can be precomputed.

Signed-off-by: Alyssa Rosenzweig <alyssa@rosenzweig.io>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/10869>

src/gallium/drivers/panfrost/pan_context.c
src/gallium/drivers/panfrost/pan_context.h
src/gallium/drivers/panfrost/pan_job.c
src/gallium/drivers/panfrost/pan_job.h

index 96be717..cd78199 100644 (file)
@@ -444,7 +444,9 @@ panfrost_direct_draw(struct panfrost_context *ctx,
         if (batch->scoreboard.job_index > 10000)
                 batch = panfrost_get_fresh_batch_for_fbo(ctx);
 
-        panfrost_batch_set_requirements(batch);
+        unsigned zs_draws = ctx->depth_stencil->draws;
+        batch->draws |= zs_draws;
+        batch->resolve |= zs_draws;
 
         /* Take into account a negative bias */
         ctx->indirect_draw = false;
@@ -575,7 +577,9 @@ panfrost_indirect_draw(struct panfrost_context *ctx,
         if (batch->scoreboard.job_index + (indirect->draw_count * 3) > 10000)
                 batch = panfrost_get_fresh_batch_for_fbo(ctx);
 
-        panfrost_batch_set_requirements(batch);
+        unsigned zs_draws = ctx->depth_stencil->draws;
+        batch->draws |= zs_draws;
+        batch->resolve |= zs_draws;
 
         mali_ptr shared_mem = panfrost_batch_reserve_tls(batch, false);
 
@@ -1470,6 +1474,13 @@ panfrost_create_depth_stencil_state(struct pipe_context *pipe,
         so->enabled = zsa->stencil[0].enabled ||
                 (zsa->depth_enabled && zsa->depth_func != PIPE_FUNC_ALWAYS);
 
+        /* Write masks need tracking together */
+        if (zsa->depth_writemask)
+                so->draws |= PIPE_CLEAR_DEPTH;
+
+        if (zsa->stencil[0].enabled)
+                so->draws |= PIPE_CLEAR_STENCIL;
+
         /* TODO: Bounds test should be easy */
         assert(!zsa->depth_bounds_test);
 
index 847f2f5..f72dd72 100644 (file)
@@ -268,6 +268,9 @@ struct panfrost_zsa_state {
         /* Is any depth, stencil, or alpha testing enabled? */
         bool enabled;
 
+        /* Mask of PIPE_CLEAR_{DEPTH,STENCIL} written */
+        unsigned draws;
+
         /* Prepacked words from the RSD */
         struct mali_multisample_misc_packed rsd_depth;
         struct mali_stencil_mask_misc_packed rsd_stencil;
index cabc772..c008ca7 100644 (file)
@@ -1080,22 +1080,6 @@ panfrost_flush_batches_accessing_bo(struct panfrost_context *ctx,
 }
 
 void
-panfrost_batch_set_requirements(struct panfrost_batch *batch)
-{
-        struct panfrost_context *ctx = batch->ctx;
-        unsigned draws = 0;
-
-        if (ctx->depth_stencil && ctx->depth_stencil->base.depth_writemask)
-                draws |= PIPE_CLEAR_DEPTH;
-
-        if (ctx->depth_stencil && ctx->depth_stencil->base.stencil[0].enabled)
-                draws |= PIPE_CLEAR_STENCIL;
-
-        batch->draws |= draws;
-        batch->resolve |= draws;
-}
-
-void
 panfrost_batch_adjust_stack_size(struct panfrost_batch *batch)
 {
         struct panfrost_context *ctx = batch->ctx;
index 9a5194a..85e1a9b 100644 (file)
@@ -152,9 +152,6 @@ panfrost_flush_batches_accessing_bo(struct panfrost_context *ctx,
                                     struct panfrost_bo *bo, bool flush_readers);
 
 void
-panfrost_batch_set_requirements(struct panfrost_batch *batch);
-
-void
 panfrost_batch_adjust_stack_size(struct panfrost_batch *batch);
 
 struct panfrost_bo *