Lines Matching refs:cache

82 rehash(struct gl_program_cache *cache)  in rehash()  argument
88 cache->last = NULL; in rehash()
90 size = cache->size * 3; in rehash()
94 for (i = 0; i < cache->size; i++) in rehash()
95 for (c = cache->items[i]; c; c = next) { in rehash()
101 free(cache->items); in rehash()
102 cache->items = items; in rehash()
103 cache->size = size; in rehash()
108 clear_cache(struct gl_context *ctx, struct gl_program_cache *cache, in clear_cache() argument
114 cache->last = NULL; in clear_cache()
116 for (i = 0; i < cache->size; i++) { in clear_cache()
117 for (c = cache->items[i]; c; c = next) { in clear_cache()
129 cache->items[i] = NULL; in clear_cache()
133 cache->n_items = 0; in clear_cache()
141 struct gl_program_cache *cache = CALLOC_STRUCT(gl_program_cache); in _mesa_new_program_cache() local
142 if (cache) { in _mesa_new_program_cache()
143 cache->size = 17; in _mesa_new_program_cache()
144 cache->items = (struct cache_item **) in _mesa_new_program_cache()
145 calloc(1, cache->size * sizeof(struct cache_item)); in _mesa_new_program_cache()
146 if (!cache->items) { in _mesa_new_program_cache()
147 free(cache); in _mesa_new_program_cache()
151 return cache; in _mesa_new_program_cache()
156 _mesa_delete_program_cache(struct gl_context *ctx, struct gl_program_cache *cache) in _mesa_delete_program_cache() argument
158 clear_cache(ctx, cache, GL_FALSE); in _mesa_delete_program_cache()
159 free(cache->items); in _mesa_delete_program_cache()
160 free(cache); in _mesa_delete_program_cache()
165 struct gl_program_cache *cache) in _mesa_delete_shader_cache() argument
167 clear_cache(ctx, cache, GL_TRUE); in _mesa_delete_shader_cache()
168 free(cache->items); in _mesa_delete_shader_cache()
169 free(cache); in _mesa_delete_shader_cache()
174 _mesa_search_program_cache(struct gl_program_cache *cache, in _mesa_search_program_cache() argument
177 if (cache->last && in _mesa_search_program_cache()
178 memcmp(cache->last->key, key, keysize) == 0) { in _mesa_search_program_cache()
179 return cache->last->program; in _mesa_search_program_cache()
185 for (c = cache->items[hash % cache->size]; c; c = c->next) { in _mesa_search_program_cache()
187 cache->last = c; in _mesa_search_program_cache()
199 struct gl_program_cache *cache, in _mesa_program_cache_insert() argument
213 if (cache->n_items > cache->size * 1.5) { in _mesa_program_cache_insert()
214 if (cache->size < 1000) in _mesa_program_cache_insert()
215 rehash(cache); in _mesa_program_cache_insert()
217 clear_cache(ctx, cache, GL_FALSE); in _mesa_program_cache_insert()
220 cache->n_items++; in _mesa_program_cache_insert()
221 c->next = cache->items[hash % cache->size]; in _mesa_program_cache_insert()
222 cache->items[hash % cache->size] = c; in _mesa_program_cache_insert()
227 struct gl_program_cache *cache, in _mesa_shader_cache_insert() argument
241 if (cache->n_items > cache->size * 1.5) { in _mesa_shader_cache_insert()
242 if (cache->size < 1000) in _mesa_shader_cache_insert()
243 rehash(cache); in _mesa_shader_cache_insert()
245 clear_cache(ctx, cache, GL_TRUE); in _mesa_shader_cache_insert()
248 cache->n_items++; in _mesa_shader_cache_insert()
249 c->next = cache->items[hash % cache->size]; in _mesa_shader_cache_insert()
250 cache->items[hash % cache->size] = c; in _mesa_shader_cache_insert()