summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDave Airlie <airlied@redhat.com>2009-11-20 12:15:02 +1000
committerDave Airlie <airlied@itt42.(none)>2009-11-23 13:04:44 +1000
commite20af9c94982ec6487dae42c141d33cf6a7a2eb4 (patch)
tree6c933d03f4b0978751d5b6277f5ff3741f9035a3
parentdd3eab848cf352bb96c3d01fe6028d8a4a8e451e (diff)
radeon: avoid using hw pixmaps when we have little VRAM.
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. v2: add Option "EXALowVRAM" to allow configuring this, value in MBs. Signed-off-by: Dave Airlie <airlied@redhat.com>
-rw-r--r--man/radeon.man9
-rw-r--r--src/radeon.h3
-rw-r--r--src/radeon_dri2.c8
-rw-r--r--src/radeon_exa.c14
-rw-r--r--src/radeon_kms.c15
-rw-r--r--src/radeon_textured_video.c2
6 files changed, 50 insertions, 1 deletions
diff --git a/man/radeon.man b/man/radeon.man
index 47fa9f5e..5f6d9fb0 100644
--- a/man/radeon.man
+++ b/man/radeon.man
@@ -606,6 +606,15 @@ The default is
This option enables modesetting on R/RV4xx chips using atombios.
The default is
.B off.
+.TP
+.BI "Option \*qEXALowVRAM\*q \*q" integer \*q
+(KMS Only) Under kernel modesetting to avoid thrashing pixmaps in/out
+of VRAM on low memory cards, we set a threshhold for the amount of VRAM
+a GPU should have before we start using VRAM to accelerate pixmaps that
+aren't required to be used by the GPU. Value is in MB. This shouldn't
+really be changed apart from testing.
+The default is
+.B 32.
.SH TEXTURED VIDEO ATTRIBUTES
The driver supports the following X11 Xv attributes for Textured Video.
diff --git a/src/radeon.h b/src/radeon.h
index 1e479f4e..0dbaa52a 100644
--- a/src/radeon.h
+++ b/src/radeon.h
@@ -173,6 +173,7 @@ typedef enum {
OPTION_PCIAPER_SIZE,
#ifdef USE_EXA
OPTION_ACCEL_DFS,
+ OPTION_EXA_LOW_VRAM,
#endif
#endif
OPTION_IGNORE_EDID,
@@ -894,6 +895,7 @@ typedef struct {
Bool accelOn;
Bool useEXA;
#ifdef USE_EXA
+ Bool exa_force_create;
XF86ModReqInfo exaReq;
#endif
#ifdef USE_XAA
@@ -1004,6 +1006,7 @@ typedef struct {
uint64_t vram_size;
uint64_t gart_size;
drmmode_rec drmmode;
+ int exa_low_vram_threshhold_mb;
#else
/* fake bool */
Bool cs;
diff --git a/src/radeon_dri2.c b/src/radeon_dri2.c
index db46d27a..56c00a32 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 99a93a4e..b2456c87 100644
--- a/src/radeon_exa.c
+++ b/src/radeon_exa.c
@@ -391,6 +391,12 @@ 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 <= (info->exa_low_vram_threshhold_mb*1024*1024))
+ return NULL;
+ }
+
new_priv = xcalloc(1, sizeof(struct radeon_exa_pixmap_priv));
if (!new_priv)
return NULL;
@@ -421,7 +427,13 @@ 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 <= (info->exa_low_vram_threshhold_mb*1024*1024))
+ return NULL;
+ }
+
if (usage_hint) {
if (info->allowColorTiling) {
if (usage_hint & RADEON_CREATE_PIXMAP_TILING_MACRO)
diff --git a/src/radeon_kms.c b/src/radeon_kms.c
index 5a4255f9..e624f86d 100644
--- a/src/radeon_kms.c
+++ b/src/radeon_kms.c
@@ -67,6 +67,7 @@ const OptionInfoRec RADEONOptions_KMS[] = {
{ OPTION_DRI, "DRI", OPTV_BOOLEAN, {0}, FALSE },
{ OPTION_TVSTD, "TVStandard", OPTV_STRING, {0}, FALSE },
{ OPTION_EXA_VSYNC, "EXAVSync", OPTV_BOOLEAN, {0}, FALSE },
+ { OPTION_EXA_LOW_VRAM, "EXALowVRAM", OPTV_INTEGER, {0}, FALSE },
{ -1, NULL, OPTV_NONE, {0}, FALSE }
};
@@ -450,6 +451,20 @@ Bool RADEONPreInit_KMS(ScrnInfoPtr pScrn, int flags)
(unsigned long long)mminfo.vram_visible);
}
}
+
+ info->exa_low_vram_threshhold_mb = 32;
+ if (xf86GetOptValInteger(info->Options, OPTION_EXA_LOW_VRAM,
+ &(info->exa_low_vram_threshhold_mb))) {
+ if (info->exa_low_vram_threshhold_mb < 0 ||
+ info->exa_low_vram_threshhold_mb > (info->vram_size * 1024 * 1024)) {
+ xf86DrvMsg(pScrn->scrnIndex, X_ERROR,
+ "Illegal Low VRAM limit selected %d, total %lld\n",
+ info->exa_low_vram_threshhold_mb,
+ info->vram_size / (1024*1024));
+ info->exa_low_vram_threshhold_mb = 32;
+ }
+ }
+
RADEONSetPitch(pScrn);
/* Set display resolution */
diff --git a/src/radeon_textured_video.c b/src/radeon_textured_video.c
index 39c75749..7396f6f0 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