gallium: more work on ccw flag removal
authorKeith Whitwell <keithw@vmware.com>
Fri, 14 May 2010 18:20:25 +0000 (19:20 +0100)
committerKeith Whitwell <keithw@vmware.com>
Fri, 14 May 2010 18:20:25 +0000 (19:20 +0100)
The linux-debug target builds...

src/gallium/auxiliary/util/u_inlines.h
src/gallium/drivers/i965/brw_pipe_rast.c
src/gallium/drivers/i965/brw_sf.c
src/gallium/drivers/i965/brw_sf_state.c
src/gallium/drivers/i965/brw_wm_state.c
src/gallium/drivers/nv50/nv50_state.c
src/gallium/drivers/nvfx/nvfx_state.c
src/gallium/drivers/r300/r300_state.c
src/gallium/drivers/svga/svga_pipe_rasterizer.c
src/gallium/state_trackers/vega/polygon.c
src/mesa/state_tracker/st_atom_rasterizer.c

index a48689ee8be78329b271975a106ba0f68d35676b..540305c1465765a90c3fd141ca484520e5a0a285 100644 (file)
@@ -369,6 +369,24 @@ pipe_transfer_destroy( struct pipe_context *context,
 }
 
 
+static INLINE boolean util_get_offset( 
+   const struct pipe_rasterizer_state *templ,
+   unsigned fill_mode)
+{
+   switch(fill_mode) {
+   case PIPE_POLYGON_MODE_POINT:
+      return templ->offset_point;
+   case PIPE_POLYGON_MODE_LINE:
+      return templ->offset_line;
+   case PIPE_POLYGON_MODE_FILL:
+      return templ->offset_tri;
+   default:
+      assert(0);
+      return FALSE;
+   }
+}
+
+
 #ifdef __cplusplus
 }
 #endif
