diff options
author | Zack Rusin <zack@tungstengraphics.com> | 2007-09-18 13:24:44 -0400 |
---|---|---|
committer | Zack Rusin <zack@tungstengraphics.com> | 2007-09-18 13:24:44 -0400 |
commit | ccd63b54cfbb6bb241d55f7ac95afcd14819f469 (patch) | |
tree | 3ea07838de79877e6d441506cdd6f805fcb9d308 /src/mesa/state_tracker/st_cache.c | |
parent | 498a1b5dc4ca431bb1de45d04140bfb2ac319ab2 (diff) |
Convert shader to an immutable state object.
Diffstat (limited to 'src/mesa/state_tracker/st_cache.c')
-rw-r--r-- | src/mesa/state_tracker/st_cache.c | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/src/mesa/state_tracker/st_cache.c b/src/mesa/state_tracker/st_cache.c index e9c79634bd7..7b851e3901b 100644 --- a/src/mesa/state_tracker/st_cache.c +++ b/src/mesa/state_tracker/st_cache.c @@ -111,3 +111,21 @@ struct pipe_rasterizer_state * st_cached_rasterizer_state( } return (struct pipe_rasterizer_state*)(cso_hash_iter_data(iter)); } + +struct pipe_shader_state * st_cached_shader_state( + struct st_context *st, + const struct pipe_shader_state *templ) +{ + unsigned hash_key = cso_construct_key((void*)templ, + sizeof(struct pipe_shader_state)); + struct cso_hash_iter iter = cso_find_state_template(st->cache, + hash_key, CSO_SHADER, + (void*)templ); + if (cso_hash_iter_is_null(iter)) { + const struct pipe_shader_state *created_state = + st->pipe->create_shader_state(st->pipe, templ); + iter = cso_insert_state(st->cache, hash_key, CSO_SHADER, + (void*)created_state); + } + return (struct pipe_shader_state*)(cso_hash_iter_data(iter)); +} |