summaryrefslogtreecommitdiffstats
path: root/src/mesa/main/texobj.c
diff options
context:
space:
mode:
authorBrian Paul <[email protected]>2005-02-05 18:12:59 +0000
committerBrian Paul <[email protected]>2005-02-05 18:12:59 +0000
commitbb7d5f8837a9c7658a18dbaf02d52583e29443e3 (patch)
tree9d10947fc7effb79c6594994e3f34dc6d4fd76d8 /src/mesa/main/texobj.c
parent8c3ddf4270ff075ee783a67e5d5d04fa16a9cb45 (diff)
Remove the Shared->TexObjectList pointer and Next field from gl_texture_object.
Was only used by two drivers to walk over all texture objects. Can do that via the hash table instead. Cleaned up some comments for struct gl_texture_object.
Diffstat (limited to 'src/mesa/main/texobj.c')
-rw-r--r--src/mesa/main/texobj.c76
1 files changed, 19 insertions, 57 deletions
diff --git a/src/mesa/main/texobj.c b/src/mesa/main/texobj.c
index 68fe79760d4..1691ae13879 100644
--- a/src/mesa/main/texobj.c
+++ b/src/mesa/main/texobj.c
@@ -157,63 +157,11 @@ _mesa_delete_texture_object( GLcontext *ctx, struct gl_texture_object *texObj )
}
-/**
- * Add the given texture object to the texture object pool.
- */
-void
-_mesa_save_texture_object( GLcontext *ctx, struct gl_texture_object *texObj )
-{
- /* insert into linked list */
- _glthread_LOCK_MUTEX(ctx->Shared->Mutex);
- texObj->Next = ctx->Shared->TexObjectList;
- ctx->Shared->TexObjectList = texObj;
- _glthread_UNLOCK_MUTEX(ctx->Shared->Mutex);
-
- if (texObj->Name > 0) {
- /* insert into hash table */
- _mesa_HashInsert(ctx->Shared->TexObjects, texObj->Name, texObj);
- }
-}
-
-
-/**
- * Remove the given texture object from the texture object pool.
- * Do not deallocate the texture object though.
- */
-void
-_mesa_remove_texture_object( GLcontext *ctx, struct gl_texture_object *texObj )
-{
- struct gl_texture_object *tprev, *tcurr;
-
- _glthread_LOCK_MUTEX(ctx->Shared->Mutex);
- /* unlink from the linked list */
- tprev = NULL;
- tcurr = ctx->Shared->TexObjectList;
- while (tcurr) {
- if (tcurr == texObj) {
- if (tprev) {
- tprev->Next = texObj->Next;
- }
- else {
- ctx->Shared->TexObjectList = texObj->Next;
- }
- break;
- }
- tprev = tcurr;
- tcurr = tcurr->Next;
- }
-
- _glthread_UNLOCK_MUTEX(ctx->Shared->Mutex);
-
- if (texObj->Name > 0) {
- /* remove from hash table */
- _mesa_HashRemove(ctx->Shared->TexObjects, texObj->Name);
- }
-}
/**
* Copy texture object state from one texture object to another.
+ * Use for glPush/PopAttrib.
*
* \param dest destination texture object.
* \param src source texture object.
@@ -620,7 +568,12 @@ _mesa_GenTextures( GLsizei n, GLuint *textures )
_mesa_error(ctx, GL_OUT_OF_MEMORY, "glGenTextures");
return;
}
- _mesa_save_texture_object(ctx, texObj);
+
+ /* insert into hash table */
+ _glthread_LOCK_MUTEX(ctx->Shared->Mutex);
+ _mesa_HashInsert(ctx->Shared->TexObjects, texObj->Name, texObj);
+ _glthread_UNLOCK_MUTEX(ctx->Shared->Mutex);
+
textures[i] = name;
}
@@ -702,8 +655,13 @@ _mesa_DeleteTextures( GLsizei n, const GLuint *textures)
}
ctx->NewState |= _NEW_TEXTURE;
- /* The texture _name_ is now free for re-use. */
- _mesa_remove_texture_object(ctx, delObj);
+ /* The texture _name_ is now free for re-use.
+ * Remove it from the hash table now.
+ */
+ _glthread_LOCK_MUTEX(ctx->Shared->Mutex);
+ _mesa_HashRemove(ctx->Shared->TexObjects, delObj->Name);
+ _glthread_UNLOCK_MUTEX(ctx->Shared->Mutex);
+
/* The actual texture object will not be freed until it's no
* longer bound in any context.
* XXX all RefCount accesses should be protected by a mutex.
@@ -848,7 +806,11 @@ _mesa_BindTexture( GLenum target, GLuint texName )
_mesa_error(ctx, GL_OUT_OF_MEMORY, "glBindTexture");
return;
}
- _mesa_save_texture_object(ctx, newTexObj);
+
+ /* and insert it into hash table */
+ _glthread_LOCK_MUTEX(ctx->Shared->Mutex);
+ _mesa_HashInsert(ctx->Shared->TexObjects, texName, newTexObj);
+ _glthread_UNLOCK_MUTEX(ctx->Shared->Mutex);
}
newTexObj->Target = target;
}