Lines Matching refs:table
53 struct _mesa_HashTable *table = CALLOC_STRUCT(_mesa_HashTable); in _mesa_NewHashTable() local
55 if (table) { in _mesa_NewHashTable()
56 table->ht = _mesa_hash_table_create(NULL, uint_key_hash, in _mesa_NewHashTable()
58 if (table->ht == NULL) { in _mesa_NewHashTable()
59 free(table); in _mesa_NewHashTable()
64 _mesa_hash_table_set_deleted_key(table->ht, uint_key(DELETED_KEY_VALUE)); in _mesa_NewHashTable()
65 simple_mtx_init(&table->Mutex, mtx_plain); in _mesa_NewHashTable()
71 return table; in _mesa_NewHashTable()
85 _mesa_DeleteHashTable(struct _mesa_HashTable *table) in _mesa_DeleteHashTable() argument
87 assert(table); in _mesa_DeleteHashTable()
89 if (_mesa_hash_table_next_entry(table->ht, NULL) != NULL) { in _mesa_DeleteHashTable()
93 _mesa_hash_table_destroy(table->ht, NULL); in _mesa_DeleteHashTable()
94 if (table->id_alloc) { in _mesa_DeleteHashTable()
95 util_idalloc_fini(table->id_alloc); in _mesa_DeleteHashTable()
96 free(table->id_alloc); in _mesa_DeleteHashTable()
99 simple_mtx_destroy(&table->Mutex); in _mesa_DeleteHashTable()
100 FREE(table); in _mesa_DeleteHashTable()
103 static void init_name_reuse(struct _mesa_HashTable *table) in init_name_reuse() argument
105 assert(_mesa_hash_table_num_entries(table->ht) == 0); in init_name_reuse()
106 table->id_alloc = MALLOC_STRUCT(util_idalloc); in init_name_reuse()
107 util_idalloc_init(table->id_alloc, 8); in init_name_reuse()
108 ASSERTED GLuint reserve0 = util_idalloc_alloc(table->id_alloc); in init_name_reuse()
113 _mesa_HashEnableNameReuse(struct _mesa_HashTable *table) in _mesa_HashEnableNameReuse() argument
115 _mesa_HashLockMutex(table); in _mesa_HashEnableNameReuse()
116 init_name_reuse(table); in _mesa_HashEnableNameReuse()
117 _mesa_HashUnlockMutex(table); in _mesa_HashEnableNameReuse()
125 _mesa_HashLookup_unlocked(struct _mesa_HashTable *table, GLuint key) in _mesa_HashLookup_unlocked() argument
129 assert(table); in _mesa_HashLookup_unlocked()
133 return table->deleted_key_data; in _mesa_HashLookup_unlocked()
135 entry = _mesa_hash_table_search_pre_hashed(table->ht, in _mesa_HashLookup_unlocked()
154 _mesa_HashLookup(struct _mesa_HashTable *table, GLuint key) in _mesa_HashLookup() argument
157 _mesa_HashLockMutex(table); in _mesa_HashLookup()
158 res = _mesa_HashLookup_unlocked(table, key); in _mesa_HashLookup()
159 _mesa_HashUnlockMutex(table); in _mesa_HashLookup()
176 _mesa_HashLookupLocked(struct _mesa_HashTable *table, GLuint key) in _mesa_HashLookupLocked() argument
178 return _mesa_HashLookup_unlocked(table, key); in _mesa_HashLookupLocked()
183 _mesa_HashInsert_unlocked(struct _mesa_HashTable *table, GLuint key, void *data) in _mesa_HashInsert_unlocked() argument
188 assert(table); in _mesa_HashInsert_unlocked()
191 if (key > table->MaxKey) in _mesa_HashInsert_unlocked()
192 table->MaxKey = key; in _mesa_HashInsert_unlocked()
195 table->deleted_key_data = data; in _mesa_HashInsert_unlocked()
197 entry = _mesa_hash_table_search_pre_hashed(table->ht, hash, uint_key(key)); in _mesa_HashInsert_unlocked()
201 _mesa_hash_table_insert_pre_hashed(table->ht, hash, uint_key(key), data); in _mesa_HashInsert_unlocked()
220 _mesa_HashInsertLocked(struct _mesa_HashTable *table, GLuint key, void *data, in _mesa_HashInsertLocked() argument
223 _mesa_HashInsert_unlocked(table, key, data); in _mesa_HashInsertLocked()
224 if (!isGenName && table->id_alloc) in _mesa_HashInsertLocked()
225 util_idalloc_reserve(table->id_alloc, key); in _mesa_HashInsertLocked()
239 _mesa_HashInsert(struct _mesa_HashTable *table, GLuint key, void *data, in _mesa_HashInsert() argument
242 _mesa_HashLockMutex(table); in _mesa_HashInsert()
243 _mesa_HashInsert_unlocked(table, key, data); in _mesa_HashInsert()
244 if (!isGenName && table->id_alloc) in _mesa_HashInsert()
245 util_idalloc_reserve(table->id_alloc, key); in _mesa_HashInsert()
246 _mesa_HashUnlockMutex(table); in _mesa_HashInsert()
260 _mesa_HashRemove_unlocked(struct _mesa_HashTable *table, GLuint key) in _mesa_HashRemove_unlocked() argument
264 assert(table); in _mesa_HashRemove_unlocked()
271 assert(!table->InDeleteAll); in _mesa_HashRemove_unlocked()
275 table->deleted_key_data = NULL; in _mesa_HashRemove_unlocked()
277 entry = _mesa_hash_table_search_pre_hashed(table->ht, in _mesa_HashRemove_unlocked()
280 _mesa_hash_table_remove(table->ht, entry); in _mesa_HashRemove_unlocked()
283 if (table->id_alloc) in _mesa_HashRemove_unlocked()
284 util_idalloc_free(table->id_alloc, key); in _mesa_HashRemove_unlocked()
289 _mesa_HashRemoveLocked(struct _mesa_HashTable *table, GLuint key) in _mesa_HashRemoveLocked() argument
291 _mesa_HashRemove_unlocked(table, key); in _mesa_HashRemoveLocked()
295 _mesa_HashRemove(struct _mesa_HashTable *table, GLuint key) in _mesa_HashRemove() argument
297 _mesa_HashLockMutex(table); in _mesa_HashRemove()
298 _mesa_HashRemove_unlocked(table, key); in _mesa_HashRemove()
299 _mesa_HashUnlockMutex(table); in _mesa_HashRemove()
312 _mesa_HashDeleteAll(struct _mesa_HashTable *table, in _mesa_HashDeleteAll() argument
317 _mesa_HashLockMutex(table); in _mesa_HashDeleteAll()
319 table->InDeleteAll = GL_TRUE; in _mesa_HashDeleteAll()
321 hash_table_foreach(table->ht, entry) { in _mesa_HashDeleteAll()
323 _mesa_hash_table_remove(table->ht, entry); in _mesa_HashDeleteAll()
325 if (table->deleted_key_data) { in _mesa_HashDeleteAll()
326 callback(table->deleted_key_data, userData); in _mesa_HashDeleteAll()
327 table->deleted_key_data = NULL; in _mesa_HashDeleteAll()
329 if (table->id_alloc) { in _mesa_HashDeleteAll()
330 util_idalloc_fini(table->id_alloc); in _mesa_HashDeleteAll()
331 free(table->id_alloc); in _mesa_HashDeleteAll()
332 init_name_reuse(table); in _mesa_HashDeleteAll()
335 table->InDeleteAll = GL_FALSE; in _mesa_HashDeleteAll()
337 table->MaxKey = 0; in _mesa_HashDeleteAll()
338 _mesa_HashUnlockMutex(table); in _mesa_HashDeleteAll()
350 hash_walk_unlocked(const struct _mesa_HashTable *table, in hash_walk_unlocked() argument
354 assert(table); in hash_walk_unlocked()
357 hash_table_foreach(table->ht, entry) { in hash_walk_unlocked()
360 if (table->deleted_key_data) in hash_walk_unlocked()
361 callback(table->deleted_key_data, userData); in hash_walk_unlocked()
366 _mesa_HashWalk(const struct _mesa_HashTable *table, in _mesa_HashWalk() argument
371 struct _mesa_HashTable *table2 = (struct _mesa_HashTable *) table; in _mesa_HashWalk()
374 hash_walk_unlocked(table, callback, userData); in _mesa_HashWalk()
379 _mesa_HashWalkLocked(const struct _mesa_HashTable *table, in _mesa_HashWalkLocked() argument
383 hash_walk_unlocked(table, callback, userData); in _mesa_HashWalkLocked()
392 _mesa_HashPrint(const struct _mesa_HashTable *table) in _mesa_HashPrint() argument
394 if (table->deleted_key_data) in _mesa_HashPrint()
395 _mesa_debug(NULL, "%u %p\n", DELETED_KEY_VALUE, table->deleted_key_data); in _mesa_HashPrint()
397 hash_table_foreach(table->ht, entry) { in _mesa_HashPrint()
418 _mesa_HashFindFreeKeyBlock(struct _mesa_HashTable *table, GLuint numKeys) in _mesa_HashFindFreeKeyBlock() argument
421 if (table->id_alloc && numKeys == 1) { in _mesa_HashFindFreeKeyBlock()
422 return util_idalloc_alloc(table->id_alloc); in _mesa_HashFindFreeKeyBlock()
423 } else if (maxKey - numKeys > table->MaxKey) { in _mesa_HashFindFreeKeyBlock()
425 return table->MaxKey + 1; in _mesa_HashFindFreeKeyBlock()
433 if (_mesa_HashLookup_unlocked(table, key)) { in _mesa_HashFindFreeKeyBlock()
453 _mesa_HashFindFreeKeys(struct _mesa_HashTable *table, GLuint* keys, GLuint numKeys) in _mesa_HashFindFreeKeys() argument
455 if (!table->id_alloc) { in _mesa_HashFindFreeKeys()
456 GLuint first = _mesa_HashFindFreeKeyBlock(table, numKeys); in _mesa_HashFindFreeKeys()
464 keys[i] = util_idalloc_alloc(table->id_alloc); in _mesa_HashFindFreeKeys()
475 _mesa_HashNumEntries(const struct _mesa_HashTable *table) in _mesa_HashNumEntries() argument
479 if (table->deleted_key_data) in _mesa_HashNumEntries()
482 count += _mesa_hash_table_num_entries(table->ht); in _mesa_HashNumEntries()