void *data;
};
+struct cso_rasterizer {
+ struct pipe_rasterizer_state state;
+ void *data;
+};
+
enum cso_cache_type {
CSO_BLEND,
CSO_SAMPLER,
const struct fo_state *blend;
const struct pipe_sampler_state *sampler[PIPE_MAX_SAMPLERS];
const struct pipe_depth_stencil_state *depth_stencil;
- const struct pipe_rasterizer_state *rasterizer;
+ const struct fo_state *rasterizer;
const struct pipe_shader_state *fragment_shader;
const struct pipe_shader_state *vertex_shader;
failover->hw->set_polygon_stipple( failover->hw, stipple );
}
+static void *
+failover_create_rasterizer_state(struct pipe_context *pipe,
+ const struct pipe_rasterizer_state *templ)
+{
+ struct fo_state *state = malloc(sizeof(struct fo_state));
+ struct failover_context *failover = failover_context(pipe);
+ state->sw_state = failover->sw->create_rasterizer_state(pipe, templ);
+ state->hw_state = failover->hw->create_rasterizer_state(pipe, templ);
+
+ return state;
+}
static void
-failover_bind_rasterizer_state( struct pipe_context *pipe,
- const struct pipe_rasterizer_state *setup )
+failover_bind_rasterizer_state(struct pipe_context *pipe,
+ void *raster)
{
struct failover_context *failover = failover_context(pipe);
- failover->rasterizer = setup;
+ failover->rasterizer = (struct fo_state *)raster;
failover->dirty |= FO_NEW_RASTERIZER;
- failover->hw->bind_rasterizer_state( failover->hw, setup );
+ failover->hw->bind_rasterizer_state( failover->hw, raster );
+}
+
+static void
+failover_delete_rasterizer_state(struct pipe_context *pipe,
+ void *raster)
+{
+ struct fo_state *state = (struct fo_state*)raster;
+ struct failover_context *failover = failover_context(pipe);
+
+ failover->sw->delete_rasterizer_state(pipe, state->sw_state);
+ failover->hw->delete_rasterizer_state(pipe, state->hw_state);
+ state->sw_state = 0;
+ state->hw_state = 0;
+ free(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_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->pipe.bind_fs_state = failover_bind_fs_state;
failover->pipe.bind_vs_state = failover_bind_vs_state;
failover->sw->set_polygon_stipple( failover->sw, &failover->poly_stipple );
if (failover->dirty & FO_NEW_RASTERIZER)
- failover->sw->bind_rasterizer_state( failover->sw, failover->rasterizer );
+ failover->sw->bind_rasterizer_state( failover->sw,
+ failover->rasterizer->sw_state );
if (failover->dirty & FO_NEW_SCISSOR)
failover->sw->set_scissor_state( failover->sw, &failover->scissor );
}
-static const struct pipe_rasterizer_state *
+static void *
i915_create_rasterizer_state(struct pipe_context *pipe,
const struct pipe_rasterizer_state *setup)
{
- struct pipe_rasterizer_state *raster =
- malloc(sizeof(struct pipe_rasterizer_state));
- memcpy(raster, setup, sizeof(struct pipe_rasterizer_state));
-
- return raster;
+ return 0;
}
static void i915_bind_rasterizer_state( struct pipe_context *pipe,
- const struct pipe_rasterizer_state *setup )
+ void *setup )
{
struct i915_context *i915 = i915_context(pipe);
- i915->rasterizer = setup;
+ i915->rasterizer = (struct pipe_rasterizer_state *)setup;
/* pass-through to draw module */
draw_set_rasterizer_state(i915->draw, setup);
i915->dirty |= I915_NEW_RASTERIZER;
}
-static void i915_delete_rasterizer_state( struct pipe_context *pipe,
- const struct pipe_rasterizer_state *setup )
+static void i915_delete_rasterizer_state(struct pipe_context *pipe,
+ void *setup)
{
- free((struct pipe_rasterizer_state*)setup);
+ /* do nothing */
}
static void i915_set_vertex_buffer( struct pipe_context *pipe,
void (*delete_sampler_state)(struct pipe_context *,
const struct pipe_sampler_state *);
- const struct pipe_rasterizer_state *(*create_rasterizer_state)(
- struct pipe_context *,
- const struct pipe_rasterizer_state *);
- void (*bind_rasterizer_state)(struct pipe_context *,
- const struct pipe_rasterizer_state *);
- void (*delete_rasterizer_state)(struct pipe_context *,
- const struct pipe_rasterizer_state *);
+ void *(*create_rasterizer_state)(struct pipe_context *,
+ const struct pipe_rasterizer_state *);
+ 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 *,
void softpipe_delete_depth_stencil_state(struct pipe_context *,
const struct pipe_depth_stencil_state *);
-const struct pipe_rasterizer_state *
+void *
softpipe_create_rasterizer_state(struct pipe_context *,
- const struct pipe_rasterizer_state *);
-void softpipe_bind_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 *,
- const struct pipe_rasterizer_state *);
+ void *);
void softpipe_set_framebuffer_state( struct pipe_context *,
const struct pipe_framebuffer_state * );
-const struct pipe_rasterizer_state *
+void *
softpipe_create_rasterizer_state(struct pipe_context *pipe,
- const struct pipe_rasterizer_state *setup)
+ const struct pipe_rasterizer_state *setup)
{
- struct pipe_rasterizer_state *raster =
- malloc(sizeof(struct pipe_rasterizer_state));
- memcpy(raster, setup, sizeof(struct pipe_rasterizer_state));
-
- return raster;
+ return 0;
}
void softpipe_bind_rasterizer_state(struct pipe_context *pipe,
- const struct pipe_rasterizer_state *setup)
+ void *setup)
{
struct softpipe_context *softpipe = softpipe_context(pipe);
/* pass-through to draw module */
draw_set_rasterizer_state(softpipe->draw, setup);
- softpipe->rasterizer = setup;
+ softpipe->rasterizer = (struct pipe_rasterizer_state *)setup;
softpipe->dirty |= SP_NEW_RASTERIZER;
}
void softpipe_delete_rasterizer_state(struct pipe_context *pipe,
- const struct pipe_rasterizer_state *rasterizer)
+ void *rasterizer)
{
- free((struct pipe_rasterizer_state*)rasterizer);
+ /* do nothing */
}
{
GLcontext *ctx = st->ctx;
struct pipe_rasterizer_state raster;
- const struct pipe_rasterizer_state *cached;
+ const struct cso_rasterizer *cso;
memset(&raster, 0, sizeof(raster));
if (ctx->Scissor.Enabled)
raster.scissor = 1;
- cached = st_cached_rasterizer_state(st, &raster);
- if (st->state.rasterizer != cached) {
- st->state.rasterizer = cached;
- st->pipe->bind_rasterizer_state( st->pipe, cached );
+ cso = st_cached_rasterizer_state(st, &raster);
+ if (st->state.rasterizer != cso) {
+ st->state.rasterizer = cso;
+ st->pipe->bind_rasterizer_state(st->pipe, cso->data);
}
}
return (struct pipe_depth_stencil_state*)(cso_hash_iter_data(iter));
}
-struct pipe_rasterizer_state * st_cached_rasterizer_state(
+const struct cso_rasterizer* st_cached_rasterizer_state(
struct st_context *st,
- const struct pipe_rasterizer_state *raster)
+ const struct pipe_rasterizer_state *templ)
{
- unsigned hash_key = cso_construct_key((void*)raster,
+ unsigned hash_key = cso_construct_key((void*)templ,
sizeof(struct pipe_rasterizer_state));
struct cso_hash_iter iter = cso_find_state_template(st->cache,
hash_key, CSO_RASTERIZER,
- (void*)raster);
+ (void*)templ);
if (cso_hash_iter_is_null(iter)) {
- const struct pipe_rasterizer_state *created_state =
- st->pipe->create_rasterizer_state(st->pipe, raster);
- iter = cso_insert_state(st->cache, hash_key, CSO_RASTERIZER,
- (void*)created_state);
+ struct cso_rasterizer *cso = malloc(sizeof(struct cso_rasterizer));
+ memcpy(&cso->state, templ, sizeof(struct pipe_rasterizer_state));
+ cso->data = st->pipe->create_rasterizer_state(st->pipe, templ);
+ if (!cso->data)
+ cso->data = &cso->state;
+ iter = cso_insert_state(st->cache, hash_key, CSO_RASTERIZER, cso);
}
- return (struct pipe_rasterizer_state*)(cso_hash_iter_data(iter));
+ return (struct cso_rasterizer*)(cso_hash_iter_data(iter));
}
struct pipe_shader_state * st_cached_fs_state(
struct st_context *st,
const struct pipe_depth_stencil_state *depth_stencil);
-struct pipe_rasterizer_state *st_cached_rasterizer_state(
- struct st_context *st,
- const struct pipe_rasterizer_state *raster);
+const struct cso_rasterizer *
+st_cached_rasterizer_state(struct st_context *st,
+ const struct pipe_rasterizer_state *raster);
struct pipe_shader_state *st_cached_fs_state(
struct st_context *st,
/* setup state: nothing */
{
struct pipe_rasterizer_state raster;
- const struct pipe_rasterizer_state *cached;
+ const struct cso_rasterizer *cso;
memset(&raster, 0, sizeof(raster));
#if 0
/* don't do per-pixel scissor; we'll just draw a PIPE_PRIM_QUAD
if (ctx->Scissor.Enabled)
raster.scissor = 1;
#endif
- cached = st_cached_rasterizer_state(ctx->st, &raster);
- pipe->bind_rasterizer_state(pipe, cached);
+ cso = st_cached_rasterizer_state(ctx->st, &raster);
+ pipe->bind_rasterizer_state(pipe, cso->data);
}
/* fragment shader state: color pass-through program */
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);
- pipe->bind_rasterizer_state(pipe, st->state.rasterizer);
+ pipe->bind_rasterizer_state(pipe, st->state.rasterizer->data);
pipe->set_viewport_state(pipe, &ctx->st->state.viewport);
/* OR:
st_invalidate_state(ctx, _NEW_COLOR | _NEW_DEPTH | _NEW_STENCIL);
/* setup state: just scissor */
{
struct pipe_rasterizer_state setup;
- struct pipe_rasterizer_state *cached;
+ const struct cso_rasterizer *cso;
memset(&setup, 0, sizeof(setup));
if (ctx->Scissor.Enabled)
setup.scissor = 1;
- cached = st_cached_rasterizer_state(ctx->st, &setup);
- pipe->bind_rasterizer_state(pipe, cached);
+ cso = st_cached_rasterizer_state(ctx->st, &setup);
+ pipe->bind_rasterizer_state(pipe, cso->data);
}
/* fragment shader state: TEX lookup program */
draw_quad(ctx, x0, y0, z, x1, y1);
/* restore GL state */
- pipe->bind_rasterizer_state(pipe, ctx->st->state.rasterizer);
+ pipe->bind_rasterizer_state(pipe, ctx->st->state.rasterizer->data);
pipe->bind_fs_state(pipe, ctx->st->state.fs);
pipe->bind_vs_state(pipe, ctx->st->state.vs);
pipe->set_texture_state(pipe, unit, ctx->st->state.texture[unit]);
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;
+ const struct cso_rasterizer *rasterizer;
const struct pipe_shader_state *fs;
const struct pipe_shader_state *vs;
assert(draw);
draw_set_viewport_state(draw, &st->state.viewport);
draw_set_clip_state(draw, &st->state.clip);
- draw_set_rasterizer_state(draw, st->state.rasterizer);
+ draw_set_rasterizer_state(draw, st->state.rasterizer->data);
draw_set_vertex_shader(draw, st->state.vs);
/* XXX need to set vertex info too */