converting the setup state to immutable object and renaming it to rasterizer state
authorZack Rusin <zack@tungstengraphics.com>
Mon, 17 Sep 2007 16:59:50 +0000 (12:59 -0400)
committerZack Rusin <zack@tungstengraphics.com>
Tue, 18 Sep 2007 11:18:12 +0000 (07:18 -0400)
36 files changed:
src/mesa/cso_cache/cso_cache.c
src/mesa/cso_cache/cso_cache.h
src/mesa/pipe/draw/draw_context.c
src/mesa/pipe/draw/draw_context.h
src/mesa/pipe/draw/draw_cull.c
src/mesa/pipe/draw/draw_offset.c
src/mesa/pipe/draw/draw_private.h
src/mesa/pipe/draw/draw_twoside.c
src/mesa/pipe/draw/draw_unfilled.c
src/mesa/pipe/failover/fo_context.h
src/mesa/pipe/failover/fo_state.c
src/mesa/pipe/failover/fo_state_emit.c
src/mesa/pipe/i915simple/i915_context.h
src/mesa/pipe/i915simple/i915_state.c
src/mesa/pipe/i915simple/i915_state_derived.c
src/mesa/pipe/i915simple/i915_state_dynamic.c
src/mesa/pipe/i915simple/i915_state_immediate.c
src/mesa/pipe/p_context.h
src/mesa/pipe/p_state.h
src/mesa/pipe/softpipe/sp_context.c
src/mesa/pipe/softpipe/sp_context.h
src/mesa/pipe/softpipe/sp_prim_setup.c
src/mesa/pipe/softpipe/sp_quad.c
src/mesa/pipe/softpipe/sp_quad_coverage.c
src/mesa/pipe/softpipe/sp_state.h
src/mesa/pipe/softpipe/sp_state_derived.c
src/mesa/pipe/softpipe/sp_state_setup.c
src/mesa/state_tracker/st_atom.c
src/mesa/state_tracker/st_atom.h
src/mesa/state_tracker/st_atom_setup.c
src/mesa/state_tracker/st_cache.c
src/mesa/state_tracker/st_cache.h
src/mesa/state_tracker/st_cb_clear.c
src/mesa/state_tracker/st_cb_drawpixels.c
src/mesa/state_tracker/st_context.h
src/mesa/state_tracker/st_draw.c

index a4730394f87e753eb1bc4ead89fe358a464d9ee0..4aaadf00e646f60b621e4a6a656e8372842d1b22 100644 (file)
@@ -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);
 }
 
index c340cf7f674dd1a7dc11939798da9cfbb73908ab..23be9cd71359f43e2d9c1b9a221325b4486674e6 100644 (file)
@@ -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);
index 4498293e92b33aca34443bb5763f1365bd95c47d..f3236ad59e12f03f5273e845560eb5df1fc41f99 100644 (file)
@@ -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 );
 }
 
index 2babc02f45f578ad968e0e9a773486c56c906cfe..2714252fc5dae3ad0cbfe3571b3c703fca96cbc4 100644 (file)
@@ -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 );
index f3d56ad7197a1b3c2e9df13ce5d8b3eef0809e5f..f898834ba5d265c619789015788fbceba07455cc 100644 (file)
@@ -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 );
 }
index 4f653e8c54269b669956e3ad16a430f71163c5e2..6acc7cbcd29ed579cb13fb221884b64aa0ab51a8 100644 (file)
@@ -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 );
 }
index 8bcc3717c4591627e1c9215ba6388ab1d9061c48..fb0aaff40d77e648b29dd76218ae3dcdfaa00e67 100644 (file)
@@ -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];
index 98eb088035adc96f4fc67fdeb760a27ccf9f9139..3eb8cce637612d159244cc6e980ee6c3e05ea5fb 100644 (file)
@@ -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 );
 }
index b0d6f3d0655e92096b5e04037352b1fbb279a382..2d374329d83173daa489ba3e57ef558b1730915b 100644 (file)
@@ -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 );
 }
