summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorZack Rusin <zack@tungstengraphics.com>2007-09-17 12:59:50 -0400
committerZack Rusin <zack@tungstengraphics.com>2007-09-18 07:18:12 -0400
commit294401814d1d89cc731de1c22c25333aa5d59374 (patch)
treec392643aaed3660fe9d577044b3f928fb50c4ac7
parentd6ac959833a8e40a27907940969c622692f749b1 (diff)
converting the setup state to immutable object and renaming it to rasterizer state
-rw-r--r--src/mesa/cso_cache/cso_cache.c6
-rw-r--r--src/mesa/cso_cache/cso_cache.h4
-rw-r--r--src/mesa/pipe/draw/draw_context.c16
-rw-r--r--src/mesa/pipe/draw/draw_context.h2
-rw-r--r--src/mesa/pipe/draw/draw_cull.c2
-rw-r--r--src/mesa/pipe/draw/draw_offset.c4
-rw-r--r--src/mesa/pipe/draw/draw_private.h2
-rw-r--r--src/mesa/pipe/draw/draw_twoside.c2
-rw-r--r--src/mesa/pipe/draw/draw_unfilled.c4
-rw-r--r--src/mesa/pipe/failover/fo_context.h8
-rw-r--r--src/mesa/pipe/failover/fo_state.c14
-rw-r--r--src/mesa/pipe/failover/fo_state_emit.c4
-rw-r--r--src/mesa/pipe/i915simple/i915_context.h4
-rw-r--r--src/mesa/pipe/i915simple/i915_state.c30
-rw-r--r--src/mesa/pipe/i915simple/i915_state_derived.c6
-rw-r--r--src/mesa/pipe/i915simple/i915_state_dynamic.c16
-rw-r--r--src/mesa/pipe/i915simple/i915_state_immediate.c30
-rw-r--r--src/mesa/pipe/p_context.h11
-rw-r--r--src/mesa/pipe/p_state.h4
-rw-r--r--src/mesa/pipe/softpipe/sp_context.c4
-rw-r--r--src/mesa/pipe/softpipe/sp_context.h4
-rw-r--r--src/mesa/pipe/softpipe/sp_prim_setup.c18
-rw-r--r--src/mesa/pipe/softpipe/sp_quad.c8
-rw-r--r--src/mesa/pipe/softpipe/sp_quad_coverage.c6
-rw-r--r--src/mesa/pipe/softpipe/sp_state.h12
-rw-r--r--src/mesa/pipe/softpipe/sp_state_derived.c10
-rw-r--r--src/mesa/pipe/softpipe/sp_state_setup.c26
-rw-r--r--src/mesa/state_tracker/st_atom.c2
-rw-r--r--src/mesa/state_tracker/st_atom.h2
-rw-r--r--src/mesa/state_tracker/st_atom_setup.c95
-rw-r--r--src/mesa/state_tracker/st_cache.c18
-rw-r--r--src/mesa/state_tracker/st_cache.h6
-rw-r--r--src/mesa/state_tracker/st_cb_clear.c12
-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
36 files changed, 245 insertions, 159 deletions
diff --git a/src/mesa/cso_cache/cso_cache.c b/src/mesa/cso_cache/cso_cache.c
index a4730394f8..4aaadf00e6 100644
--- a/src/mesa/cso_cache/cso_cache.c
+++ b/src/mesa/cso_cache/cso_cache.c
@@ -78,6 +78,8 @@ static struct cso_hash *_cso_hash_for_type(struct cso_cache *sc, enum cso_cache_
hash = sc->sampler_hash;
case CSO_DEPTH_STENCIL:
hash = sc->depth_stencil_hash;
+ case CSO_RASTERIZER:
+ hash = sc->rasterizer_hash;
}
return hash;
@@ -92,6 +94,8 @@ static int _cso_size_for_type(enum cso_cache_type type)
return sizeof(struct pipe_sampler_state);
case CSO_DEPTH_STENCIL:
return sizeof(struct pipe_depth_stencil_state);
+ case CSO_RASTERIZER:
+ return sizeof(struct pipe_rasterizer_state);
}
return 0;
}
@@ -143,6 +147,7 @@ struct cso_cache *cso_cache_create(void)
sc->blend_hash = cso_hash_create();
sc->sampler_hash = cso_hash_create();
sc->depth_stencil_hash = cso_hash_create();
+ sc->rasterizer_hash = cso_hash_create();
return sc;
}
@@ -153,6 +158,7 @@ void cso_cache_delete(struct cso_cache *sc)
cso_hash_delete(sc->blend_hash);
cso_hash_delete(sc->sampler_hash);
cso_hash_delete(sc->depth_stencil_hash);
+ cso_hash_delete(sc->rasterizer_hash);
free(sc);
}
diff --git a/src/mesa/cso_cache/cso_cache.h b/src/mesa/cso_cache/cso_cache.h
index c340cf7f67..23be9cd713 100644
--- a/src/mesa/cso_cache/cso_cache.h
+++ b/src/mesa/cso_cache/cso_cache.h
@@ -43,12 +43,14 @@ struct cso_cache {
struct cso_hash *blend_hash;
struct cso_hash *sampler_hash;
struct cso_hash *depth_stencil_hash;
+ struct cso_hash *rasterizer_hash;
};
enum cso_cache_type {
CSO_BLEND,
CSO_SAMPLER,
- CSO_DEPTH_STENCIL
+ CSO_DEPTH_STENCIL,
+ CSO_RASTERIZER
};
unsigned cso_construct_key(void *item, int item_size);
diff --git a/src/mesa/pipe/draw/draw_context.c b/src/mesa/pipe/draw/draw_context.c
index 4498293e92..f3236ad59e 100644
--- a/src/mesa/pipe/draw/draw_context.c
+++ b/src/mesa/pipe/draw/draw_context.c
@@ -98,19 +98,19 @@ static void validate_pipeline( struct draw_context *draw )
* shorter pipelines for lines & points.
*/
- if (draw->setup.fill_cw != PIPE_POLYGON_MODE_FILL ||
- draw->setup.fill_ccw != PIPE_POLYGON_MODE_FILL) {
+ if (draw->rasterizer->fill_cw != PIPE_POLYGON_MODE_FILL ||
+ draw->rasterizer->fill_ccw != PIPE_POLYGON_MODE_FILL) {
draw->pipeline.unfilled->next = next;
next = draw->pipeline.unfilled;
}
- if (draw->setup.offset_cw ||
- draw->setup.offset_ccw) {
+ if (draw->rasterizer->offset_cw ||
+ draw->rasterizer->offset_ccw) {
draw->pipeline.offset->next = next;
next = draw->pipeline.offset;
}
- if (draw->setup.light_twoside) {
+ if (draw->rasterizer->light_twoside) {
draw->pipeline.twoside->next = next;
next = draw->pipeline.twoside;
}
@@ -134,7 +134,7 @@ static void validate_pipeline( struct draw_context *draw )
* this for clipped primitives, ie it is a part of the clip
* routine.
*/
- if (draw->setup.flatshade) {
+ if (draw->rasterizer->flatshade) {
draw->pipeline.flatshade->next = next;
next = draw->pipeline.flatshade;
}
@@ -161,9 +161,9 @@ void draw_set_feedback_state( struct draw_context *draw,
* This causes the drawing pipeline to be rebuilt.
*/
void draw_set_setup_state( struct draw_context *draw,
- const struct pipe_setup_state *setup )
+ const struct pipe_rasterizer_state *raster )
{
- draw->setup = *setup; /* struct copy */
+ draw->rasterizer = raster;
validate_pipeline( draw );
}
diff --git a/src/mesa/pipe/draw/draw_context.h b/src/mesa/pipe/draw/draw_context.h
index 2babc02f45..2714252fc5 100644
--- a/src/mesa/pipe/draw/draw_context.h
+++ b/src/mesa/pipe/draw/draw_context.h
@@ -87,7 +87,7 @@ void draw_set_feedback_state( struct draw_context *draw,
const struct pipe_feedback_state * );
void draw_set_setup_state( struct draw_context *draw,
- const struct pipe_setup_state *setup );
+ const struct pipe_rasterizer_state *raster );
void draw_set_setup_stage( struct draw_context *draw,
struct draw_stage *stage );
diff --git a/src/mesa/pipe/draw/draw_cull.c b/src/mesa/pipe/draw/draw_cull.c
index f3d56ad719..f898834ba5 100644
--- a/src/mesa/pipe/draw/draw_cull.c
+++ b/src/mesa/pipe/draw/draw_cull.c
@@ -54,7 +54,7 @@ static void cull_begin( struct draw_stage *stage )
{
struct cull_stage *cull = cull_stage(stage);
- cull->winding = stage->draw->setup.cull_mode;
+ cull->winding = stage->draw->rasterizer->cull_mode;
stage->next->begin( stage->next );
}
diff --git a/src/mesa/pipe/draw/draw_offset.c b/src/mesa/pipe/draw/draw_offset.c
index 4f653e8c54..6acc7cbcd2 100644
--- a/src/mesa/pipe/draw/draw_offset.c
+++ b/src/mesa/pipe/draw/draw_offset.c
@@ -57,8 +57,8 @@ static void offset_begin( struct draw_stage *stage )
struct offset_stage *offset = offset_stage(stage);
float mrd = 1.0f / 65535.0f; /* XXX this depends on depthbuffer bits! */
- offset->units = stage->draw->setup.offset_units * mrd;
- offset->scale = stage->draw->setup.offset_scale;
+ offset->units = stage->draw->rasterizer->offset_units * mrd;
+ offset->scale = stage->draw->rasterizer->offset_scale;
stage->next->begin( stage->next );
}
diff --git a/src/mesa/pipe/draw/draw_private.h b/src/mesa/pipe/draw/draw_private.h
index 8bcc3717c4..fb0aaff40d 100644
--- a/src/mesa/pipe/draw/draw_private.h
+++ b/src/mesa/pipe/draw/draw_private.h
@@ -137,7 +137,7 @@ struct draw_context
} pipeline;
/* pipe state that we need: */
- struct pipe_setup_state setup;
+ const struct pipe_rasterizer_state *rasterizer;
struct pipe_feedback_state feedback;
struct pipe_viewport_state viewport;
struct pipe_vertex_buffer vertex_buffer[PIPE_ATTRIB_MAX];
diff --git a/src/mesa/pipe/draw/draw_twoside.c b/src/mesa/pipe/draw/draw_twoside.c
index 98eb088035..3eb8cce637 100644
--- a/src/mesa/pipe/draw/draw_twoside.c
+++ b/src/mesa/pipe/draw/draw_twoside.c
@@ -55,7 +55,7 @@ static void twoside_begin( struct draw_stage *stage )
* if the triangle is back-facing (negative).
* sign = -1 for CCW, +1 for CW
*/
- twoside->sign = (stage->draw->setup.front_winding == PIPE_WINDING_CCW) ? -1.0f : 1.0f;
+ twoside->sign = (stage->draw->rasterizer->front_winding == PIPE_WINDING_CCW) ? -1.0f : 1.0f;
stage->next->begin( stage->next );
}
diff --git a/src/mesa/pipe/draw/draw_unfilled.c b/src/mesa/pipe/draw/draw_unfilled.c
index b0d6f3d065..2d374329d8 100644
--- a/src/mesa/pipe/draw/draw_unfilled.c
+++ b/src/mesa/pipe/draw/draw_unfilled.c
@@ -59,8 +59,8 @@ static void unfilled_begin( struct draw_stage *stage )
{
struct unfilled_stage *unfilled = unfilled_stage(stage);
- unfilled->mode[0] = stage->draw->setup.fill_ccw; /* front */
- unfilled->mode[1] = stage->draw->setup.fill_cw; /* back */
+ unfilled->mode[0] = stage->draw->rasterizer->fill_ccw; /* front */
+ unfilled->mode[1] = stage->draw->rasterizer->fill_cw; /* back */
stage->next->begin( stage->next );
}
diff --git a/src/mesa/pipe/failover/fo_context.h b/src/mesa/pipe/failover/fo_context.h
index 63ec7239ab..b05ceb88ad 100644
--- a/src/mesa/pipe/failover/fo_context.h
+++ b/src/mesa/pipe/failover/fo_context.h
@@ -37,7 +37,7 @@
#define FO_NEW_VIEWPORT 0x1
-#define FO_NEW_SETUP 0x2
+#define FO_NEW_RASTERIZER 0x2
#define FO_NEW_FRAGMENT_SHADER 0x4
#define FO_NEW_BLEND 0x8
#define FO_NEW_CLIP 0x10
@@ -66,9 +66,10 @@ struct failover_context {
/* The most recent drawing state as set by the driver:
*/
- const struct pipe_blend_state *blend;
- const struct pipe_sampler_state *sampler[PIPE_MAX_SAMPLERS];
+ const struct pipe_blend_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;
struct pipe_alpha_test_state alpha_test;
struct pipe_blend_color blend_color;
@@ -79,7 +80,6 @@ struct failover_context {
struct pipe_shader_state vertex_shader;
struct pipe_poly_stipple poly_stipple;
struct pipe_scissor_state scissor;
- struct pipe_setup_state setup;
struct pipe_mipmap_tree *texture[PIPE_MAX_SAMPLERS];
struct pipe_viewport_state viewport;
struct pipe_vertex_buffer vertex_buffer[PIPE_ATTRIB_MAX];
diff --git a/src/mesa/pipe/failover/fo_state.c b/src/mesa/pipe/failover/fo_state.c
index 43b9757b31..8e2b649590 100644
--- a/src/mesa/pipe/failover/fo_state.c
+++ b/src/mesa/pipe/failover/fo_state.c
@@ -160,15 +160,15 @@ failover_set_polygon_stipple( struct pipe_context *pipe,
-static void
-failover_set_setup_state( struct pipe_context *pipe,
- const struct pipe_setup_state *setup )
+static void
+failover_bind_rasterizer_state( struct pipe_context *pipe,
+ const struct pipe_rasterizer_state *setup )
{
struct failover_context *failover = failover_context(pipe);
- failover->setup = *setup;
- failover->dirty |= FO_NEW_SETUP;
- failover->hw->set_setup_state( failover->hw, setup );
+ failover->rasterizer = setup;
+ failover->dirty |= FO_NEW_RASTERIZER;
+ failover->hw->bind_rasterizer_state( failover->hw, setup );
}
@@ -257,6 +257,7 @@ failover_init_state_functions( struct failover_context *failover )
failover->pipe.bind_blend_state = failover_bind_blend_state;
failover->pipe.bind_sampler_state = failover_bind_sampler_state;
failover->pipe.bind_depth_stencil_state = failover_bind_depth_stencil_state;
+ failover->pipe.bind_rasterizer_state = failover_bind_rasterizer_state;
failover->pipe.set_alpha_test_state = failover_set_alpha_test_state;
failover->pipe.set_blend_color = failover_set_blend_color;
@@ -267,7 +268,6 @@ failover_init_state_functions( struct failover_context *failover )
failover->pipe.set_vs_state = failover_set_vs_state;
failover->pipe.set_polygon_stipple = failover_set_polygon_stipple;
failover->pipe.set_scissor_state = failover_set_scissor_state;
- failover->pipe.set_setup_state = failover_set_setup_state;
failover->pipe.set_texture_state = failover_set_texture_state;
failover->pipe.set_viewport_state = failover_set_viewport_state;
failover->pipe.set_vertex_buffer = failover_set_vertex_buffer;
diff --git a/src/mesa/pipe/failover/fo_state_emit.c b/src/mesa/pipe/failover/fo_state_emit.c
index 3a1865d766..1c9573a7b0 100644
--- a/src/mesa/pipe/failover/fo_state_emit.c
+++ b/src/mesa/pipe/failover/fo_state_emit.c
@@ -85,8 +85,8 @@ failover_state_emit( struct failover_context *failover )
if (failover->dirty & FO_NEW_STIPPLE)
failover->sw->set_polygon_stipple( failover->sw, &failover->poly_stipple );
- if (failover->dirty & FO_NEW_SETUP)
- failover->sw->set_setup_state( failover->sw, &failover->setup );
+ if (failover->dirty & FO_NEW_RASTERIZER)
+ failover->sw->bind_rasterizer_state( failover->sw, failover->rasterizer );
if (failover->dirty & FO_NEW_SCISSOR)
failover->sw->set_scissor_state( failover->sw, &failover->scissor );
diff --git a/src/mesa/pipe/i915simple/i915_context.h b/src/mesa/pipe/i915simple/i915_context.h
index 518f780449..3fab821fde 100644
--- a/src/mesa/pipe/i915simple/i915_context.h
+++ b/src/mesa/pipe/i915simple/i915_context.h
@@ -126,6 +126,7 @@ struct i915_context
const struct pipe_blend_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;
struct pipe_alpha_test_state alpha_test;
struct pipe_blend_color blend_color;
@@ -136,7 +137,6 @@ struct i915_context
struct pipe_shader_state fs;
struct pipe_poly_stipple poly_stipple;
struct pipe_scissor_state scissor;
- struct pipe_setup_state setup;
struct pipe_mipmap_tree *texture[PIPE_MAX_SAMPLERS];
struct pipe_viewport_state viewport;
struct pipe_vertex_buffer vertex_buffer[PIPE_ATTRIB_MAX];
@@ -159,7 +159,7 @@ struct i915_context
/* A flag for each state_tracker state object:
*/
#define I915_NEW_VIEWPORT 0x1
-#define I915_NEW_SETUP 0x2
+#define I915_NEW_RASTERIZER 0x2
#define I915_NEW_FS 0x4
#define I915_NEW_BLEND 0x8
#define I915_NEW_CLIP 0x10
diff --git a/src/mesa/pipe/i915simple/i915_state.c b/src/mesa/pipe/i915simple/i915_state.c
index 5ac2e27d1a..00764902bc 100644
--- a/src/mesa/pipe/i915simple/i915_state.c
+++ b/src/mesa/pipe/i915simple/i915_state.c
@@ -288,19 +288,36 @@ static void i915_set_viewport_state( struct pipe_context *pipe,
}
-static void i915_set_setup_state( struct pipe_context *pipe,
- const struct pipe_setup_state *setup )
+
+static const struct pipe_rasterizer_state *
+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;
+}
+
+static void i915_bind_rasterizer_state( struct pipe_context *pipe,
+ const struct pipe_rasterizer_state *setup )
{
struct i915_context *i915 = i915_context(pipe);
- i915->setup = *setup;
+ i915->rasterizer = setup;
/* pass-through to draw module */
draw_set_setup_state(i915->draw, setup);
- i915->dirty |= I915_NEW_SETUP;
+ i915->dirty |= I915_NEW_RASTERIZER;
}
+static void i915_delete_rasterizer_state( struct pipe_context *pipe,
+ const struct pipe_rasterizer_state *setup )
+{
+ free((struct pipe_rasterizer_state*)setup);
+}
static void i915_set_vertex_buffer( struct pipe_context *pipe,
unsigned index,
@@ -338,6 +355,10 @@ i915_init_state_functions( struct i915_context *i915 )
i915->pipe.bind_depth_stencil_state = i915_bind_depth_stencil_state;
i915->pipe.delete_depth_stencil_state = i915_delete_depth_stencil_state;
+ i915->pipe.create_rasterizer_state = i915_create_rasterizer_state;
+ i915->pipe.bind_rasterizer_state = i915_bind_rasterizer_state;
+ i915->pipe.delete_rasterizer_state = i915_delete_rasterizer_state;
+
i915->pipe.set_alpha_test_state = i915_set_alpha_test_state;
i915->pipe.set_blend_color = i915_set_blend_color;
i915->pipe.set_clip_state = i915_set_clip_state;
@@ -348,7 +369,6 @@ i915_init_state_functions( struct i915_context *i915 )
i915->pipe.set_vs_state = i915_set_vs_state;
i915->pipe.set_polygon_stipple = i915_set_polygon_stipple;
i915->pipe.set_scissor_state = i915_set_scissor_state;
- i915->pipe.set_setup_state = i915_set_setup_state;
i915->pipe.set_texture_state = i915_set_texture_state;
i915->pipe.set_viewport_state = i915_set_viewport_state;
i915->pipe.set_vertex_buffer = i915_set_vertex_buffer;
diff --git a/src/mesa/pipe/i915simple/i915_state_derived.c b/src/mesa/pipe/i915simple/i915_state_derived.c
index 792bb93b17..504bc10a9e 100644
--- a/src/mesa/pipe/i915simple/i915_state_derived.c
+++ b/src/mesa/pipe/i915simple/i915_state_derived.c
@@ -44,7 +44,7 @@ static void calculate_vertex_layout( struct i915_context *i915 )
{
const uint inputsRead = i915->fs.inputs_read;
const interp_mode colorInterp
- = i915->setup.flatshade ? INTERP_CONSTANT : INTERP_LINEAR;
+ = i915->rasterizer->flatshade ? INTERP_CONSTANT : INTERP_LINEAR;
struct vertex_info *vinfo = &i915->current.vertex_info;
uint front0 = 0, back0 = 0, front1 = 0, back1 = 0;
boolean needW = 0;
@@ -103,7 +103,7 @@ static void calculate_vertex_layout( struct i915_context *i915 )
* lighting. Edgeflag is dealt with specially by setting bits in
* the vertex header.
*/
- if (i915->setup.light_twoside) {
+ if (i915->rasterizer->light_twoside) {
if (inputsRead & (1 << TGSI_ATTRIB_COLOR0)) {
back0 = draw_emit_vertex_attr(vinfo, TGSI_ATTRIB_BFC0,
FORMAT_OMIT, colorInterp);
@@ -142,7 +142,7 @@ static void calculate_vertex_layout( struct i915_context *i915 )
*/
void i915_update_derived( struct i915_context *i915 )
{
- if (i915->dirty & (I915_NEW_SETUP | I915_NEW_FS))
+ if (i915->dirty & (I915_NEW_RASTERIZER | I915_NEW_FS))
calculate_vertex_layout( i915 );
if (i915->dirty & (I915_NEW_SAMPLER | I915_NEW_TEXTURE))
diff --git a/src/mesa/pipe/i915simple/i915_state_dynamic.c b/src/mesa/pipe/i915simple/i915_state_dynamic.c
index 9140eee7c2..a9791962e2 100644
--- a/src/mesa/pipe/i915simple/i915_state_dynamic.c
+++ b/src/mesa/pipe/i915simple/i915_state_dynamic.c
@@ -261,10 +261,10 @@ static void upload_DEPTHSCALE( struct i915_context *i915 )
memset( ds, 0, sizeof(ds) );
- /* I915_NEW_SETUP
+ /* I915_NEW_RASTERIZER
*/
ds[0].u = _3DSTATE_DEPTH_OFFSET_SCALE;
- ds[1].f = i915->setup.offset_scale;
+ ds[1].f = i915->rasterizer->offset_scale;
set_dynamic_indirect( i915,
I915_DYNAMIC_DEPTHSCALE_0,
@@ -273,7 +273,7 @@ static void upload_DEPTHSCALE( struct i915_context *i915 )
}
const struct i915_tracked_state i915_upload_DEPTHSCALE = {
- .dirty = I915_NEW_SETUP,
+ .dirty = I915_NEW_RASTERIZER,
.update = upload_DEPTHSCALE
};
@@ -298,9 +298,9 @@ static void upload_STIPPLE( struct i915_context *i915 )
st[0] = _3DSTATE_STIPPLE;
st[1] = 0;
- /* I915_NEW_SETUP
+ /* I915_NEW_RASTERIZER
*/
- if (i915->setup.poly_stipple_enable) {
+ if (i915->rasterizer->poly_stipple_enable) {
st[1] |= ST1_ENABLE;
}
@@ -333,7 +333,7 @@ static void upload_STIPPLE( struct i915_context *i915 )
const struct i915_tracked_state i915_upload_STIPPLE = {
- .dirty = I915_NEW_SETUP | I915_NEW_STIPPLE,
+ .dirty = I915_NEW_RASTERIZER | I915_NEW_STIPPLE,
.update = upload_STIPPLE
};
@@ -346,7 +346,7 @@ static void upload_SCISSOR_ENABLE( struct i915_context *i915 )
{
unsigned sc[1];
- if (i915->setup.scissor)
+ if (i915->rasterizer->scissor)
sc[0] = _3DSTATE_SCISSOR_ENABLE_CMD | ENABLE_SCISSOR_RECT;
else
sc[0] = _3DSTATE_SCISSOR_ENABLE_CMD | DISABLE_SCISSOR_RECT;
@@ -358,7 +358,7 @@ static void upload_SCISSOR_ENABLE( struct i915_context *i915 )
}
const struct i915_tracked_state i915_upload_SCISSOR_ENABLE = {
- .dirty = I915_NEW_SETUP,
+ .dirty = I915_NEW_RASTERIZER,
.update = upload_SCISSOR_ENABLE
};
diff --git a/src/mesa/pipe/i915simple/i915_state_immediate.c b/src/mesa/pipe/i915simple/i915_state_immediate.c
index 484913d308..73508f557f 100644
--- a/src/mesa/pipe/i915simple/i915_state_immediate.c
+++ b/src/mesa/pipe/i915simple/i915_state_immediate.c
@@ -62,8 +62,8 @@ static void upload_S2S4(struct i915_context *i915)
assert(LIS4); /* should never be zero? */
}
- /* I915_NEW_SETUP */
- switch (i915->setup.cull_mode) {
+ /* I915_NEW_RASTERIZER */
+ switch (i915->rasterizer->cull_mode) {
case PIPE_WINDING_NONE:
LIS4 |= S4_CULLMODE_NONE;
break;
@@ -78,25 +78,25 @@ static void upload_S2S4(struct i915_context *i915)
break;
}
- /* I915_NEW_SETUP */
+ /* I915_NEW_RASTERIZER */
{
- int line_width = CLAMP((int)(i915->setup.line_width * 2), 1, 0xf);
+ int line_width = CLAMP((int)(i915->rasterizer->line_width * 2), 1, 0xf);
LIS4 |= line_width << S4_LINE_WIDTH_SHIFT;
- if (i915->setup.line_smooth)
+ if (i915->rasterizer->line_smooth)
LIS4 |= S4_LINE_ANTIALIAS_ENABLE;
}
- /* I915_NEW_SETUP */
+ /* I915_NEW_RASTERIZER */
{
- int point_size = CLAMP((int) i915->setup.point_size, 1, 0xff);
+ int point_size = CLAMP((int) i915->rasterizer->point_size, 1, 0xff);
LIS4 |= point_size << S4_POINT_WIDTH_SHIFT;
}
- /* I915_NEW_SETUP */
- if (i915->setup.flatshade) {
+ /* I915_NEW_RASTERIZER */
+ if (i915->rasterizer->flatshade) {
LIS4 |= (S4_FLATSHADE_ALPHA |
S4_FLATSHADE_COLOR |
S4_FLATSHADE_SPECULAR);
@@ -114,7 +114,7 @@ static void upload_S2S4(struct i915_context *i915)
const struct i915_tracked_state i915_upload_S2S4 = {
- .dirty = I915_NEW_SETUP | I915_NEW_VERTEX_FORMAT,
+ .dirty = I915_NEW_RASTERIZER | I915_NEW_VERTEX_FORMAT,
.update = upload_S2S4
};
@@ -165,7 +165,7 @@ static void upload_S5( struct i915_context *i915 )
#if 0
- /* I915_NEW_SETUP */
+ /* I915_NEW_RASTERIZER */
if (i915->state.Polygon->OffsetFill) {
LIS5 |= S5_GLOBAL_DEPTH_OFFSET_ENABLE;
}
@@ -179,7 +179,7 @@ static void upload_S5( struct i915_context *i915 )
}
const struct i915_tracked_state i915_upload_S5 = {
- .dirty = (I915_NEW_DEPTH_STENCIL | I915_NEW_BLEND | I915_NEW_SETUP),
+ .dirty = (I915_NEW_DEPTH_STENCIL | I915_NEW_BLEND | I915_NEW_RASTERIZER),
.update = upload_S5
};
@@ -247,9 +247,9 @@ static void upload_S7( struct i915_context *i915 )
{
float LIS7;
- /* I915_NEW_SETUP
+ /* I915_NEW_RASTERIZER
*/
- LIS7 = i915->setup.offset_units; /* probably incorrect */
+ LIS7 = i915->rasterizer->offset_units; /* probably incorrect */
if (LIS7 != i915->current.immediate[I915_IMMEDIATE_S7]) {
i915->current.immediate[I915_IMMEDIATE_S7] = LIS7;
@@ -258,7 +258,7 @@ static void upload_S7( struct i915_context *i915 )
}
const struct i915_tracked_state i915_upload_S7 = {
- .dirty = I915_NEW_SETUP,
+ .dirty = I915_NEW_RASTERIZER,
.update = upload_S7
};
diff --git a/src/mesa/pipe/p_context.h b/src/mesa/pipe/p_context.h
index 488f002531..dda758fe6a 100644
--- a/src/mesa/pipe/p_context.h
+++ b/src/mesa/pipe/p_context.h
@@ -101,6 +101,14 @@ 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 *);
+
const struct pipe_depth_stencil_state * (*create_depth_stencil_state)(
struct pipe_context *,
const struct pipe_depth_stencil_state *);
@@ -140,9 +148,6 @@ struct pipe_context {
void (*set_polygon_stipple)( struct pipe_context *,
const struct pipe_poly_stipple * );
- void (*set_setup_state)( struct pipe_context *,
- const struct pipe_setup_state * );
-
void (*set_scissor_state)( struct pipe_context *,
const struct pipe_scissor_state * );
diff --git a/src/mesa/pipe/p_state.h b/src/mesa/pipe/p_state.h
index 30e559b594..048feede3b 100644
--- a/src/mesa/pipe/p_state.h
+++ b/src/mesa/pipe/p_state.h
@@ -65,9 +65,9 @@ struct pipe_buffer_handle;
/**
- * Primitive (point/line/tri) setup info
+ * Primitive (point/line/tri) rasterization info
*/
-struct pipe_setup_state
+struct pipe_rasterizer_state
{
unsigned flatshade:1;
unsigned light_twoside:1;
diff --git a/src/mesa/pipe/softpipe/sp_context.c b/src/mesa/pipe/softpipe/sp_context.c
index 9a8b55bb0e..7753ce40d7 100644
--- a/src/mesa/pipe/softpipe/sp_context.c
+++ b/src/mesa/pipe/softpipe/sp_context.c
@@ -259,6 +259,9 @@ struct pipe_context *softpipe_create( struct pipe_winsys *pipe_winsys,
softpipe->pipe.create_depth_stencil_state = softpipe_create_depth_stencil_state;
softpipe->pipe.bind_depth_stencil_state = softpipe_bind_depth_stencil_state;
softpipe->pipe.delete_depth_stencil_state = softpipe_delete_depth_stencil_state;
+ softpipe->pipe.create_rasterizer_state = softpipe_create_rasterizer_state;
+ softpipe->pipe.bind_rasterizer_state = softpipe_bind_rasterizer_state;
+ softpipe->pipe.delete_rasterizer_state = softpipe_delete_rasterizer_state;
softpipe->pipe.set_alpha_test_state = softpipe_set_alpha_test_state;
softpipe->pipe.set_blend_color = softpipe_set_blend_color;
@@ -271,7 +274,6 @@ struct pipe_context *softpipe_create( struct pipe_winsys *pipe_winsys,
softpipe->pipe.set_vs_state = softpipe_set_vs_state;
softpipe->pipe.set_polygon_stipple = softpipe_set_polygon_stipple;
softpipe->pipe.set_scissor_state = softpipe_set_scissor_state;
- softpipe->pipe.set_setup_state = softpipe_set_setup_state;
softpipe->pipe.set_texture_state = softpipe_set_texture_state;
softpipe->pipe.set_viewport_state = softpipe_set_viewport_state;
diff --git a/src/mesa/pipe/softpipe/sp_context.h b/src/mesa/pipe/softpipe/sp_context.h
index 4cbb0f891e..f1bb3d39a6 100644
--- a/src/mesa/pipe/softpipe/sp_context.h
+++ b/src/mesa/pipe/softpipe/sp_context.h
@@ -47,7 +47,7 @@ struct draw_stage;
#define SP_NEW_VIEWPORT 0x1
-#define SP_NEW_SETUP 0x2
+#define SP_NEW_RASTERIZER 0x2
#define SP_NEW_FS 0x4
#define SP_NEW_BLEND 0x8
#define SP_NEW_CLIP 0x10
@@ -73,6 +73,7 @@ struct softpipe_context {
const struct pipe_blend_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;
struct pipe_alpha_test_state alpha_test;
struct pipe_blend_color blend_color;
@@ -85,7 +86,6 @@ struct softpipe_context {
struct pipe_shader_state vs;
struct pipe_poly_stipple poly_stipple;
struct pipe_scissor_state scissor;
- struct pipe_setup_state setup;
struct pipe_mipmap_tree *texture[PIPE_MAX_SAMPLERS];
struct pipe_viewport_state viewport;
struct pipe_vertex_buffer vertex_buffer[PIPE_ATTRIB_MAX];
diff --git a/src/mesa/pipe/softpipe/sp_prim_setup.c b/src/mesa/pipe/softpipe/sp_prim_setup.c
index 83d317c36f..c64a4e9708 100644
--- a/src/mesa/pipe/softpipe/sp_prim_setup.c
+++ b/src/mesa/pipe/softpipe/sp_prim_setup.c
@@ -351,7 +351,7 @@ static boolean setup_sort_vertices( struct setup_stage *setup,
* - the GLSL gl_FrontFacing fragment attribute (bool)
* - two-sided stencil test
*/
- setup->quad.facing = (prim->det > 0.0) ^ (setup->softpipe->setup.front_winding == PIPE_WINDING_CW);
+ setup->quad.facing = (prim->det > 0.0) ^ (setup->softpipe->rasterizer->front_winding == PIPE_WINDING_CW);
return TRUE;
}
@@ -830,10 +830,10 @@ setup_line(struct draw_stage *stage, struct prim_header *prim)
const int errorDec = error - dx;
for (i = 0; i < dx; i++) {
- if (!sp->setup.line_stipple_enable ||
+ if (!sp->rasterizer->line_stipple_enable ||
stipple_test(sp->line_stipple_counter,
- sp->setup.line_stipple_pattern,
- sp->setup.line_stipple_factor + 1)) {
+ sp->rasterizer->line_stipple_pattern,
+ sp->rasterizer->line_stipple_factor + 1)) {
plot(setup, x0, y0);
}
@@ -857,10 +857,10 @@ setup_line(struct draw_stage *stage, struct prim_header *prim)
const int errorDec = error - dy;
for (i = 0; i < dy; i++) {
- if (!sp->setup.line_stipple_enable ||
+ if (!sp->rasterizer->line_stipple_enable ||
stipple_test(sp->line_stipple_counter,
- sp->setup.line_stipple_pattern,
- sp->setup.line_stipple_factor + 1)) {
+ sp->rasterizer->line_stipple_pattern,
+ sp->rasterizer->line_stipple_factor + 1)) {
plot(setup, x0, y0);
}
@@ -899,8 +899,8 @@ setup_point(struct draw_stage *stage, struct prim_header *prim)
const int sizeAttr = setup->lookup[TGSI_ATTRIB_POINTSIZE];
const float halfSize
= sizeAttr ? (0.5f * v0->data[sizeAttr][0])
- : (0.5f * setup->softpipe->setup.point_size);
- const boolean round = setup->softpipe->setup.point_smooth;
+ : (0.5f * setup->softpipe->rasterizer->point_size);
+ const boolean round = setup->softpipe->rasterizer->point_smooth;
const float x = v0->data[TGSI_ATTRIB_POS][0];
const float y = v0->data[TGSI_ATTRIB_POS][1];
unsigned slot, j;
diff --git a/src/mesa/pipe/softpipe/sp_quad.c b/src/mesa/pipe/softpipe/sp_quad.c
index 1f45776d47..fc4f8328cf 100644
--- a/src/mesa/pipe/softpipe/sp_quad.c
+++ b/src/mesa/pipe/softpipe/sp_quad.c
@@ -36,9 +36,9 @@ sp_build_quad_pipeline(struct softpipe_context *sp)
sp->quad.first = sp->quad.occlusion;
}
- if (sp->setup.poly_smooth ||
- sp->setup.line_smooth ||
- sp->setup.point_smooth) {
+ if (sp->rasterizer->poly_smooth ||
+ sp->rasterizer->line_smooth ||
+ sp->rasterizer->point_smooth) {
sp->quad.coverage->next = sp->quad.first;
sp->quad.first = sp->quad.coverage;
}
@@ -65,7 +65,7 @@ sp_build_quad_pipeline(struct softpipe_context *sp)
sp->quad.first = sp->quad.shade;
}
- if (sp->setup.poly_stipple_enable) {
+ if (sp->rasterizer->poly_stipple_enable) {
sp->quad.polygon_stipple->next = sp->quad.first;
sp->quad.first = sp->quad.polygon_stipple;
}
diff --git a/src/mesa/pipe/softpipe/sp_quad_coverage.c b/src/mesa/pipe/softpipe/sp_quad_coverage.c
index 8dfec59350..89f50bcca2 100644
--- a/src/mesa/pipe/softpipe/sp_quad_coverage.c
+++ b/src/mesa/pipe/softpipe/sp_quad_coverage.c
@@ -47,9 +47,9 @@ coverage_quad(struct quad_stage *qs, struct quad_header *quad)
{
struct softpipe_context *softpipe = qs->softpipe;
- if ((softpipe->setup.poly_smooth && quad->prim == PRIM_TRI) ||
- (softpipe->setup.line_smooth && quad->prim == PRIM_LINE) ||
- (softpipe->setup.point_smooth && quad->prim == PRIM_POINT)) {
+ if ((softpipe->rasterizer->poly_smooth && quad->prim == PRIM_TRI) ||
+ (softpipe->rasterizer->line_smooth && quad->prim == PRIM_LINE) ||
+ (softpipe->rasterizer->point_smooth && quad->prim == PRIM_POINT)) {
unsigned j;
for (j = 0; j < QUAD_SIZE; j++) {
assert(quad->coverage[j] >= 0.0);
diff --git a/src/mesa/pipe/softpipe/sp_state.h b/src/mesa/pipe/softpipe/sp_state.h
index caec3b4519..62bd26c4df 100644
--- a/src/mesa/pipe/softpipe/sp_state.h
+++ b/src/mesa/pipe/softpipe/sp_state.h
@@ -50,7 +50,6 @@ 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 *
softpipe_create_depth_stencil_state(struct pipe_context *,
const struct pipe_depth_stencil_state *);
@@ -59,6 +58,14 @@ 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 *
+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_delete_rasterizer_state(struct pipe_context *,
+ const struct pipe_rasterizer_state *);
+
void softpipe_set_framebuffer_state( struct pipe_context *,
const struct pipe_framebuffer_state * );
@@ -93,9 +100,6 @@ void softpipe_set_polygon_stipple( struct pipe_context *,
void softpipe_set_scissor_state( struct pipe_context *,
const struct pipe_scissor_state * );
-void softpipe_set_setup_state( struct pipe_context *,
- const struct pipe_setup_state * );
-
void softpipe_set_texture_state( struct pipe_context *,
unsigned unit,
struct pipe_mipmap_tree * );
diff --git a/src/mesa/pipe/softpipe/sp_state_derived.c b/src/mesa/pipe/softpipe/sp_state_derived.c
index 47743e185c..8c6bacf65c 100644
--- a/src/mesa/pipe/softpipe/sp_state_derived.c
+++ b/src/mesa/pipe/softpipe/sp_state_derived.c
@@ -45,7 +45,7 @@ static void calculate_vertex_layout( struct softpipe_context *softpipe )
{
const uint inputsRead = softpipe->fs.inputs_read;
const interp_mode colorInterp
- = softpipe->setup.flatshade ? INTERP_CONSTANT : INTERP_LINEAR;
+ = softpipe->rasterizer->flatshade ? INTERP_CONSTANT : INTERP_LINEAR;
struct vertex_info *vinfo = &softpipe->vertex_info;
uint front0 = 0, back0 = 0, front1 = 0, back1 = 0;
uint i;
@@ -112,7 +112,7 @@ static void calculate_vertex_layout( struct softpipe_context *softpipe )
* lighting. Edgeflag is dealt with specially by setting bits in
* the vertex header.
*/
- if (softpipe->setup.light_twoside) {
+ if (softpipe->rasterizer->light_twoside) {
if (inputsRead & (1 << TGSI_ATTRIB_COLOR0)) {
back0 = draw_emit_vertex_attr(vinfo, TGSI_ATTRIB_BFC0,
FORMAT_OMIT, colorInterp);
@@ -160,7 +160,7 @@ compute_cliprect(struct softpipe_context *sp)
surfHeight = sp->scissor.maxy;
}
- if (sp->setup.scissor) {
+ if (sp->rasterizer->scissor) {
/* clip to scissor rect */
sp->cliprect.minx = MAX2(sp->scissor.minx, 0);
sp->cliprect.miny = MAX2(sp->scissor.miny, 0);
@@ -182,7 +182,7 @@ compute_cliprect(struct softpipe_context *sp)
*/
void softpipe_update_derived( struct softpipe_context *softpipe )
{
- if (softpipe->dirty & (SP_NEW_SETUP | SP_NEW_FS))
+ if (softpipe->dirty & (SP_NEW_RASTERIZER | SP_NEW_FS))
calculate_vertex_layout( softpipe );
if (softpipe->dirty & (SP_NEW_SCISSOR |
@@ -194,7 +194,7 @@ void softpipe_update_derived( struct softpipe_context *softpipe )
SP_NEW_DEPTH_STENCIL |
SP_NEW_ALPHA_TEST |
SP_NEW_FRAMEBUFFER |
- SP_NEW_SETUP |
+ SP_NEW_RASTERIZER |
SP_NEW_FS))
sp_build_quad_pipeline(softpipe);
diff --git a/src/mesa/pipe/softpipe/sp_state_setup.c b/src/mesa/pipe/softpipe/sp_state_setup.c
index 4715a26f55..6788396355 100644
--- a/src/mesa/pipe/softpipe/sp_state_setup.c
+++ b/src/mesa/pipe/softpipe/sp_state_setup.c
@@ -31,17 +31,35 @@
#include "pipe/draw/draw_context.h"
-void softpipe_set_setup_state( struct pipe_context *pipe,
- const struct pipe_setup_state *setup )
+
+const struct pipe_rasterizer_state *
+softpipe_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;
+}
+
+void softpipe_bind_rasterizer_state(struct pipe_context *pipe,
+ const struct pipe_rasterizer_state *setup)
{
struct softpipe_context *softpipe = softpipe_context(pipe);
/* pass-through to draw module */
draw_set_setup_state(softpipe->draw, setup);
- memcpy( &softpipe->setup, setup, sizeof(*setup) );
+ softpipe->rasterizer = setup;
+
+ softpipe->dirty |= SP_NEW_RASTERIZER;
+}
- softpipe->dirty |= SP_NEW_SETUP;
+void softpipe_delete_rasterizer_state(struct pipe_context *pipe,
+ const struct pipe_rasterizer_state *rasterizer)
+{
+ free((struct pipe_rasterizer_state*)rasterizer);
}
diff --git a/src/mesa/state_tracker/st_atom.c b/src/mesa/state_tracker/st_atom.c
index 99d0bcb90b..a4af3aeb20 100644
--- a/src/mesa/state_tracker/st_atom.c
+++ b/src/mesa/state_tracker/st_atom.c
@@ -53,7 +53,7 @@ static const struct st_tracked_state *atoms[] =
&st_update_vs,
&st_update_fs,
- &st_update_setup,
+ &st_update_rasterizer,
&st_update_polygon_stipple,
&st_update_viewport,
&st_update_scissor,
diff --git a/src/mesa/state_tracker/st_atom.h b/src/mesa/state_tracker/st_atom.h
index 0e362b1fbf..26f6514698 100644
--- a/src/mesa/state_tracker/st_atom.h
+++ b/src/mesa/state_tracker/st_atom.h
@@ -51,7 +51,7 @@ const struct st_tracked_state st_update_depth_stencil;
const struct st_tracked_state st_update_tnl;
const struct st_tracked_state st_update_fs;
const struct st_tracked_state st_update_vs;
-const struct st_tracked_state st_update_setup;
+const struct st_tracked_state st_update_rasterizer;
const struct st_tracked_state st_update_polygon_stipple;
const struct st_tracked_state st_update_viewport;
const struct st_tracked_state st_update_scissor;
diff --git a/src/mesa/state_tracker/st_atom_setup.c b/src/mesa/state_tracker/st_atom_setup.c
index 09d921560d..cab8ad5cd6 100644
--- a/src/mesa/state_tracker/st_atom_setup.c
+++ b/src/mesa/state_tracker/st_atom_setup.c
@@ -32,6 +32,7 @@
#include "st_context.h"
+#include "st_cache.h"
#include "pipe/p_context.h"
#include "pipe/p_defines.h"
#include "st_atom.h"
@@ -68,20 +69,21 @@ static GLboolean get_offset_flag( GLuint fill_mode,
}
-static void update_setup_state( struct st_context *st )
+static void update_raster_state( struct st_context *st )
{
GLcontext *ctx = st->ctx;
- struct pipe_setup_state setup;
+ struct pipe_rasterizer_state raster;
+ const struct pipe_rasterizer_state *cached;
- memset(&setup, 0, sizeof(setup));
+ memset(&raster, 0, sizeof(raster));
/* _NEW_POLYGON, _NEW_BUFFERS
*/
{
if (ctx->Polygon.FrontFace == GL_CCW)
- setup.front_winding = PIPE_WINDING_CCW;
+ raster.front_winding = PIPE_WINDING_CCW;
else
- setup.front_winding = PIPE_WINDING_CW;
+ raster.front_winding = PIPE_WINDING_CW;
/* XXX
* I think the intention here is that user-created framebuffer objects
@@ -90,13 +92,13 @@ static void update_setup_state( struct st_context *st )
* But this is an implementation/driver-specific artifact - remove...
*/
if (ctx->DrawBuffer && ctx->DrawBuffer->Name != 0)
- setup.front_winding ^= PIPE_WINDING_BOTH;
+ raster.front_winding ^= PIPE_WINDING_BOTH;
}
/* _NEW_LIGHT
*/
if (ctx->Light.ShadeModel == GL_FLAT)
- setup.flatshade = 1;
+ raster.flatshade = 1;
/* _NEW_LIGHT | _NEW_PROGRAM
*
@@ -105,23 +107,23 @@ static void update_setup_state( struct st_context *st )
* GL_VERTEX_PROGRAM_TWO_SIDE is set). Note the logic here.
*/
if (ctx->VertexProgram._Enabled) {
- setup.light_twoside = ctx->VertexProgram.TwoSideEnabled;
+ raster.light_twoside = ctx->VertexProgram.TwoSideEnabled;
}
else if (ctx->Light.Enabled && ctx->Light.Model.TwoSide) {
- setup.light_twoside = 1;
+ raster.light_twoside = 1;
}
/* _NEW_POLYGON
*/
if (ctx->Polygon.CullFlag) {
if (ctx->Polygon.CullFaceMode == GL_FRONT_AND_BACK) {
- setup.cull_mode = PIPE_WINDING_BOTH;
+ raster.cull_mode = PIPE_WINDING_BOTH;
}
else if (ctx->Polygon.CullFaceMode == GL_FRONT) {
- setup.cull_mode = setup.front_winding;
+ raster.cull_mode = raster.front_winding;
}
else {
- setup.cull_mode = setup.front_winding ^ PIPE_WINDING_BOTH;
+ raster.cull_mode = raster.front_winding ^ PIPE_WINDING_BOTH;
}
}
@@ -131,23 +133,23 @@ static void update_setup_state( struct st_context *st )
GLuint fill_front = translate_fill( ctx->Polygon.FrontMode );
GLuint fill_back = translate_fill( ctx->Polygon.BackMode );
- if (setup.front_winding == PIPE_WINDING_CW) {
- setup.fill_cw = fill_front;
- setup.fill_ccw = fill_back;
+ if (raster.front_winding == PIPE_WINDING_CW) {
+ raster.fill_cw = fill_front;
+ raster.fill_ccw = fill_back;
}
else {
- setup.fill_cw = fill_back;
- setup.fill_ccw = fill_front;
+ raster.fill_cw = fill_back;
+ raster.fill_ccw = fill_front;
}
/* Simplify when culling is active:
*/
- if (setup.cull_mode & PIPE_WINDING_CW) {
- setup.fill_cw = setup.fill_ccw;
+ if (raster.cull_mode & PIPE_WINDING_CW) {
+ raster.fill_cw = raster.fill_ccw;
}
- if (setup.cull_mode & PIPE_WINDING_CCW) {
- setup.fill_ccw = setup.fill_cw;
+ if (raster.cull_mode & PIPE_WINDING_CCW) {
+ raster.fill_ccw = raster.fill_cw;
}
}
@@ -155,67 +157,68 @@ static void update_setup_state( struct st_context *st )
*/
if (ctx->Polygon.OffsetUnits != 0.0 ||
ctx->Polygon.OffsetFactor != 0.0) {
- setup.offset_cw = get_offset_flag( setup.fill_cw, &ctx->Polygon );
- setup.offset_ccw = get_offset_flag( setup.fill_ccw, &ctx->Polygon );
- setup.offset_units = ctx->Polygon.OffsetUnits;
- setup.offset_scale = ctx->Polygon.OffsetFactor;
+ raster.offset_cw = get_offset_flag( raster.fill_cw, &ctx->Polygon );
+ raster.offset_ccw = get_offset_flag( raster.fill_ccw, &ctx->Polygon );
+ raster.offset_units = ctx->Polygon.OffsetUnits;
+ raster.offset_scale = ctx->Polygon.OffsetFactor;
}
if (ctx->Polygon.SmoothFlag)
- setup.poly_smooth = 1;
+ raster.poly_smooth = 1;
if (ctx->Polygon.StippleFlag)
- setup.poly_stipple_enable = 1;
+ raster.poly_stipple_enable = 1;
/* _NEW_BUFFERS, _NEW_POLYGON
*/
- if (setup.fill_cw != PIPE_POLYGON_MODE_FILL ||
- setup.fill_ccw != PIPE_POLYGON_MODE_FILL)
+ if (raster.fill_cw != PIPE_POLYGON_MODE_FILL ||
+ raster.fill_ccw != PIPE_POLYGON_MODE_FILL)
{
GLfloat mrd = (ctx->DrawBuffer ?
ctx->DrawBuffer->_MRD :
1.0);
- setup.offset_units = ctx->Polygon.OffsetFactor * mrd;
- setup.offset_scale = (ctx->Polygon.OffsetUnits * mrd *
+ raster.offset_units = ctx->Polygon.OffsetFactor * mrd;
+ raster.offset_scale = (ctx->Polygon.OffsetUnits * mrd *
st->polygon_offset_scale);
}
/* _NEW_POINT
*/
- setup.point_size = ctx->Point.Size;
- setup.point_smooth = ctx->Point.SmoothFlag;
+ raster.point_size = ctx->Point.Size;
+ raster.point_smooth = ctx->Point.SmoothFlag;
/* _NEW_LINE
*/
- setup.line_width = ctx->Line.Width;
- setup.line_smooth = ctx->Line.SmoothFlag;
- setup.line_stipple_enable = ctx->Line.StippleFlag;
- setup.line_stipple_pattern = ctx->Line.StipplePattern;
+ raster.line_width = ctx->Line.Width;
+ raster.line_smooth = ctx->Line.SmoothFlag;
+ raster.line_stipple_enable = ctx->Line.StippleFlag;
+ raster.line_stipple_pattern = ctx->Line.StipplePattern;
/* GL stipple factor is in [1,256], remap to [0, 255] here */
- setup.line_stipple_factor = ctx->Line.StippleFactor - 1;
+ raster.line_stipple_factor = ctx->Line.StippleFactor - 1;
/* _NEW_MULTISAMPLE */
if (ctx->Multisample.Enabled)
- setup.multisample = 1;
+ raster.multisample = 1;
/* _NEW_SCISSOR */
if (ctx->Scissor.Enabled)
- setup.scissor = 1;
+ raster.scissor = 1;
- if (memcmp(&setup, &st->state.setup, sizeof(setup)) != 0) {
- st->state.setup = setup;
- st->pipe->set_setup_state( st->pipe, &setup );
+ cached = st_cached_rasterizer_state(st, &raster);
+ if (st->state.rasterizer != cached) {
+ st->state.rasterizer = cached;
+ st->pipe->bind_rasterizer_state( st->pipe, cached );
}
}
-const struct st_tracked_state st_update_setup = {
- .name = "st_update_setup",
+const struct st_tracked_state st_update_rasterizer = {
+ .name = "st_update_rasterizer",
.dirty = {
.mesa = (_NEW_LIGHT | _NEW_POLYGON | _NEW_LINE | _NEW_SCISSOR |
_NEW_POINT | _NEW_BUFFERS | _NEW_MULTISAMPLE),
.st = 0,
},
- .update = update_setup_state
+ .update = update_raster_state
};
diff --git a/src/mesa/state_tracker/st_cache.c b/src/mesa/state_tracker/st_cache.c
index 64c03be99d..a687c15587 100644
--- a/src/mesa/state_tracker/st_cache.c
+++ b/src/mesa/state_tracker/st_cache.c
@@ -93,3 +93,21 @@ 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(
+ struct st_context *st,
+ const struct pipe_rasterizer_state *raster)
+{
+ unsigned hash_key = cso_construct_key((void*)raster,
+ sizeof(struct pipe_rasterizer_state));
+ struct cso_hash_iter iter = cso_find_state_template(st->cache,
+ hash_key, CSO_RASTERIZER,
+ (void*)raster);
+ 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);
+ }
+ return (struct pipe_rasterizer_state*)(cso_hash_iter_data(iter));
+}
diff --git a/src/mesa/state_tracker/st_cache.h b/src/mesa/state_tracker/st_cache.h
index 78cb2e774e..a06af31123 100644
--- a/src/mesa/state_tracker/st_cache.h
+++ b/src/mesa/state_tracker/st_cache.h
@@ -47,6 +47,10 @@ struct pipe_sampler_state * st_cached_sampler_state(
struct pipe_depth_stencil_state *st_cached_depth_stencil_state(
struct st_context *st,
- const struct pipe_depth_stencil_state *sampler);
+ 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);
#endif
diff --git a/src/mesa/state_tracker/st_cb_clear.c b/src/mesa/state_tracker/st_cb_clear.c
index e9aabd15b5..584bc1cc2a 100644
--- a/src/mesa/state_tracker/st_cb_clear.c
+++ b/src/mesa/state_tracker/st_cb_clear.c
@@ -329,16 +329,18 @@ clear_with_quad(GLcontext *ctx,
/* setup state: nothing */
{
- struct pipe_setup_state setup;
- memset(&setup, 0, sizeof(setup));
+ struct pipe_rasterizer_state raster;
+ const struct pipe_rasterizer_state *cached;
+ memset(&raster, 0, sizeof(raster));
#if 0
/* don't do per-pixel scissor; we'll just draw a PIPE_PRIM_QUAD
* that matches the scissor bounds.
*/
if (ctx->Scissor.Enabled)
- setup.scissor = 1;
+ raster.scissor = 1;
#endif
- pipe->set_setup_state(pipe, &setup);
+ cached = st_cached_rasterizer_state(ctx->st, &raster);
+ pipe->bind_rasterizer_state(pipe, cached);
}
/* fragment shader state: color pass-through program */
@@ -394,7 +396,7 @@ clear_with_quad(GLcontext *ctx,
pipe->bind_depth_stencil_state(pipe, st->state.depth_stencil);
pipe->set_fs_state(pipe, &st->state.fs);
pipe->set_vs_state(pipe, &st->state.vs);
- pipe->set_setup_state(pipe, &st->state.setup);
+ pipe->bind_rasterizer_state(pipe, st->state.rasterizer);
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 a0012e3a8c..78ede8e225 100644
--- a/src/mesa/state_tracker/st_cb_drawpixels.c
+++ b/src/mesa/state_tracker/st_cb_drawpixels.c
@@ -316,11 +316,13 @@ draw_textured_quad(GLcontext *ctx, GLint x, GLint y, GLfloat z,
/* setup state: just scissor */
{
- struct pipe_setup_state setup;
+ struct pipe_rasterizer_state setup;
+ struct pipe_rasterizer_state *cached;
memset(&setup, 0, sizeof(setup));
if (ctx->Scissor.Enabled)
setup.scissor = 1;
- pipe->set_setup_state(pipe, &setup);
+ cached = st_cached_rasterizer_state(ctx->st, &setup);
+ pipe->bind_rasterizer_state(pipe, cached);
}
/* fragment shader state: TEX lookup program */
@@ -400,7 +402,7 @@ draw_textured_quad(GLcontext *ctx, GLint x, GLint y, GLfloat z,
draw_quad(ctx, x0, y0, z, x1, y1);
/* restore GL state */
- pipe->set_setup_state(pipe, &ctx->st->state.setup);
+ pipe->bind_rasterizer_state(pipe, ctx->st->state.rasterizer);
pipe->set_fs_state(pipe, &ctx->st->state.fs);
pipe->set_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 7c887d0b55..516d319a6e 100644
--- a/src/mesa/state_tracker/st_context.h
+++ b/src/mesa/state_tracker/st_context.h
@@ -77,6 +77,7 @@ struct st_context
const struct pipe_blend_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;
struct pipe_alpha_test_state alpha_test;
struct pipe_blend_color blend_color;
@@ -88,7 +89,6 @@ struct st_context
struct pipe_mipmap_tree *texture[PIPE_MAX_SAMPLERS];
struct pipe_poly_stipple poly_stipple;
struct pipe_scissor_state scissor;
- struct pipe_setup_state setup;
struct pipe_shader_state fs;
struct pipe_shader_state vs;
struct pipe_viewport_state viewport;
diff --git a/src/mesa/state_tracker/st_draw.c b/src/mesa/state_tracker/st_draw.c
index 69f4b7fa5b..1ea7799021 100644
--- a/src/mesa/state_tracker/st_draw.c
+++ b/src/mesa/state_tracker/st_draw.c
@@ -394,7 +394,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_setup_state(draw, &st->state.setup);
+ draw_set_setup_state(draw, st->state.rasterizer);
draw_set_vertex_shader(draw, &st->state.vs);
/* XXX need to set vertex info too */