Lines Matching refs:cache

83 rehash(struct gl_program_cache *cache)
89 cache->last = NULL;
91 size = cache->size * 3;
95 for (i = 0; i < cache->size; i++)
96 for (c = cache->items[i]; c; c = next) {
102 free(cache->items);
103 cache->items = items;
104 cache->size = size;
109 clear_cache(struct gl_context *ctx, struct gl_program_cache *cache,
115 cache->last = NULL;
117 for (i = 0; i < cache->size; i++) {
118 for (c = cache->items[i]; c; c = next) {
130 cache->items[i] = NULL;
134 cache->n_items = 0;
142 struct gl_program_cache *cache = CALLOC_STRUCT(gl_program_cache);
143 if (cache) {
144 cache->size = 17;
145 cache->items =
146 calloc(cache->size, sizeof(struct cache_item *));
147 if (!cache->items) {
148 free(cache);
152 return cache;
157 _mesa_delete_program_cache(struct gl_context *ctx, struct gl_program_cache *cache)
159 clear_cache(ctx, cache, GL_FALSE);
160 free(cache->items);
161 free(cache);
166 struct gl_program_cache *cache)
168 clear_cache(ctx, cache, GL_TRUE);
169 free(cache->items);
170 free(cache);
175 _mesa_search_program_cache(struct gl_program_cache *cache,
178 if (cache->last &&
179 cache->last->keysize == keysize &&
180 memcmp(cache->last->key, key, keysize) == 0) {
181 return cache->last->program;
187 for (c = cache->items[hash % cache->size]; c; c = c->next) {
192 cache->last = c;
204 struct gl_program_cache *cache,
219 if (cache->n_items > cache->size * 1.5) {
220 if (cache->size < 1000)
221 rehash(cache);
223 clear_cache(ctx, cache, GL_FALSE);
226 cache->n_items++;
227 c->next = cache->items[hash % cache->size];
228 cache->items[hash % cache->size] = c;
233 struct gl_program_cache *cache,
248 if (cache->n_items > cache->size * 1.5) {
249 if (cache->size < 1000)
250 rehash(cache);
252 clear_cache(ctx, cache, GL_TRUE);
255 cache->n_items++;
256 c->next = cache->items[hash % cache->size];
257 cache->items[hash % cache->size] = c;