diff --git a/src/gallium/drivers/zink/zink_context.c b/src/gallium/drivers/zink/zink_context.c index 42c097703ef..633edbe3952 100644 --- a/src/gallium/drivers/zink/zink_context.c +++ b/src/gallium/drivers/zink/zink_context.c @@ -908,6 +908,13 @@ zink_batch_no_rp(struct zink_context *ctx) return batch; } +void +zink_flush_compute(struct zink_context *ctx) +{ + zink_end_batch(ctx, &ctx->compute_batch); + zink_start_batch(ctx, &ctx->compute_batch); +} + static void zink_set_framebuffer_state(struct pipe_context *pctx, const struct pipe_framebuffer_state *state) @@ -1293,10 +1300,7 @@ zink_texture_barrier(struct pipe_context *pctx, unsigned flags) struct zink_context *ctx = zink_context(pctx); if (zink_curr_batch(ctx)->has_draw) pctx->flush(pctx, NULL, 0); - if (ctx->compute_batch.has_draw) { - zink_end_batch(ctx, &ctx->compute_batch); - zink_start_batch(ctx, &ctx->compute_batch); - } + zink_flush_compute(ctx); } static void diff --git a/src/gallium/drivers/zink/zink_context.h b/src/gallium/drivers/zink/zink_context.h index b484f97d33d..bf8cc767d18 100644 --- a/src/gallium/drivers/zink/zink_context.h +++ b/src/gallium/drivers/zink/zink_context.h @@ -207,6 +207,9 @@ zink_fence_wait(struct pipe_context *ctx); void zink_wait_on_batch(struct zink_context *ctx, int batch_id); +void +zink_flush_compute(struct zink_context *ctx); + bool zink_resource_access_is_write(VkAccessFlags flags); diff --git a/src/gallium/drivers/zink/zink_draw.c b/src/gallium/drivers/zink/zink_draw.c index 276783f0147..10b76305493 100644 --- a/src/gallium/drivers/zink/zink_draw.c +++ b/src/gallium/drivers/zink/zink_draw.c @@ -495,8 +495,7 @@ update_descriptors(struct zink_context *ctx, struct zink_screen *screen, bool is ctx->base.flush(&ctx->base, NULL, PIPE_FLUSH_HINT_FINISH); else { /* flush compute batch */ - zink_end_batch(ctx, &ctx->compute_batch); - zink_start_batch(ctx, &ctx->compute_batch); + zink_flush_compute(ctx); } } diff --git a/src/gallium/drivers/zink/zink_query.c b/src/gallium/drivers/zink/zink_query.c index 1f81ab1ab7c..5cafb544eac 100644 --- a/src/gallium/drivers/zink/zink_query.c +++ b/src/gallium/drivers/zink/zink_query.c @@ -419,10 +419,8 @@ force_cpu_read(struct zink_context *ctx, struct pipe_query *pquery, bool wait, e union pipe_query_result result; if (zink_curr_batch(ctx)->batch_id == query->batch_id) ctx->base.flush(&ctx->base, NULL, PIPE_FLUSH_HINT_FINISH); - else if (is_cs_query(query)) { - zink_end_batch(ctx, &ctx->compute_batch); - zink_start_batch(ctx, &ctx->compute_batch); - } + else if (is_cs_query(query)) + zink_flush_compute(ctx); bool success = get_query_result(&ctx->base, pquery, wait, &result); if (!success) { @@ -608,8 +606,7 @@ zink_get_query_result(struct pipe_context *pctx, if (wait) zink_wait_on_batch(ctx, ZINK_COMPUTE_BATCH_ID); else { - zink_end_batch(ctx, &ctx->compute_batch); - zink_start_batch(ctx, &ctx->compute_batch); + zink_flush_compute(ctx); } } else { if (wait) {