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:
@@ -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.
|
||||
*/
|
||||
|
||||
@@ -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);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user