gallium: take reduced prim, fill modes into account when culling
authorBrian Paul <brian.paul@tungstengraphics.com>
Mon, 14 Apr 2008 16:56:56 +0000 (10:56 -0600)
committerBrian Paul <brian.paul@tungstengraphics.com>
Mon, 14 Apr 2008 16:57:40 +0000 (10:57 -0600)
src/gallium/drivers/softpipe/sp_context.h
src/gallium/drivers/softpipe/sp_draw_arrays.c
src/gallium/drivers/softpipe/sp_setup.c

index 2442bd1eb008c40e4c82890ac498775525e23646..0e1d5e561d97767ec0dd51bf01e23a2f6b5f287d 100644 (file)
@@ -105,6 +105,8 @@ struct softpipe_context {
 
    int psize_slot;
 
+   unsigned reduced_api_prim;  /**< PIPE_PRIM_POINTS, _LINES or _TRIANGLES */
+
 #if 0
    /* Stipple derived state:
     */
index 61bcf51899356b5397526cb7f0e01ae74b2bc8fc..421509495a0dc6475460a350f4a63a4230692fe2 100644 (file)
@@ -78,6 +78,20 @@ softpipe_unmap_constant_buffers(struct softpipe_context *sp)
 }
 
 
+static unsigned reduced_prim[PIPE_PRIM_POLYGON + 1] = {
+   PIPE_PRIM_POINTS,
+   PIPE_PRIM_LINES,
+   PIPE_PRIM_LINES,
+   PIPE_PRIM_LINES,
+   PIPE_PRIM_TRIANGLES,
+   PIPE_PRIM_TRIANGLES,
+   PIPE_PRIM_TRIANGLES,
+   PIPE_PRIM_TRIANGLES,
+   PIPE_PRIM_TRIANGLES,
+   PIPE_PRIM_TRIANGLES
+};
+
+
 boolean
 softpipe_draw_arrays(struct pipe_context *pipe, unsigned mode,
                      unsigned start, unsigned count)
@@ -115,6 +129,7 @@ softpipe_draw_elements(struct pipe_context *pipe,
       assert(0);
 #endif
 
+   sp->reduced_api_prim = reduced_prim[mode];
 
    if (sp->dirty)
       softpipe_update_derived( sp );
index 0164d0588d68248e8bb108b1ddb19b2799e60366..813d7031083b5a0fefbdb1d33099b4724c531613 100644 (file)
@@ -1254,7 +1254,16 @@ void setup_prepare( struct setup_context *setup )
       sp->quad.first->begin(sp->quad.first);
    }
 
-   setup->winding = sp->rasterizer->cull_mode;
+   if (sp->reduced_api_prim == PIPE_PRIM_TRIANGLES &&
+       sp->rasterizer->fill_cw == PIPE_POLYGON_MODE_FILL &&
+       sp->rasterizer->fill_ccw == PIPE_POLYGON_MODE_FILL) {
+      /* we'll do culling */
+      setup->winding = sp->rasterizer->cull_mode;
+   }
+   else {
+      /* 'draw' will do culling */
+      setup->winding = PIPE_WINDING_NONE;
+   }
 }