freedreno/batch: Add helper to set fb state
authorRob Clark <robdclark@chromium.org>
Sat, 22 Apr 2023 19:32:21 +0000 (12:32 -0700)
committerMarge Bot <emma+marge@anholt.net>
Wed, 10 May 2023 15:36:02 +0000 (15:36 +0000)
Stop open-coding and add a helper.

Signed-off-by: Rob Clark <robdclark@chromium.org>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/22895>

src/gallium/drivers/freedreno/freedreno_batch.c
src/gallium/drivers/freedreno/freedreno_batch.h
src/gallium/drivers/freedreno/freedreno_batch_cache.c
src/gallium/drivers/freedreno/freedreno_context.c

index d26fec2..ef70276 100644 (file)
@@ -339,6 +339,14 @@ batch_flush(struct fd_batch *batch) assert_dt
    cleanup_submit(batch);
 }
 
+void
+fd_batch_set_fb(struct fd_batch *batch, const struct pipe_framebuffer_state *pfb)
+{
+   assert(!batch->nondraw);
+
+   util_copy_framebuffer_state(&batch->framebuffer, pfb);
+}
+
 /* NOTE: could drop the last ref to batch
  */
 void
index c1ed2e3..38efc62 100644 (file)
@@ -256,6 +256,8 @@ struct fd_batch {
 
 struct fd_batch *fd_batch_create(struct fd_context *ctx, bool nondraw);
 
+void fd_batch_set_fb(struct fd_batch *batch, const struct pipe_framebuffer_state *pfb) assert_dt;
+
 void fd_batch_flush(struct fd_batch *batch) assert_dt;
 bool fd_batch_has_dep(struct fd_batch *batch, struct fd_batch *dep) assert_dt;
 void fd_batch_add_dep(struct fd_batch *batch, struct fd_batch *dep) assert_dt;
index df49d94..9028f0a 100644 (file)
@@ -552,5 +552,7 @@ fd_batch_from_fb(struct fd_context *ctx,
    struct fd_batch *batch = batch_from_key(ctx, key);
    fd_screen_unlock(ctx->screen);
 
+   fd_batch_set_fb(batch, pfb);
+
    return batch;
 }
index b566a30..577ce4e 100644 (file)
@@ -343,7 +343,6 @@ fd_context_batch(struct fd_context *ctx)
    if (unlikely(!batch)) {
       batch =
          fd_batch_from_fb(ctx, &ctx->framebuffer);
-      util_copy_framebuffer_state(&batch->framebuffer, &ctx->framebuffer);
       fd_batch_reference(&ctx->batch, batch);
       fd_context_all_dirty(ctx);
    }