struct cso_context {
struct pipe_context *pipe;
- struct cso_cache *cache;
struct u_vbuf *vbuf;
struct u_vbuf *vbuf_current;
unsigned sample_mask, sample_mask_saved;
unsigned min_samples, min_samples_saved;
struct pipe_stencil_ref stencil_ref, stencil_ref_saved;
+
+ /* This should be last to keep all of the above together in memory. */
+ struct cso_cache cache;
};
struct pipe_context *cso_get_pipe_context(struct cso_context *cso)
if (!ctx)
return NULL;
- ctx->cache = cso_cache_create();
- if (ctx->cache == NULL)
- goto out;
- cso_cache_set_sanitize_callback(ctx->cache,
- sanitize_hash,
- ctx);
+ cso_cache_init(&ctx->cache);
+ cso_cache_set_sanitize_callback(&ctx->cache, sanitize_hash, ctx);
ctx->pipe = pipe;
ctx->sample_mask = ~0;
cso_init_vbuf(ctx, flags);
/* Enable for testing: */
- if (0) cso_set_maximum_cache_size( ctx->cache, 4 );
+ if (0) cso_set_maximum_cache_size(&ctx->cache, 4);
if (pipe->screen->get_shader_param(pipe->screen, PIPE_SHADER_GEOMETRY,
PIPE_SHADER_CAP_MAX_INSTRUCTIONS) > 0) {
ctx->max_sampler_seen = -1;
return ctx;
-
-out:
- cso_destroy_context( ctx );
- return NULL;
}
/**
pipe_so_target_reference(&ctx->so_targets_saved[i], NULL);
}
- if (ctx->cache) {
- cso_cache_delete( ctx->cache );
- ctx->cache = NULL;
- }
+ cso_cache_delete(&ctx->cache);
if (ctx->vbuf)
u_vbuf_destroy(ctx->vbuf);
sizeof(struct pipe_blend_state) :
(char *)&(templ->rt[1]) - (char *)templ;
hash_key = cso_construct_key((void*)templ, key_size);
- iter = cso_find_state_template(ctx->cache, hash_key, CSO_BLEND,
+ iter = cso_find_state_template(&ctx->cache, hash_key, CSO_BLEND,
(void*)templ, key_size);
if (cso_hash_iter_is_null(iter)) {
cso->delete_state = (cso_state_callback)ctx->pipe->delete_blend_state;
cso->context = ctx->pipe;
- iter = cso_insert_state(ctx->cache, hash_key, CSO_BLEND, cso);
+ iter = cso_insert_state(&ctx->cache, hash_key, CSO_BLEND, cso);
if (cso_hash_iter_is_null(iter)) {
FREE(cso);
return PIPE_ERROR_OUT_OF_MEMORY;
{
unsigned key_size = sizeof(struct pipe_depth_stencil_alpha_state);
unsigned hash_key = cso_construct_key((void*)templ, key_size);
- struct cso_hash_iter iter = cso_find_state_template(ctx->cache,
+ struct cso_hash_iter iter = cso_find_state_template(&ctx->cache,
hash_key,
CSO_DEPTH_STENCIL_ALPHA,
(void*)templ, key_size);
(cso_state_callback)ctx->pipe->delete_depth_stencil_alpha_state;
cso->context = ctx->pipe;
- iter = cso_insert_state(ctx->cache, hash_key,
+ iter = cso_insert_state(&ctx->cache, hash_key,
CSO_DEPTH_STENCIL_ALPHA, cso);
if (cso_hash_iter_is_null(iter)) {
FREE(cso);
{
unsigned key_size = sizeof(struct pipe_rasterizer_state);
unsigned hash_key = cso_construct_key((void*)templ, key_size);
- struct cso_hash_iter iter = cso_find_state_template(ctx->cache,
+ struct cso_hash_iter iter = cso_find_state_template(&ctx->cache,
hash_key,
CSO_RASTERIZER,
(void*)templ, key_size);
(cso_state_callback)ctx->pipe->delete_rasterizer_state;
cso->context = ctx->pipe;
- iter = cso_insert_state(ctx->cache, hash_key, CSO_RASTERIZER, cso);
+ iter = cso_insert_state(&ctx->cache, hash_key, CSO_RASTERIZER, cso);
if (cso_hash_iter_is_null(iter)) {
FREE(cso);
return PIPE_ERROR_OUT_OF_MEMORY;
key_size = sizeof(struct pipe_vertex_element) * velems->count +
sizeof(unsigned);
hash_key = cso_construct_key((void*)velems, key_size);
- iter = cso_find_state_template(ctx->cache, hash_key, CSO_VELEMENTS,
+ iter = cso_find_state_template(&ctx->cache, hash_key, CSO_VELEMENTS,
(void*)velems, key_size);
if (cso_hash_iter_is_null(iter)) {
(cso_state_callback) ctx->pipe->delete_vertex_elements_state;
cso->context = ctx->pipe;
- iter = cso_insert_state(ctx->cache, hash_key, CSO_VELEMENTS, cso);
+ iter = cso_insert_state(&ctx->cache, hash_key, CSO_VELEMENTS, cso);
if (cso_hash_iter_is_null(iter)) {
FREE(cso);
return;
unsigned hash_key = cso_construct_key((void*)templ, key_size);
struct cso_sampler *cso;
struct cso_hash_iter iter =
- cso_find_state_template(ctx->cache,
+ cso_find_state_template(&ctx->cache,
hash_key, CSO_SAMPLER,
(void *) templ, key_size);
cso->context = ctx->pipe;
cso->hash_key = hash_key;
- iter = cso_insert_state(ctx->cache, hash_key, CSO_SAMPLER, cso);
+ iter = cso_insert_state(&ctx->cache, hash_key, CSO_SAMPLER, cso);
if (cso_hash_iter_is_null(iter)) {
FREE(cso);
return;
struct pipe_context *pipe;
struct translate_cache *translate_cache;
- struct cso_cache *cso_cache;
+ struct cso_cache cso_cache;
/* This is what was set in set_vertex_buffers.
* May contain user buffers. */
mgr->caps = *caps;
mgr->pipe = pipe;
- mgr->cso_cache = cso_cache_create();
+ cso_cache_init(&mgr->cso_cache);
mgr->translate_cache = translate_cache_create();
memset(mgr->fallback_vbs, ~0, sizeof(mgr->fallback_vbs));
mgr->allowed_vb_mask = u_bit_consecutive(0, mgr->caps.max_vertex_buffers);
key_size = sizeof(struct pipe_vertex_element) * velems->count +
sizeof(unsigned);
hash_key = cso_construct_key((void*)velems, key_size);
- iter = cso_find_state_template(mgr->cso_cache, hash_key, CSO_VELEMENTS,
+ iter = cso_find_state_template(&mgr->cso_cache, hash_key, CSO_VELEMENTS,
(void*)velems, key_size);
if (cso_hash_iter_is_null(iter)) {
cso->delete_state = (cso_state_callback)u_vbuf_delete_vertex_elements;
cso->context = (void*)mgr;
- iter = cso_insert_state(mgr->cso_cache, hash_key, CSO_VELEMENTS, cso);
+ iter = cso_insert_state(&mgr->cso_cache, hash_key, CSO_VELEMENTS, cso);
ve = cso->data;
} else {
ve = ((struct cso_velements *)cso_hash_iter_data(iter))->data;
pipe_vertex_buffer_unreference(&mgr->vertex_buffer0_saved);
translate_cache_destroy(mgr->translate_cache);
- cso_cache_delete(mgr->cso_cache);
+ cso_cache_delete(&mgr->cso_cache);
FREE(mgr);
}