/** * Remove an entry from the map. * The delete callback will be called if the given key/entry is found. * \param user passed to the delete callback as the last param. */ void util_keymap_remove(struct keymap *map, const void *key, void *user) { unsigned key_hash; struct cso_hash_iter iter; struct keymap_item *item; assert(map); if (!map) return; key_hash = hash(key, map->key_size); iter = hash_table_find_iter(map, key, key_hash); if (cso_hash_iter_is_null(iter)) return; item = hash_table_item(iter); assert(item); if (!item) return; map->delete_func(map, item->key, item->value, user); FREE(item->key); FREE(item); map->num_entries--; cso_hash_erase(map->cso, iter); }
void util_surfaces_do_detach(struct util_surfaces *us, struct pipe_surface *ps) { struct pipe_resource *pt = ps->texture; if(pt->target == PIPE_TEXTURE_3D || pt->target == PIPE_TEXTURE_CUBE) { /* or 2D array */ cso_hash_erase(us->u.hash, cso_hash_find(us->u.hash, (ps->u.tex.first_layer << 8) | ps->u.tex.level)); } else us->u.array[ps->u.tex.level] = 0; }
static void regs_hash_destroy(struct cso_hash *hash) { struct cso_hash_iter iter = cso_hash_first_node(hash); while (!cso_hash_iter_is_null(iter)) { scan_register *reg = (scan_register *)cso_hash_iter_data(iter); iter = cso_hash_erase(hash, iter); assert(reg->file < TGSI_FILE_COUNT); FREE(reg); } cso_hash_delete(hash); }
void shaders_cache_destroy(struct shaders_cache *sc) { struct cso_hash_iter iter = cso_hash_first_node(sc->hash); while (!cso_hash_iter_is_null(iter)) { struct cached_shader *cached = (struct cached_shader *)cso_hash_iter_data(iter); cso_delete_fragment_shader(sc->pipe->cso_context, cached->driver_shader); iter = cso_hash_erase(sc->hash, iter); } cso_hash_delete(sc->hash); FREE(sc); }
static void cache_destroy(struct cso_context *cso, struct cso_hash *hash, unsigned processor) { struct cso_hash_iter iter = cso_hash_first_node(hash); while (!cso_hash_iter_is_null(iter)) { void *shader = (void *)cso_hash_iter_data(iter); if (processor == PIPE_SHADER_FRAGMENT) { cso_delete_fragment_shader(cso, shader); } else if (processor == PIPE_SHADER_VERTEX) { cso_delete_vertex_shader(cso, shader); } iter = cso_hash_erase(hash, iter); } cso_hash_delete(hash); }
static INLINE void sanitize_hash(struct cso_hash *hash, enum cso_cache_type type, int max_size, void *user_data) { struct cso_context *ctx = (struct cso_context *)user_data; /* if we're approach the maximum size, remove fourth of the entries * otherwise every subsequent call will go through the same */ int hash_size = cso_hash_size(hash); int max_entries = (max_size > hash_size) ? max_size : hash_size; int to_remove = (max_size < max_entries) * max_entries/4; struct cso_hash_iter iter = cso_hash_first_node(hash); if (hash_size > max_size) to_remove += hash_size - max_size; while (to_remove) { /*remove elements until we're good */ /*fixme: currently we pick the nodes to remove at random*/ void *cso = cso_hash_iter_data(iter); if (delete_cso(ctx, cso, type)) { iter = cso_hash_erase(hash, iter); --to_remove; } else iter = cso_hash_iter_next(iter); } }