All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH xf86-video-ati 1/2] Use EventCallback to avoid flushing every time in the FlushCallback
@ 2016-08-01  9:59 Michel Dänzer
       [not found] ` <1470045560-7220-1-git-send-email-michel-otUistvHUpPR7s880joybQ@public.gmane.org>
  0 siblings, 1 reply; 4+ messages in thread
From: Michel Dänzer @ 2016-08-01  9:59 UTC (permalink / raw)
  To: amd-gfx-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW

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

We only need to flush for XDamageNotify events.

Significantly reduces compositing slowdown due to flushing overhead, in
particular with glamor.

Signed-off-by: Michel Dänzer <michel.daenzer@amd.com>
---
 src/radeon.h     |  2 ++
 src/radeon_kms.c | 79 +++++++++++++++++++++++++++++++++++++++++++++-----------
 2 files changed, 66 insertions(+), 15 deletions(-)

diff --git a/src/radeon.h b/src/radeon.h
index 37d5fb6..25ff61c 100644
--- a/src/radeon.h
+++ b/src/radeon.h
@@ -473,6 +473,8 @@ typedef struct {
     Bool              RenderAccel; /* Render */
     Bool              allowColorTiling;
     Bool              allowColorTiling2D;
+    int               callback_event_type;
+    uint_fast32_t     callback_needs_flush;
     uint_fast32_t     gpu_flushed;
     uint_fast32_t     gpu_synced;
     struct radeon_accel_state *accel_state;
diff --git a/src/radeon_kms.c b/src/radeon_kms.c
index 122b932..da11358 100644
--- a/src/radeon_kms.c
+++ b/src/radeon_kms.c
@@ -51,6 +51,8 @@
 #include <X11/extensions/dpms.h>
 #endif
 
+#include <X11/extensions/damageproto.h>
+
 #include "radeon_chipinfo_gen.h"
 
 #include "radeon_bo_gem.h"
@@ -91,10 +93,11 @@ void radeon_cs_flush_indirect(ScrnInfoPtr pScrn)
     struct radeon_accel_state *accel_state;
     int ret;
 
+    info->gpu_flushed++;
+
 #ifdef USE_GLAMOR
     if (info->use_glamor) {
 	glamor_block_handler(pScrn->pScreen);
-	info->gpu_flushed++;
 	return;
     }
 #endif
@@ -237,8 +240,51 @@ radeonUpdatePacked(ScreenPtr pScreen, shadowBufPtr pBuf)
     shadowUpdatePacked(pScreen, pBuf);
 }
 
+static Bool
+callback_needs_flush(RADEONInfoPtr info)
+{
+    return (int)(info->callback_needs_flush - info->gpu_flushed) > 0;
+}
+
+static void
+radeon_event_callback(CallbackListPtr *list,
+		      pointer user_data, pointer call_data)
+{
+    EventInfoRec *eventinfo = call_data;
+    ScrnInfoPtr pScrn = user_data;
+    RADEONInfoPtr info = RADEONPTR(pScrn);
+    int i;
+
+    if (callback_needs_flush(info))
+	return;
+
+    /* Don't let gpu_flushed get too far ahead of callback_needs_flush,
+     * in order to prevent false positives in callback_needs_flush()
+     */
+    info->callback_needs_flush = info->gpu_flushed;
+    
+    for (i = 0; i < eventinfo->count; i++) {
+	if (eventinfo->events[i].u.u.type == info->callback_event_type) {
+	    info->callback_needs_flush++;
+	    return;
+	}
+    }
+}
+
+static void
+radeon_flush_callback(CallbackListPtr *list,
+		      pointer user_data, pointer call_data)
+{
+    ScrnInfoPtr pScrn = user_data;
+    RADEONInfoPtr info = RADEONPTR(pScrn);
+
+    if (pScrn->vtSema && callback_needs_flush(info))
+        radeon_cs_flush_indirect(pScrn);
+}
+
 static Bool RADEONCreateScreenResources_KMS(ScreenPtr pScreen)
 {
+    ExtensionEntry *damage_ext = CheckExtension("DAMAGE");
     ScrnInfoPtr pScrn = xf86ScreenToScrn(pScreen);
     RADEONInfoPtr  info   = RADEONPTR(pScrn);
     PixmapPtr pixmap;
@@ -294,6 +340,19 @@ static Bool RADEONCreateScreenResources_KMS(ScreenPtr pScreen)
     if (info->use_glamor)
 	radeon_glamor_create_screen_resources(pScreen);
 
+    info->callback_event_type = -1;
+    if (damage_ext) {
+	info->callback_event_type = damage_ext->eventBase + XDamageNotify;
+
+	if (!AddCallback(&FlushCallback, radeon_flush_callback, pScrn))
+	    return FALSE;
+
+	if (!AddCallback(&EventCallback, radeon_event_callback, pScrn)) {
+	    DeleteCallback(&FlushCallback, radeon_flush_callback, pScrn);
+	    return FALSE;
+	}
+    }
+
     return TRUE;
 }
 
@@ -641,16 +700,6 @@ static void RADEONBlockHandler_oneshot(BLOCKHANDLER_ARGS_DECL)
     drmmode_set_desired_modes(pScrn, &info->drmmode, TRUE);
 }
 
-static void
-radeon_flush_callback(CallbackListPtr *list,
-		      pointer user_data, pointer call_data)
-{
-    ScrnInfoPtr pScrn = user_data;
-
-    if (pScrn->vtSema)
-        radeon_cs_flush_indirect(pScrn);
-}
-
 static Bool RADEONIsFastFBWorking(ScrnInfoPtr pScrn)
 {
     RADEONInfoPtr info = RADEONPTR(pScrn);
@@ -1564,7 +1613,10 @@ static Bool RADEONCloseScreen_KMS(CLOSE_SCREEN_ARGS_DECL)
     radeon_drm_queue_close(pScrn);
     radeon_cs_flush_indirect(pScrn);
 
-    DeleteCallback(&FlushCallback, radeon_flush_callback, pScrn);
+    if (info->callback_event_type != -1) {
+	DeleteCallback(&EventCallback, radeon_event_callback, pScrn);
+	DeleteCallback(&FlushCallback, radeon_flush_callback, pScrn);
+    }
 
     if (info->accel_state->exa) {
 	exaDriverFini(pScreen);
@@ -1838,9 +1890,6 @@ Bool RADEONScreenInit_KMS(SCREEN_INIT_ARGS_DECL)
     info->BlockHandler = pScreen->BlockHandler;
     pScreen->BlockHandler = RADEONBlockHandler_oneshot;
 
-    if (!AddCallback(&FlushCallback, radeon_flush_callback, pScrn))
-        return FALSE;
-
     info->CreateScreenResources = pScreen->CreateScreenResources;
     pScreen->CreateScreenResources = RADEONCreateScreenResources_KMS;
 
-- 
2.8.1

_______________________________________________
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [PATCH xf86-video-ati 2/2] Keep track of damage event related flushes per-client
       [not found] ` <1470045560-7220-1-git-send-email-michel-otUistvHUpPR7s880joybQ@public.gmane.org>
