void *data;
};
+struct cso_depth_stencil {
+ struct pipe_depth_stencil_state state;
+ void *data;
+};
+
struct cso_rasterizer {
struct pipe_rasterizer_state state;
void *data;
*/
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;
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)
{
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;
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 );
* 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,
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 *);
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 * );
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 */
}
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));
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 */
}
}
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(
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,
/* 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;
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 */
/* 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);
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
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;