[PATCH] radeon: avoid using hw pixmaps when we have little VRAM.

Dave Airlie airlied at gmail.com
Thu Nov 19 18:21:13 PST 2009


From: Dave Airlie <airlied at redhat.com>

This patch returns NULL for pixmap creation when we are using
mixed pixmaps and the pixmap has a size.

The size check is necessary for the front buffer.

We add a flag to force pixmap creation for certain pixmaps
that need to be hw, like the DRI2 and Xv ones.

Idea from Michel and workarounds from Ben Skeggs.

Signed-off-by: Dave Airlie <airlied at redhat.com>
---
 src/radeon.h                |    1 +
 src/radeon_dri2.c           |    8 ++++++++
 src/radeon_exa.c            |   12 +++++++++++-
 src/radeon_textured_video.c |    2 ++
 4 files changed, 22 insertions(+), 1 deletions(-)

diff --git a/src/radeon.h b/src/radeon.h
index 5cdc3db..c959c56 100644
--- a/src/radeon.h
+++ b/src/radeon.h
@@ -888,6 +888,7 @@ typedef struct {
     Bool              accelOn;
     Bool              useEXA;
 #ifdef USE_EXA
+    Bool              exa_force_create;
     XF86ModReqInfo    exaReq;
 #endif
 #ifdef USE_XAA
diff --git a/src/radeon_dri2.c b/src/radeon_dri2.c
index db46d27..56c00a3 100644
--- a/src/radeon_dri2.c
+++ b/src/radeon_dri2.c
@@ -65,6 +65,8 @@ radeon_dri2_create_buffers(DrawablePtr drawable,
                            int count)
 {
     ScreenPtr pScreen = drawable->pScreen;
+    ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
+    RADEONInfoPtr info = RADEONPTR(pScrn);
     BufferPtr buffers;
     struct dri2_buffer_priv *privates;
     PixmapPtr pixmap, depth_pixmap;
@@ -120,7 +122,9 @@ radeon_dri2_create_buffers(DrawablePtr drawable,
         if (attachments[i] == DRI2BufferDepth) {
             depth_pixmap = pixmap;
         }
+	info->exa_force_create = TRUE;
 	exaMoveInPixmap(pixmap);
+	info->exa_force_create = FALSE;
         driver_priv = exaGetPixmapDriverPrivate(pixmap);
 	r = radeon_gem_get_kernel_name(driver_priv->bo, &buffers[i].name);
 	if (r)
@@ -143,6 +147,8 @@ radeon_dri2_create_buffer(DrawablePtr drawable,
                           unsigned int format)
 {
     ScreenPtr pScreen = drawable->pScreen;
+    ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
+    RADEONInfoPtr info = RADEONPTR(pScrn);
     BufferPtr buffers;
     struct dri2_buffer_priv *privates;
     PixmapPtr pixmap, depth_pixmap;
@@ -198,7 +204,9 @@ radeon_dri2_create_buffer(DrawablePtr drawable,
     if (attachment == DRI2BufferDepth) {
         depth_pixmap = pixmap;
     }
+    info->exa_force_create = TRUE;
     exaMoveInPixmap(pixmap);
+    info->exa_force_create = FALSE;
     driver_priv = exaGetPixmapDriverPrivate(pixmap);
     r = radeon_gem_get_kernel_name(driver_priv->bo, &buffers->name);
     if (r)
diff --git a/src/radeon_exa.c b/src/radeon_exa.c
index 99a93a4..a985624 100644
--- a/src/radeon_exa.c
+++ b/src/radeon_exa.c
@@ -391,6 +391,11 @@ void *RADEONEXACreatePixmap(ScreenPtr pScreen, int size, int align)
     RADEONInfoPtr info = RADEONPTR(pScrn);
     struct radeon_exa_pixmap_priv *new_priv;
 
+    if (info->accel_state->exa->flags & EXA_MIXED_PIXMAPS) {
+        if (size != 0 && !info->exa_force_create && info->vram_size <= (32*1024*1024))
+            return NULL;
+    }
+	    
     new_priv = xcalloc(1, sizeof(struct radeon_exa_pixmap_priv));
     if (!new_priv)
 	return NULL;
@@ -421,7 +426,12 @@ void *RADEONEXACreatePixmap2(ScreenPtr pScreen, int width, int height,
     uint32_t size;
     uint32_t tiling = 0;
     int pixmap_align = 0;
-    
+
+    if (info->accel_state->exa->flags & EXA_MIXED_PIXMAPS) {
+        if (width != 0 && height != 0 && !info->exa_force_create && info->vram_size <= (32*1024*1024))
+            return NULL;
+    }
+
     if (usage_hint) {
 	if (info->allowColorTiling) {
     	    if (usage_hint & RADEON_CREATE_PIXMAP_TILING_MACRO)
diff --git a/src/radeon_textured_video.c b/src/radeon_textured_video.c
index 39c7574..7396f6f 100644
--- a/src/radeon_textured_video.c
+++ b/src/radeon_textured_video.c
@@ -349,7 +349,9 @@ RADEONPutImageTextured(ScrnInfoPtr pScrn,
 #ifdef USE_EXA
     if (info->useEXA) {
 	/* Force the pixmap into framebuffer so we can draw to it. */
+	info->exa_force_create = TRUE;
 	exaMoveInPixmap(pPriv->pPixmap);
+	info->exa_force_create = FALSE;
     }
 #endif
 
-- 
1.6.5.2



More information about the xorg-driver-ati mailing list