@ 2016-08-01  9:59   ` Michel Dänzer
       [not found]     ` <1470045560-7220-2-git-send-email-michel-otUistvHUpPR7s880joybQ@public.gmane.org>
  0 siblings, 1 reply; 4+ messages in thread
From: Michel Dänzer @ 2016-08-01  9:59 UTC (permalink / raw)
  To: amd-gfx-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW

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

This further reduces the compositing slowdown due to flushing overhead,
by only flushing when the X server actually sends XDamageNotify events
to a client, and there hasn't been a flush yet in the meantime.

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

This patch can't have an effect without a corresponding xserver patch
which passes the ClientPtr to the FlushCallback, so I'll only push this
one once the xserver patch has landed.

 src/radeon.h     |  5 ++++-
 src/radeon_kms.c | 34 ++++++++++++++++++++++++++++------
 2 files changed, 32 insertions(+), 7 deletions(-)

diff --git a/src/radeon.h b/src/radeon.h
index 25ff61c..b119241 100644
--- a/src/radeon.h
+++ b/src/radeon.h
@@ -448,6 +448,10 @@ struct radeon_accel_state {
     Bool              force;
 };
 
+struct radeon_client_priv {
+    uint_fast32_t     needs_flush[0];
+};
+
 typedef struct {
     EntityInfoPtr     pEnt;
     pciVideoPtr       PciInfo;
@@ -474,7 +478,6 @@ typedef struct {
     Bool              allowColorTiling;
     Bool              allowColorTiling2D;
     int               callback_event_type;
-    uint_fast32_t     callback_needs_flush;
     uint_fast32_t     gpu_flushed;
     uint_fast32_t     gpu_synced;
     struct radeon_accel_state *accel_state;
diff --git a/src/radeon_kms.c b/src/radeon_kms.c
index da11358..7ede3a1 100644
--- a/src/radeon_kms.c
+++ b/src/radeon_kms.c
@@ -40,6 +40,7 @@
 
 #include "radeon_version.h"
 #include "shadow.h"
+#include <xf86Priv.h>
 
 #include "atipciids.h"
 
@@ -59,6 +60,8 @@
 #include "radeon_cs_gem.h"
 #include "radeon_vbo.h"
 
+static DevPrivateKeyRec radeon_client_private_key;
+
 extern SymTabRec RADEONChipsets[];
 static Bool radeon_setup_kernel_mem(ScreenPtr pScreen);
 
@@ -241,9 +244,9 @@ radeonUpdatePacked(ScreenPtr pScreen, shadowBufPtr pBuf)
 }
 
 static Bool
-callback_needs_flush(RADEONInfoPtr info)
+callback_needs_flush(RADEONInfoPtr info, uint_fast32_t needs_flush)
 {
-    return (int)(info->callback_needs_flush - info->gpu_flushed) > 0;
+    return (int)(needs_flush - info->gpu_flushed) > 0;
 }
 
 static void
@@ -251,21 +254,28 @@ radeon_event_callback(CallbackListPtr *list,
 		      pointer user_data, pointer call_data)
 {
     EventInfoRec *eventinfo = call_data;
+    struct radeon_client_priv *client_priv =
+	dixLookupPrivate(&eventinfo->client->devPrivates, &radeon_client_private_key);
+    struct radeon_client_priv *server_priv =
+	dixLookupPrivate(&serverClient->devPrivates, &radeon_client_private_key);
     ScrnInfoPtr pScrn = user_data;
     RADEONInfoPtr info = RADEONPTR(pScrn);
     int i;
 
-    if (callback_needs_flush(info))
+    if (callback_needs_flush(info, client_priv->needs_flush[pScrn->scrnIndex]) ||
+	callback_needs_flush(info, server_priv->needs_flush[pScrn->scrnIndex]))
 	return;
 
     /* Don't let gpu_flushed get too far ahead of callback_needs_flush,
      * in order to prevent false positives in callback_needs_flush()
      */
-    info->callback_needs_flush = info->gpu_flushed;
+    client_priv->needs_flush[pScrn->scrnIndex] = info->gpu_flushed;
+    server_priv->needs_flush[pScrn->scrnIndex] = info->gpu_flushed;
     
     for (i = 0; i < eventinfo->count; i++) {
 	if (eventinfo->events[i].u.u.type == info->callback_event_type) {
-	    info->callback_needs_flush++;
+	    client_priv->needs_flush[pScrn->scrnIndex]++;
+	    server_priv->needs_flush[pScrn->scrnIndex]++;
 	    return;
 	}
     }
@@ -276,9 +286,13 @@ radeon_flush_callback(CallbackListPtr *list,
 		      pointer user_data, pointer call_data)
 {
     ScrnInfoPtr pScrn = user_data;
+    ClientPtr client = call_data ? call_data : serverClient;
+    struct radeon_client_priv *client_priv =
+	dixLookupPrivate(&client->devPrivates, &radeon_client_private_key);
     RADEONInfoPtr info = RADEONPTR(pScrn);
 
-    if (pScrn->vtSema && callback_needs_flush(info))
+    if (pScrn->vtSema &&
+	callback_needs_flush(info, client_priv->needs_flush[pScrn->scrnIndex]))
         radeon_cs_flush_indirect(pScrn);
 }
 
@@ -351,6 +365,14 @@ static Bool RADEONCreateScreenResources_KMS(ScreenPtr pScreen)
 	    DeleteCallback(&FlushCallback, radeon_flush_callback, pScrn);
 	    return FALSE;
 	}
+
+	if (!dixPrivateKeyRegistered(&radeon_client_private_key) &&
+	    !dixRegisterPrivateKey(&radeon_client_private_key, PRIVATE_CLIENT,
+				   xf86NumScreens * sizeof(uint_fast32_t))) {
+	    DeleteCallback(&FlushCallback, radeon_flush_callback, pScrn);
+	    DeleteCallback(&EventCallback, radeon_event_callback, pScrn);
+	    return FALSE;
+	}
     }
 
     return TRUE;
