From c271ac0066a637c18cb6db2278676c2f3bd46f33 Mon Sep 17 00:00:00 2001 From: Mike Blumenkrantz Date: Wed, 30 Sep 2020 12:54:10 -0400 Subject: [PATCH] zink: add util function for returning previous batch Reviewed-by: Dave Airlie Part-of: --- src/gallium/drivers/zink/zink_context.h | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/gallium/drivers/zink/zink_context.h b/src/gallium/drivers/zink/zink_context.h index 77ae3953cb3..141bfc33e0f 100644 --- a/src/gallium/drivers/zink/zink_context.h +++ b/src/gallium/drivers/zink/zink_context.h @@ -204,6 +204,18 @@ zink_curr_batch(struct zink_context *ctx) return ctx->batches + ctx->curr_batch; } +static inline struct zink_batch * +zink_prev_batch(struct zink_context *ctx) +{ + unsigned curr_batch = ctx->curr_batch; + if (!curr_batch) + curr_batch = ZINK_NUM_GFX_BATCHES - 1; + else + curr_batch--; + assert(curr_batch < ARRAY_SIZE(ctx->batches)); + return ctx->batches + curr_batch; +} + struct zink_batch * zink_batch_rp(struct zink_context *ctx);