[PATCH xserver] Pass ClientPtr to FlushCallback

Michel Dänzer michel at daenzer.net
Tue Aug 2 08:53:01 UTC 2016


From: Michel Dänzer <michel.daenzer at amd.com>

This change has two effects:

1. Only calls FlushCallbacks when we're actually flushing data to a
   client. The unnecessary FlushCallback calls could cause significant
   performance degradation with compositing, which is significantly
   reduced even without any driver changes.

2. By passing the ClientPtr to FlushCallbacks, drivers can completely
   eliminate unnecessary flushing of GPU commands by keeping track of
   whether we're flushing any XDamageNotify events to the client for
   which the corresponding rendering commands haven't been flushed to
   the GPU yet.

Signed-off-by: Michel Dänzer <michel.daenzer at amd.com>
---

See https://lists.freedesktop.org/archives/amd-gfx/2016-August/000977.html
for an example of how to take advantage of this change to eliminate
unnecessary GPU flushes.

 os/connection.c | 2 +-
 os/io.c         | 9 +++------
 2 files changed, 4 insertions(+), 7 deletions(-)

diff --git a/os/connection.c b/os/connection.c
index 4294ee7..a901ebf 100644
--- a/os/connection.c
+++ b/os/connection.c
@@ -908,7 +908,7 @@ CloseDownConnection(ClientPtr client)
     OsCommPtr oc = (OsCommPtr) client->osPrivate;
 
     if (FlushCallback)
-        CallCallbacks(&FlushCallback, NULL);
+        CallCallbacks(&FlushCallback, client);
 
     if (oc->output)
 	FlushClient(client, oc, (char *) NULL, 0);
diff --git a/os/io.c b/os/io.c
index 88edf12..ff0ec3d 100644
--- a/os/io.c
+++ b/os/io.c
@@ -598,9 +598,6 @@ FlushAllOutput(void)
     register ClientPtr client, tmp;
     Bool newoutput = NewOutputPending;
 
-    if (FlushCallback)
-        CallCallbacks(&FlushCallback, NULL);
-
     if (!newoutput)
         return;
 
@@ -767,9 +764,6 @@ WriteToClient(ClientPtr who, int count, const void *__buf)
             NewOutputPending = FALSE;
         }
 
-        if (FlushCallback)
-            CallCallbacks(&FlushCallback, NULL);
-
         return FlushClient(who, oc, buf, count);
     }
 
@@ -815,6 +809,9 @@ FlushClient(ClientPtr who, OsCommPtr oc, const void *__extraBuf, int extraCount)
     if (!notWritten)
         return 0;
 
+    if (FlushCallback)
+        CallCallbacks(&FlushCallback, who);
+
     todo = notWritten;
     while (notWritten) {
         long before = written;  /* amount of whole thing written */
-- 
2.8.1



More information about the xorg-devel mailing list