summaryrefslogtreecommitdiff
path: root/src/mesa/state_tracker/st_cache.c
diff options
context:
space:
mode:
authorZack Rusin <zack@tungstengraphics.com>2007-09-19 12:35:29 -0400
committerZack Rusin <zack@tungstengraphics.com>2007-09-19 13:12:09 -0400
commitc0bf7322088715bb411068c3d631b0c4be8cdff5 (patch)
treeacc04e8f411800c3dbdc6672585d38894dd11b5d /src/mesa/state_tracker/st_cache.c
parentb3cc74aa448f42340cbd01578a51f94eb2949618 (diff)
Redo the cso cache to map driver data in a lot more pleasing way.
Drivers can now create whatever they want from the state template. We use cso_state object to store the template (necessary during lookups), and the driver data. Convert blend state to the new semantics.
Diffstat (limited to 'src/mesa/state_tracker/st_cache.c')
-rw-r--r--src/mesa/state_tracker/st_cache.c21
1 files changed, 11 insertions, 10 deletions
diff --git a/src/mesa/state_tracker/st_cache.c b/src/mesa/state_tracker/st_cache.c
index d84a396e18..bd6c63b7a1 100644
--- a/src/mesa/state_tracker/st_cache.c
+++ b/src/mesa/state_tracker/st_cache.c
@@ -43,21 +43,22 @@
* in the cache or it will create a new state state from the given
* template, will insert it in the cache and return it.
*/
-struct pipe_blend_state * st_cached_blend_state(
- struct st_context *st,
- const struct pipe_blend_state *blend)
+const struct cso_blend * st_cached_blend_state(struct st_context *st,
+ const struct pipe_blend_state *templ)
{
- unsigned hash_key = cso_construct_key((void*)blend, sizeof(struct pipe_blend_state));
+ unsigned hash_key = cso_construct_key((void*)templ, sizeof(struct pipe_blend_state));
struct cso_hash_iter iter = cso_find_state_template(st->cache,
hash_key, CSO_BLEND,
- (void*)blend);
+ (void*)templ);
if (cso_hash_iter_is_null(iter)) {
- const struct pipe_blend_state *created_state = st->pipe->create_blend_state(
- st->pipe, blend);
- iter = cso_insert_state(st->cache, hash_key, CSO_BLEND,
- (void*)created_state);
+ struct cso_blend *cso = malloc(sizeof(struct cso_blend));
+ memcpy(&cso->state, templ, sizeof(struct pipe_blend_state));
+ cso->data = st->pipe->create_blend_state(st->pipe, templ);
+ if (!cso->data)
+ cso->data = &cso->state;
+ iter = cso_insert_state(st->cache, hash_key, CSO_BLEND, cso);
}
- return (struct pipe_blend_state*)(cso_hash_iter_data(iter));
+ return ((struct cso_blend *)cso_hash_iter_data(iter));
}
struct pipe_sampler_state * st_cached_sampler_state(