diff options
author | Brian Paul <brianp@vmware.com> | 2009-11-18 12:40:58 -0700 |
---|---|---|
committer | Brian Paul <brianp@vmware.com> | 2009-11-18 16:52:26 -0700 |
commit | e72df5a9e73020b9227d384ffe8043cd17857a70 (patch) | |
tree | 0c173d1a89147f09e39e66f1abcb3d3cb1c5f249 | |
parent | 9866bd6db8c073dceacf2cd505f6ef2d5879421c (diff) |
mesa: put tex memory functions in new texmem.c file
-rw-r--r-- | src/mesa/SConscript | 1 | ||||
-rw-r--r-- | src/mesa/drivers/common/driverfuncs.c | 5 | ||||
-rw-r--r-- | src/mesa/drivers/dri/intel/intel_tex.c | 7 | ||||
-rw-r--r-- | src/mesa/main/teximage.c | 37 | ||||
-rw-r--r-- | src/mesa/main/teximage.h | 8 | ||||
-rw-r--r-- | src/mesa/main/texmem.c | 74 | ||||
-rw-r--r-- | src/mesa/main/texmem.h | 39 | ||||
-rw-r--r-- | src/mesa/sources.mak | 1 | ||||
-rw-r--r-- | src/mesa/state_tracker/st_cb_texture.c | 1 | ||||
-rw-r--r-- | src/mesa/swrast/s_context.c | 2 |
10 files changed, 127 insertions, 48 deletions
diff --git a/src/mesa/SConscript b/src/mesa/SConscript index 309e0e54d0..becf5d0ba6 100644 --- a/src/mesa/SConscript +++ b/src/mesa/SConscript @@ -97,6 +97,7 @@ if env['platform'] != 'winddk': 'main/texgen.c', 'main/texgetimage.c', 'main/teximage.c', + 'main/texmem.c', 'main/texobj.c', 'main/texparam.c', 'main/texrender.c', diff --git a/src/mesa/drivers/common/driverfuncs.c b/src/mesa/drivers/common/driverfuncs.c index 47645fda05..e27df4b17f 100644 --- a/src/mesa/drivers/common/driverfuncs.c +++ b/src/mesa/drivers/common/driverfuncs.c @@ -36,6 +36,7 @@ #include "main/texformat.h" #include "main/texgetimage.h" #include "main/teximage.h" +#include "main/texmem.h" #include "main/texobj.h" #include "main/texstore.h" #if FEATURE_ARB_vertex_buffer_object @@ -119,10 +120,14 @@ _mesa_init_driver_functions(struct dd_function_table *driver) driver->NewTextureObject = _mesa_new_texture_object; driver->DeleteTexture = _mesa_delete_texture_object; driver->NewTextureImage = _mesa_new_texture_image; + driver->AllocTexImageData = _mesa_alloc_texture_image_data; driver->FreeTexImageData = _mesa_free_texture_image_data; driver->MapTexture = NULL; driver->UnmapTexture = NULL; + driver->MapTextureImage = NULL; + driver->UnmapTextureImage = NULL; + driver->TextureMemCpy = _mesa_memcpy; driver->IsTextureResident = NULL; driver->UpdateTexturePalette = NULL; diff --git a/src/mesa/drivers/dri/intel/intel_tex.c b/src/mesa/drivers/dri/intel/intel_tex.c index eb5e8c3610..70cd1d9d20 100644 --- a/src/mesa/drivers/dri/intel/intel_tex.c +++ b/src/mesa/drivers/dri/intel/intel_tex.c @@ -1,8 +1,9 @@ -#include "swrast/swrast.h" -#include "main/texobj.h" -#include "main/teximage.h" #include "main/mipmap.h" +#include "main/teximage.h" +#include "main/texmem.h" +#include "main/texobj.h" #include "drivers/common/meta.h" +#include "swrast/swrast.h" #include "intel_context.h" #include "intel_mipmap_tree.h" #include "intel_tex.h" diff --git a/src/mesa/main/teximage.c b/src/mesa/main/teximage.c index 8a8f7e5f6e..7f06e6d691 100644 --- a/src/mesa/main/teximage.c +++ b/src/mesa/main/teximage.c @@ -428,43 +428,6 @@ _mesa_new_texture_image( GLcontext *ctx ) /** - * Allocate space for the given texture image. - * This is a fallback called via ctx->Driver.AllocTexImageData(). - */ -GLboolean -_mesa_alloc_texture_image_data(GLcontext *ctx, struct gl_texture_image *tImage) -{ - GLint bytes = _mesa_format_image_size(tImage->TexFormat, tImage->Width, - tImage->Height, tImage->Depth); - tImage->Map.Data = _mesa_align_malloc(bytes, 512); - return tImage->Map.Data != NULL; -} - - -/** - * Free texture image data. - * This function is a fallback called via ctx->Driver.FreeTexImageData(). - * - * \param texImage texture image. - * - * Free the texture image data if it's not marked as client data. - */ -void -_mesa_free_texture_image_data(GLcontext *ctx, - struct gl_texture_image *texImage) -{ - (void) ctx; - - if (texImage->Map.Data && !texImage->IsClientData) { - /* free the old texture data */ - _mesa_align_free(texImage->Map.Data); - } - - texImage->Map.Data = NULL; -} - - -/** * Free texture image. * * \param texImage texture image. diff --git a/src/mesa/main/teximage.h b/src/mesa/main/teximage.h index baadb1dbbc..01c7d776ff 100644 --- a/src/mesa/main/teximage.h +++ b/src/mesa/main/teximage.h @@ -53,14 +53,6 @@ _mesa_new_texture_image( GLcontext *ctx ); extern void _mesa_delete_texture_image( GLcontext *ctx, struct gl_texture_image *teximage ); -extern GLboolean -_mesa_alloc_texture_image_data(GLcontext *ctx, - struct gl_texture_image *texImage); - -extern void -_mesa_free_texture_image_data( GLcontext *ctx, - struct gl_texture_image *texImage ); - extern void _mesa_init_teximage_fields(GLcontext *ctx, GLenum target, diff --git a/src/mesa/main/texmem.c b/src/mesa/main/texmem.c new file mode 100644 index 0000000000..a1848a9cc1 --- /dev/null +++ b/src/mesa/main/texmem.c @@ -0,0 +1,74 @@ +/* + * Mesa 3-D graphics library + * + * Copyright (C) 1999-2008 Brian Paul All Rights Reserved. + * Copyright (C) 2009 VMware, Inc. All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN + * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + + +/** + * \file texmem.c + * Texture memory-related functions. + */ + + +#include "mtypes.h" +#include "formats.h" +#include "imports.h" +#include "texmem.h" + + +/** + * Allocate space for the given texture image. + * This is a fallback called via ctx->Driver.AllocTexImageData(). + */ +GLboolean +_mesa_alloc_texture_image_data(GLcontext *ctx, struct gl_texture_image *tImage) +{ + GLint bytes = _mesa_format_image_size(tImage->TexFormat, tImage->Width, + tImage->Height, tImage->Depth); + /* XXX store data on tImgae->DriverData */ + tImage->Map.Data = _mesa_align_malloc(bytes, 512); + return tImage->Map.Data != NULL; +} + + +/** + * Free texture image data. + * This function is a fallback called via ctx->Driver.FreeTexImageData(). + * + * \param texImage texture image. + * + * Free the texture image data if it's not marked as client data. + */ +void +_mesa_free_texture_image_data(GLcontext *ctx, + struct gl_texture_image *texImage) +{ + (void) ctx; + + if (texImage->Map.Data && !texImage->IsClientData) { + /* free the old texture data */ + /* XXX store data on tImgae->DriverData */ + _mesa_align_free(texImage->Map.Data); + } + + texImage->Map.Data = NULL; +} diff --git a/src/mesa/main/texmem.h b/src/mesa/main/texmem.h new file mode 100644 index 0000000000..69bae31446 --- /dev/null +++ b/src/mesa/main/texmem.h @@ -0,0 +1,39 @@ +/* + * Mesa 3-D graphics library + * + * Copyright (C) 1999-2008 Brian Paul All Rights Reserved. + * Copyright (C) 2009 VMware, Inc. All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN + * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + + +#ifndef TEXMEM_H +#define TEXMEM_H + + +extern GLboolean +_mesa_alloc_texture_image_data(GLcontext *ctx, + struct gl_texture_image *texImage); + +extern void +_mesa_free_texture_image_data( GLcontext *ctx, + struct gl_texture_image *texImage ); + + +#endif /* TEXMEM_H */ diff --git a/src/mesa/sources.mak b/src/mesa/sources.mak index 615a5588ea..f846280c4e 100644 --- a/src/mesa/sources.mak +++ b/src/mesa/sources.mak @@ -74,6 +74,7 @@ MAIN_SOURCES = \ main/texgen.c \ main/texgetimage.c \ main/teximage.c \ + main/texmem.c \ main/texobj.c \ main/texparam.c \ main/texrender.c \ diff --git a/src/mesa/state_tracker/st_cb_texture.c b/src/mesa/state_tracker/st_cb_texture.c index fb409f7a48..b9baabfed3 100644 --- a/src/mesa/state_tracker/st_cb_texture.c +++ b/src/mesa/state_tracker/st_cb_texture.c @@ -42,6 +42,7 @@ #include "main/texformat.h" #include "main/texgetimage.h" #include "main/teximage.h" +#include "main/texmem.h" #include "main/texobj.h" #include "main/texstore.h" diff --git a/src/mesa/swrast/s_context.c b/src/mesa/swrast/s_context.c index 38ee744e99..493cef4eaf 100644 --- a/src/mesa/swrast/s_context.c +++ b/src/mesa/swrast/s_context.c @@ -32,6 +32,7 @@ #include "main/colormac.h" #include "main/mtypes.h" #include "main/teximage.h" +#include "main/texmem.h" #include "shader/prog_parameter.h" #include "shader/prog_statevars.h" #include "swrast.h" @@ -436,6 +437,7 @@ _swrast_validate_texture_images(GLcontext *ctx) return; } + /* Make sure that all the texture images which we need are mapped */ for (u = 0; u < ctx->Const.MaxTextureImageUnits; u++) { if (ctx->Texture.Unit[u]._ReallyEnabled) { struct gl_texture_object *texObj = ctx->Texture.Unit[u]._Current; |