summaryrefslogtreecommitdiff
path: root/src/mesa/main/texobj.c
diff options
context:
space:
mode:
authorBrian Paul <brian.paul@tungstengraphics.com>2001-04-25 18:21:05 +0000
committerBrian Paul <brian.paul@tungstengraphics.com>2001-04-25 18:21:05 +0000
commit5a2f32b102ab862fb10ba6b89e0b68a71552c674 (patch)
tree71f666f0b9307ed80f58b0515cc8ce7e599843d5 /src/mesa/main/texobj.c
parent830bf652758050bb1c90a77a7f868f2bcf5be60d (diff)
fixed a potential tex obj reference count problem involving multi-texture
Diffstat (limited to 'src/mesa/main/texobj.c')
-rw-r--r--src/mesa/main/texobj.c25
1 files changed, 13 insertions, 12 deletions
diff --git a/src/mesa/main/texobj.c b/src/mesa/main/texobj.c
index fc2915531b..644d99a9e7 100644
--- a/src/mesa/main/texobj.c
+++ b/src/mesa/main/texobj.c
@@ -1,4 +1,4 @@
-/* $Id: texobj.c,v 1.47 2001/04/20 17:16:52 brianp Exp $ */
+/* $Id: texobj.c,v 1.48 2001/04/25 18:21:05 brianp Exp $ */
/*
* Mesa 3-D graphics library
@@ -503,8 +503,10 @@ _mesa_DeleteTextures( GLsizei n, const GLuint *texName)
/* Decrement reference count and delete if zero */
delObj->RefCount--;
- ASSERT( delObj->RefCount >= 0 );
+ ASSERT(delObj->RefCount >= 0);
+
if (delObj->RefCount == 0) {
+ ASSERT(delObj->Name != 0);
if (ctx->Driver.DeleteTexture)
(*ctx->Driver.DeleteTexture)( ctx, delObj );
_mesa_free_texture_object(ctx->Shared, delObj);
@@ -592,7 +594,8 @@ _mesa_BindTexture( GLenum target, GLuint texName )
/* error checking */
if (newTexObj->Dimensions > 0 && newTexObj->Dimensions != targetDim) {
/* the named texture object's dimensions don't match the target */
- _mesa_error( ctx, GL_INVALID_OPERATION, "glBindTexture(wrong dimensionality)" );
+ _mesa_error( ctx, GL_INVALID_OPERATION,
+ "glBindTexture(wrong dimensionality)" );
return;
}
}
@@ -610,7 +613,6 @@ _mesa_BindTexture( GLenum target, GLuint texName )
newTexObj->RefCount++;
-
/* do the actual binding, but first flush outstanding vertices:
*/
FLUSH_VERTICES(ctx, _NEW_TEXTURE);
@@ -636,15 +638,14 @@ _mesa_BindTexture( GLenum target, GLuint texName )
if (ctx->Driver.BindTexture)
(*ctx->Driver.BindTexture)( ctx, target, newTexObj );
- if (oldTexObj->Name > 0) {
- /* never delete default (id=0) texture objects */
- oldTexObj->RefCount--;
- if (oldTexObj->RefCount <= 0) {
- if (ctx->Driver.DeleteTexture) {
- (*ctx->Driver.DeleteTexture)( ctx, oldTexObj );
- }
- _mesa_free_texture_object(ctx->Shared, oldTexObj);
+ oldTexObj->RefCount--;
+ assert(oldTexObj->RefCount >= 0);
+ if (oldTexObj->RefCount == 0) {
+ assert(oldTexObj->Name != 0);
+ if (ctx->Driver.DeleteTexture) {
+ (*ctx->Driver.DeleteTexture)( ctx, oldTexObj );
}
+ _mesa_free_texture_object(ctx->Shared, oldTexObj);
}
}