06b805d
From fb3008787193b79909fe922577794f7d4a656922 Mon Sep 17 00:00:00 2001
afcbbe2
From: Adam Jackson <ajax@redhat.com>
06b805d
Date: Thu, 1 Nov 2007 15:18:31 -0400
06b805d
Subject: [PATCH] Add pixmap eviction call for XAA.
afcbbe2
afcbbe2
DRI drivers without zero-copy EXT_texture_from_pixmap need to copy the
afcbbe2
texture image out of video memory to bind it.  Ick.  Add a hack to
afcbbe2
evict XAA pixmaps and disable the pixmap cache when the first texture
afcbbe2
is bound.
afcbbe2
---
06b805d
 GL/glx/glxdri.c          |   16 ++++++++++++++++
06b805d
 hw/xfree86/xaa/xaaInit.c |   24 ++++++++++++++++++++++++
06b805d
 2 files changed, 40 insertions(+), 0 deletions(-)
06b805d
06b805d
diff --git a/GL/glx/glxdri.c b/GL/glx/glxdri.c
06b805d
index c0da07b..6c4faed 100644
06b805d
--- a/GL/glx/glxdri.c
06b805d
+++ b/GL/glx/glxdri.c
9e07a0f
@@ -360,6 +360,22 @@
06b805d
 
06b805d
     pixmap = (PixmapPtr) glxPixmap->pDraw;
06b805d
 
06b805d
+    if (!screen->texOffsetStart) {
06b805d
+         /* When the GLX_EXT_texture_from_pixmap is used, as it's
06b805d
+          * implemented here, we want to pull pixmap out of video memory
06b805d
+          * and into host memory. */
06b805d
+         extern void XAAEvictPixmaps(void);
06b805d
+         static int evictedPixmaps = 0;
06b805d
+
06b805d
+         if (!evictedPixmaps) {
06b805d
+             __glXDRIenterServer(GL_FALSE);
06b805d
+                 if (dlsym(RTLD_DEFAULT, "XAAEvictPixmaps"))
06b805d
+                      XAAEvictPixmaps();
06b805d
+             __glXDRIleaveServer(GL_FALSE);
06b805d
+         evictedPixmaps = TRUE;
06b805d
+         }
06b805d
+    }
06b805d
+
06b805d
     if (screen->texOffsetStart && screen->texOffset) {
06b805d
 	__GLXDRIdrawable **texOffsetOverride = screen->texOffsetOverride;
06b805d
 	int i, firstEmpty = 16;
06b805d
diff --git a/hw/xfree86/xaa/xaaInit.c b/hw/xfree86/xaa/xaaInit.c
06b805d
--- a/hw/xfree86/xaa/xaaInit.c
06b805d
+++ b/hw/xfree86/xaa/xaaInit.c
9e07a0f
@@ -88,6 +88,30 @@
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
+
9e07a0f
+	pScreenPriv = dixLookupPrivate(&pScreen->devPrivates, XAAScreenKey);
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;
06b805d
+
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)
06b805d
-- 
06b805d
1.5.3.4
06b805d