summaryrefslogtreecommitdiff
path: root/src/mesa
diff options
context:
space:
mode:
authorZack Rusin <zack@tungstengraphics.com>2007-09-20 08:35:10 -0400
committerZack Rusin <zack@tungstengraphics.com>2007-09-20 08:35:10 -0400
commita6c0c5532f7bfa50ae54c36cf4d74ad4b9f926f8 (patch)
treedaf1a194cad1b9c4a4033193a19435a60531714b /src/mesa
parentdaf5b0f41baa50951e7c2f9ea5cd90b119085a7f (diff)
Convert depth_stencil state to the new semantics.
Diffstat (limited to 'src/mesa')
-rw-r--r--src/mesa/pipe/cso_cache/cso_cache.h5
-rw-r--r--src/mesa/pipe/failover/fo_context.h2
-rw-r--r--src/mesa/pipe/failover/fo_state.c35
-rw-r--r--src/mesa/pipe/failover/fo_state_emit.c3
-rw-r--r--src/mesa/pipe/i915simple/i915_state.c16
-rw-r--r--src/mesa/pipe/p_context.h11
-rw-r--r--src/mesa/pipe/softpipe/sp_state.h14
-rw-r--r--src/mesa/pipe/softpipe/sp_state_blend.c16
-rw-r--r--src/mesa/state_tracker/st_atom_depth.c10
-rw-r--r--src/mesa/state_tracker/st_cache.c23
-rw-r--r--src/mesa/state_tracker/st_cache.h6
-rw-r--r--src/mesa/state_tracker/st_cb_clear.c9
-rw-r--r--src/mesa/state_tracker/st_cb_drawpixels.c2
-rw-r--r--src/mesa/state_tracker/st_context.h2
14 files changed, 88 insertions, 66 deletions
diff --git a/src/mesa/pipe/cso_cache/cso_cache.h b/src/mesa/pipe/cso_cache/cso_cache.h
index 57d162b2ac..291759d5d1 100644
--- a/src/mesa/pipe/cso_cache/cso_cache.h
+++ b/src/mesa/pipe/cso_cache/cso_cache.h
@@ -53,6 +53,11 @@ struct cso_blend {
void *data;
};
+struct cso_depth_stencil {
+ struct pipe_depth_stencil_state state;
+ void *data;
+};
+
struct cso_rasterizer {
struct pipe_rasterizer_state state;
void *data;
diff --git a/src/mesa/pipe/failover/fo_context.h b/src/mesa/pipe/failover/fo_context.h
index a81bfe82dd..7371ad4392 100644
--- a/src/mesa/pipe/failover/fo_context.h
+++ b/src/mesa/pipe/failover/fo_context.h
@@ -72,7 +72,7 @@ struct failover_context {
*/
const struct fo_state *blend;
const struct pipe_sampler_state *sampler[PIPE_MAX_SAMPLERS];
- const struct pipe_depth_stencil_state *depth_stencil;
+ const struct fo_state *depth_stencil;
const struct fo_state *rasterizer;
const struct fo_state *fragment_shader;
const struct fo_state *vertex_shader;
diff --git a/src/mesa/pipe/failover/fo_state.c b/src/mesa/pipe/failover/fo_state.c
index db3aea7756..3379f45355 100644
--- a/src/mesa/pipe/failover/fo_state.c
+++ b/src/mesa/pipe/failover/fo_state.c
@@ -128,18 +128,45 @@ failover_set_clear_color_state( struct pipe_context *pipe,
failover->hw->set_clear_color_state( failover->hw, clear_color );
}
+static void *
+failover_create_depth_stencil_state(struct pipe_context *pipe,
+ const struct pipe_depth_stencil_state *templ)
+{
+ struct fo_state *state = malloc(sizeof(struct fo_state));
+ struct failover_context *failover = failover_context(pipe);
+
+ state->sw_state = failover->sw->create_depth_stencil_state(pipe, templ);
+ state->hw_state = failover->hw->create_depth_stencil_state(pipe, templ);
+
+ return state;
+}
+
static void
failover_bind_depth_stencil_state(struct pipe_context *pipe,
- const struct pipe_depth_stencil_state *depth_stencil)
+ void *depth_stencil)
{
struct failover_context *failover = failover_context(pipe);
- failover->depth_stencil = depth_stencil;
+ failover->depth_stencil = (struct fo_state *)depth_stencil;
failover->dirty |= FO_NEW_DEPTH_STENCIL;
failover->hw->bind_depth_stencil_state( failover->hw, depth_stencil );
}
static void
+failover_delete_depth_stencil_state(struct pipe_context *pipe,
+ void *ds)
+{
+ struct fo_state *state = (struct fo_state*)ds;
+ struct failover_context *failover = failover_context(pipe);
+
+ failover->sw->delete_depth_stencil_state(pipe, state->sw_state);
+ failover->hw->delete_depth_stencil_state(pipe, state->hw_state);
+ state->sw_state = 0;
+ state->hw_state = 0;
+ free(state);
+}
+
+static void
failover_set_framebuffer_state(struct pipe_context *pipe,
const struct pipe_framebuffer_state *framebuffer)
{
@@ -363,7 +390,9 @@ failover_init_state_functions( struct failover_context *failover )
failover->pipe.bind_blend_state = failover_bind_blend_state;
failover->pipe.delete_blend_state = failover_delete_blend_state;
failover->pipe.bind_sampler_state = failover_bind_sampler_state;
- failover->pipe.bind_depth_stencil_state = failover_bind_depth_stencil_state;
+ failover->pipe.create_depth_stencil_state = failover_create_depth_stencil_state;
+ failover->pipe.bind_depth_stencil_state = failover_bind_depth_stencil_state;
+ failover->pipe.delete_depth_stencil_state = failover_delete_depth_stencil_state;
failover->pipe.create_rasterizer_state = failover_create_rasterizer_state;
failover->pipe.bind_rasterizer_state = failover_bind_rasterizer_state;
failover->pipe.delete_rasterizer_state = failover_delete_rasterizer_state;
diff --git a/src/mesa/pipe/failover/fo_state_emit.c b/src/mesa/pipe/failover/fo_state_emit.c
index ec896fd020..da12b4e25c 100644
--- a/src/mesa/pipe/failover/fo_state_emit.c
+++ b/src/mesa/pipe/failover/fo_state_emit.c
@@ -72,7 +72,8 @@ failover_state_emit( struct failover_context *failover )
failover->sw->set_clear_color_state( failover->sw, &failover->clear_color );
if (failover->dirty & FO_NEW_DEPTH_STENCIL)
- failover->sw->bind_depth_stencil_state( failover->sw, failover->depth_stencil );
+ failover->sw->bind_depth_stencil_state( failover->sw,
+ failover->depth_stencil->sw_state );
if (failover->dirty & FO_NEW_FRAMEBUFFER)
failover->sw->set_framebuffer_state( failover->sw, &failover->framebuffer );
diff --git a/src/mesa/pipe/i915simple/i915_state.c b/src/mesa/pipe/i915simple/i915_state.c
index 1104c9519d..be549ed6fd 100644
--- a/src/mesa/pipe/i915simple/i915_state.c
+++ b/src/mesa/pipe/i915simple/i915_state.c
@@ -175,31 +175,27 @@ static void i915_delete_sampler_state(struct pipe_context *pipe,
* into one file.
*/
-static const struct pipe_depth_stencil_state *
+static void *
i915_create_depth_stencil_state(struct pipe_context *pipe,
const struct pipe_depth_stencil_state *depth_stencil)
{
- struct pipe_depth_stencil_state *new_ds =
- malloc(sizeof(struct pipe_depth_stencil_state));
- memcpy(new_ds, depth_stencil, sizeof(struct pipe_depth_stencil_state));
-
- return new_ds;
+ return 0;
}
static void i915_bind_depth_stencil_state(struct pipe_context *pipe,
- const struct pipe_depth_stencil_state *depth_stencil)
+ void *depth_stencil)
{
struct i915_context *i915 = i915_context(pipe);
- i915->depth_stencil = depth_stencil;
+ i915->depth_stencil = (const struct pipe_depth_stencil_state *)depth_stencil;
i915->dirty |= I915_NEW_DEPTH_STENCIL;
}
static void i915_delete_depth_stencil_state(struct pipe_context *pipe,
- const struct pipe_depth_stencil_state *depth_stencil)
+ void *depth_stencil)
{
- free((struct pipe_depth_stencil_state *)depth_stencil);
+ /* do nothing */
}
static void i915_set_alpha_test_state(struct pipe_context *pipe,
diff --git a/src/mesa/pipe/p_context.h b/src/mesa/pipe/p_context.h
index e17faad2c7..84aca20c58 100644
--- a/src/mesa/pipe/p_context.h
+++ b/src/mesa/pipe/p_context.h
@@ -105,13 +105,10 @@ struct pipe_context {
void (*bind_rasterizer_state)(struct pipe_context *, void *);
void (*delete_rasterizer_state)(struct pipe_context *, void *);
- const struct pipe_depth_stencil_state * (*create_depth_stencil_state)(
- struct pipe_context *,
- const struct pipe_depth_stencil_state *);
- void (*bind_depth_stencil_state)(struct pipe_context *,
- const struct pipe_depth_stencil_state *);
- void (*delete_depth_stencil_state)(struct pipe_context *,
- const struct pipe_depth_stencil_state *);
+ void * (*create_depth_stencil_state)(struct pipe_context *,
+ const struct pipe_depth_stencil_state *);
+ void (*bind_depth_stencil_state)(struct pipe_context *, void *);
+ void (*delete_depth_stencil_state)(struct pipe_context *, void *);
void * (*create_fs_state)(struct pipe_context *,
const struct pipe_shader_state *);
diff --git a/src/mesa/pipe/softpipe/sp_state.h b/src/mesa/pipe/softpipe/sp_state.h
index 5ed963c21d..08dfe208fb 100644
--- a/src/mesa/pipe/softpipe/sp_state.h
+++ b/src/mesa/pipe/softpipe/sp_state.h
@@ -50,21 +50,17 @@ void softpipe_bind_sampler_state(struct pipe_context *,
void softpipe_delete_sampler_state(struct pipe_context *,
const struct pipe_sampler_state *);
-const struct pipe_depth_stencil_state *
+void *
softpipe_create_depth_stencil_state(struct pipe_context *,
const struct pipe_depth_stencil_state *);
-void softpipe_bind_depth_stencil_state(struct pipe_context *,
- const struct pipe_depth_stencil_state *);
-void softpipe_delete_depth_stencil_state(struct pipe_context *,
- const struct pipe_depth_stencil_state *);
+void softpipe_bind_depth_stencil_state(struct pipe_context *, void *);
+void softpipe_delete_depth_stencil_state(struct pipe_context *, void *);
void *
softpipe_create_rasterizer_state(struct pipe_context *,
const struct pipe_rasterizer_state *);
-void softpipe_bind_rasterizer_state(struct pipe_context *,
- void *);
-void softpipe_delete_rasterizer_state(struct pipe_context *,
- void *);
+void softpipe_bind_rasterizer_state(struct pipe_context *, void *);
+void softpipe_delete_rasterizer_state(struct pipe_context *, void *);
void softpipe_set_framebuffer_state( struct pipe_context *,
const struct pipe_framebuffer_state * );
diff --git a/src/mesa/pipe/softpipe/sp_state_blend.c b/src/mesa/pipe/softpipe/sp_state_blend.c
index 7fb47e7aab..cf47607955 100644
--- a/src/mesa/pipe/softpipe/sp_state_blend.c
+++ b/src/mesa/pipe/softpipe/sp_state_blend.c
@@ -82,30 +82,26 @@ softpipe_set_alpha_test_state(struct pipe_context *pipe,
softpipe->dirty |= SP_NEW_ALPHA_TEST;
}
-const struct pipe_depth_stencil_state *
+void *
softpipe_create_depth_stencil_state(struct pipe_context *pipe,
const struct pipe_depth_stencil_state *depth_stencil)
{
- struct pipe_depth_stencil_state *new_ds = malloc(sizeof(struct pipe_depth_stencil_state));
- memcpy(new_ds, depth_stencil, sizeof(struct pipe_depth_stencil_state));
-
- return new_ds;
+ return 0;
}
void
softpipe_bind_depth_stencil_state(struct pipe_context *pipe,
- const struct pipe_depth_stencil_state *depth_stencil)
+ void *depth_stencil)
{
struct softpipe_context *softpipe = softpipe_context(pipe);
- softpipe->depth_stencil = depth_stencil;
+ softpipe->depth_stencil = (const struct pipe_depth_stencil_state *)depth_stencil;
softpipe->dirty |= SP_NEW_DEPTH_STENCIL;
}
void
-softpipe_delete_depth_stencil_state(struct pipe_context *pipe,
- const struct pipe_depth_stencil_state *depth)
+softpipe_delete_depth_stencil_state(struct pipe_context *pipe, void *depth)
{
- free((struct pipe_depth_stencil_state*)depth);
+ /* do nothing */
}
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;