-/* $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
return 0;
}
+ /*
+ * Make this an atomic operation
+ */
+ _glthread_LOCK_MUTEX(ctx->Shared->Mutex);
+
base = _mesa_HashFindFreeKeyBlock(ctx->Shared->DisplayList, range);
if (base) {
/* reserve the list IDs by with empty/dummy lists */
_mesa_HashInsert(ctx->Shared->DisplayList, base+i, make_empty_list());
}
}
+
+ _glthread_UNLOCK_MUTEX(ctx->Shared->Mutex);
+
return base;
}
-/* $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
/*
* Return the key of the "first" entry in the hash table.
- * By calling this function until zero is returned we can get
- * the keys of all entries in the table.
+ * This is used in the course of deleting all display lists when
+ * a context is destroyed.
*/
GLuint _mesa_HashFirstEntry(const struct _mesa_HashTable *table)
{
GLuint pos;
assert(table);
+ _glthread_LOCK_MUTEX(table->Mutex);
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;
+ }
}
+ _glthread_UNLOCK_MUTEX(table->Mutex);
return 0;
}
GLuint _mesa_HashFindFreeKeyBlock(const struct _mesa_HashTable *table, GLuint numKeys)
{
GLuint maxKey = ~((GLuint) 0);
+ _glthread_LOCK_MUTEX(table->Mutex);
if (maxKey - numKeys > table->MaxKey) {
/* the quick solution */
+ _glthread_UNLOCK_MUTEX(table->Mutex);
return table->MaxKey + 1;
}
else {
/* this key not in use, check if we've found enough */
freeCount++;
if (freeCount == numKeys) {
+ _glthread_UNLOCK_MUTEX(table->Mutex);
return freeStart;
}
}
}
/* cannot allocate a block of numKeys consecutive keys */
+ _glthread_UNLOCK_MUTEX(table->Mutex);
return 0;
}
}
-/* $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
}
+_glthread_DECLARE_STATIC_MUTEX(GenTexturesLock);
+
/*
* Execute glGenTextures
return;
}
+
+ /*
+ * This must be atomic (generation and allocation of texture IDs)
+ */
+ _glthread_LOCK_MUTEX(GenTexturesLock);
+
first = _mesa_HashFindFreeKeyBlock(ctx->Shared->TexObjects, n);
/* Return the texture names */
GLuint dims = 0;
(void) gl_alloc_texture_object(ctx->Shared, name, dims);
}
+
+ _glthread_UNLOCK_MUTEX(GenTexturesLock);
}