[Mesa-dev] [PATCH 2/3] mesa: remove _mesa_alloc_texmemory(), _mesa_free_texmemory()

Brian Paul brian.e.paul at gmail.com
Mon Oct 10 19:27:45 PDT 2011


From: Brian Paul <brianp at vmware.com>

Core Mesa no longer does any texture memory allocation.
---
 src/mesa/drivers/dri/intel/intel_mipmap_tree.c   |    4 +-
 src/mesa/drivers/dri/intel/intel_tex.c           |    2 +-
 src/mesa/drivers/dri/intel/intel_tex_image.c     |    1 +
 src/mesa/drivers/dri/radeon/radeon_mipmap_tree.c |    2 +-
 src/mesa/drivers/dri/radeon/radeon_texture.c     |    7 ++-
 src/mesa/main/teximage.c                         |   46 ----------------------
 src/mesa/main/teximage.h                         |   11 -----
 7 files changed, 9 insertions(+), 64 deletions(-)

diff --git a/src/mesa/drivers/dri/intel/intel_mipmap_tree.c b/src/mesa/drivers/dri/intel/intel_mipmap_tree.c
index 6b15c42..bca77f0 100644
--- a/src/mesa/drivers/dri/intel/intel_mipmap_tree.c
+++ b/src/mesa/drivers/dri/intel/intel_mipmap_tree.c
@@ -436,8 +436,8 @@ intel_miptree_copy_teximage(struct intel_context *intel,
       }
    }
 
