Revert "freedreno: Cooperate with tc to stop checking the BC for resource_busy()."
authorEmma Anholt <emma@anholt.net>
Thu, 24 Jun 2021 20:37:52 +0000 (13:37 -0700)
committerMarge Bot <eric+marge@anholt.net>
Thu, 24 Jun 2021 23:24:44 +0000 (23:24 +0000)
This reverts commit 5cb043cf82af4af88dbfe83ce1eff4cc41e2a766.

While the numbers were impressive for drawoverhead, it comes at the cost
of additional flushes, which for gmem access (what we actually care about
most!) would greatly increase the actual cost to render.  Also, gl_driver2
overhead is increased, probably due to spending time in the kernel for the
flushes.

drawoverhead's win came from the increased flushing causing the GPU to
start processing the buffers sooner on everything but test 1, which
already had some incremental flushing happening.  That was certainly not
intended by the change.

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/11599>

src/gallium/drivers/freedreno/freedreno_context.c
src/gallium/drivers/freedreno/freedreno_resource.c

index ce8a6ba..1df7155 100644 (file)
@@ -60,8 +60,6 @@ fd_context_flush(struct pipe_context *pctx, struct pipe_fence_handle **fencep,
       if (ctx->screen->reorder)
          fd_bc_flush(ctx, flags & PIPE_FLUSH_DEFERRED);
       fd_bc_dump(ctx, "%p: NULL batch, remaining:\n", ctx);
-      if (!(flags & PIPE_FLUSH_DEFERRED))
-         tc_driver_internal_flush_notify(ctx->tc);
       return;
    }
 
@@ -140,12 +138,6 @@ fd_context_flush(struct pipe_context *pctx, struct pipe_fence_handle **fencep,
    fd_bc_dump(ctx, "%p: remaining:\n", ctx);
 
 out:
-   /* If we just flushed all rendering out of the batch cache, then inform TC
-    * that it can use the resource_busy callback to check if they're still busy.
-    */
-   if (!(flags & PIPE_FLUSH_DEFERRED))
-      tc_driver_internal_flush_notify(ctx->tc);
-
    if (fencep)
       fd_fence_ref(fencep, fence);
 
@@ -711,7 +703,7 @@ fd_context_init_tc(struct pipe_context *pctx, unsigned flags)
       fd_replace_buffer_storage,
       fd_fence_create_unflushed,
       fd_resource_busy,
-      true,
+      false,
       &ctx->tc);
 
    uint64_t total_ram;
index d696f02..89d2750 100644 (file)
@@ -312,20 +312,15 @@ translate_usage(unsigned usage)
    return op;
 }
 
-/* This is called by TC to check if a buffer is idle on the GPU so it can do
- * unsynchronized mappings from the frontend.
- *
- * Note that TC tracks what buffers are outstanding in its queue in between
- * pctx->flush() calls (which we inform it of through
- * tc_driver_internal_flush_notify()) so we don't need to go digging in our
- * batch cache to check for usages.
- */
 bool
 fd_resource_busy(struct pipe_screen *pscreen, struct pipe_resource *prsc,
                  unsigned usage)
 {
    struct fd_resource *rsc = fd_resource(prsc);
 
+   if (pending(rsc, !!(usage & PIPE_MAP_WRITE)))
+      return true;
+
    if (resource_busy(rsc, translate_usage(usage)))
       return true;