aboutsummaryrefslogtreecommitdiffstats
path: root/src/mesa/main/texstate.c
diff options
context:
space:
mode:
authorBrian <[email protected]>2007-08-16 10:05:00 +0100
committerBrian <[email protected]>2007-08-16 10:05:00 +0100
commit145d762044f795bf9d68f28079cc5e5d3056920e (patch)
tree643c2eed8a0cc8522f1fdf89b795f8167b6f3ef0 /src/mesa/main/texstate.c
parent2193c4de83acfc3268ccca7b54b00543307e0baa (diff)
Bring over the texobj refcounting changes from mesa_7_0_branch
Diffstat (limited to 'src/mesa/main/texstate.c')
-rw-r--r--src/mesa/main/texstate.c46
1 files changed, 29 insertions, 17 deletions
diff --git a/src/mesa/main/texstate.c b/src/mesa/main/texstate.c
index 08d083d201b..91ee6513dcf 100644
--- a/src/mesa/main/texstate.c
+++ b/src/mesa/main/texstate.c
@@ -119,20 +119,20 @@ _mesa_copy_texture_state( const GLcontext *src, GLcontext *dst )
/* copy texture object bindings, not contents of texture objects */
_mesa_lock_context_textures(dst);
- _mesa_reference_texobj(&dst->Texture.Unit[i].Current1D,
- src->Texture.Unit[i].Current1D);
- _mesa_reference_texobj(&dst->Texture.Unit[i].Current2D,
- src->Texture.Unit[i].Current2D);
- _mesa_reference_texobj(&dst->Texture.Unit[i].Current3D,
- src->Texture.Unit[i].Current3D);
- _mesa_reference_texobj(&dst->Texture.Unit[i].CurrentCubeMap,
- src->Texture.Unit[i].CurrentCubeMap);
- _mesa_reference_texobj(&dst->Texture.Unit[i].CurrentRect,
- src->Texture.Unit[i].CurrentRect);
- _mesa_reference_texobj(&dst->Texture.Unit[i].Current1DArray,
- src->Texture.Unit[i].Current1DArray);
- _mesa_reference_texobj(&dst->Texture.Unit[i].Current2DArray,
- src->Texture.Unit[i].Current2DArray);
+ _mesa_reference_texobj(&dst->Texture.Unit[i].Current1D,
+ src->Texture.Unit[i].Current1D);
+ _mesa_reference_texobj(&dst->Texture.Unit[i].Current2D,
+ src->Texture.Unit[i].Current2D);
+ _mesa_reference_texobj(&dst->Texture.Unit[i].Current3D,
+ src->Texture.Unit[i].Current3D);
+ _mesa_reference_texobj(&dst->Texture.Unit[i].CurrentCubeMap,
+ src->Texture.Unit[i].CurrentCubeMap);
+ _mesa_reference_texobj(&dst->Texture.Unit[i].CurrentRect,
+ src->Texture.Unit[i].CurrentRect);
+ _mesa_reference_texobj(&dst->Texture.Unit[i].Current1DArray,
+ src->Texture.Unit[i].Current1DArray);
+ _mesa_reference_texobj(&dst->Texture.Unit[i].Current2DArray,
+ src->Texture.Unit[i].Current2DArray);
_mesa_unlock_context_textures(dst);
}
@@ -3201,7 +3201,19 @@ _mesa_init_texture(GLcontext *ctx)
void
_mesa_free_texture_data(GLcontext *ctx)
{
- GLuint i;
+ GLuint u;
+
+ /* unreference current textures */
+ for (u = 0; u < MAX_TEXTURE_IMAGE_UNITS; u++) {
+ struct gl_texture_unit *unit = ctx->Texture.Unit + u;
+ _mesa_reference_texobj(&unit->Current1D, NULL);
+ _mesa_reference_texobj(&unit->Current2D, NULL);
+ _mesa_reference_texobj(&unit->Current3D, NULL);
+ _mesa_reference_texobj(&unit->CurrentCubeMap, NULL);
+ _mesa_reference_texobj(&unit->CurrentRect, NULL);
+ _mesa_reference_texobj(&unit->Current1DArray, NULL);
+ _mesa_reference_texobj(&unit->Current2DArray, NULL);
+ }
/* Free proxy texture objects */
(ctx->Driver.DeleteTexture)(ctx, ctx->Texture.Proxy1D );
@@ -3212,8 +3224,8 @@ _mesa_free_texture_data(GLcontext *ctx)
(ctx->Driver.DeleteTexture)(ctx, ctx->Texture.Proxy1DArray );
(ctx->Driver.DeleteTexture)(ctx, ctx->Texture.Proxy2DArray );
- for (i = 0; i < MAX_TEXTURE_IMAGE_UNITS; i++)
- _mesa_free_colortable_data( &ctx->Texture.Unit[i].ColorTable );
+ for (u = 0; u < MAX_TEXTURE_IMAGE_UNITS; u++)
+ _mesa_free_colortable_data( &ctx->Texture.Unit[u].ColorTable );
_mesa_TexEnvProgramCacheDestroy( ctx );
}