diff options
author | Zack Rusin <[email protected]> | 2007-09-17 09:47:41 -0400 |
---|---|---|
committer | Zack Rusin <[email protected]> | 2007-09-18 06:31:22 -0400 |
commit | f117327a3f246713abfd4dc4320d4a1a7f1b811a (patch) | |
tree | 81c5c58c0ae0685c917996ad04f10003aa95cfa3 /src/mesa/state_tracker | |
parent | e16c045b83f5c5b4f4064df67623bb76b46b6619 (diff) |
Make sampler an immutable state object.
Switch the sample to be an immutable state object.
Diffstat (limited to 'src/mesa/state_tracker')
-rw-r--r-- | src/mesa/state_tracker/st_atom_sampler.c | 10 | ||||
-rw-r--r-- | src/mesa/state_tracker/st_cache.c | 17 | ||||
-rw-r--r-- | src/mesa/state_tracker/st_cache.h | 6 | ||||
-rw-r--r-- | src/mesa/state_tracker/st_cb_drawpixels.c | 6 | ||||
-rw-r--r-- | src/mesa/state_tracker/st_context.h | 4 |
5 files changed, 36 insertions, 7 deletions
diff --git a/src/mesa/state_tracker/st_atom_sampler.c b/src/mesa/state_tracker/st_atom_sampler.c index d65565f991d..9a728e2d791 100644 --- a/src/mesa/state_tracker/st_atom_sampler.c +++ b/src/mesa/state_tracker/st_atom_sampler.c @@ -33,6 +33,7 @@ #include "st_context.h" +#include "st_cache.h" #include "st_atom.h" #include "pipe/p_context.h" #include "pipe/p_defines.h" @@ -142,10 +143,13 @@ update_samplers(struct st_context *st) /* XXX more sampler state here */ } - if (memcmp(&sampler, &st->state.sampler[u], sizeof(sampler)) != 0) { + const struct pipe_sampler_state *cached_sampler = + st_cached_sampler_state(st, &sampler); + + if (cached_sampler == st->state.sampler[u]) { /* state has changed */ - st->state.sampler[u] = sampler; - st->pipe->set_sampler_state(st->pipe, u, &sampler); + st->state.sampler[u] = cached_sampler; + st->pipe->bind_sampler_state(st->pipe, u, cached_sampler); } } } diff --git a/src/mesa/state_tracker/st_cache.c b/src/mesa/state_tracker/st_cache.c index 0205b1cab32..99fb45f00a6 100644 --- a/src/mesa/state_tracker/st_cache.c +++ b/src/mesa/state_tracker/st_cache.c @@ -59,3 +59,20 @@ struct pipe_blend_state * st_cached_blend_state( } return (struct pipe_blend_state*)(cso_hash_iter_data(iter)); } + +struct pipe_sampler_state * st_cached_sampler_state( + struct st_context *st, + const struct pipe_sampler_state *sampler) +{ + unsigned hash_key = cso_construct_key((void*)sampler, sizeof(struct pipe_sampler_state)); + struct cso_hash_iter iter = cso_find_state_template(st->cache, + hash_key, CSO_SAMPLER, + (void*)sampler); + if (cso_hash_iter_is_null(iter)) { + const struct pipe_sampler_state *created_state = st->pipe->create_sampler_state( + st->pipe, sampler); + iter = cso_insert_state(st->cache, hash_key, CSO_SAMPLER, + (void*)created_state); + } + return (struct pipe_sampler_state*)(cso_hash_iter_data(iter)); +} diff --git a/src/mesa/state_tracker/st_cache.h b/src/mesa/state_tracker/st_cache.h index 29b1d00dca1..927585141c6 100644 --- a/src/mesa/state_tracker/st_cache.h +++ b/src/mesa/state_tracker/st_cache.h @@ -34,10 +34,16 @@ #define ST_CACHE_H struct pipe_blend_state; +struct pipe_sampler_state; struct st_context; struct pipe_blend_state * st_cached_blend_state( struct st_context *st, const struct pipe_blend_state *blend); +struct pipe_sampler_state * st_cached_sampler_state( + struct st_context *st, + const struct pipe_sampler_state *sampler); + + #endif diff --git a/src/mesa/state_tracker/st_cb_drawpixels.c b/src/mesa/state_tracker/st_cb_drawpixels.c index c2d231cdb5d..31a37e5cd4c 100644 --- a/src/mesa/state_tracker/st_cb_drawpixels.c +++ b/src/mesa/state_tracker/st_cb_drawpixels.c @@ -34,6 +34,7 @@ #include "st_context.h" #include "st_atom.h" +#include "st_cache.h" #include "st_draw.h" #include "st_program.h" #include "st_cb_drawpixels.h" @@ -359,7 +360,8 @@ draw_textured_quad(GLcontext *ctx, GLint x, GLint y, GLfloat z, sampler.min_img_filter = PIPE_TEX_FILTER_NEAREST; sampler.min_mip_filter = PIPE_TEX_MIPFILTER_NONE; sampler.mag_img_filter = PIPE_TEX_FILTER_NEAREST; - pipe->set_sampler_state(pipe, unit, &sampler); + const struct pipe_sampler_state *state = st_cached_sampler_state(ctx->st, &sampler); + pipe->bind_sampler_state(pipe, unit, state); } /* viewport state: viewport matching window dims */ @@ -402,7 +404,7 @@ draw_textured_quad(GLcontext *ctx, GLint x, GLint y, GLfloat z, pipe->set_fs_state(pipe, &ctx->st->state.fs); pipe->set_vs_state(pipe, &ctx->st->state.vs); pipe->set_texture_state(pipe, unit, ctx->st->state.texture[unit]); - pipe->set_sampler_state(pipe, unit, &ctx->st->state.sampler[unit]); + pipe->bind_sampler_state(pipe, unit, ctx->st->state.sampler[unit]); pipe->set_viewport_state(pipe, &ctx->st->state.viewport); free_mipmap_tree(pipe, mt); diff --git a/src/mesa/state_tracker/st_context.h b/src/mesa/state_tracker/st_context.h index bd2efdb960b..13526ff9e7c 100644 --- a/src/mesa/state_tracker/st_context.h +++ b/src/mesa/state_tracker/st_context.h @@ -74,7 +74,8 @@ struct st_context * though, we just shove random objects across the interface. */ struct { - const struct pipe_blend_state *blend; + const struct pipe_blend_state *blend; + const struct pipe_sampler_state *sampler[PIPE_MAX_SAMPLERS]; struct pipe_alpha_test_state alpha_test; struct pipe_blend_color blend_color; @@ -86,7 +87,6 @@ struct st_context struct pipe_framebuffer_state framebuffer; struct pipe_mipmap_tree *texture[PIPE_MAX_SAMPLERS]; struct pipe_poly_stipple poly_stipple; - struct pipe_sampler_state sampler[PIPE_MAX_SAMPLERS]; struct pipe_scissor_state scissor; struct pipe_setup_state setup; struct pipe_shader_state fs; |