[PATCH] dri2: Register the DRI2DrawableType after server regeneration

Chris Wilson chris at chris-wilson.co.uk
Thu Aug 25 04:50:33 PDT 2011


The Resource database is reset upon regeneration and so the dri2 module
needs to re-register its RESTYPE for the drawable or else it will
clobber the next unsuspecting user of the database. Fortunately, DRI2 is
loaded late in the initialisation sequence and was last up until
xf86-video-intel started using the Resource database to track
outstanding swaps...

Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk>
---
 hw/xfree86/dri2/dri2.c |   11 +++++++++--
 1 files changed, 9 insertions(+), 2 deletions(-)

diff --git a/hw/xfree86/dri2/dri2.c b/hw/xfree86/dri2/dri2.c
index 561237d..535078a 100644
--- a/hw/xfree86/dri2/dri2.c
+++ b/hw/xfree86/dri2/dri2.c
@@ -1102,6 +1102,7 @@ DRI2SetWindowPixmap(WindowPtr pWin, PixmapPtr pPixmap)
 Bool
 DRI2ScreenInit(ScreenPtr pScreen, DRI2InfoPtr info)
 {
+    static int dri2_server_generation;
     DRI2ScreenPtr ds;
     const char* driverTypeNames[] = {
 	"DRI", /* DRI2DriverDRI */
@@ -1119,6 +1120,14 @@ DRI2ScreenInit(ScreenPtr pScreen, DRI2InfoPtr info)
         return FALSE;
     }
 
+    if (serverGeneration != dri2_server_generation) {
+	dri2DrawableRes = CreateNewResourceType(DRI2DrawableGone, "DRI2Drawable");
+	if (!dri2DrawableRes)
+	    return FALSE;
+
+	dri2_server_generation = serverGeneration;
+    }
+
     if (!dixRegisterPrivateKey(&dri2ScreenPrivateKeyRec, PRIVATE_SCREEN, 0))
 	return FALSE;
 
@@ -1227,8 +1236,6 @@ DRI2Setup(pointer module, pointer opts, int *errmaj, int *errmin)
 {
     static Bool setupDone = FALSE;
 
-    dri2DrawableRes = CreateNewResourceType(DRI2DrawableGone, "DRI2Drawable");
-
     if (!setupDone)
     {
 	setupDone = TRUE;
-- 
1.7.5.4



More information about the xorg-devel mailing list