Merge remote branch 'origin/gallium-0.2' into gallium-0.2
[mesa.git] / src / mesa / drivers / dri / unichrome / via_tris.c
index 4cc7942b1b617fe88b3a8b21fb6fc92212ba5d2e..79e67620c9edc784558fc5e11607a4d0d6a3edde 100644 (file)
 #include <stdio.h>
 #include <math.h>
 
-#include "glheader.h"
-#include "context.h"
-#include "mtypes.h"
-#include "macros.h"
-#include "colormac.h"
-#include "enums.h"
+#include "main/glheader.h"
+#include "main/context.h"
+#include "main/mtypes.h"
+#include "main/macros.h"
+#include "main/colormac.h"
+#include "main/enums.h"
 
 #include "swrast/swrast.h"
 #include "swrast_setup/swrast_setup.h"
@@ -625,13 +625,12 @@ static void viaFastRenderClippedPoly(GLcontext *ctx, const GLuint *elts,
     }
 }
 
+
 /**********************************************************************/
 /*                    Choose render functions                         */
 /**********************************************************************/
 
 
-
-
 #define _VIA_NEW_VERTEX (_NEW_TEXTURE |                         \
                          _DD_NEW_SEPARATE_SPECULAR |            \
                          _DD_NEW_TRI_UNFILLED |                 \
@@ -665,14 +664,17 @@ static void viaChooseRenderState(GLcontext *ctx)
       vmesa->drawTri = via_draw_triangle;
    }
 
-   if (flags & (ANY_FALLBACK_FLAGS|ANY_RASTER_FLAGS)) {
-      if (flags & DD_TRI_LIGHT_TWOSIDE)    index |= VIA_TWOSIDE_BIT;
-      if (flags & DD_TRI_OFFSET)           index |= VIA_OFFSET_BIT;
-      if (flags & DD_TRI_UNFILLED)         index |= VIA_UNFILLED_BIT;
-      if (flags & ANY_FALLBACK_FLAGS)      index |= VIA_FALLBACK_BIT;
-
-      /* Hook in fallbacks for specific primitives.
-       */
+   if (flags & (ANY_FALLBACK_FLAGS | ANY_RASTER_FLAGS)) {
+      if (ctx->Light.Enabled && ctx->Light.Model.TwoSide)
+         index |= VIA_TWOSIDE_BIT;
+      if (ctx->Polygon.FrontMode != GL_FILL || ctx->Polygon.BackMode != GL_FILL)
+         index |= VIA_UNFILLED_BIT;
+      if (flags & DD_TRI_OFFSET)
+         index |= VIA_OFFSET_BIT;
+      if (flags & ANY_FALLBACK_FLAGS)
+         index |= VIA_FALLBACK_BIT;
+
+      /* Hook in fallbacks for specific primitives. */
       if (flags & POINT_FALLBACK)
         vmesa->drawPoint = via_fallback_point;
       
@@ -683,11 +685,8 @@ static void viaChooseRenderState(GLcontext *ctx)
         vmesa->drawTri = via_fallback_tri;
    }
 
-
-   if ((flags & DD_SEPARATE_SPECULAR) &&
-       ctx->Light.ShadeModel == GL_FLAT) {
+   if ((flags & DD_SEPARATE_SPECULAR) && ctx->Light.ShadeModel == GL_FLAT)
       index = VIA_MAX_TRIFUNC; /* flat specular */
-   }
 
    if (vmesa->renderIndex != index) {
       vmesa->renderIndex = index;