static boolean epilog( struct tgsi_iterate_context *iter ) { struct sanity_check_ctx *ctx = (struct sanity_check_ctx *) iter; /* There must be an END instruction somewhere. */ if (ctx->index_of_END == ~0) { report_error( ctx, "Missing END instruction" ); } /* Check if all declared registers were used. */ { struct cso_hash_iter iter = cso_hash_first_node(ctx->regs_decl); while (!cso_hash_iter_is_null(iter)) { scan_register *reg = (scan_register *)cso_hash_iter_data(iter); if (!is_register_used(ctx, reg) && !is_ind_register_used(ctx, reg)) { report_warning( ctx, "%s[%u]: Register never used", file_names[reg->file], reg->indices[0] ); } iter = cso_hash_iter_next(iter); } } /* Print totals, if any. */ if (ctx->errors || ctx->warnings) debug_printf( "%u errors, %u warnings\n", ctx->errors, ctx->warnings ); return TRUE; }
void util_surfaces_destroy(struct util_surfaces *us, struct pipe_resource *pt, void (*destroy_surface) (struct pipe_surface *)) { if(pt->target == PIPE_TEXTURE_3D || pt->target == PIPE_TEXTURE_CUBE) { /* or 2D array */ if(us->u.hash) { struct cso_hash_iter iter; iter = cso_hash_first_node(us->u.hash); while (!cso_hash_iter_is_null(iter)) { destroy_surface(cso_hash_iter_data(iter)); iter = cso_hash_iter_next(iter); } cso_hash_delete(us->u.hash); us->u.hash = NULL; } } else { if(us->u.array) { unsigned i; for(i = 0; i <= pt->last_level; ++i) { struct pipe_surface *ps = us->u.array[i]; if(ps) destroy_surface(ps); } FREE(us->u.array); us->u.array = NULL; } } }
/** * Remove all entries from the map, calling the delete callback for each. * \param user passed to the delete callback as the last param. */ void util_keymap_remove_all(struct keymap *map, void *user) { struct cso_hash_iter iter; struct keymap_item *item; assert(map); if (!map) return; iter = cso_hash_first_node(map->cso); while (!cso_hash_iter_is_null(iter)) { item = (struct keymap_item *) cso_hash_take(map->cso, cso_hash_iter_key(iter)); map->delete_func(map, item->key, item->value, user); FREE(item->key); FREE(item); iter = cso_hash_first_node(map->cso); } }
static INLINE void delete_translates(struct translate_cache *cache) { struct cso_hash *hash = cache->hash; struct cso_hash_iter iter = cso_hash_first_node(hash); while (!cso_hash_iter_is_null(iter)) { struct translate *state = (struct translate*)cso_hash_iter_data(iter); iter = cso_hash_iter_next(iter); if (state) { state->release(state); } } }
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 cso_for_each_state(struct cso_cache *sc, enum cso_cache_type type, cso_state_callback func, void *user_data) { struct cso_hash *hash = _cso_hash_for_type(sc, type); struct cso_hash_iter iter; iter = cso_hash_first_node(hash); while (!cso_hash_iter_is_null(iter)) { void *state = cso_hash_iter_data(iter); iter = cso_hash_iter_next(iter); if (state) { func(state, user_data); } } }
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 boolean is_any_register_declared( struct sanity_check_ctx *ctx, uint file ) { struct cso_hash_iter iter = cso_hash_first_node(ctx->regs_decl); while (!cso_hash_iter_is_null(iter)) { scan_register *reg = (scan_register *)cso_hash_iter_data(iter); if (reg->file == file) return TRUE; iter = cso_hash_iter_next(iter); } return FALSE; }
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_cb(struct cso_hash *hash, enum cso_cache_type type, int max_size, void *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; 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*/ struct cso_hash_iter iter = cso_hash_first_node(hash); void *cso = cso_hash_take(hash, cso_hash_iter_key(iter)); delete_cso(cso, type); --to_remove; } }
void font_destroy(struct vg_font *font) { struct vg_context *ctx = vg_current_context(); struct cso_hash_iter iter; vg_context_remove_object(ctx, &font->base); iter = cso_hash_first_node(font->glyphs); while (!cso_hash_iter_is_null(iter)) { struct vg_glyph *glyph = (struct vg_glyph *) cso_hash_iter_data(iter); FREE(glyph); iter = cso_hash_iter_next(iter); } cso_hash_delete(font->glyphs); vg_free_object(&font->base); FREE(font); }
void cso_for_each_state(struct cso_cache *sc, enum cso_cache_type type, cso_state_callback func, void *user_data) { struct cso_hash *hash = 0; struct cso_hash_iter iter; switch (type) { case CSO_BLEND: hash = sc->blend_hash; break; case CSO_SAMPLER: hash = sc->sampler_hash; break; case CSO_DEPTH_STENCIL_ALPHA: hash = sc->depth_stencil_hash; break; case CSO_RASTERIZER: hash = sc->rasterizer_hash; break; case CSO_FRAGMENT_SHADER: hash = sc->fs_hash; break; case CSO_VERTEX_SHADER: hash = sc->vs_hash; break; case CSO_VELEMENTS: hash = sc->velements_hash; break; } iter = cso_hash_first_node(hash); while (!cso_hash_iter_is_null(iter)) { void *state = cso_hash_iter_data(iter); iter = cso_hash_iter_next(iter); if (state) { func(state, user_data); } } }
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); } }