diff --git a/src/mesa/main/hash.c b/src/mesa/main/hash.c index e0d71dad3bf..2f36fc84425 100644 --- a/src/mesa/main/hash.c +++ b/src/mesa/main/hash.c @@ -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. */ diff --git a/src/mesa/main/hash.h b/src/mesa/main/hash.h index a0411651384..98647674467 100644 --- a/src/mesa/main/hash.h +++ b/src/mesa/main/hash.h @@ -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);