From 9307028255f1f60b52c3852e0e4b68afa494d43b Mon Sep 17 00:00:00 2001 From: Alyssa Rosenzweig Date: Thu, 12 Aug 2021 21:17:29 +0000 Subject: [PATCH] panfrost: Simplify get_fresh_batch_for_fbo Makes the code easier to read, too. Signed-off-by: Alyssa Rosenzweig Part-of: --- src/gallium/drivers/panfrost/pan_job.c | 20 +++++++------------- 1 file changed, 7 insertions(+), 13 deletions(-) diff --git a/src/gallium/drivers/panfrost/pan_job.c b/src/gallium/drivers/panfrost/pan_job.c index c52d45a7d02..ee67d363729 100644 --- a/src/gallium/drivers/panfrost/pan_job.c +++ b/src/gallium/drivers/panfrost/pan_job.c @@ -222,21 +222,15 @@ panfrost_get_fresh_batch_for_fbo(struct panfrost_context *ctx, const char *reaso batch = panfrost_get_batch(ctx, &ctx->pipe_framebuffer); panfrost_dirty_state_all(ctx); - /* The batch has no draw/clear queued, let's return it directly. - * Note that it's perfectly fine to re-use a batch with an - * existing clear, we'll just update it with the new clear request. - */ - if (!batch->scoreboard.first_job) { - ctx->batch = batch; - return batch; + /* We only need to submit and get a fresh batch if there is no + * draw/clear queued. Otherwise we may reuse the batch. */ + + if (batch->scoreboard.first_job) { + perf_debug_ctx(ctx, "Flushing the current FBO due to: %s", reason); + panfrost_batch_submit(batch, 0, 0); + batch = panfrost_get_batch(ctx, &ctx->pipe_framebuffer); } - /* Otherwise, we need to freeze the existing one and instantiate a new - * one. - */ - perf_debug_ctx(ctx, "Flushing the current FBO due to: %s", reason); - panfrost_batch_submit(batch, 0, 0); - batch = panfrost_get_batch(ctx, &ctx->pipe_framebuffer); ctx->batch = batch; return batch; }