mesa/hash: switch to simple_mtx

simple_mtx are faster and smaller (4 bytes instead of 8) so switch to using them.

Reviewed-by: Marek Olšák <marek.olsak@amd.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/9533>
This commit is contained in:
Pierre-Eric Pelloux-Prayer 2021-03-10 12:04:39 +01:00 committed by Marge Bot
parent 0a78c22666
commit e26f261c7e
2 changed files with 6 additions and 5 deletions

View File

@ -62,7 +62,7 @@ _mesa_NewHashTable(void)
}
_mesa_hash_table_set_deleted_key(table->ht, uint_key(DELETED_KEY_VALUE));
mtx_init(&table->Mutex, mtx_plain);
simple_mtx_init(&table->Mutex, mtx_plain);
}
else {
_mesa_error_no_memory(__func__);
@ -96,7 +96,7 @@ _mesa_DeleteHashTable(struct _mesa_HashTable *table)
free(table->id_alloc);
}
mtx_destroy(&table->Mutex);
simple_mtx_destroy(&table->Mutex);
free(table);
}

View File

@ -37,6 +37,7 @@
#include "glheader.h"
#include "c11/threads.h"
#include "util/simple_mtx.h"
struct util_idalloc;
@ -103,7 +104,7 @@ uint_key(GLuint id)
struct _mesa_HashTable {
struct hash_table *ht;
GLuint MaxKey; /**< highest key inserted so far */
mtx_t Mutex; /**< mutual exclusion lock */
simple_mtx_t Mutex; /**< mutual exclusion lock */
GLboolean InDeleteAll; /**< Debug check */
/* Used when name reuse is enabled */
struct util_idalloc* id_alloc;
@ -136,7 +137,7 @@ static inline void
_mesa_HashLockMutex(struct _mesa_HashTable *table)
{
assert(table);
mtx_lock(&table->Mutex);
simple_mtx_lock(&table->Mutex);
}
@ -149,7 +150,7 @@ static inline void
_mesa_HashUnlockMutex(struct _mesa_HashTable *table)
{
assert(table);
mtx_unlock(&table->Mutex);
simple_mtx_unlock(&table->Mutex);
}
extern void *_mesa_HashLookupLocked(struct _mesa_HashTable *table, GLuint key);