From 6611866246e01d35cd5a08c82c635f1db9890637 Mon Sep 17 00:00:00 2001 From: Lucas Stach Date: Wed, 31 May 2023 00:18:57 +0200 Subject: [PATCH] etnaviv: don't flush implicit flush resources when forced Resources only need to become visible when the application requested the context flush, so we can safely skip the flushing when the flush is forced internally by running out of commandstream space. Signed-off-by: Lucas Stach Reviewed-by: Christian Gmeiner Part-of: --- src/gallium/drivers/etnaviv/etnaviv_context.c | 27 ++++++++++++++++++--------- 1 file changed, 18 insertions(+), 9 deletions(-) diff --git a/src/gallium/drivers/etnaviv/etnaviv_context.c b/src/gallium/drivers/etnaviv/etnaviv_context.c index 435b39e..84a64c4 100644 --- a/src/gallium/drivers/etnaviv/etnaviv_context.c +++ b/src/gallium/drivers/etnaviv/etnaviv_context.c @@ -508,7 +508,7 @@ etna_reset_gpu_state(struct etna_context *ctx) static void etna_flush(struct pipe_context *pctx, struct pipe_fence_handle **fence, - enum pipe_flush_flags flags) + enum pipe_flush_flags flags, bool internal) { struct etna_context *ctx = etna_context(pctx); int out_fence_fd = -1; @@ -516,14 +516,16 @@ etna_flush(struct pipe_context *pctx, struct pipe_fence_handle **fence, list_for_each_entry(struct etna_acc_query, aq, &ctx->active_acc_queries, node) etna_acc_query_suspend(aq, ctx); - /* flush all resources that need an implicit flush */ - set_foreach(ctx->flush_resources, entry) { - struct pipe_resource *prsc = (struct pipe_resource *)entry->key; + if (!internal) { + /* flush all resources that need an implicit flush */ + set_foreach(ctx->flush_resources, entry) { + struct pipe_resource *prsc = (struct pipe_resource *)entry->key; - pctx->flush_resource(pctx, prsc); - pipe_resource_reference(&prsc, NULL); + pctx->flush_resource(pctx, prsc); + pipe_resource_reference(&prsc, NULL); + } + _mesa_set_clear(ctx->flush_resources, NULL); } - _mesa_set_clear(ctx->flush_resources, NULL); etna_cmd_stream_flush(ctx->stream, ctx->in_fence_fd, (flags & PIPE_FLUSH_FENCE_FD) ? &out_fence_fd : NULL, @@ -541,11 +543,18 @@ etna_flush(struct pipe_context *pctx, struct pipe_fence_handle **fence, } static void +etna_context_flush(struct pipe_context *pctx, struct pipe_fence_handle **fence, + enum pipe_flush_flags flags) +{ + etna_flush(pctx, fence, flags, false); +} + +static void etna_context_force_flush(struct etna_cmd_stream *stream, void *priv) { struct pipe_context *pctx = priv; - pctx->flush(pctx, NULL, 0); + etna_flush(pctx, NULL, 0, true); /* update derived states as the context is now fully dirty */ etna_state_update(etna_context(pctx)); @@ -619,7 +628,7 @@ etna_context_create(struct pipe_screen *pscreen, void *priv, unsigned flags) pctx->destroy = etna_context_destroy; pctx->draw_vbo = etna_draw_vbo; - pctx->flush = etna_flush; + pctx->flush = etna_context_flush; pctx->set_debug_callback = etna_set_debug_callback; pctx->create_fence_fd = etna_create_fence_fd; pctx->fence_server_sync = etna_fence_server_sync; -- 2.7.4