-   if (!src_mt) {
-      _mesa_free_texmemory(intelImage->base.Data);
+   if (!src_mt && intelImage->base.Data) {
+      _mesa_align_free(intelImage->base.Data);
       intelImage->base.Data = NULL;
    }
 
diff --git a/src/mesa/drivers/dri/intel/intel_tex.c b/src/mesa/drivers/dri/intel/intel_tex.c
index 7cbd0f5..183bba3 100644
--- a/src/mesa/drivers/dri/intel/intel_tex.c
+++ b/src/mesa/drivers/dri/intel/intel_tex.c
@@ -130,7 +130,7 @@ intel_free_texture_image_buffer(struct gl_context * ctx,
    intel_miptree_release(&intelImage->mt);
 
    if (intelImage->base.Data) {
-      _mesa_free_texmemory(intelImage->base.Data);
+      _mesa_align_free(intelImage->base.Data);
       intelImage->base.Data = NULL;
    }
 
diff --git a/src/mesa/drivers/dri/intel/intel_tex_image.c b/src/mesa/drivers/dri/intel/intel_tex_image.c
index c34b4c5..618368e 100644
--- a/src/mesa/drivers/dri/intel/intel_tex_image.c
+++ b/src/mesa/drivers/dri/intel/intel_tex_image.c
@@ -14,6 +14,7 @@
 #include "main/texgetimage.h"
 #include "main/texobj.h"
 #include "main/teximage.h"
+#include "main/texstore.h"
 
 #include "intel_context.h"
 #include "intel_mipmap_tree.h"
diff --git a/src/mesa/drivers/dri/radeon/radeon_mipmap_tree.c b/src/mesa/drivers/dri/radeon/radeon_mipmap_tree.c
index 8daeb5e..d251670 100644
--- a/src/mesa/drivers/dri/radeon/radeon_mipmap_tree.c
+++ b/src/mesa/drivers/dri/radeon/radeon_mipmap_tree.c
@@ -499,7 +499,7 @@ static void migrate_image_to_miptree(radeon_mipmap_tree *mt,
 		copy_rows(dest, dstlvl->rowstride, image->base.Data, srcrowstride,
 				  rows, srcrowstride);
 
-		_mesa_free_texmemory(image->base.Data);
+		_mesa_align_free(image->base.Data);
 		image->base.Data = 0;
 	}
 
diff --git a/src/mesa/drivers/dri/radeon/radeon_texture.c b/src/mesa/drivers/dri/radeon/radeon_texture.c
index 2d17d30..abe7510 100644
--- a/src/mesa/drivers/dri/radeon/radeon_texture.c
+++ b/src/mesa/drivers/dri/radeon/radeon_texture.c
@@ -106,14 +106,14 @@ void radeonFreeTextureImageBuffer(struct gl_context *ctx, struct gl_texture_imag
 		radeon_miptree_unreference(&image->mt);
 		assert(!image->base.Data);
 	} else {
-		_mesa_free_texture_image_data(ctx, timage);
+		_swrast_free_texture_image_buffer(ctx, timage);
 	}
 	if (image->bo) {
 		radeon_bo_unref(image->bo);
 		image->bo = NULL;
 	}
 	if (image->base.Data) {
-		_mesa_free_texmemory(image->base.Data);
+		_mesa_align_free(image->base.Data);
 		image->base.Data = NULL;
 	}
 
@@ -828,7 +828,8 @@ static void radeon_teximage(
 								texImage->Width,
 								texImage->Height,
 								texImage->Depth);
-			image->base.Data = _mesa_alloc_texmemory(size);
+			image->base.Data = _mesa_align_malloc(size, 512);
+
 			radeon_print(RADEON_TEXTURE, RADEON_VERBOSE,
 					"%s %dd: texObj %p, texImage %p, "
 					" no miptree assigned, using local memory %p\n",
diff --git a/src/mesa/main/teximage.c b/src/mesa/main/teximage.c
index 3a96693..317bab7 100644
--- a/src/mesa/main/teximage.c
+++ b/src/mesa/main/teximage.c
@@ -58,27 +58,6 @@
 
 
 /**
- * We allocate texture memory on 512-byte boundaries so we can use MMX/SSE
- * elsewhere.
- */
-void *
-_mesa_alloc_texmemory(GLsizei bytes)
-{
-   return _mesa_align_malloc(bytes, 512);
-}
-
-
-/**
- * Free texture memory allocated with _mesa_alloc_texmemory()
- */
-void
-_mesa_free_texmemory(void *m)
-{
-   _mesa_align_free(m);
-}
-
-
-/**
  * Return the simple base format for a given internal texture format.
  * For example, given GL_LUMINANCE12_ALPHA4, return GL_LUMINANCE_ALPHA.
  *
@@ -599,31 +578,6 @@ _mesa_new_texture_image( struct gl_context *ctx )
 
 
 /**
- * Free texture image data.
- * This function is a fallback called via ctx->Driver.FreeTextureImageBuffer().
- *
- * \param texImage texture image.
- *
- * Free the texture image data if it's not marked as client data.
- */
-void
-_mesa_free_texture_image_data(struct gl_context *ctx,
-                              struct gl_texture_image *texImage)
-{
-   (void) ctx;
-
-#if 0
-   if (texImage->Data) {
-      /* free the old texture data */
-      _mesa_free_texmemory(texImage->Data);
-   }
-
-   texImage->Data = NULL;
-#endif
-}
-
-
-/**
  * Free a gl_texture_image and associated data.
  * This function is a fallback called via ctx->Driver.DeleteTextureImage().
  *
diff --git a/src/mesa/main/teximage.h b/src/mesa/main/teximage.h
index 6ce0fe9..fd315be 100644
--- a/src/mesa/main/teximage.h
+++ b/src/mesa/main/teximage.h
@@ -36,13 +36,6 @@
 #include "formats.h"
 
 
-extern void *
-_mesa_alloc_texmemory(GLsizei bytes);
-
-extern void
-_mesa_free_texmemory(void *m);
-
-
 /** \name Internal functions */
 /*@{*/
 
@@ -62,10 +55,6 @@ extern void
 _mesa_delete_texture_image( struct gl_context *ctx,
                             struct gl_texture_image *teximage );
 
-extern void
-_mesa_free_texture_image_data( struct gl_context *ctx, 
-			       struct gl_texture_image *texImage );
-
 
 extern void
 _mesa_init_teximage_fields(struct gl_context *ctx, GLenum target,
-- 
1.7.3.4



More information about the mesa-dev mailing list