added more locking
This commit is contained in:
@@ -1,4 +1,4 @@
|
|||||||
/* $Id: dlist.c,v 1.35 2000/03/19 01:10:11 brianp Exp $ */
|
/* $Id: dlist.c,v 1.36 2000/03/21 17:42:27 brianp Exp $ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Mesa 3-D graphics library
|
* Mesa 3-D graphics library
|
||||||
@@ -3957,6 +3957,11 @@ _mesa_GenLists(GLsizei range )
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Make this an atomic operation
|
||||||
|
*/
|
||||||
|
_glthread_LOCK_MUTEX(ctx->Shared->Mutex);
|
||||||
|
|
||||||
base = _mesa_HashFindFreeKeyBlock(ctx->Shared->DisplayList, range);
|
base = _mesa_HashFindFreeKeyBlock(ctx->Shared->DisplayList, range);
|
||||||
if (base) {
|
if (base) {
|
||||||
/* reserve the list IDs by with empty/dummy lists */
|
/* reserve the list IDs by with empty/dummy lists */
|
||||||
@@ -3965,6 +3970,9 @@ _mesa_GenLists(GLsizei range )
|
|||||||
_mesa_HashInsert(ctx->Shared->DisplayList, base+i, make_empty_list());
|
_mesa_HashInsert(ctx->Shared->DisplayList, base+i, make_empty_list());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
_glthread_UNLOCK_MUTEX(ctx->Shared->Mutex);
|
||||||
|
|
||||||
return base;
|
return base;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -1,4 +1,4 @@
|
|||||||
/* $Id: hash.c,v 1.7 2000/01/31 23:11:39 brianp Exp $ */
|
/* $Id: hash.c,v 1.8 2000/03/21 17:42:27 brianp Exp $ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Mesa 3-D graphics library
|
* Mesa 3-D graphics library
|
||||||
@@ -203,17 +203,21 @@ void _mesa_HashRemove(struct _mesa_HashTable *table, GLuint key)
|
|||||||
|
|
||||||
/*
|
/*
|
||||||
* Return the key of the "first" entry in the hash table.
|
* Return the key of the "first" entry in the hash table.
|
||||||
* By calling this function until zero is returned we can get
|
* This is used in the course of deleting all display lists when
|
||||||
* the keys of all entries in the table.
|
* a context is destroyed.
|
||||||
*/
|
*/
|
||||||
GLuint _mesa_HashFirstEntry(const struct _mesa_HashTable *table)
|
GLuint _mesa_HashFirstEntry(const struct _mesa_HashTable *table)
|
||||||
{
|
{
|
||||||
GLuint pos;
|
GLuint pos;
|
||||||
assert(table);
|
assert(table);
|
||||||
|
_glthread_LOCK_MUTEX(table->Mutex);
|
||||||
for (pos=0; pos < TABLE_SIZE; pos++) {
|
for (pos=0; pos < TABLE_SIZE; pos++) {
|
||||||
if (table->Table[pos])
|
if (table->Table[pos]) {
|
||||||
|
_glthread_UNLOCK_MUTEX(table->Mutex);
|
||||||
return table->Table[pos]->Key;
|
return table->Table[pos]->Key;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
_glthread_UNLOCK_MUTEX(table->Mutex);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -246,8 +250,10 @@ void _mesa_HashPrint(const struct _mesa_HashTable *table)
|
|||||||
GLuint _mesa_HashFindFreeKeyBlock(const struct _mesa_HashTable *table, GLuint numKeys)
|
GLuint _mesa_HashFindFreeKeyBlock(const struct _mesa_HashTable *table, GLuint numKeys)
|
||||||
{
|
{
|
||||||
GLuint maxKey = ~((GLuint) 0);
|
GLuint maxKey = ~((GLuint) 0);
|
||||||
|
_glthread_LOCK_MUTEX(table->Mutex);
|
||||||
if (maxKey - numKeys > table->MaxKey) {
|
if (maxKey - numKeys > table->MaxKey) {
|
||||||
/* the quick solution */
|
/* the quick solution */
|
||||||
|
_glthread_UNLOCK_MUTEX(table->Mutex);
|
||||||
return table->MaxKey + 1;
|
return table->MaxKey + 1;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@@ -265,11 +271,13 @@ GLuint _mesa_HashFindFreeKeyBlock(const struct _mesa_HashTable *table, GLuint nu
|
|||||||
/* this key not in use, check if we've found enough */
|
/* this key not in use, check if we've found enough */
|
||||||
freeCount++;
|
freeCount++;
|
||||||
if (freeCount == numKeys) {
|
if (freeCount == numKeys) {
|
||||||
|
_glthread_UNLOCK_MUTEX(table->Mutex);
|
||||||
return freeStart;
|
return freeStart;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/* cannot allocate a block of numKeys consecutive keys */
|
/* cannot allocate a block of numKeys consecutive keys */
|
||||||
|
_glthread_UNLOCK_MUTEX(table->Mutex);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -1,4 +1,4 @@
|
|||||||
/* $Id: texobj.c,v 1.14 2000/02/12 01:59:19 brianp Exp $ */
|
/* $Id: texobj.c,v 1.15 2000/03/21 17:42:27 brianp Exp $ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Mesa 3-D graphics library
|
* Mesa 3-D graphics library
|
||||||
@@ -325,6 +325,8 @@ void gl_test_texture_object_completeness( const GLcontext *ctx, struct gl_textur
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
_glthread_DECLARE_STATIC_MUTEX(GenTexturesLock);
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Execute glGenTextures
|
* Execute glGenTextures
|
||||||
@@ -342,6 +344,12 @@ _mesa_GenTextures( GLsizei n, GLuint *texName )
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* This must be atomic (generation and allocation of texture IDs)
|
||||||
|
*/
|
||||||
|
_glthread_LOCK_MUTEX(GenTexturesLock);
|
||||||
|
|
||||||
first = _mesa_HashFindFreeKeyBlock(ctx->Shared->TexObjects, n);
|
first = _mesa_HashFindFreeKeyBlock(ctx->Shared->TexObjects, n);
|
||||||
|
|
||||||
/* Return the texture names */
|
/* Return the texture names */
|
||||||
@@ -355,6 +363,8 @@ _mesa_GenTextures( GLsizei n, GLuint *texName )
|
|||||||
GLuint dims = 0;
|
GLuint dims = 0;
|
||||||
(void) gl_alloc_texture_object(ctx->Shared, name, dims);
|
(void) gl_alloc_texture_object(ctx->Shared, name, dims);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
_glthread_UNLOCK_MUTEX(GenTexturesLock);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user