radeonsi: don't flush in fence_server_sync
authorMarek Olšák <marek.olsak@amd.com>
Tue, 23 Jun 2020 03:54:59 +0000 (23:54 -0400)
committerMarek Olšák <marek.olsak@amd.com>
Tue, 30 Jun 2020 10:38:50 +0000 (06:38 -0400)
This reverts commit 50b06cbc10dbca1dfee89b529ba9b564cc4ea6f6 and fixes
an Android performance regression.

Fixes: 50b06cbc10dbca1dfee89b529ba9b564cc4ea6f6 "radeonsi: fix fence_server_sync() holding up extra work v2"
Acked-by: Pierre-Eric Pelloux-Prayer <pierre-eric.pelloux-prayer@amd.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/5602>

src/gallium/drivers/radeonsi/si_fence.c

index f6505ecf26ce0c7d4efd30b9c5e1f552be560537..0ab28c40c8f432f4f785b61202f426719bf2116d 100644 (file)
@@ -589,13 +589,16 @@ static void si_fence_server_sync(struct pipe_context *ctx, struct pipe_fence_han
    if (sfence->gfx_unflushed.ctx && sfence->gfx_unflushed.ctx == sctx)
       return;
 
-   /* All unflushed commands will not start execution before
-    * this fence dependency is signalled.
+   /* All unflushed commands will not start execution before this fence
+    * dependency is signalled. That's fine. Flushing is very expensive
+    * if we get fence_server_sync after every draw call. (which happens
+    * with Android/SurfaceFlinger)
     *
-    * Therefore we must flush before inserting the dependency
+    * In a nutshell, when CPU overhead is greater than GPU overhead,
+    * or when the time it takes to execute an IB on the GPU is less than
+    * the time it takes to create and submit that IB, flushing decreases
+    * performance. Therefore, DO NOT FLUSH.
     */
-   si_flush_from_st(ctx, NULL, PIPE_FLUSH_ASYNC);
-
    if (sfence->sdma)
       si_add_fence_dependency(sctx, sfence->sdma);
    if (sfence->gfx)