[PATCH xf86-video-amdgpu 1/2] glamor: Restore all ScreenRec hooks during CloseScreen

Michel Dänzer michel at daenzer.net
Thu Nov 19 01:05:25 PST 2015


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

(ported from radeon commit 535e5438b2c32f774b9c8c27ee0289b4749548ef)

Signed-off-by: Michel Dänzer <michel.daenzer at amd.com>
---
 src/amdgpu_drv.h             |  8 ++++++++
 src/amdgpu_glamor.c          | 20 ++++++++++++++++++++
 src/amdgpu_glamor.h          |  1 +
 src/amdgpu_glamor_wrappers.c |  5 -----
 src/amdgpu_kms.c             |  1 +
 src/amdgpu_pixmap.h          |  4 ----
 6 files changed, 30 insertions(+), 9 deletions(-)

diff --git a/src/amdgpu_drv.h b/src/amdgpu_drv.h
index 9acd202..0e7b3b5 100644
--- a/src/amdgpu_drv.h
+++ b/src/amdgpu_drv.h
@@ -148,6 +148,10 @@ typedef enum {
 	OPTION_DELETE_DP12,
 } AMDGPUOpts;
 
+#if XF86_CRTC_VERSION >= 5
+#define AMDGPU_PIXMAP_SHARING 1
+#endif
+
 #define AMDGPU_VSYNC_TIMEOUT	20000	/* Maximum wait for VSYNC (in usecs) */
 
 /* Buffer are aligned on 4096 byte boundaries */
@@ -265,6 +269,10 @@ typedef struct {
 		AddTrapsProcPtr SavedAddTraps;
 		UnrealizeGlyphProcPtr SavedUnrealizeGlyph;
 #endif
+#ifdef AMDGPU_PIXMAP_SHARING
+		SharePixmapBackingProcPtr SavedSharePixmapBacking;
+		SetSharedPixmapBackingProcPtr SavedSetSharedPixmapBacking;
+#endif
 	} glamor;
 
 } AMDGPUInfoRec, *AMDGPUInfoPtr;
diff --git a/src/amdgpu_glamor.c b/src/amdgpu_glamor.c
index c979561..a745555 100644
--- a/src/amdgpu_glamor.c
+++ b/src/amdgpu_glamor.c
@@ -353,10 +353,14 @@ Bool amdgpu_glamor_init(ScreenPtr screen)
 		ps->UnrealizeGlyph = SavedUnrealizeGlyph;
 #endif
 
+	info->glamor.SavedCreatePixmap = screen->CreatePixmap;
 	screen->CreatePixmap = amdgpu_glamor_create_pixmap;
+	info->glamor.SavedDestroyPixmap = screen->DestroyPixmap;
 	screen->DestroyPixmap = amdgpu_glamor_destroy_pixmap;
 #ifdef AMDGPU_PIXMAP_SHARING
+	info->glamor.SavedSharePixmapBacking = screen->SharePixmapBacking;
 	screen->SharePixmapBacking = amdgpu_glamor_share_pixmap_backing;
+	info->glamor.SavedSetSharedPixmapBacking = screen->SetSharedPixmapBacking;
 	screen->SetSharedPixmapBacking =
 	    amdgpu_glamor_set_shared_pixmap_backing;
 #endif
@@ -385,6 +389,22 @@ void amdgpu_glamor_finish(ScrnInfoPtr pScrn)
 	}
 }
 
