etnaviv: don't flush implicit flush resources when forced
authorLucas Stach <l.stach@pengutronix.de>
Tue, 30 May 2023 22:18:57 +0000 (00:18 +0200)
committerMarge Bot <emma+marge@anholt.net>
Wed, 31 May 2023 09:54:39 +0000 (09:54 +0000)
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 <l.stach@pengutronix.de>
Reviewed-by: Christian Gmeiner <christian.gmeiner@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/23329>

src/gallium/drivers/etnaviv/etnaviv_context.c

index 435b39e..84a64c4 100644 (file)
@@ -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;