diff options
author | Brian Paul <[email protected]> | 2006-03-26 05:22:17 +0000 |
---|---|---|
committer | Brian Paul <[email protected]> | 2006-03-26 05:22:17 +0000 |
commit | ea4fe661d7f3a95d9db17e1475076f1badf8e1a6 (patch) | |
tree | ffc663f1a02dea07254e08620f8ad872fb1a3e20 /src/mesa/swrast/s_context.c | |
parent | 4cbd16ed3ffecd743b4921fab3a65f8510d151c9 (diff) |
merge from texman branchmesa_20060325
Diffstat (limited to 'src/mesa/swrast/s_context.c')
-rw-r--r-- | src/mesa/swrast/s_context.c | 81 |
1 files changed, 81 insertions, 0 deletions
diff --git a/src/mesa/swrast/s_context.c b/src/mesa/swrast/s_context.c index ee15813f3c6..ea283a19430 100644 --- a/src/mesa/swrast/s_context.c +++ b/src/mesa/swrast/s_context.c @@ -32,6 +32,7 @@ #include "colormac.h" #include "mtypes.h" #include "program.h" +#include "teximage.h" #include "swrast.h" #include "s_blend.h" #include "s_context.h" @@ -372,6 +373,83 @@ _swrast_validate_blend_func( GLcontext *ctx, GLuint n, } +/** + * Make sure we have texture image data for all the textures we may need + * for subsequent rendering. + */ +static void +_swrast_validate_texture_images(GLcontext *ctx) +{ + SWcontext *swrast = SWRAST_CONTEXT(ctx); + GLuint u; + + if (!swrast->ValidateTextureImage || !ctx->Texture._EnabledUnits) { + /* no textures enabled, or no way to validate images! */ + return; + } + + for (u = 0; u < ctx->Const.MaxTextureImageUnits; u++) { + if (ctx->Texture.Unit[u]._ReallyEnabled) { + struct gl_texture_object *texObj = ctx->Texture.Unit[u]._Current; + ASSERT(texObj); + if (texObj) { + GLuint numFaces = (texObj->Target == GL_TEXTURE_CUBE_MAP) ? 6 : 1; + GLuint face; + for (face = 0; face < numFaces; face++) { + GLuint lvl; + for (lvl = texObj->BaseLevel; lvl <= texObj->_MaxLevel; lvl++) { + struct gl_texture_image *texImg = texObj->Image[face][lvl]; + if (texImg && !texImg->Data) { + swrast->ValidateTextureImage(ctx, texObj, face, lvl); + ASSERT(texObj->Image[face][lvl]->Data); + } + } + } + } + } + } +} + + +/** + * Free the texture image data attached to all currently enabled + * textures. Meant to be called by device drivers when transitioning + * from software to hardware rendering. + */ +void +_swrast_eject_texture_images(GLcontext *ctx) +{ + GLuint u; + + if (!ctx->Texture._EnabledUnits) { + /* no textures enabled */ + return; + } + + for (u = 0; u < ctx->Const.MaxTextureImageUnits; u++) { + if (ctx->Texture.Unit[u]._ReallyEnabled) { + struct gl_texture_object *texObj = ctx->Texture.Unit[u]._Current; + ASSERT(texObj); + if (texObj) { + GLuint numFaces = (texObj->Target == GL_TEXTURE_CUBE_MAP) ? 6 : 1; + GLuint face; + for (face = 0; face < numFaces; face++) { + GLuint lvl; + for (lvl = texObj->BaseLevel; lvl <= texObj->_MaxLevel; lvl++) { + struct gl_texture_image *texImg = texObj->Image[face][lvl]; + if (texImg && texImg->Data) { + _mesa_free_texmemory(texImg->Data); + texImg->Data = NULL; + } + } + } + } + } + } +} + + + static void _swrast_sleep( GLcontext *ctx, GLbitfield new_state ) { @@ -456,6 +534,9 @@ _swrast_validate_derived( GLcontext *ctx ) if (swrast->NewState & _NEW_TEXTURE) _swrast_update_texture_samplers( ctx ); + if (swrast->NewState & (_NEW_TEXTURE | _NEW_PROGRAM)) + _swrast_validate_texture_images( ctx ); + swrast->NewState = 0; swrast->StateChanges = 0; swrast->InvalidateState = _swrast_invalidate_state; |