mesa: add _mesa_HashFindFreeKeys

_mesa_HashFindFreeKeyBlock function returns a name range, so it cannot be
used to recycle non-consecutive names.

Reviewed-by: Marek Olšák <marek.olsak@amd.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6600>
This commit is contained in:
Pierre-Eric Pelloux-Prayer
2020-08-17 15:10:31 +02:00
parent fefc6d264a
commit 60ffadcbc0
2 changed files with 22 additions and 0 deletions
+19
View File
@@ -446,6 +446,25 @@ _mesa_HashFindFreeKeyBlock(struct _mesa_HashTable *table, GLuint numKeys)
}
bool
_mesa_HashFindFreeKeys(struct _mesa_HashTable *table, GLuint* keys, GLuint numKeys)
{
if (!table->id_alloc) {
GLuint first = _mesa_HashFindFreeKeyBlock(table, numKeys);
for (int i = 0; i < numKeys; i++) {
keys[i] = first + i;
}
return first != 0;
}
for (int i = 0; i < numKeys; i++) {
keys[i] = util_idalloc_alloc(table->id_alloc);
}
return true;
}
/**
* Return the number of entries in the hash table.
*/
+3
View File
@@ -178,6 +178,9 @@ extern void _mesa_HashPrint(const struct _mesa_HashTable *table);
extern GLuint _mesa_HashFindFreeKeyBlock(struct _mesa_HashTable *table, GLuint numKeys);
extern bool
_mesa_HashFindFreeKeys(struct _mesa_HashTable *table, GLuint* keys, GLuint numKeys);
extern GLuint
_mesa_HashNumEntries(const struct _mesa_HashTable *table);