diff options
Diffstat (limited to 'src/mesa/state_tracker')
-rw-r--r-- | src/mesa/state_tracker/st_atom_blend.c | 11 | ||||
-rw-r--r-- | src/mesa/state_tracker/st_cb_clear.c | 7 | ||||
-rw-r--r-- | src/mesa/state_tracker/st_cb_drawpixels.c | 4 | ||||
-rw-r--r-- | src/mesa/state_tracker/st_context.c | 4 | ||||
-rw-r--r-- | src/mesa/state_tracker/st_context.h | 7 |
5 files changed, 24 insertions, 9 deletions
diff --git a/src/mesa/state_tracker/st_atom_blend.c b/src/mesa/state_tracker/st_atom_blend.c index afd21a6141c..d007d50ad39 100644 --- a/src/mesa/state_tracker/st_atom_blend.c +++ b/src/mesa/state_tracker/st_atom_blend.c @@ -36,6 +36,7 @@ #include "st_atom.h" #include "pipe/p_context.h" #include "pipe/p_defines.h" +#include "cso_cache/cso_cache.h" /** @@ -209,10 +210,14 @@ update_blend( struct st_context *st ) if (st->ctx->Color.DitherFlag) blend.dither = 1; - if (memcmp(&blend, &st->state.blend, sizeof(blend)) != 0) { + struct pipe_blend_state *real_blend = + cso_cached_blend_state(st, &blend); + + if (st->state.blend != real_blend) { /* state has changed */ - st->state.blend = blend; /* struct copy */ - st->pipe->set_blend_state(st->pipe, &blend); /* set new state */ + st->state.blend = real_blend; + /* bind new state */ + st->pipe->bind_blend_state(st->pipe, real_blend); } if (memcmp(st->ctx->Color.BlendColor, &st->state.blend_color, 4 * sizeof(GLfloat)) != 0) { diff --git a/src/mesa/state_tracker/st_cb_clear.c b/src/mesa/state_tracker/st_cb_clear.c index fa222df2a48..dc8a84af08f 100644 --- a/src/mesa/state_tracker/st_cb_clear.c +++ b/src/mesa/state_tracker/st_cb_clear.c @@ -49,6 +49,8 @@ #include "pipe/tgsi/mesa/mesa_to_tgsi.h" +#include "cso_cache/cso_cache.h" + #include "vf/vf.h" @@ -295,7 +297,8 @@ clear_with_quad(GLcontext *ctx, if (st->ctx->Color.DitherFlag) blend.dither = 1; } - pipe->set_blend_state(pipe, &blend); + const struct pipe_blend_state *state = cso_cached_blend_state(st, &blend); + pipe->bind_blend_state(pipe, state); } /* depth state: always pass */ @@ -390,7 +393,7 @@ clear_with_quad(GLcontext *ctx, /* Restore pipe state */ pipe->set_alpha_test_state(pipe, &st->state.alpha_test); - pipe->set_blend_state(pipe, &st->state.blend); + pipe->bind_blend_state(pipe, st->state.blend); pipe->set_depth_state(pipe, &st->state.depth); pipe->set_fs_state(pipe, &st->state.fs); pipe->set_vs_state(pipe, &st->state.vs); diff --git a/src/mesa/state_tracker/st_cb_drawpixels.c b/src/mesa/state_tracker/st_cb_drawpixels.c index e2280cdafa8..c2d231cdb5d 100644 --- a/src/mesa/state_tracker/st_cb_drawpixels.c +++ b/src/mesa/state_tracker/st_cb_drawpixels.c @@ -474,8 +474,8 @@ static GLboolean any_fragment_ops(const struct st_context *st) { if (st->state.alpha_test.enabled || - st->state.blend.blend_enable || - st->state.blend.logicop_enable || + st->state.blend->blend_enable || + st->state.blend->logicop_enable || st->state.depth.enabled) /* XXX more checks */ return GL_TRUE; diff --git a/src/mesa/state_tracker/st_context.c b/src/mesa/state_tracker/st_context.c index 6ab643f1fef..26815d5cd42 100644 --- a/src/mesa/state_tracker/st_context.c +++ b/src/mesa/state_tracker/st_context.c @@ -45,6 +45,7 @@ #include "st_program.h" #include "pipe/p_context.h" #include "pipe/draw/draw_context.h" +#include "cso_cache/cso_cache.h" void st_invalidate_state(GLcontext * ctx, GLuint new_state) @@ -71,6 +72,8 @@ struct st_context *st_create_context( GLcontext *ctx, st->dirty.mesa = ~0; st->dirty.st = ~0; + st->cache = cso_cache_create(); + st_init_atoms( st ); st_init_draw( st ); @@ -112,6 +115,7 @@ void st_destroy_context( struct st_context *st ) /*st_destroy_cb_teximage( st );*/ st_destroy_cb_texture( st ); #endif + cso_cache_destroy( st->cache ); st->pipe->destroy( st->pipe ); FREE( st ); diff --git a/src/mesa/state_tracker/st_context.h b/src/mesa/state_tracker/st_context.h index 56cae7d9734..bd2efdb960b 100644 --- a/src/mesa/state_tracker/st_context.h +++ b/src/mesa/state_tracker/st_context.h @@ -39,7 +39,7 @@ struct st_texture_image; struct st_fragment_program; struct draw_context; struct draw_stage; - +struct cso_cache; #define ST_NEW_MESA 0x1 /* Mesa state has changed */ #define ST_NEW_FRAGMENT_PROGRAM 0x2 @@ -74,8 +74,9 @@ struct st_context * though, we just shove random objects across the interface. */ struct { + const struct pipe_blend_state *blend; + struct pipe_alpha_test_state alpha_test; - struct pipe_blend_state blend; struct pipe_blend_color blend_color; struct pipe_clear_color_state clear_color; struct pipe_clip_state clip; @@ -122,6 +123,8 @@ struct st_context struct st_fragment_program *fp; struct pipe_buffer_handle *default_attrib_buffer; + + struct cso_cache *cache; }; |