summaryrefslogtreecommitdiffstats
path: root/src/mesa/state_tracker
diff options
context:
space:
mode:
authorZack Rusin <[email protected]>2007-09-14 04:08:58 -0400
committerZack Rusin <[email protected]>2007-09-18 06:31:22 -0400
commit9780327c5d95586a88fce94d7b47342355ead118 (patch)
tree9007ea135504d8fd90b49a391a43fa579b9374b5 /src/mesa/state_tracker
parentffacb1c12a77d71613e8171e31ffc348959881e4 (diff)
First stab at immutable state objects (create/bind/delete)
We want our state objects to be immutable, handled via the create/bind/delete calls instead of struct propagation. Only implementing the blend state to see how it would look like and work.
Diffstat (limited to 'src/mesa/state_tracker')
-rw-r--r--src/mesa/state_tracker/st_atom_blend.c11
-rw-r--r--src/mesa/state_tracker/st_cb_clear.c7
-rw-r--r--src/mesa/state_tracker/st_cb_drawpixels.c4
-rw-r--r--src/mesa/state_tracker/st_context.c4
-rw-r--r--src/mesa/state_tracker/st_context.h7
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;
};