From a6c0c5532f7bfa50ae54c36cf4d74ad4b9f926f8 Mon Sep 17 00:00:00 2001 From: Zack Rusin Date: Thu, 20 Sep 2007 08:35:10 -0400 Subject: Convert depth_stencil state to the new semantics. --- src/mesa/state_tracker/st_atom_depth.c | 10 +++++----- src/mesa/state_tracker/st_cache.c | 23 +++++++++++++---------- src/mesa/state_tracker/st_cache.h | 6 +++--- src/mesa/state_tracker/st_cb_clear.c | 9 ++++----- src/mesa/state_tracker/st_cb_drawpixels.c | 2 +- src/mesa/state_tracker/st_context.h | 2 +- 6 files changed, 27 insertions(+), 25 deletions(-) (limited to 'src/mesa/state_tracker') diff --git a/src/mesa/state_tracker/st_atom_depth.c b/src/mesa/state_tracker/st_atom_depth.c index 406773213d..caf51f17ac 100644 --- a/src/mesa/state_tracker/st_atom_depth.c +++ b/src/mesa/state_tracker/st_atom_depth.c @@ -115,6 +115,7 @@ static void update_depth_stencil(struct st_context *st) { struct pipe_depth_stencil_state depth_stencil; + const struct cso_depth_stencil *cso; memset(&depth_stencil, 0, sizeof(depth_stencil)); @@ -149,12 +150,11 @@ update_depth_stencil(struct st_context *st) depth_stencil.stencil.clear_value = st->ctx->Stencil.Clear & 0xff; } - struct pipe_depth_stencil_state *cached_state = - st_cached_depth_stencil_state(st, &depth_stencil); - if (st->state.depth_stencil != cached_state) { + cso = st_cached_depth_stencil_state(st, &depth_stencil); + if (st->state.depth_stencil != cso) { /* state has changed */ - st->state.depth_stencil = cached_state; - st->pipe->bind_depth_stencil_state(st->pipe, cached_state); /* set new state */ + st->state.depth_stencil = cso; + st->pipe->bind_depth_stencil_state(st->pipe, cso->data); /* bind new state */ } } diff --git a/src/mesa/state_tracker/st_cache.c b/src/mesa/state_tracker/st_cache.c index e5ba0592cf..c1ec130b32 100644 --- a/src/mesa/state_tracker/st_cache.c +++ b/src/mesa/state_tracker/st_cache.c @@ -78,21 +78,24 @@ struct pipe_sampler_state * st_cached_sampler_state( return (struct pipe_sampler_state*)(cso_hash_iter_data(iter)); } -struct pipe_depth_stencil_state * st_cached_depth_stencil_state( - struct st_context *st, - const struct pipe_depth_stencil_state *depth_stencil) +const struct cso_depth_stencil * +st_cached_depth_stencil_state(struct st_context *st, + const struct pipe_depth_stencil_state *templ) { - unsigned hash_key = cso_construct_key((void*)depth_stencil, sizeof(struct pipe_depth_stencil_state)); + unsigned hash_key = cso_construct_key((void*)templ, + sizeof(struct pipe_depth_stencil_state)); struct cso_hash_iter iter = cso_find_state_template(st->cache, hash_key, CSO_DEPTH_STENCIL, - (void*)depth_stencil); + (void*)templ); if (cso_hash_iter_is_null(iter)) { - const struct pipe_depth_stencil_state *created_state = st->pipe->create_depth_stencil_state( - st->pipe, depth_stencil); - iter = cso_insert_state(st->cache, hash_key, CSO_DEPTH_STENCIL, - (void*)created_state); + struct cso_depth_stencil *cso = malloc(sizeof(struct cso_depth_stencil)); + memcpy(&cso->state, templ, sizeof(struct pipe_depth_stencil_state)); + cso->data = st->pipe->create_depth_stencil_state(st->pipe, templ); + if (!cso->data) + cso->data = &cso->state; + iter = cso_insert_state(st->cache, hash_key, CSO_DEPTH_STENCIL, cso); } - return (struct pipe_depth_stencil_state*)(cso_hash_iter_data(iter)); + return (struct cso_depth_stencil*)(cso_hash_iter_data(iter)); } const struct cso_rasterizer* st_cached_rasterizer_state( diff --git a/src/mesa/state_tracker/st_cache.h b/src/mesa/state_tracker/st_cache.h index 356dd98183..167d9ec11a 100644 --- a/src/mesa/state_tracker/st_cache.h +++ b/src/mesa/state_tracker/st_cache.h @@ -47,9 +47,9 @@ 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, - const struct pipe_depth_stencil_state *depth_stencil); +const struct cso_depth_stencil * +st_cached_depth_stencil_state(struct st_context *st, + const struct pipe_depth_stencil_state *depth_stencil); const struct cso_rasterizer * st_cached_rasterizer_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 03a81652cb..bfc977daa4 100644 --- a/src/mesa/state_tracker/st_cb_clear.c +++ b/src/mesa/state_tracker/st_cb_clear.c @@ -303,7 +303,7 @@ clear_with_quad(GLcontext *ctx, /* depth_stencil state: always pass/set to ref value */ { struct pipe_depth_stencil_state depth_stencil; - struct pipe_depth_stencil_state *cached; + const struct cso_depth_stencil *cso; memset(&depth_stencil, 0, sizeof(depth_stencil)); if (depth) { depth_stencil.depth.enabled = 1; @@ -321,9 +321,8 @@ clear_with_quad(GLcontext *ctx, depth_stencil.stencil.value_mask[0] = 0xff; depth_stencil.stencil.write_mask[0] = ctx->Stencil.WriteMask[0] & 0xff; } - cached = - st_cached_depth_stencil_state(ctx->st, &depth_stencil); - pipe->bind_depth_stencil_state(pipe, cached); + cso = st_cached_depth_stencil_state(ctx->st, &depth_stencil); + pipe->bind_depth_stencil_state(pipe, cso->data); } /* setup state: nothing */ @@ -382,7 +381,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->data); - pipe->bind_depth_stencil_state(pipe, st->state.depth_stencil); + pipe->bind_depth_stencil_state(pipe, st->state.depth_stencil->data); pipe->bind_fs_state(pipe, st->state.fs->data); pipe->bind_vs_state(pipe, st->state.vs->data); pipe->bind_rasterizer_state(pipe, st->state.rasterizer->data); diff --git a/src/mesa/state_tracker/st_cb_drawpixels.c b/src/mesa/state_tracker/st_cb_drawpixels.c index 4e3c24353e..95810b7baf 100644 --- a/src/mesa/state_tracker/st_cb_drawpixels.c +++ b/src/mesa/state_tracker/st_cb_drawpixels.c @@ -470,7 +470,7 @@ any_fragment_ops(const struct st_context *st) if (st->state.alpha_test.enabled || st->state.blend->state.blend_enable || st->state.blend->state.logicop_enable || - st->state.depth_stencil->depth.enabled) + st->state.depth_stencil->state.depth.enabled) /* XXX more checks */ return GL_TRUE; else diff --git a/src/mesa/state_tracker/st_context.h b/src/mesa/state_tracker/st_context.h index df976260f8..b82cf24273 100644 --- a/src/mesa/state_tracker/st_context.h +++ b/src/mesa/state_tracker/st_context.h @@ -77,7 +77,7 @@ struct st_context struct { const struct cso_blend *blend; const struct pipe_sampler_state *sampler[PIPE_MAX_SAMPLERS]; - const struct pipe_depth_stencil_state *depth_stencil; + const struct cso_depth_stencil *depth_stencil; const struct cso_rasterizer *rasterizer; const struct cso_fragment_shader *fs; const struct cso_vertex_shader *vs; -- cgit v1.2.3