panfrost: Move batch_set_requirements to the CSO

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>
This commit is contained in:
Alyssa Rosenzweig 2021-05-18 10:00:25 -04:00 committed by Marge Bot
parent bfd76ab501
commit 4b3ac29bb9
4 changed files with 16 additions and 21 deletions

View 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);

View 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;

View File

@ -1079,22 +1079,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)
{

View File

@ -151,9 +151,6 @@ void
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);