a2af23f
From fb3008787193b79909fe922577794f7d4a656922 Mon Sep 17 00:00:00 2001
042ccfb
From: Adam Jackson <ajax@redhat.com>
a2af23f
Date: Thu, 1 Nov 2007 15:18:31 -0400
a2af23f
Subject: [PATCH] Add pixmap eviction call for XAA.
042ccfb
042ccfb
DRI drivers without zero-copy EXT_texture_from_pixmap need to copy the
042ccfb
texture image out of video memory to bind it.  Ick.  Add a hack to
042ccfb
evict XAA pixmaps and disable the pixmap cache when the first texture
042ccfb
is bound.
042ccfb
---
a2af23f
 GL/glx/glxdri.c          |   16 ++++++++++++++++
a2af23f
 hw/xfree86/xaa/xaaInit.c |   24 ++++++++++++++++++++++++
a2af23f
 2 files changed, 40 insertions(+), 0 deletions(-)
a2af23f
a2af23f
diff --git a/GL/glx/glxdri.c b/GL/glx/glxdri.c
a2af23f
index c0da07b..6c4faed 100644
a2af23f
--- a/GL/glx/glxdri.c
a2af23f
+++ b/GL/glx/glxdri.c
a2af23f
@@ -360,6 +360,22 @@ __glXDRIbindTexImage(__GLXcontext *baseContext,
a2af23f
 
a2af23f
     pixmap = (PixmapPtr) glxPixmap->pDraw;
a2af23f
 
a2af23f
+    if (!screen->texOffsetStart) {
a2af23f
+         /* When the GLX_EXT_texture_from_pixmap is used, as it's
a2af23f
+          * implemented here, we want to pull pixmap out of video memory
a2af23f
+          * and into host memory. */
a2af23f
+         extern void XAAEvictPixmaps(void);
a2af23f
+         static int evictedPixmaps = 0;
a2af23f
+
a2af23f
+         if (!evictedPixmaps) {
a2af23f
+             __glXDRIenterServer(GL_FALSE);
a2af23f
+                 if (dlsym(RTLD_DEFAULT, "XAAEvictPixmaps"))
a2af23f
+                      XAAEvictPixmaps();
a2af23f
+             __glXDRIleaveServer(GL_FALSE);
a2af23f
+         evictedPixmaps = TRUE;
a2af23f
+         }
a2af23f
+    }
a2af23f
+
a2af23f
     if (screen->texOffsetStart && screen->texOffset) {
a2af23f
 	__GLXDRIdrawable **texOffsetOverride = screen->texOffsetOverride;
a2af23f
 	int i, firstEmpty = 16;
a2af23f
diff --git a/hw/xfree86/xaa/xaaInit.c b/hw/xfree86/xaa/xaaInit.c
a2af23f
index 4222425..602b525 100644
a2af23f
--- a/hw/xfree86/xaa/xaaInit.c
a2af23f
+++ b/hw/xfree86/xaa/xaaInit.c
a2af23f
@@ -88,6 +88,30 @@ XAADestroyInfoRec(XAAInfoRecPtr infoRec)
Kristian Høgsberg 22c56dc
     xfree(infoRec);
Kristian Høgsberg 22c56dc
 }
Kristian Høgsberg 22c56dc
 
Kristian Høgsberg ed663d8
+void
Kristian Høgsberg ed663d8
+XAAEvictPixmaps(void)
Kristian Høgsberg 22c56dc
+{
Kristian Høgsberg ed663d8
+    XAAScreenPtr pScreenPriv;
Kristian Høgsberg ed663d8
+    XAAInfoRecPtr infoRec;
Kristian Høgsberg ed663d8
+    ScreenPtr pScreen;
Kristian Høgsberg ed663d8
+    int i;
Kristian Høgsberg 22c56dc
+
Kristian Høgsberg ed663d8
+    xf86MsgVerb(X_INFO, 3, "XAA: Evicting pixmaps\n");
Kristian Høgsberg 22c56dc
+
Kristian Høgsberg ed663d8
+    for (i = 0; i < screenInfo.numScreens; i++) {
Kristian Høgsberg ed663d8
+	pScreen = screenInfo.screens[i];
Kristian Høgsberg ed663d8
+	infoRec = GET_XAAINFORECPTR_FROM_SCREEN(pScreen);
Kristian Høgsberg ed663d8
+
Kristian Høgsberg ed663d8
+	pScreenPriv = pScreen->devPrivates[XAAScreenIndex].ptr;
Kristian Høgsberg ed663d8
+	infoRec = pScreenPriv->AccelInfoRec;
Kristian Høgsberg 8d0b84f
+
Kristian Høgsberg 22c56dc
+	infoRec->offscreenDepths = 0;
Kristian Høgsberg 22c56dc
+	infoRec->Flags &= ~OFFSCREEN_PIXMAPS;
a2af23f
+
Kristian Høgsberg 22c56dc
+	XAAMoveOutOffscreenPixmaps(pScreen);
Kristian Høgsberg 22c56dc
+	XAAInvalidatePixmapCache(pScreen);
Kristian Høgsberg 22c56dc
+    }
Kristian Høgsberg 22c56dc
+}
Kristian Høgsberg 22c56dc
 
Kristian Høgsberg 22c56dc
 Bool 
Kristian Høgsberg 22c56dc
 XAAInit(ScreenPtr pScreen, XAAInfoRecPtr infoRec)
a2af23f
-- 
a2af23f
1.5.3.4
a2af23f