summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEric Anholt <eric@anholt.net>2007-02-26 09:54:04 -0800
committerEric Anholt <eric@anholt.net>2007-02-26 09:54:04 -0800
commit5732dd7221b7bb24bf21e16066f014a0c7cb6b2a (patch)
tree4a0d9944d6b2beb69b65e17fa2fa5a42eabeb284
parentaeeae1b40fc012bcc01fcd2243d4993de819b7cf (diff)
Fix some texture memory allocation issues.
-rw-r--r--src/i830.h1
-rw-r--r--src/i830_dri.c36
-rw-r--r--src/i830_driver.c21
-rw-r--r--src/i830_memory.c4
4 files changed, 33 insertions, 29 deletions
diff --git a/src/i830.h b/src/i830.h
index 38d49bed..08d9e3ed 100644
--- a/src/i830.h
+++ b/src/i830.h
@@ -579,6 +579,7 @@ void i830_describe_allocations(ScrnInfoPtr pScrn, int verbosity,
const char *prefix);
void i830_reset_allocations(ScrnInfoPtr pScrn);
void i830_free_3d_memory(ScrnInfoPtr pScrn);
+void i830_free_memory(ScrnInfoPtr pScrn, i830_memory *mem);
extern long I830CheckAvailableMemory(ScrnInfoPtr pScrn);
Bool i830_allocate_2d_memory(ScrnInfoPtr pScrn);
Bool i830_allocate_3d_memory(ScrnInfoPtr pScrn);
diff --git a/src/i830_dri.c b/src/i830_dri.c
index 9ea86aea..e14880f6 100644
--- a/src/i830_dri.c
+++ b/src/i830_dri.c
@@ -654,21 +654,18 @@ I830DRIScreenInit(ScreenPtr pScreen)
return FALSE;
}
pI830->drmMinor = version->version_minor;
- if (!(pI830->mmModeFlags & I830_KERNEL_TEX)) {
-#ifdef XF86DRI_MM
- if ((version->version_major > 1) ||
- ((version->version_minor >= 7) &&
- (version->version_major == 1))) {
- pI830->mmModeFlags |= I830_KERNEL_MM;
- } else
-#endif
- {
- pI830->mmModeFlags |= I830_KERNEL_TEX;
- }
- } else {
- xf86DrvMsg(pScreen->myNum, X_INFO,
- "Not enabling the DRM memory manager.\n");
- }
+ if (version->version_minor < 7) {
+ if (pI830->mmModeFlags & I830_KERNEL_MM) {
+ xf86DrvMsg(pScrn->scrnIndex, X_WARNING,
+ "DRM version %d.%d older than required 1.7 for "
+ "DRM memory manager. Disabling.\n",
+ version->version_major, version->version_minor);
+ pI830->mmModeFlags &= ~I830_KERNEL_MM;
+
+ i830_free_memory(pScrn, pI830->memory_manager);
+ pI830->memory_manager = NULL;
+ }
+ }
drmFreeVersion(version);
}
}
@@ -1464,8 +1461,13 @@ I830UpdateDRIBuffers(ScrnInfoPtr pScrn, drmI830Sarea *sarea)
sarea->back_size = pI830->back_buffer->size;
sarea->depth_offset = pI830->depth_buffer->offset;
sarea->depth_size = pI830->depth_buffer->size;
- sarea->tex_offset = pI830->textures->offset;
- sarea->tex_size = pI830->textures->size;
+ if (pI830->textures != NULL) {
+ sarea->tex_offset = pI830->textures->offset;
+ sarea->tex_size = pI830->textures->size;
+ } else {
+ sarea->tex_offset = 0;
+ sarea->tex_size = 0;
+ }
sarea->log_tex_granularity = pI830->TexGranularity;
sarea->pitch = pScrn->displayWidth;
sarea->virtualX = pScrn->virtualX;
diff --git a/src/i830_driver.c b/src/i830_driver.c
index c660a354..4746c72f 100644
--- a/src/i830_driver.c
+++ b/src/i830_driver.c
@@ -1229,8 +1229,11 @@ I830PreInit(ScrnInfoPtr pScrn, int flags)
if (!pI830->directRenderingDisabled) {
Bool tmp = FALSE;
- if (IS_I965G(pI830))
- pI830->mmModeFlags |= I830_KERNEL_TEX;
+ pI830->mmModeFlags |= I830_KERNEL_TEX;
+#ifdef XF86DRI_MM
+ if (!IS_I965G(pI830))
+ pI830->mmModeFlags |= I830_KERNEL_MM;
+#endif
from = X_PROBED;
if (xf86GetOptValBool(pI830->Options,
@@ -1242,14 +1245,12 @@ I830PreInit(ScrnInfoPtr pScrn, int flags)
pI830->mmModeFlags &= ~I830_KERNEL_TEX;
}
}
- if (from == X_CONFIG ||
- (pI830->mmModeFlags & I830_KERNEL_TEX)) {
- xf86DrvMsg(pScrn->scrnIndex, from,
- "Will %stry to allocate texture pool "
- "for old Mesa 3D driver.\n",
- (pI830->mmModeFlags & I830_KERNEL_TEX) ?
- "" : "not ");
- }
+ xf86DrvMsg(pScrn->scrnIndex, from,
+ "Will %stry to allocate texture pool "
+ "for old Mesa 3D driver.\n",
+ (pI830->mmModeFlags & I830_KERNEL_TEX) ?
+ "" : "not ");
+
pI830->mmSize = I830_MM_MAXSIZE;
from = X_INFO;
if (xf86GetOptValInteger(pI830->Options, OPTION_INTELMMSIZE,
diff --git a/src/i830_memory.c b/src/i830_memory.c
index 74610706..3e84a900 100644
--- a/src/i830_memory.c
+++ b/src/i830_memory.c
@@ -180,7 +180,7 @@ i830_unbind_memory(ScrnInfoPtr pScrn, i830_memory *mem)
}
}
-static void
+void
i830_free_memory(ScrnInfoPtr pScrn, i830_memory *mem)
{
if (mem == NULL)
@@ -1133,7 +1133,7 @@ i830_allocate_texture_memory(ScrnInfoPtr pScrn)
if (pI830->mmModeFlags & I830_KERNEL_MM) {
pI830->memory_manager =
i830_allocate_aperture(pScrn, "DRI memory manager",
- pI830->mmSize, GTT_PAGE_SIZE,
+ pI830->mmSize * KB(1), GTT_PAGE_SIZE,
ALIGN_BOTH_ENDS);
/* XXX: try memory manager size backoff here? */
if (pI830->memory_manager == NULL)