+void
+amdgpu_glamor_fini(ScreenPtr screen)
+{
+	AMDGPUInfoPtr info = AMDGPUPTR(xf86ScreenToScrn(screen));
+
+	if (!info->use_glamor)
+		return;
+
+	screen->CreatePixmap = info->glamor.SavedCreatePixmap;
+	screen->DestroyPixmap = info->glamor.SavedDestroyPixmap;
+#ifdef AMDGPU_PIXMAP_SHARING
+	screen->SharePixmapBacking = info->glamor.SavedSharePixmapBacking;
+	screen->SetSharedPixmapBacking = info->glamor.SavedSetSharedPixmapBacking;
+#endif
+}
+
 XF86VideoAdaptorPtr amdgpu_glamor_xv_init(ScreenPtr pScreen, int num_adapt)
 {
 	return glamor_xv_init(pScreen, num_adapt);
diff --git a/src/amdgpu_glamor.h b/src/amdgpu_glamor.h
index de63005..77e0c21 100644
--- a/src/amdgpu_glamor.h
+++ b/src/amdgpu_glamor.h
@@ -60,6 +60,7 @@ struct amdgpu_pixmap;
 
 Bool amdgpu_glamor_pre_init(ScrnInfoPtr scrn);
 Bool amdgpu_glamor_init(ScreenPtr screen);
+void amdgpu_glamor_fini(ScreenPtr screen);
 void amdgpu_glamor_screen_init(ScreenPtr screen);
 Bool amdgpu_glamor_create_screen_resources(ScreenPtr screen);
 void amdgpu_glamor_free_screen(int scrnIndex, int flags);
diff --git a/src/amdgpu_glamor_wrappers.c b/src/amdgpu_glamor_wrappers.c
index 7ff2f30..6700851 100644
--- a/src/amdgpu_glamor_wrappers.c
+++ b/src/amdgpu_glamor_wrappers.c
@@ -924,8 +924,6 @@ amdgpu_glamor_close_screen(CLOSE_SCREEN_ARGS_DECL)
 	pScreen->CloseScreen = info->glamor.SavedCloseScreen;
 	pScreen->GetImage = info->glamor.SavedGetImage;
 	pScreen->GetSpans = info->glamor.SavedGetSpans;
-	pScreen->CreatePixmap = info->glamor.SavedCreatePixmap;
-	pScreen->DestroyPixmap = info->glamor.SavedDestroyPixmap;
 	pScreen->CopyWindow = info->glamor.SavedCopyWindow;
 	pScreen->ChangeWindowAttributes =
 	    info->glamor.SavedChangeWindowAttributes;
@@ -969,9 +967,6 @@ amdgpu_glamor_screen_init(ScreenPtr screen)
 	info->glamor.SavedGetSpans = screen->GetSpans;
 	screen->GetSpans = amdgpu_glamor_get_spans;
 
-	info->glamor.SavedCreatePixmap = screen->CreatePixmap;
-	info->glamor.SavedDestroyPixmap = screen->DestroyPixmap;
-
 	info->glamor.SavedCopyWindow = screen->CopyWindow;
 	screen->CopyWindow = amdgpu_glamor_copy_window;
 
diff --git a/src/amdgpu_kms.c b/src/amdgpu_kms.c
index 3993591..30bce08 100644
--- a/src/amdgpu_kms.c
+++ b/src/amdgpu_kms.c
@@ -1033,6 +1033,7 @@ static Bool AMDGPUCloseScreen_KMS(CLOSE_SCREEN_ARGS_DECL)
 	if (info->dri2.enabled) {
 		amdgpu_dri2_close_screen(pScreen);
 	}
+	amdgpu_glamor_fini(pScreen);
 	pScrn->vtSema = FALSE;
 	xf86ClearPrimInitDone(info->pEnt->index);
 	pScreen->BlockHandler = info->BlockHandler;
diff --git a/src/amdgpu_pixmap.h b/src/amdgpu_pixmap.h
index a8f204f..7e0e449 100644
--- a/src/amdgpu_pixmap.h
+++ b/src/amdgpu_pixmap.h
@@ -56,10 +56,6 @@ static inline void amdgpu_set_pixmap_private(PixmapPtr pixmap,
 	dixSetPrivate(&pixmap->devPrivates, &amdgpu_pixmap_index, priv);
 }
 
-#if XF86_CRTC_VERSION >= 5
-#define AMDGPU_PIXMAP_SHARING 1
-#endif
-
 static inline void amdgpu_set_pixmap_bo(PixmapPtr pPix, struct amdgpu_buffer *bo)
 {
 	struct amdgpu_pixmap *priv;
-- 
2.6.2



More information about the xorg-driver-ati mailing list