index 63ec7239abf9f475f8f344882beb1777b5b24db7..b05ceb88adf95a867412a4005551a6bb700be56e 100644 (file)
@@ -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];
index 43b9757b319b94e62913b2e824e894aa3cd1a198..8e2b649590f2a669d95a8f6c00afc84dca1905ee 100644 (file)
@@ -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;
index 3a1865d7668a7d5c8405f9bc5b57cc423b5a883e..1c9573a7b001f166b087e1c2876b4d1bd2e77449 100644 (file)
@@ -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 );
index 518f780449b7de3a3456b0c70ee6713c10bb66de..3fab821fde60e76be4dc6f9611f408741d352ce7 100644 (file)
@@ -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
index 5ac2e27d1a62423fd8ca0c4206ec0c2fda885c03..00764902bc3d0cd65058b63eb96478f2f1d1526d 100644 (file)
@@ -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;
index 792bb93b170d6f2100c98ff55ea404e793031c0f..504bc10a9e44739397a6bd2cbbb8555d402a2f92 100644 (file)
@@ -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))
index 9140eee7c2919581daefa0ec82ac013d1f0cc117..a9791962e2dc12dc6e8912044d4e6f0bf6d9ad20 100644 (file)
@@ -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
 };
 
index 484913d308c3fb208efae6c5c6e3d58df7f679fb..73508f557fadddf7a278a8f872dc7a357ad1e954 100644 (file)
@@ -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
 };
 
index 488f0025311fc439331d441cdd7a0245b4613fb5..dda758fe6adadd60c3d27bbdfc4ff265697b8748 100644 (file)
@@ -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 * );
 
index 30e559b594844f8fb35d7cb9945fe35622db7055..048feede3ba68764776674af720f2b896722b16a 100644 (file)
@@ -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;
index 9a8b55bb0e3b29a52ea752987d7760330ba1c343..7753ce40d7573a69482468252c376b5c5999cae3 100644 (file)
@@ -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;
 
index 4cbb0f891ed39037f6ddf84d6515b02753929fb4..f1bb3d39a66a5fd9d5c75cc1d3486080ff6e2299 100644 (file)
@@ -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];
index 83d317c36f78e7ae338375bde1e4870b0f137229..c64a4e970812e14a76698f5db7217e97216d690e 100644 (file)
@@ -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;
index 1f45776d4776edcb5fd11e23c1d0256acdcc7784..fc4f8328cf8637faf93077cfb6628e498c0a14ba 100644 (file)
@@ -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;
    }
index 8dfec5935003b31327658fdda7dffeb4944d8543..89f50bcca2214d4c94269aeaf9a9be319fab97b3 100644 (file)
@@ -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);
index caec3b4519a100c4c351158d0a026e0f9ec043cd..62bd26c4dfe4180c1f6a061630453b643d0f2634 100644 (file)
@@ -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 * );
index 47743e185c2cf47289d7d24de6541091071feaa9..8c6bacf65cfbf69c1f96b52692de99b063b6a0d7 100644 (file)
@@ -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);
 
index 4715a26f55308e474d89dcc4513b02d37806e4c7..678839635558fbb70d41a897ae76b67393c5b886 100644 (file)
 #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);
 }
 
 
index 99d0bcb90bb410ded83969a1e9c087d00b727d23..a4af3aeb2057d945f7704186246a53743b535d1e 100644 (file)
@@ -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,
index 0e362b1fbf1080a1a7627d3a13f3a752ef25e3bd..26f6514698c337a2241e45f650c71b116ca7ca1e 100644 (file)
@@ -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;
index 09d921560d288843a58dc6280b643da945017e11..cab8ad5cd6c1d09fc7b8235dc5f4c862ba8fcfcf 100644 (file)
@@ -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
 };
index 64c03be99db7d543a66f00a3ccf1ebc30d81f8e6..a687c155874b205a7e92d7e1e32cf32858c0cb0e 100644 (file)
@@ -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));
+}
index 78cb2e774e1d003fdb7fef3d2686b1002b5acf73..a06af311237522094f2d6457153c87deac5f23f8 100644 (file)
@@ -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
index e9aabd15b5820052acc660761c5f337912e8c21a..584bc1cc2ae8a566abf2ff87793a2aea38913e86 100644 (file)
@@ -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);
index a0012e3a8c3d6e8ad3f2781c4ac08b5cfc32a5ec..78ede8e225049b4eaf3b8c7abfabbbd71bd830e1 100644 (file)
@@ -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]);
index 7c887d0b559c8d5d509ec8b60254ee6f321665ad..516d319a6eeff156c48bfb463a42cb2a22d2df43 100644 (file)
@@ -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;
index 69f4b7fa5b025eba73cedbec633b3f359b7eb64e..1ea7799021b8ff713038a9b6c325e09e6bf7245b 100644 (file)
@@ -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 */