index 79c445e8b019e6d76cb88a29d3e9177dbb8b10c7..4c1a6d7dcdfde014ae3248c9457395e9279c4dfa 100644 (file)
@@ -50,14 +50,14 @@ calculate_clip_key_rast( const struct brw_context *brw,
    key->fill_ccw = CLIP_CULL;
    key->fill_cw = CLIP_CULL;
 
-   if (!(templ->cull_mode & PIPE_FACE_FRONT)) {
+   if (!(templ->cull_face & PIPE_FACE_FRONT)) {
       if (templ->front_ccw)
          key->fill_ccw = translate_fill(templ->fill_front);
       else 
          key->fill_cw = translate_fill(templ->fill_front);
    }
 
-   if (!(templ->cull_mode & PIPE_FACE_BACK)) {
+   if (!(templ->cull_face & PIPE_FACE_BACK)) {
       if (templ->front_ccw)
          key->fill_cw = translate_fill(templ->fill_back);
       else 
@@ -138,12 +138,12 @@ static void *brw_create_rasterizer_state( struct pipe_context *pipe,
    /* Caclculate lookup value for WM IZ table.
     */
    if (templ->line_smooth) {
-      if (templ->fill_cw == PIPE_POLYGON_MODE_LINE &&
-         templ->fill_ccw == PIPE_POLYGON_MODE_LINE) {
+      if (templ->fill_front == PIPE_POLYGON_MODE_LINE &&
+         templ->fill_back == PIPE_POLYGON_MODE_LINE) {
         rast->unfilled_aa_line = AA_ALWAYS;
       }
-      else if (templ->fill_cw == PIPE_POLYGON_MODE_LINE ||
-              templ->fill_ccw == PIPE_POLYGON_MODE_LINE) {
+      else if (templ->fill_front == PIPE_POLYGON_MODE_LINE ||
+              templ->fill_back == PIPE_POLYGON_MODE_LINE) {
         rast->unfilled_aa_line = AA_SOMETIMES;
       }
       else {
index 058b1e12e2cd04d38753a45e28872a757ae8158b..5abf3848ab4e6d7865c505e5215845443cbb7946 100644 (file)
@@ -166,8 +166,8 @@ static enum pipe_error upload_sf_prog(struct brw_context *brw)
    case PIPE_PRIM_TRIANGLES: 
       /* PIPE_NEW_RAST
        */
-      if (rast->fill_cw != PIPE_POLYGON_MODE_FILL ||
-         rast->fill_ccw != PIPE_POLYGON_MODE_FILL)
+      if (rast->fill_front != PIPE_POLYGON_MODE_FILL ||
+         rast->fill_back != PIPE_POLYGON_MODE_FILL)
         key.primitive = SF_UNFILLED_TRIS;
       else
         key.primitive = SF_TRIANGLES;
index fede8bd30091911088a17ebce05709cd43edd1dd..6c299a86b4986a0f2d5a793ff4348df0a229f377 100644 (file)
@@ -89,8 +89,8 @@ struct brw_sf_unit_key {
    unsigned line_smooth:1;
    unsigned point_sprite:1;
    unsigned point_attenuated:1;
-   unsigned front_face:2;
-   unsigned cull_mode:2;
+   unsigned front_ccw:1;
+   unsigned cull_face:2;
    unsigned flatshade_first:1;
    unsigned gl_rasterization_rules:1;
    unsigned line_last_pixel_enable:1;
@@ -115,8 +115,8 @@ sf_unit_populate_key(struct brw_context *brw, struct brw_sf_unit_key *key)
 
    /* PIPE_NEW_RAST */
    key->scissor = rast->scissor;
-   key->front_face = rast->front_winding;
-   key->cull_mode = rast->cull_mode;
+   key->front_ccw = rast->front_ccw;
+   key->cull_face = rast->cull_face;
    key->line_smooth = rast->line_smooth;
    key->line_width = rast->line_width;
    key->flatshade_first = rast->flatshade_first;
index ee970ac75bcd0a53a019e6aa2e7b8e5a880d8281..efc2d96be135a60427fc37ac5ec4310bee04de68 100644 (file)
@@ -128,8 +128,9 @@ wm_unit_populate_key(struct brw_context *brw, struct brw_wm_unit_key *key)
    key->line_stipple = brw->curr.rast->templ.line_stipple_enable;
 
 
-   key->offset_enable = (brw->curr.rast->templ.offset_cw ||
-                        brw->curr.rast->templ.offset_ccw);
+   key->offset_enable = (brw->curr.rast->templ.offset_point ||
+                        brw->curr.rast->templ.offset_line ||
+                        brw->curr.rast->templ.offset_tri);
 
    key->offset_units = brw->curr.rast->templ.offset_units;
    key->offset_factor = brw->curr.rast->templ.offset_scale;
index 2f11ed001bbdc60b9a7fa528355a6ce3967c4af6..b20781fa1fbdd6808f86c43c34ce80072cf7a1e9 100644 (file)
@@ -390,7 +390,7 @@ nv50_rasterizer_state_create(struct pipe_context *pipe,
        so_data(so, cso->poly_smooth ? 1 : 0);
 
        so_method(so, tesla, NV50TCL_CULL_FACE_ENABLE, 3);
-       so_data  (so, cso->cull_mode != PIPE_FACE_NONE);
+       so_data  (so, cso->cull_face != PIPE_FACE_NONE);
        if (cso->front_ccw) {
                so_data(so, NV50TCL_FRONT_FACE_CCW);
         }
index d7177b0f0bbd4f7111a976b1f2fcbef491e815ec..17f3f701406ea3360081e6986f262a160bd80fc5 100644 (file)
@@ -218,7 +218,7 @@ nvfx_rasterizer_state_create(struct pipe_context *pipe,
        sb_method(sb, NV34TCL_POLYGON_MODE_FRONT, 6);
         sb_data(sb, nvgl_polygon_mode(cso->fill_front));
         sb_data(sb, nvgl_polygon_mode(cso->fill_back));
-       switch (cso->cull_mode) {
+       switch (cso->cull_face) {
        case PIPE_FACE_FRONT:
                sb_data(sb, NV34TCL_CULL_FACE_FRONT);
                break;
index 6e72f2ebdc0659541031762e744b9fe6b2604e13..006a34119b7f61e4092c311badf757287b8fb527 100644 (file)
@@ -777,10 +777,10 @@ static void* r300_create_rs_state(struct pipe_context* pipe,
         rs->cull_mode = R300_FRONT_FACE_CW;
 
     /* Polygon offset */
-    if (state->offset_front) {
+    if (util_get_offset(state, state->fill_front)) {
        rs->polygon_offset_enable |= R300_FRONT_ENABLE;
     }
-    if (state->offset_back) {
+    if (util_get_offset(state, state->fill_back)) {
        rs->polygon_offset_enable |= R300_BACK_ENABLE;
     }
 
@@ -862,7 +862,9 @@ static void r300_bind_rs_state(struct pipe_context* pipe, void* state)
     }
 
     if (rs) {
-        r300->polygon_offset_enabled = rs->rs.offset_cw || rs->rs.offset_ccw;
+        r300->polygon_offset_enabled = (rs->rs.offset_point ||
+                                        rs->rs.offset_line ||
+                                        rs->rs.offset_tri);
         r300->sprite_coord_enable = rs->rs.sprite_coord_enable;
         r300->two_sided_color = rs->rs.light_twoside;
     } else {
index 1661a564e3fdd8dd133459266f2afe2496c74968..660eb0757a6778bfc0c2fdf434a30d20da2039ab 100644 (file)
@@ -82,7 +82,7 @@ svga_create_rasterizer_state(struct pipe_context *pipe,
    /* fill_cw, fill_ccw      - draw module or index translation */
 
    rast->shademode = svga_translate_flatshade( templ->flatshade );
-   rast->cullmode = svga_translate_cullmode( templ->cull_mode, 
+   rast->cullmode = svga_translate_cullmode( templ->cull_face, 
                                              templ->front_ccw );
    rast->scissortestenable = templ->scissor;
    rast->multisampleantialias = templ->multisample;
@@ -118,12 +118,12 @@ svga_create_rasterizer_state(struct pipe_context *pipe,
       rast->need_pipeline |= SVGA_PIPELINE_FLAG_POINTS;
 
    {
-      boolean offset_cw = templ->offset_cw;
-      boolean offset_ccw = templ->offset_ccw;
-      boolean offset  = 0;
-      int fill_cw = templ->fill_cw;
-      int fill_ccw = templ->fill_ccw;
+      int fill_front = templ->fill_front;
+      int fill_back = templ->fill_back;
       int fill = PIPE_POLYGON_MODE_FILL;
+      boolean offset_front = util_get_offset(templ, fill_front);
+      boolean offset_back = util_get_offset(templ, fill_back);
+      boolean offset  = 0;
 
       switch (templ->cull_face) {
       case PIPE_FACE_FRONT_AND_BACK:
index d2b7e489124ad607cf11cf43f40c32eba61af839..e9c8f03137396628efda862e8495f455964257ea 100644 (file)
@@ -379,7 +379,7 @@ void polygon_fill(struct polygon *poly, struct vg_context *ctx)
          dsa.stencil[0].func = PIPE_FUNC_ALWAYS;
          dsa.stencil[0].valuemask = ~0;
 
-         raster.cull_mode = raster.front_winding ^ PIPE_WINDING_BOTH;
+         raster.cull_face = PIPE_FACE_BACK;
          dsa.stencil[0].fail_op = PIPE_STENCIL_OP_KEEP;
          dsa.stencil[0].zfail_op = PIPE_STENCIL_OP_KEEP;
          dsa.stencil[0].zpass_op = PIPE_STENCIL_OP_INCR_WRAP;
@@ -389,7 +389,7 @@ void polygon_fill(struct polygon *poly, struct vg_context *ctx)
          cso_set_rasterizer(ctx->cso_context, &raster);
          draw_polygon(ctx, poly);
 
-         raster.cull_mode = raster.front_winding;
+         raster.cull_face = PIPE_FACE_FRONT;
          dsa.stencil[0].fail_op = PIPE_STENCIL_OP_KEEP;
          dsa.stencil[0].zfail_op = PIPE_STENCIL_OP_KEEP;
          dsa.stencil[0].zpass_op = PIPE_STENCIL_OP_DECR_WRAP;
@@ -501,7 +501,7 @@ void polygon_array_fill(struct polygon_array *polyarray, struct vg_context *ctx)
          dsa.stencil[0].func = PIPE_FUNC_ALWAYS;
          dsa.stencil[0].valuemask = ~0;
 
-         raster.cull_mode = raster.front_winding ^ PIPE_WINDING_BOTH;
+         raster.cull_face = PIPE_FACE_BACK;
          dsa.stencil[0].fail_op = PIPE_STENCIL_OP_KEEP;
          dsa.stencil[0].zfail_op = PIPE_STENCIL_OP_KEEP;
          dsa.stencil[0].zpass_op = PIPE_STENCIL_OP_INCR_WRAP;
@@ -514,7 +514,7 @@ void polygon_array_fill(struct polygon_array *polyarray, struct vg_context *ctx)
             draw_polygon(ctx, poly);
          }
 
-         raster.cull_mode = raster.front_winding;
+         raster.cull_face = PIPE_FACE_FRONT;
          dsa.stencil[0].fail_op = PIPE_STENCIL_OP_KEEP;
          dsa.stencil[0].zfail_op = PIPE_STENCIL_OP_KEEP;
          dsa.stencil[0].zpass_op = PIPE_STENCIL_OP_DECR_WRAP;
index 5669b1f82af0053d78f509fcb374236684a932c2..2599bd5ca0339b6b9a81608b0c8782a60cc4e158 100644 (file)
@@ -53,21 +53,6 @@ static GLuint translate_fill( GLenum mode )
    }
 }
 
-static GLboolean get_offset_flag( GLuint fill_mode, 
-                                 const struct gl_polygon_attrib *p )
-{
-   switch (fill_mode) {
-   case PIPE_POLYGON_MODE_POINT:
-      return p->OffsetPoint;
-   case PIPE_POLYGON_MODE_LINE:
-      return p->OffsetLine;
-   case PIPE_POLYGON_MODE_FILL:
-      return p->OffsetFill;
-   default:
-      assert(0);
-      return 0;
-   }
-}
 
 
 static void update_raster_state( struct st_context *st )
@@ -82,10 +67,7 @@ static void update_raster_state( struct st_context *st )
    /* _NEW_POLYGON, _NEW_BUFFERS
     */
    {
-      if (ctx->Polygon.FrontFace == GL_CCW)
-         raster->front_winding = PIPE_WINDING_CCW;
-      else
-         raster->front_winding = PIPE_WINDING_CW;
+      raster->front_ccw = (ctx->Polygon.FrontFace == GL_CCW);
 
       /* XXX
        * I think the intention here is that user-created framebuffer objects
@@ -94,7 +76,7 @@ static void update_raster_state( struct st_context *st )
        * But this is an implementation/driver-specific artifact - remove...
        */
       if (ctx->DrawBuffer && ctx->DrawBuffer->Name != 0)
-         raster->front_winding ^= PIPE_WINDING_BOTH;
+         raster->front_ccw ^= 1;
    }
 
    /* _NEW_LIGHT
@@ -131,40 +113,36 @@ static void update_raster_state( struct st_context *st )
    /* _NEW_POLYGON
     */
    if (ctx->Polygon.CullFlag) {
-      if (ctx->Polygon.CullFaceMode == GL_FRONT_AND_BACK) {
-        raster->cull_mode = PIPE_WINDING_BOTH;
-      }
-      else if (ctx->Polygon.CullFaceMode == GL_FRONT) {
-        raster->cull_mode = raster->front_winding;
-      }
-      else {
-        raster->cull_mode = raster->front_winding ^ PIPE_WINDING_BOTH;
+      switch (ctx->Polygon.CullFaceMode) {
+      case GL_FRONT:
+        raster->cull_face = PIPE_FACE_FRONT;
+         break;
+      case GL_BACK:
+        raster->cull_face = PIPE_FACE_BACK;
+         break;
+      case GL_FRONT_AND_BACK:
+        raster->cull_face = PIPE_FACE_FRONT_AND_BACK;
+         break;
       }
    }
+   else {
+      raster->cull_face = PIPE_FACE_NONE;
+   }
 
    /* _NEW_POLYGON
     */
    {
-      GLuint fill_front = translate_fill( ctx->Polygon.FrontMode );
-      GLuint fill_back = translate_fill( ctx->Polygon.BackMode );
-      
-      if (raster->front_winding == PIPE_WINDING_CW) {
-        raster->fill_cw = fill_front;
-        raster->fill_ccw = fill_back;
-      }
-      else {
-        raster->fill_cw = fill_back;
-        raster->fill_ccw = fill_front;
-      }
+      raster->fill_front = translate_fill( ctx->Polygon.FrontMode );
+      raster->fill_back = translate_fill( ctx->Polygon.BackMode );
 
       /* Simplify when culling is active:
        */
-      if (raster->cull_mode & PIPE_WINDING_CW) {
-        raster->fill_cw = raster->fill_ccw;
+      if (raster->cull_face & PIPE_FACE_FRONT) {
+        raster->fill_front = raster->fill_back;
       }
       
-      if (raster->cull_mode & PIPE_WINDING_CCW) {
-        raster->fill_ccw = raster->fill_cw;
+      if (raster->cull_face & PIPE_FACE_BACK) {
+        raster->fill_back = raster->fill_front;
       }
    }
 
@@ -172,8 +150,14 @@ static void update_raster_state( struct st_context *st )
     */
    if (ctx->Polygon.OffsetUnits != 0.0 ||
        ctx->Polygon.OffsetFactor != 0.0) {
-      raster->offset_cw = get_offset_flag( raster->fill_cw, &ctx->Polygon );
-      raster->offset_ccw = get_offset_flag( raster->fill_ccw, &ctx->Polygon );
+      raster->offset_point = ctx->Polygon.OffsetPoint;
+      raster->offset_line = ctx->Polygon.OffsetLine;
+      raster->offset_tri = ctx->Polygon.OffsetFill;
+   }
+
+   if (ctx->Polygon.OffsetPoint ||
+       ctx->Polygon.OffsetLine ||
+       ctx->Polygon.OffsetFill) {
       raster->offset_units = ctx->Polygon.OffsetUnits;
       raster->offset_scale = ctx->Polygon.OffsetFactor;
    }