From 4b3ac29bb9b2a6b17543fc75f5fb157744845182 Mon Sep 17 00:00:00 2001 From: Alyssa Rosenzweig Date: Tue, 18 May 2021 10:00:25 -0400 Subject: [PATCH] panfrost: Move batch_set_requirements to the CSO Much of the per-draw work can be precomputed. Signed-off-by: Alyssa Rosenzweig Part-of: --- src/gallium/drivers/panfrost/pan_context.c | 15 +++++++++++++-- src/gallium/drivers/panfrost/pan_context.h | 3 +++ src/gallium/drivers/panfrost/pan_job.c | 16 ---------------- src/gallium/drivers/panfrost/pan_job.h | 3 --- 4 files changed, 16 insertions(+), 21 deletions(-) diff --git a/src/gallium/drivers/panfrost/pan_context.c b/src/gallium/drivers/panfrost/pan_context.c index 96be71738be..cd78199f84c 100644 --- a/src/gallium/drivers/panfrost/pan_context.c +++ b/src/gallium/drivers/panfrost/pan_context.c @@ -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); diff --git a/src/gallium/drivers/panfrost/pan_context.h b/src/gallium/drivers/panfrost/pan_context.h index 847f2f5eb58..f72dd722873 100644 --- a/src/gallium/drivers/panfrost/pan_context.h +++ b/src/gallium/drivers/panfrost/pan_context.h @@ -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; diff --git a/src/gallium/drivers/panfrost/pan_job.c b/src/gallium/drivers/panfrost/pan_job.c index cabc7729b12..c008ca78482 100644 --- a/src/gallium/drivers/panfrost/pan_job.c +++ b/src/gallium/drivers/panfrost/pan_job.c @@ -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) { diff --git a/src/gallium/drivers/panfrost/pan_job.h b/src/gallium/drivers/panfrost/pan_job.h index 9a5194a0dd9..85e1a9bf028 100644 --- a/src/gallium/drivers/panfrost/pan_job.h +++ b/src/gallium/drivers/panfrost/pan_job.h @@ -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);