Mesa (gallium-front-ccw): softpipe: restore culling code

Keith Whitwell keithw at kemper.freedesktop.org
Fri May 14 19:36:19 UTC 2010


Module: Mesa
Branch: gallium-front-ccw
Commit: 4ff1274e2312c7d9d8538dc443af500ec3b769cf
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=4ff1274e2312c7d9d8538dc443af500ec3b769cf

Author: Keith Whitwell <keithw at vmware.com>
Date:   Fri May 14 20:36:08 2010 +0100

softpipe: restore culling code

---

 src/gallium/drivers/softpipe/sp_setup.c |   24 +++++++++++++++++++++---
 1 files changed, 21 insertions(+), 3 deletions(-)

diff --git a/src/gallium/drivers/softpipe/sp_setup.c b/src/gallium/drivers/softpipe/sp_setup.c
index ca02d4d..5d727dc 100644
--- a/src/gallium/drivers/softpipe/sp_setup.c
+++ b/src/gallium/drivers/softpipe/sp_setup.c
@@ -111,6 +111,7 @@ struct setup_context {
    uint numFragsWritten;  /**< per primitive */
 #endif
 
+   unsigned cull_face;		/* which faces cull */
    unsigned nr_vertex_attrs;
 };
 
@@ -374,6 +375,14 @@ setup_sort_vertices(struct setup_context *setup,
       ((det < 0.0) ^ 
        (setup->softpipe->rasterizer->front_ccw));
 
+   {
+      unsigned face = setup->facing == 0 ? PIPE_FACE_FRONT : PIPE_FACE_BACK;
+
+      if (face & setup->cull_face)
+	 return FALSE;
+   }
+
+
    /* Prepare pixel offset for rasterisation:
     *  - pixel center (0.5, 0.5) for GL, or
     *  - assume (0.0, 0.0) for other APIs.
@@ -810,11 +819,9 @@ sp_setup_tri(struct setup_context *setup,
    setup->numFragsWritten = 0;
 #endif
 
-   /* Culling already done by draw module.
-    */
-
    if (!setup_sort_vertices( setup, det, v0, v1, v2 ))
       return;
+
    setup_tri_coefficients( setup );
    setup_tri_edges( setup );
 
@@ -1396,6 +1403,17 @@ sp_setup_prepare(struct setup_context *setup)
    setup->nr_vertex_attrs = draw_num_shader_outputs(sp->draw);
 
    sp->quad.first->begin( sp->quad.first );
+
+   if (sp->reduced_api_prim == PIPE_PRIM_TRIANGLES &&
+       sp->rasterizer->fill_front == PIPE_POLYGON_MODE_FILL &&
+       sp->rasterizer->fill_back == PIPE_POLYGON_MODE_FILL) {
+      /* we'll do culling */
+      setup->cull_face = sp->rasterizer->cull_face;
+   }
+   else {
+      /* 'draw' will do culling */
+      setup->cull_face = PIPE_FACE_NONE;
+   }
 }
 
 




More information about the mesa-commit mailing list