summaryrefslogtreecommitdiffstats
path: root/src/mesa/state_tracker/st_cache.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/mesa/state_tracker/st_cache.c')
-rw-r--r--src/mesa/state_tracker/st_cache.c23
1 files changed, 13 insertions, 10 deletions
diff --git a/src/mesa/state_tracker/st_cache.c b/src/mesa/state_tracker/st_cache.c
index e5ba0592cfb..c1ec130b321 100644
--- a/src/mesa/state_tracker/st_cache.c
+++ b/src/mesa/state_tracker/st_cache.c
@@ -78,21 +78,24 @@ struct pipe_sampler_state * st_cached_sampler_state(
return (struct pipe_sampler_state*)(cso_hash_iter_data(iter));
}
-struct pipe_depth_stencil_state * st_cached_depth_stencil_state(
- struct st_context *st,
- const struct pipe_depth_stencil_state *depth_stencil)
+const struct cso_depth_stencil *
+st_cached_depth_stencil_state(struct st_context *st,
+ const struct pipe_depth_stencil_state *templ)
{
- unsigned hash_key = cso_construct_key((void*)depth_stencil, sizeof(struct pipe_depth_stencil_state));
+ unsigned hash_key = cso_construct_key((void*)templ,
+ sizeof(struct pipe_depth_stencil_state));
struct cso_hash_iter iter = cso_find_state_template(st->cache,
hash_key, CSO_DEPTH_STENCIL,
- (void*)depth_stencil);
+ (void*)templ);
if (cso_hash_iter_is_null(iter)) {
- const struct pipe_depth_stencil_state *created_state = st->pipe->create_depth_stencil_state(
- st->pipe, depth_stencil);
- iter = cso_insert_state(st->cache, hash_key, CSO_DEPTH_STENCIL,
- (void*)created_state);
+ struct cso_depth_stencil *cso = malloc(sizeof(struct cso_depth_stencil));
+ memcpy(&cso->state, templ, sizeof(struct pipe_depth_stencil_state));
+ cso->data = st->pipe->create_depth_stencil_state(st->pipe, templ);
+ if (!cso->data)
+ cso->data = &cso->state;
+ iter = cso_insert_state(st->cache, hash_key, CSO_DEPTH_STENCIL, cso);
}
- return (struct pipe_depth_stencil_state*)(cso_hash_iter_data(iter));
+ return (struct cso_depth_stencil*)(cso_hash_iter_data(iter));
}
const struct cso_rasterizer* st_cached_rasterizer_state(