Lines Matching refs:sc

83 static INLINE struct cso_hash *_cso_hash_for_type(struct cso_cache *sc, enum cso_cache_type type)
86 hash = sc->hashes[type];
155 static INLINE void sanitize_hash(struct cso_cache *sc,
160 if (sc->sanitize_cb)
161 sc->sanitize_cb(hash, type, max_size, sc->sanitize_data);
186 cso_insert_state(struct cso_cache *sc,
190 struct cso_hash *hash = _cso_hash_for_type(sc, type);
191 sanitize_hash(sc, hash, type, sc->max_size);
197 cso_find_state(struct cso_cache *sc,
200 struct cso_hash *hash = _cso_hash_for_type(sc, type);
225 struct cso_hash_iter cso_find_state_template(struct cso_cache *sc,
229 struct cso_hash_iter iter = cso_find_state(sc, hash_key, type);
239 void * cso_take_state(struct cso_cache *sc,
242 struct cso_hash *hash = _cso_hash_for_type(sc, type);
248 struct cso_cache *sc = MALLOC_STRUCT(cso_cache);
250 if (sc == NULL)
253 sc->max_size = 4096;
255 sc->hashes[i] = cso_hash_create();
257 sc->sanitize_cb = sanitize_cb;
258 sc->sanitize_data = 0;
260 return sc;
263 void cso_for_each_state(struct cso_cache *sc, enum cso_cache_type type,
266 struct cso_hash *hash = _cso_hash_for_type(sc, type);
279 void cso_cache_delete(struct cso_cache *sc)
282 assert(sc);
284 if (!sc)
288 cso_for_each_state(sc, CSO_BLEND, delete_blend_state, 0);
289 cso_for_each_state(sc, CSO_DEPTH_STENCIL_ALPHA, delete_depth_stencil_state, 0);
290 cso_for_each_state(sc, CSO_RASTERIZER, delete_rasterizer_state, 0);
291 cso_for_each_state(sc, CSO_SAMPLER, delete_sampler_state, 0);
292 cso_for_each_state(sc, CSO_VELEMENTS, delete_velements, 0);
295 cso_hash_delete(sc->hashes[i]);
297 FREE(sc);
300 void cso_set_maximum_cache_size(struct cso_cache *sc, int number)
304 sc->max_size = number;
307 sanitize_hash(sc, sc->hashes[i], i, sc->max_size);
310 int cso_maximum_cache_size(const struct cso_cache *sc)
312 return sc->max_size;
315 void cso_cache_set_sanitize_callback(struct cso_cache *sc,
319 sc->sanitize_cb = cb;
320 sc->sanitize_data = user_data;