From 65b6a62bc726b5e4f4833ed1e27733e22fabcfa8 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Michel=20D=C3=A4nzer?= <michel.daenzer@amd.com>
Date: Wed, 15 Feb 2017 08:13:57 +0000
Subject: dix: Pass ClientPtr to FlushCallback
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

 Backported X.org commits:

 commit b380f3ac51f40ffefcde7d3db5c4c149f274246d
 Author: Michel Dänzer <michel.daenzer@amd.com>
 Date:   Tue Aug 2 17:53:01 2016 +0900

    dix: Pass ClientPtr to FlushCallback

    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.

    Reviewed-by: Adam Jackson <ajax@redha.com>
    Signed-off-by: Michel Dänzer <michel.daenzer@amd.com>

 commit c65f610e12f9df168d5639534ed3c2bd40afffc8
 Author: Kristian Høgsberg <krh@bitplanet.net>
 Date:   Thu Jul 29 18:52:35 2010 -0400

    Always call the flush callback chain when we flush client buffers

    We were missing the callback in a couple of places.  Drivers may use
    the flush callback to submit batched up rendering before events (for
    example, damage events) are sent out, to ensure that the rendering
    has been queued when the client receives the event.

    Signed-off-by: Kristian Høgsberg <krh@bitplanet.net>
    Reviewed-by: Keith Packard <keithp@keithp.com>

 Backported-to-NX-by: Mike Gabriel <mike.gabriel@das-netzwerkteam.de>
---
 nx-X11/programs/Xserver/os/connection.c | 3 +++
 nx-X11/programs/Xserver/os/io.c         | 6 +++---
 2 files changed, 6 insertions(+), 3 deletions(-)

diff --git a/nx-X11/programs/Xserver/os/connection.c b/nx-X11/programs/Xserver/os/connection.c
index 966fe208d..74bb13404 100644
--- a/nx-X11/programs/Xserver/os/connection.c
+++ b/nx-X11/programs/Xserver/os/connection.c
@@ -987,6 +987,9 @@ CloseDownConnection(ClientPtr client)
 {
     OsCommPtr oc = (OsCommPtr)client->osPrivate;
 
+    if (FlushCallback)
+	CallCallbacks(&FlushCallback, client);
+
     if (oc->output && oc->output->count)
 	FlushClient(client, oc, (char *)NULL, 0);
 #ifdef XDMCP
diff --git a/nx-X11/programs/Xserver/os/io.c b/nx-X11/programs/Xserver/os/io.c
index 23f436b84..f4da96518 100644
--- a/nx-X11/programs/Xserver/os/io.c
+++ b/nx-X11/programs/Xserver/os/io.c
@@ -755,9 +755,6 @@ FlushAllOutput(void)
     fd_set newOutputPending;
 #endif
 
-    if (FlushCallback)
-	CallCallbacks(&FlushCallback, NULL);
-
     if (!newoutput)
 	return;
 
@@ -1008,6 +1005,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 */
-- 
cgit v1.2.3