All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Michel Dänzer" <michel-otUistvHUpPR7s880joybQ@public.gmane.org>
To: amd-gfx-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW@public.gmane.org
Subject: [PATCH xf86-video-amdgpu 03/12] Keep track of damage event related flushes per-client
Date: Thu,  8 Sep 2016 19:02:36 +0900	[thread overview]
Message-ID: <20160908100242.19964-3-michel@daenzer.net> (raw)
In-Reply-To: <20160908100242.19964-1-michel-otUistvHUpPR7s880joybQ@public.gmane.org>

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.

(Ported from radeon commit 121a6de72da5fcf9a32408eff36b2235f3dfbcfe)

Signed-off-by: Michel Dänzer <michel.daenzer@amd.com>
---
 src/amdgpu_drv.h |  5 ++++-
 src/amdgpu_kms.c | 41 +++++++++++++++++++++++++++++++++--------
 2 files changed, 37 insertions(+), 9 deletions(-)

diff --git a/src/amdgpu_drv.h b/src/amdgpu_drv.h
index d2b3a6b..fc6a79d 100644
--- a/src/amdgpu_drv.h
+++ b/src/amdgpu_drv.h
@@ -185,6 +185,10 @@ struct amdgpu_buffer {
 	uint32_t flags;
 };
 
+struct amdgpu_client_priv {
+	uint_fast32_t needs_flush;
+};
+
 typedef struct {
 	EntityInfoPtr pEnt;
 	pciVideoPtr PciInfo;
@@ -210,7 +214,6 @@ typedef struct {
 	/* accel */
 	PixmapPtr fbcon_pixmap;
 	int callback_event_type;
-	uint_fast32_t callback_needs_flush;
 	uint_fast32_t gpu_flushed;
 	uint_fast32_t gpu_synced;
 	Bool use_glamor;
diff --git a/src/amdgpu_kms.c b/src/amdgpu_kms.c
index b1f6bd7..d557313 100644
--- a/src/amdgpu_kms.c
+++ b/src/amdgpu_kms.c
@@ -39,6 +39,7 @@
 
 #include "amdgpu_version.h"
 #include "shadow.h"
+#include <xf86Priv.h>
 
 #include "amdpciids.h"
 
@@ -58,6 +59,8 @@
 
 #include <gbm.h>
 
+static DevScreenPrivateKeyRec amdgpu_client_private_key;
+
 extern SymTabRec AMDGPUChipsets[];
 static Bool amdgpu_setup_kernel_mem(ScreenPtr pScreen);
 
@@ -166,9 +169,9 @@ amdgpuUpdatePacked(ScreenPtr pScreen, shadowBufPtr pBuf)
 }
 
 static Bool
-callback_needs_flush(AMDGPUInfoPtr info)
+callback_needs_flush(AMDGPUInfoPtr info, struct amdgpu_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
@@ -177,20 +180,30 @@ amdgpu_event_callback(CallbackListPtr *list,
 {
 	EventInfoRec *eventinfo = call_data;
 	ScrnInfoPtr pScrn = user_data;
+	ScreenPtr pScreen = pScrn->pScreen;
+	struct amdgpu_client_priv *client_priv =
+		dixLookupScreenPrivate(&eventinfo->client->devPrivates,
+				       &amdgpu_client_private_key, pScreen);
+	struct amdgpu_client_priv *server_priv =
+		dixLookupScreenPrivate(&serverClient->devPrivates,
+				       &amdgpu_client_private_key, pScreen);
 	AMDGPUInfoPtr info = AMDGPUPTR(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;
 		}
 	}
@@ -201,9 +214,14 @@ amdgpu_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 amdgpu_client_priv *client_priv =
+		dixLookupScreenPrivate(&client->devPrivates,
+				       &amdgpu_client_private_key, pScreen);
 	AMDGPUInfoPtr info = AMDGPUPTR(pScrn);
 
-	if (pScrn->vtSema && callback_needs_flush(info))
+	if (pScrn->vtSema && callback_needs_flush(info, client_priv))
 		amdgpu_glamor_flush(pScrn);
 }
 
@@ -273,6 +291,13 @@ static Bool AMDGPUCreateScreenResources_KMS(ScreenPtr pScreen)
 			DeleteCallback(&FlushCallback, amdgpu_flush_callback, pScrn);
 			return FALSE;
 		}
+
+		if (!dixRegisterScreenPrivateKey(&amdgpu_client_private_key, pScreen,
+						 PRIVATE_CLIENT, sizeof(struct amdgpu_client_priv))) {
+			DeleteCallback(&FlushCallback, amdgpu_flush_callback, pScrn);
+			DeleteCallback(&EventCallback, amdgpu_event_callback, pScrn);
+			return FALSE;
+		}
 	}
 
 	return TRUE;
-- 
2.9.3

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

  parent reply	other threads:[~2016-09-08 10:02 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-09-08 10:02 [PATCH xf86-video-amdgpu 01/12] Add explicit AMDGPU_DRM_QUEUE_ERROR define Michel Dänzer
     [not found] ` <20160908100242.19964-1-michel-otUistvHUpPR7s880joybQ@public.gmane.org>
2016-09-08 10:02   ` [PATCH xf86-video-amdgpu 02/12] Use EventCallback to avoid flushing every time in the FlushCallback Michel Dänzer
2016-09-08 10:02   ` Michel Dänzer [this message]
2016-09-08 10:02   ` [PATCH xf86-video-amdgpu 04/12] Wait for pending flips to complete before turning off an output or CRTC Michel Dänzer
2016-09-08 10:02   ` [PATCH xf86-video-amdgpu 05/12] Use drmmode_crtc_scanout_* helpers for RandR 1.4 scanout pixmaps Michel Dänzer
2016-09-08 10:02   ` [PATCH xf86-video-amdgpu 06/12] Handle RandR 1.4 slave dirty updates via amdgpu_drm_queue Michel Dänzer
2016-09-08 10:02   ` [PATCH xf86-video-amdgpu 07/12] Track damage accurately for RandR 1.4 slave scanout Michel Dänzer
2016-09-08 10:02   ` [PATCH xf86-video-amdgpu 08/12] Only copy from screen pixmap to shared pixmap on demand for " Michel Dänzer
2016-09-08 10:02   ` [PATCH xf86-video-amdgpu 09/12] Factor out transform_region helper Michel Dänzer
2016-09-08 10:03   ` [PATCH xf86-video-amdgpu 10/12] Move up amdgpu_scanout_extents_intersect Michel Dänzer
     [not found]     ` <20160908100310.20051-1-michel-otUistvHUpPR7s880joybQ@public.gmane.org>
2016-09-08 10:03       ` [PATCH xf86-video-amdgpu 11/12] Synchronize scanout pixmaps for TearFree Michel Dänzer
2016-09-08 10:03       ` [PATCH xf86-video-amdgpu 12/12] Make TearFree effective with PRIME slave scanout Michel Dänzer
     [not found]         ` <20160908100310.20051-3-michel-otUistvHUpPR7s880joybQ@public.gmane.org>
2016-09-08 12:53           ` Deucher, Alexander

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20160908100242.19964-3-michel@daenzer.net \
    --to=michel-otuistvhuppr7s880joybq@public.gmane.org \
    --cc=amd-gfx-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW@public.gmane.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.