diff options
author | Zack Rusin <[email protected]> | 2007-09-19 12:35:29 -0400 |
---|---|---|
committer | Zack Rusin <[email protected]> | 2007-09-19 13:12:09 -0400 |
commit | c0bf7322088715bb411068c3d631b0c4be8cdff5 (patch) | |
tree | acc04e8f411800c3dbdc6672585d38894dd11b5d /src/mesa/state_tracker | |
parent | b3cc74aa448f42340cbd01578a51f94eb2949618 (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')
-rw-r--r-- | src/mesa/state_tracker/st_atom_blend.c | 8 | ||||
-rw-r--r-- | src/mesa/state_tracker/st_cache.c | 21 | ||||
-rw-r--r-- | src/mesa/state_tracker/st_cache.h | 14 | ||||
-rw-r--r-- | src/mesa/state_tracker/st_cb_clear.c | 8 | ||||
-rw-r--r-- | src/mesa/state_tracker/st_cb_drawpixels.c | 4 | ||||
-rw-r--r-- | src/mesa/state_tracker/st_context.h | 3 |
6 files changed, 31 insertions, 27 deletions
diff --git a/src/mesa/state_tracker/st_atom_blend.c b/src/mesa/state_tracker/st_atom_blend.c index d94beb66c78..d5eadc3541a 100644 --- a/src/mesa/state_tracker/st_atom_blend.c +++ b/src/mesa/state_tracker/st_atom_blend.c @@ -211,14 +211,14 @@ update_blend( struct st_context *st ) if (st->ctx->Color.DitherFlag) blend.dither = 1; - struct pipe_blend_state *real_blend = + const struct cso_blend *cso = st_cached_blend_state(st, &blend); - if (st->state.blend != real_blend) { + if (st->state.blend != cso) { /* state has changed */ - st->state.blend = real_blend; + st->state.blend = cso; /* bind new state */ - st->pipe->bind_blend_state(st->pipe, real_blend); + st->pipe->bind_blend_state(st->pipe, cso->data); } if (memcmp(st->ctx->Color.BlendColor, &st->state.blend_color, 4 * sizeof(GLfloat)) != 0) { diff --git a/src/mesa/state_tracker/st_cache.c b/src/mesa/state_tracker/st_cache.c index d84a396e183..bd6c63b7a13 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( diff --git a/src/mesa/state_tracker/st_cache.h b/src/mesa/state_tracker/st_cache.h index bcbe19b8236..fb0ff0d4db8 100644 --- a/src/mesa/state_tracker/st_cache.h +++ b/src/mesa/state_tracker/st_cache.h @@ -33,17 +33,19 @@ #ifndef ST_CACHE_H #define ST_CACHE_H +#include "pipe/cso_cache/cso_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); +const struct cso_blend * +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); +struct pipe_sampler_state * +st_cached_sampler_state(struct st_context *st, + const struct pipe_sampler_state *sampler); struct pipe_depth_stencil_state *st_cached_depth_stencil_state( struct st_context *st, diff --git a/src/mesa/state_tracker/st_cb_clear.c b/src/mesa/state_tracker/st_cb_clear.c index 7c669ab4578..3a6991754ac 100644 --- a/src/mesa/state_tracker/st_cb_clear.c +++ b/src/mesa/state_tracker/st_cb_clear.c @@ -298,7 +298,7 @@ clear_with_quad(GLcontext *ctx, /* blend state: RGBA masking */ { struct pipe_blend_state blend; - const struct pipe_blend_state *state; + const struct cso_blend *cso; memset(&blend, 0, sizeof(blend)); if (color) { if (ctx->Color.ColorMask[0]) @@ -312,8 +312,8 @@ clear_with_quad(GLcontext *ctx, if (st->ctx->Color.DitherFlag) blend.dither = 1; } - state = st_cached_blend_state(st, &blend); - pipe->bind_blend_state(pipe, state); + cso = st_cached_blend_state(st, &blend); + pipe->bind_blend_state(pipe, cso->data); } /* depth_stencil state: always pass/set to ref value */ @@ -411,7 +411,7 @@ clear_with_quad(GLcontext *ctx, /* Restore pipe state */ pipe->set_alpha_test_state(pipe, &st->state.alpha_test); - pipe->bind_blend_state(pipe, st->state.blend); + pipe->bind_blend_state(pipe, st->state.blend->data); pipe->bind_depth_stencil_state(pipe, st->state.depth_stencil); pipe->bind_fs_state(pipe, st->state.fs); pipe->bind_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 67de781c831..4a554cd5a4a 100644 --- a/src/mesa/state_tracker/st_cb_drawpixels.c +++ b/src/mesa/state_tracker/st_cb_drawpixels.c @@ -493,8 +493,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->state.blend_enable || + st->state.blend->state.logicop_enable || st->state.depth_stencil->depth.enabled) /* XXX more checks */ return GL_TRUE; diff --git a/src/mesa/state_tracker/st_context.h b/src/mesa/state_tracker/st_context.h index a8ae5d9c562..966574b67c6 100644 --- a/src/mesa/state_tracker/st_context.h +++ b/src/mesa/state_tracker/st_context.h @@ -40,6 +40,7 @@ struct st_fragment_program; struct draw_context; struct draw_stage; struct cso_cache; +struct cso_blend; #define ST_NEW_MESA 0x1 /* Mesa state has changed */ #define ST_NEW_FRAGMENT_PROGRAM 0x2 @@ -74,7 +75,7 @@ struct st_context * though, we just shove random objects across the interface. */ struct { - const struct pipe_blend_state *blend; + const struct cso_blend *blend; const struct pipe_sampler_state *sampler[PIPE_MAX_SAMPLERS]; const struct pipe_depth_stencil_state *depth_stencil; const struct pipe_rasterizer_state *rasterizer; |