-- 
2.8.1

_______________________________________________
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* RE: [PATCH xf86-video-ati 2/2] Keep track of damage event related flushes per-client
       [not found]     ` <1470045560-7220-2-git-send-email-michel-otUistvHUpPR7s880joybQ@public.gmane.org>
@ 2016-08-01 15:56       ` Deucher, Alexander
  2016-08-02  8:48       ` [PATCH xf86-video-ati] Keep track of damage event related flushes per-client v2 Michel Dänzer
  1 sibling, 0 replies; 4+ messages in thread
From: Deucher, Alexander @ 2016-08-01 15:56 UTC (permalink / raw)
  To: 'Michel Dänzer', amd-gfx-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW

> -----Original Message-----
> From: amd-gfx [mailto:amd-gfx-bounces@lists.freedesktop.org] On Behalf
> Of Michel Dänzer
> Sent: Monday, August 01, 2016 5:59 AM
> To: amd-gfx@lists.freedesktop.org
> Subject: [PATCH xf86-video-ati 2/2] Keep track of damage event related
> flushes per-client
> 
> From: Michel Dänzer <michel.daenzer@amd.com>
> 
> This further reduces the compositing slowdown due to flushing overhead,
> by only flushing when the X server actually sends XDamageNotify events
> to a client, and there hasn't been a flush yet in the meantime.
> 
> Signed-off-by: Michel Dänzer <michel.daenzer@amd.com>

For the series:
Reviewed-by: Alex Deucher <alexander.deucher@amd.com>

> ---
> 
> This patch can't have an effect without a corresponding xserver patch
> which passes the ClientPtr to the FlushCallback, so I'll only push this
> one once the xserver patch has landed.
> 
>  src/radeon.h     |  5 ++++-
>  src/radeon_kms.c | 34 ++++++++++++++++++++++++++++------
>  2 files changed, 32 insertions(+), 7 deletions(-)
> 
> diff --git a/src/radeon.h b/src/radeon.h
> index 25ff61c..b119241 100644
> --- a/src/radeon.h
> +++ b/src/radeon.h
> @@ -448,6 +448,10 @@ struct radeon_accel_state {
>      Bool              force;
>  };
> 
> +struct radeon_client_priv {
> +    uint_fast32_t     needs_flush[0];
> +};
> +
>  typedef struct {
>      EntityInfoPtr     pEnt;
>      pciVideoPtr       PciInfo;
> @@ -474,7 +478,6 @@ typedef struct {
>      Bool              allowColorTiling;
>      Bool              allowColorTiling2D;
>      int               callback_event_type;
> -    uint_fast32_t     callback_needs_flush;
>      uint_fast32_t     gpu_flushed;
>      uint_fast32_t     gpu_synced;
>      struct radeon_accel_state *accel_state;
> diff --git a/src/radeon_kms.c b/src/radeon_kms.c
> index da11358..7ede3a1 100644
> --- a/src/radeon_kms.c
> +++ b/src/radeon_kms.c
> @@ -40,6 +40,7 @@
> 
>  #include "radeon_version.h"
>  #include "shadow.h"
> +#include <xf86Priv.h>
> 
>  #include "atipciids.h"
> 
> @@ -59,6 +60,8 @@
>  #include "radeon_cs_gem.h"
>  #include "radeon_vbo.h"
> 
> +static DevPrivateKeyRec radeon_client_private_key;
> +
>  extern SymTabRec RADEONChipsets[];
>  static Bool radeon_setup_kernel_mem(ScreenPtr pScreen);
> 
> @@ -241,9 +244,9 @@ radeonUpdatePacked(ScreenPtr pScreen,
> shadowBufPtr pBuf)
>  }
> 
>  static Bool
> -callback_needs_flush(RADEONInfoPtr info)
> +callback_needs_flush(RADEONInfoPtr info, uint_fast32_t needs_flush)
>  {
> -    return (int)(info->callback_needs_flush - info->gpu_flushed) > 0;
> +    return (int)(needs_flush - info->gpu_flushed) > 0;
>  }
> 
>  static void
> @@ -251,21 +254,28 @@ radeon_event_callback(CallbackListPtr *list,
>  		      pointer user_data, pointer call_data)
>  {
>      EventInfoRec *eventinfo = call_data;
> +    struct radeon_client_priv *client_priv =
> +	dixLookupPrivate(&eventinfo->client->devPrivates,
> &radeon_client_private_key);
> +    struct radeon_client_priv *server_priv =
> +	dixLookupPrivate(&serverClient->devPrivates,
> &radeon_client_private_key);
>      ScrnInfoPtr pScrn = user_data;
>      RADEONInfoPtr info = RADEONPTR(pScrn);
>      int i;
> 
> -    if (callback_needs_flush(info))
> +    if (callback_needs_flush(info, client_priv->needs_flush[pScrn-
> >scrnIndex]) ||
> +	callback_needs_flush(info, server_priv->needs_flush[pScrn-
> >scrnIndex]))
>  	return;
> 
>      /* Don't let gpu_flushed get too far ahead of callback_needs_flush,
>       * in order to prevent false positives in callback_needs_flush()
>       */
> -    info->callback_needs_flush = info->gpu_flushed;
> +    client_priv->needs_flush[pScrn->scrnIndex] = info->gpu_flushed;
> +    server_priv->needs_flush[pScrn->scrnIndex] = info->gpu_flushed;
> 
>      for (i = 0; i < eventinfo->count; i++) {
>  	if (eventinfo->events[i].u.u.type == info->callback_event_type) {
> -	    info->callback_needs_flush++;
> +	    client_priv->needs_flush[pScrn->scrnIndex]++;
> +	    server_priv->needs_flush[pScrn->scrnIndex]++;
>  	    return;
>  	}
>      }
> @@ -276,9 +286,13 @@ radeon_flush_callback(CallbackListPtr *list,
>  		      pointer user_data, pointer call_data)
>  {
>      ScrnInfoPtr pScrn = user_data;
> +    ClientPtr client = call_data ? call_data : serverClient;
> +    struct radeon_client_priv *client_priv =
> +	dixLookupPrivate(&client->devPrivates,
> &radeon_client_private_key);
>      RADEONInfoPtr info = RADEONPTR(pScrn);
> 
> -    if (pScrn->vtSema && callback_needs_flush(info))
> +    if (pScrn->vtSema &&
> +	callback_needs_flush(info, client_priv->needs_flush[pScrn-
> >scrnIndex]))
>          radeon_cs_flush_indirect(pScrn);
>  }
> 
> @@ -351,6 +365,14 @@ static Bool
> RADEONCreateScreenResources_KMS(ScreenPtr pScreen)
>  	    DeleteCallback(&FlushCallback, radeon_flush_callback, pScrn);
>  	    return FALSE;
>  	}
> +
> +	if (!dixPrivateKeyRegistered(&radeon_client_private_key) &&
> +	    !dixRegisterPrivateKey(&radeon_client_private_key,
> PRIVATE_CLIENT,
> +				   xf86NumScreens * sizeof(uint_fast32_t))) {
> +	    DeleteCallback(&FlushCallback, radeon_flush_callback, pScrn);
> +	    DeleteCallback(&EventCallback, radeon_event_callback, pScrn);
> +	    return FALSE;
> +	}
>      }
> 
>      return TRUE;
> --
> 2.8.1
> 
> _______________________________________________
> amd-gfx mailing list
> amd-gfx@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/amd-gfx
_______________________________________________
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH xf86-video-ati] Keep track of damage event related flushes per-client v2
       [not found]     ` <1470045560-7220-2-git-send-email-michel-otUistvHUpPR7s880joybQ@public.gmane.org>
  2016-08-01 15:56       ` Deucher, Alexander
@ 2016-08-02  8:48       ` Michel Dänzer
  1 sibling, 0 replies; 4+ messages in thread
