Blob Blame History Raw
From fb3008787193b79909fe922577794f7d4a656922 Mon Sep 17 00:00:00 2001
From: Adam Jackson <ajax@redhat.com>
Date: Thu, 1 Nov 2007 15:18:31 -0400
Subject: [PATCH] Add pixmap eviction call for XAA.

DRI drivers without zero-copy EXT_texture_from_pixmap need to copy the
texture image out of video memory to bind it.  Ick.  Add a hack to
evict XAA pixmaps and disable the pixmap cache when the first texture
is bound.
---
 GL/glx/glxdri.c          |   16 ++++++++++++++++
 hw/xfree86/xaa/xaaInit.c |   24 ++++++++++++++++++++++++
 2 files changed, 40 insertions(+), 0 deletions(-)

diff --git a/GL/glx/glxdri.c b/GL/glx/glxdri.c
index c0da07b..6c4faed 100644
--- a/GL/glx/glxdri.c
+++ b/GL/glx/glxdri.c
@@ -360,6 +360,22 @@
 
     pixmap = (PixmapPtr) glxPixmap->pDraw;
 
+    if (!screen->texOffsetStart) {
+         /* When the GLX_EXT_texture_from_pixmap is used, as it's
+          * implemented here, we want to pull pixmap out of video memory
+          * and into host memory. */
+         extern void XAAEvictPixmaps(void);
+         static int evictedPixmaps = 0;
+
+         if (!evictedPixmaps) {
+             __glXDRIenterServer(GL_FALSE);
+                 if (dlsym(RTLD_DEFAULT, "XAAEvictPixmaps"))
+                      XAAEvictPixmaps();
+             __glXDRIleaveServer(GL_FALSE);
+         evictedPixmaps = TRUE;
+         }
+    }
+
     if (screen->texOffsetStart && screen->texOffset) {
 	__GLXDRIdrawable **texOffsetOverride = screen->texOffsetOverride;
 	int i, firstEmpty = 16;
diff --git a/hw/xfree86/xaa/xaaInit.c b/hw/xfree86/xaa/xaaInit.c
--- a/hw/xfree86/xaa/xaaInit.c
+++ b/hw/xfree86/xaa/xaaInit.c
@@ -88,6 +88,30 @@
     xfree(infoRec);
 }
 
+void
+XAAEvictPixmaps(void)
+{
+    XAAScreenPtr pScreenPriv;
+    XAAInfoRecPtr infoRec;
+    ScreenPtr pScreen;
+    int i;
+
+    xf86MsgVerb(X_INFO, 3, "XAA: Evicting pixmaps\n");
+
+    for (i = 0; i < screenInfo.numScreens; i++) {
+	pScreen = screenInfo.screens[i];
+	infoRec = GET_XAAINFORECPTR_FROM_SCREEN(pScreen);
+
+	pScreenPriv = dixLookupPrivate(&pScreen->devPrivates, XAAScreenKey);
+	infoRec = pScreenPriv->AccelInfoRec;
+
+	infoRec->offscreenDepths = 0;
+	infoRec->Flags &= ~OFFSCREEN_PIXMAPS;
+
+	XAAMoveOutOffscreenPixmaps(pScreen);
+	XAAInvalidatePixmapCache(pScreen);
+    }
+}
 
 Bool 
 XAAInit(ScreenPtr pScreen, XAAInfoRecPtr infoRec)
-- 
1.5.3.4