diff options
author | Brian Paul <[email protected]> | 1999-10-09 20:17:07 +0000 |
---|---|---|
committer | Brian Paul <[email protected]> | 1999-10-09 20:17:07 +0000 |
commit | 6e6d4c66bd7fd64162ee453b143d7388bb051444 (patch) | |
tree | 09917c373880e01bfb784558296f449a5e1f7989 /src/mesa/main/texobj.c | |
parent | 7ec8d588abf67934edc78843dee28b9be509f4ca (diff) |
texture units now share default texture objects
Diffstat (limited to 'src/mesa/main/texobj.c')
-rw-r--r-- | src/mesa/main/texobj.c | 22 |
1 files changed, 17 insertions, 5 deletions
diff --git a/src/mesa/main/texobj.c b/src/mesa/main/texobj.c index 0d2f5dd9f21..b95911613b4 100644 --- a/src/mesa/main/texobj.c +++ b/src/mesa/main/texobj.c @@ -1,4 +1,4 @@ -/* $Id: texobj.c,v 1.3 1999/10/08 09:27:11 keithw Exp $ */ +/* $Id: texobj.c,v 1.4 1999/10/09 20:17:07 brianp Exp $ */ /* * Mesa 3-D graphics library @@ -71,6 +71,7 @@ gl_alloc_texture_object( struct gl_shared_state *shared, GLuint name, calloc(1,sizeof(struct gl_texture_object)); if (obj) { /* init the non-zero fields */ + obj->RefCount = 1; obj->Name = name; obj->Dimensions = dimensions; obj->WrapS = GL_REPEAT; @@ -382,8 +383,8 @@ void gl_DeleteTextures( GLcontext *ctx, GLsizei n, const GLuint *texName) GLuint d; for (d = 1 ; d <= 3 ; d++) { if (unit->CurrentD[d]==t) { - unit->CurrentD[d] = ctx->Shared->DefaultD[d][u]; - ctx->Shared->DefaultD[d][u]->RefCount++; + unit->CurrentD[d] = ctx->Shared->DefaultD[d]; + ctx->Shared->DefaultD[d]->RefCount++; t->RefCount--; assert( t->RefCount >= 0 ); } @@ -436,7 +437,7 @@ void gl_BindTexture( GLcontext *ctx, GLenum target, GLuint texName ) return; if (texName == 0) - newTexObj = ctx->Shared->DefaultD[unit][dim]; + newTexObj = ctx->Shared->DefaultD[dim]; else { struct HashTable *hash = ctx->Shared->TexObjects; newTexObj = (struct gl_texture_object *) HashLookup(hash, texName); @@ -453,8 +454,8 @@ void gl_BindTexture( GLcontext *ctx, GLenum target, GLuint texName ) } } - oldTexObj->RefCount--; newTexObj->RefCount++; + texUnit->CurrentD[dim] = newTexObj; /* If we've changed the CurrentD[123] texture object then update the @@ -482,6 +483,17 @@ void gl_BindTexture( GLcontext *ctx, 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 ); + } + gl_free_texture_object(ctx->Shared, oldTexObj); + } + } } |