From: Michel Dänzer @ 2016-08-02  8:48 UTC (permalink / raw)
  To: amd-gfx-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW

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

This further reduces the compositing slowdown due to flushing overhead,
by only flushing when the X server actually sends XDamageNotify events
to a client, and there hasn't been a flush yet in the meantime.

v2: Use ScreenPrivateKey, fixes invalid memory access with GPU screens
Signed-off-by: Michel Dänzer <michel.daenzer@amd.com>
---
 src/radeon.h     |  5 ++++-
 src/radeon_kms.c | 41 +++++++++++++++++++++++++++++++++--------
 2 files changed, 37 insertions(+), 9 deletions(-)

diff --git a/src/radeon.h b/src/radeon.h
index 25ff61c..f3a3e1c 100644
--- a/src/radeon.h
+++ b/src/radeon.h
@@ -448,6 +448,10 @@ struct radeon_accel_state {
     Bool              force;
 };
 
+struct radeon_client_priv {
+    uint_fast32_t     needs_flush;
+};
+
 typedef struct {
     EntityInfoPtr     pEnt;
     pciVideoPtr       PciInfo;
@@ -474,7 +478,6 @@ typedef struct {
     Bool              allowColorTiling;
     Bool              allowColorTiling2D;
     int               callback_event_type;
-    uint_fast32_t     callback_needs_flush;
     uint_fast32_t     gpu_flushed;
     uint_fast32_t     gpu_synced;
     struct radeon_accel_state *accel_state;
diff --git a/src/radeon_kms.c b/src/radeon_kms.c
index da11358..f525a2c 100644
--- a/src/radeon_kms.c
+++ b/src/radeon_kms.c
@@ -40,6 +40,7 @@
 
 #include "radeon_version.h"
 #include "shadow.h"
+#include <xf86Priv.h>
 
 #include "atipciids.h"
 
@@ -59,6 +60,8 @@
 #include "radeon_cs_gem.h"
 #include "radeon_vbo.h"
 
+static DevScreenPrivateKeyRec radeon_client_private_key;
+
 extern SymTabRec RADEONChipsets[];
 static Bool radeon_setup_kernel_mem(ScreenPtr pScreen);
 
@@ -241,9 +244,9 @@ radeonUpdatePacked(ScreenPtr pScreen, shadowBufPtr pBuf)
 }
 
 static Bool
-callback_needs_flush(RADEONInfoPtr info)
+callback_needs_flush(RADEONInfoPtr info, struct radeon_client_priv *client_priv)
 {
-    return (int)(info->callback_needs_flush - info->gpu_flushed) > 0;
+    return (int)(client_priv->needs_flush - info->gpu_flushed) > 0;
 }
 
 static void
@@ -252,20 +255,30 @@ radeon_event_callback(CallbackListPtr *list,
 {
     EventInfoRec *eventinfo = call_data;
     ScrnInfoPtr pScrn = user_data;
+    ScreenPtr pScreen = pScrn->pScreen;
+    struct radeon_client_priv *client_priv =
+	dixLookupScreenPrivate(&eventinfo->client->devPrivates,
+			       &radeon_client_private_key, pScreen);
+    struct radeon_client_priv *server_priv =
+	dixLookupScreenPrivate(&serverClient->devPrivates,
+			       &radeon_client_private_key, pScreen);
     RADEONInfoPtr info = RADEONPTR(pScrn);
     int i;
 
-    if (callback_needs_flush(info))
+    if (callback_needs_flush(info, client_priv) ||
+	callback_needs_flush(info, server_priv))
 	return;
 
-    /* Don't let gpu_flushed get too far ahead of callback_needs_flush,
-     * in order to prevent false positives in callback_needs_flush()
+    /* Don't let gpu_flushed get too far ahead of needs_flush, in order
+     * to prevent false positives in callback_needs_flush()
      */
-    info->callback_needs_flush = info->gpu_flushed;
+    client_priv->needs_flush = info->gpu_flushed;
+    server_priv->needs_flush = info->gpu_flushed;
     
     for (i = 0; i < eventinfo->count; i++) {
 	if (eventinfo->events[i].u.u.type == info->callback_event_type) {
-	    info->callback_needs_flush++;
+	    client_priv->needs_flush++;
+	    server_priv->needs_flush++;
 	    return;
 	}
     }
@@ -276,9 +289,14 @@ radeon_flush_callback(CallbackListPtr *list,
 		      pointer user_data, pointer call_data)
 {
     ScrnInfoPtr pScrn = user_data;
+    ScreenPtr pScreen = pScrn->pScreen;
+    ClientPtr client = call_data ? call_data : serverClient;
+    struct radeon_client_priv *client_priv =
+	dixLookupScreenPrivate(&client->devPrivates,
+			       &radeon_client_private_key, pScreen);
     RADEONInfoPtr info = RADEONPTR(pScrn);
 
-    if (pScrn->vtSema && callback_needs_flush(info))
+    if (pScrn->vtSema && callback_needs_flush(info, client_priv))
         radeon_cs_flush_indirect(pScrn);
 }
 
@@ -351,6 +369,13 @@ static Bool RADEONCreateScreenResources_KMS(ScreenPtr pScreen)
 	    DeleteCallback(&FlushCallback, radeon_flush_callback, pScrn);
 	    return FALSE;
 	}
+
+	if (!dixRegisterScreenPrivateKey(&radeon_client_private_key, pScreen,
+					 PRIVATE_CLIENT, sizeof(struct radeon_client_priv))) {
+	    DeleteCallback(&FlushCallback, radeon_flush_callback, pScrn);
+	    DeleteCallback(&EventCallback, radeon_event_callback, pScrn);
+	    return FALSE;
+	}
     }
 
     return TRUE;
-- 
2.8.1

_______________________________________________
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

^ permalink raw reply related	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2016-08-02  8:48 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-08-01  9:59 [PATCH xf86-video-ati 1/2] Use EventCallback to avoid flushing every time in the FlushCallback Michel Dänzer
     [not found] ` <1470045560-7220-1-git-send-email-michel-otUistvHUpPR7s880joybQ@public.gmane.org>
2016-08-01  9:59   ` [PATCH xf86-video-ati 2/2] Keep track of damage event related flushes per-client Michel Dänzer
     [not found]     ` <1470045560-7220-2-git-send-email-michel-otUistvHUpPR7s880joybQ@public.gmane.org>
2016-08-01 15:56       ` Deucher, Alexander
2016-08-02  8:48       ` [PATCH xf86-video-ati] Keep track of damage event related flushes per-client v2 Michel Dänzer

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.