summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorZack Rusin <zack@tungstengraphics.com>2007-09-19 14:01:18 -0400
committerZack Rusin <zack@tungstengraphics.com>2007-09-19 14:01:18 -0400
commitfe555c39bb7fd530298b5be4a8f06bff41726c86 (patch)
tree68b9b24eb883c822266f6ef82608de3a817549fc
parentb6d50abd7d483029469a0faaa28e8e2f2f742c6d (diff)
Convert the rasterizer cso to the new semantics.
Basically make cso hold the driver specific struct, while managing the template.
-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.c18
-rw-r--r--src/mesa/pipe/p_context.h11
-rw-r--r--src/mesa/pipe/softpipe/sp_state.h8
-rw-r--r--src/mesa/pipe/softpipe/sp_state_rasterizer.c18
-rw-r--r--src/mesa/state_tracker/st_atom_rasterizer.c10
-rw-r--r--src/mesa/state_tracker/st_cache.c20
-rw-r--r--src/mesa/state_tracker/st_cache.h6
-rw-r--r--src/mesa/state_tracker/st_cb_clear.c8
-rw-r--r--src/mesa/state_tracker/st_cb_drawpixels.c8
-rw-r--r--src/mesa/state_tracker/st_context.h2
-rw-r--r--src/mesa/state_tracker/st_draw.c2
15 files changed, 90 insertions, 66 deletions
diff --git a/src/mesa/pipe/cso_cache/cso_cache.h b/src/mesa/pipe/cso_cache/cso_cache.h
index 7ac5908922..cd4b64eec4 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_rasterizer {
+ struct pipe_rasterizer_state state;
+ void *data;
+};
+
enum cso_cache_type {
CSO_BLEND,
CSO_SAMPLER,
diff --git a/src/mesa/pipe/failover/fo_context.h b/src/mesa/pipe/failover/fo_context.h
index ea7fb109b3..a649899010 100644
--- a/src/mesa/pipe/failover/fo_context.h
+++ b/src/mesa/pipe/failover/fo_context.h
@@ -73,7 +73,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 pipe_rasterizer_state *rasterizer;
+ const struct fo_state *rasterizer;
const struct pipe_shader_state *fragment_shader;
const struct pipe_shader_state *vertex_shader;
diff --git a/src/mesa/pipe/failover/fo_state.c b/src/mesa/pipe/failover/fo_state.c
index ba110a6e4f..25725625e0 100644
--- a/src/mesa/pipe/failover/fo_state.c
+++ b/src/mesa/pipe/failover/fo_state.c
@@ -183,17 +183,42 @@ failover_set_polygon_stipple( struct pipe_context *pipe,
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);
}
@@ -284,7 +309,9 @@ failover_init_state_functions( struct failover_context *failover )
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;
diff --git a/src/mesa/pipe/failover/fo_state_emit.c b/src/mesa/pipe/failover/fo_state_emit.c
index 72697c01a9..f2b0b1edc0 100644
--- a/src/mesa/pipe/failover/fo_state_emit.c
+++ b/src/mesa/pipe/failover/fo_state_emit.c
@@ -87,7 +87,8 @@ failover_state_emit( struct failover_context *failover )
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 );
diff --git a/src/mesa/pipe/i915simple/i915_state.c b/src/mesa/pipe/i915simple/i915_state.c
index 4a4d26be65..66aa9a0274 100644
--- a/src/mesa/pipe/i915simple/i915_state.c
+++ b/src/mesa/pipe/i915simple/i915_state.c
@@ -371,23 +371,19 @@ static void i915_set_viewport_state( struct pipe_context *pipe,
}
-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);
@@ -395,10 +391,10 @@ static void i915_bind_rasterizer_state( struct pipe_context *pipe,
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,
diff --git a/src/mesa/pipe/p_context.h b/src/mesa/pipe/p_context.h
index adca6612d5..1c0ab794f0 100644
--- a/src/mesa/pipe/p_context.h
+++ b/src/mesa/pipe/p_context.h
@@ -99,13 +99,10 @@ struct pipe_context {
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 *,
diff --git a/src/mesa/pipe/softpipe/sp_state.h b/src/mesa/pipe/softpipe/sp_state.h
index 8e7776a6c7..a20ae1d4a2 100644
--- a/src/mesa/pipe/softpipe/sp_state.h
+++ b/src/mesa/pipe/softpipe/sp_state.h
@@ -58,13 +58,13 @@ void softpipe_bind_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 * );
diff --git a/src/mesa/pipe/softpipe/sp_state_rasterizer.c b/src/mesa/pipe/softpipe/sp_state_rasterizer.c
index d832adb91b..d7845cef82 100644
--- a/src/mesa/pipe/softpipe/sp_state_rasterizer.c
+++ b/src/mesa/pipe/softpipe/sp_state_rasterizer.c
@@ -32,34 +32,30 @@
-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 */
}
diff --git a/src/mesa/state_tracker/st_atom_rasterizer.c b/src/mesa/state_tracker/st_atom_rasterizer.c
index cab8ad5cd6..e0d83ddaea 100644
--- a/src/mesa/state_tracker/st_atom_rasterizer.c
+++ b/src/mesa/state_tracker/st_atom_rasterizer.c
@@ -73,7 +73,7 @@ static void update_raster_state( struct st_context *st )
{
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));
@@ -206,10 +206,10 @@ static void update_raster_state( struct st_context *st )
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);
}
}
diff --git a/src/mesa/state_tracker/st_cache.c b/src/mesa/state_tracker/st_cache.c
index bd6c63b7a1..0f233cea58 100644
--- a/src/mesa/state_tracker/st_cache.c
+++ b/src/mesa/state_tracker/st_cache.c
@@ -95,22 +95,24 @@ struct pipe_depth_stencil_state * st_cached_depth_stencil_state(
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(
diff --git a/src/mesa/state_tracker/st_cache.h b/src/mesa/state_tracker/st_cache.h
index fb0ff0d4db..5b8c6168a8 100644
--- a/src/mesa/state_tracker/st_cache.h
+++ b/src/mesa/state_tracker/st_cache.h
@@ -51,9 +51,9 @@ struct pipe_depth_stencil_state *st_cached_depth_stencil_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,
diff --git a/src/mesa/state_tracker/st_cb_clear.c b/src/mesa/state_tracker/st_cb_clear.c
index 3a6991754a..5d5efd9eae 100644
--- a/src/mesa/state_tracker/st_cb_clear.c
+++ b/src/mesa/state_tracker/st_cb_clear.c
@@ -345,7 +345,7 @@ clear_with_quad(GLcontext *ctx,
/* 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
@@ -354,8 +354,8 @@ clear_with_quad(GLcontext *ctx,
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 */
@@ -415,7 +415,7 @@ clear_with_quad(GLcontext *ctx,
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);
diff --git a/src/mesa/state_tracker/st_cb_drawpixels.c b/src/mesa/state_tracker/st_cb_drawpixels.c
index 4a554cd5a4..0fd728c930 100644
--- a/src/mesa/state_tracker/st_cb_drawpixels.c
+++ b/src/mesa/state_tracker/st_cb_drawpixels.c
@@ -328,12 +328,12 @@ draw_textured_quad(GLcontext *ctx, GLint x, GLint y, GLfloat z,
/* 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 */
@@ -417,7 +417,7 @@ draw_textured_quad(GLcontext *ctx, GLint x, GLint y, GLfloat z,
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]);
diff --git a/src/mesa/state_tracker/st_context.h b/src/mesa/state_tracker/st_context.h
index 966574b67c..93b6425480 100644
--- a/src/mesa/state_tracker/st_context.h
+++ b/src/mesa/state_tracker/st_context.h
@@ -78,7 +78,7 @@ struct st_context
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;
diff --git a/src/mesa/state_tracker/st_draw.c b/src/mesa/state_tracker/st_draw.c
index 6efe3ce8b8..e36c10d595 100644
--- a/src/mesa/state_tracker/st_draw.c
+++ b/src/mesa/state_tracker/st_draw.c
@@ -404,7 +404,7 @@ st_feedback_draw_vbo(GLcontext *ctx,
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 */