[g3dvl] move z-coord generation for multiple render targets into vertex shader
[mesa.git] / src / mesa / drivers / dri / unichrome / via_tris.c
index 4cc7942b1b617fe88b3a8b21fb6fc92212ba5d2e..51f6af9228a02ee1de7bc11892b5cadc8886f479 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"
@@ -257,7 +257,6 @@ static struct {
 #define DO_POINTS    1
 #define DO_FULL_QUAD 1
 
-#define HAVE_RGBA         1
 #define HAVE_SPEC         1
 #define HAVE_BACK_COLORS  0
 #define HAVE_HW_FLATSHADE 1
@@ -330,7 +329,8 @@ do {                                                        \
 
 #define LOCAL_VARS(n)                                                   \
     struct via_context *vmesa = VIA_CONTEXT(ctx);                             \
-    GLuint color[n], spec[n];                                           \
+    GLuint color[n] = { 0 };                                          \
+    GLuint spec[n] = { 0 };                                           \
     GLuint coloroffset = vmesa->coloroffset;              \
     GLuint specoffset = vmesa->specoffset;                       \
     (void)color; (void)spec; (void)coloroffset; (void)specoffset;
@@ -490,7 +490,7 @@ via_fallback_tri(struct via_context *vmesa,
                  viaVertex *v1,
                  viaVertex *v2)
 {    
-    GLcontext *ctx = vmesa->glCtx;
+    struct gl_context *ctx = vmesa->glCtx;
     SWvertex v[3];
     _swsetup_Translate(ctx, v0, &v[0]);
     _swsetup_Translate(ctx, v1, &v[1]);
@@ -506,7 +506,7 @@ via_fallback_line(struct via_context *vmesa,
                   viaVertex *v0,
                   viaVertex *v1)
 {
-    GLcontext *ctx = vmesa->glCtx;
+    struct gl_context *ctx = vmesa->glCtx;
     SWvertex v[2];
     _swsetup_Translate(ctx, v0, &v[0]);
     _swsetup_Translate(ctx, v1, &v[1]);
@@ -520,7 +520,7 @@ static void
 via_fallback_point(struct via_context *vmesa,
                    viaVertex *v0)
 {
-    GLcontext *ctx = vmesa->glCtx;
+    struct gl_context *ctx = vmesa->glCtx;
     SWvertex v[1];
     _swsetup_Translate(ctx, v0, &v[0]);
     viaSpanRenderStart( ctx );
@@ -528,7 +528,7 @@ via_fallback_point(struct via_context *vmesa,
     viaSpanRenderFinish( ctx );
 }
 
-static void viaResetLineStipple( GLcontext *ctx )
+static void viaResetLineStipple( struct gl_context *ctx )
 {
    struct via_context *vmesa = VIA_CONTEXT(ctx);
    vmesa->regCmdB |= HC_HLPrst_MASK;
@@ -578,7 +578,7 @@ static void viaResetLineStipple( GLcontext *ctx )
 
 
 
-static void viaRenderClippedPoly(GLcontext *ctx, const GLuint *elts,
+static void viaRenderClippedPoly(struct gl_context *ctx, const GLuint *elts,
                                  GLuint n)
 {
     TNLcontext *tnl = TNL_CONTEXT(ctx);
@@ -602,13 +602,13 @@ static void viaRenderClippedPoly(GLcontext *ctx, const GLuint *elts,
        tnl->Driver.Render.PrimitiveNotify( ctx, prim );
 }
 
-static void viaRenderClippedLine(GLcontext *ctx, GLuint ii, GLuint jj)
+static void viaRenderClippedLine(struct gl_context *ctx, GLuint ii, GLuint jj)
 {
     TNLcontext *tnl = TNL_CONTEXT(ctx);
     tnl->Driver.Render.Line(ctx, ii, jj);
 }
 
-static void viaFastRenderClippedPoly(GLcontext *ctx, const GLuint *elts,
+static void viaFastRenderClippedPoly(struct gl_context *ctx, const GLuint *elts,
                                      GLuint n)
 {
     struct via_context *vmesa = VIA_CONTEXT(ctx);
@@ -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 |                 \
@@ -646,7 +645,7 @@ static void viaFastRenderClippedPoly(GLcontext *ctx, const GLuint *elts,
                               _NEW_POLYGONSTIPPLE)
 
 
-static void viaChooseRenderState(GLcontext *ctx)
+static void viaChooseRenderState(struct gl_context *ctx)
 {
    TNLcontext *tnl = TNL_CONTEXT(ctx);
    struct via_context *vmesa = VIA_CONTEXT(ctx);
@@ -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;
@@ -740,7 +739,7 @@ do {                                                                        \
 
 
 
-static void viaChooseVertexState( GLcontext *ctx )
+static void viaChooseVertexState( struct gl_context *ctx )
 {
    struct via_context *vmesa = VIA_CONTEXT(ctx);
    TNLcontext *tnl = TNL_CONTEXT(ctx);
@@ -823,7 +822,7 @@ static void viaChooseVertexState( GLcontext *ctx )
  * them. Fallback to swrast if we can't. Returns GL_TRUE if projective
  * texture coordinates must be faked, GL_FALSE otherwise.
  */
-static GLboolean viaCheckPTexHack( GLcontext *ctx )
+static GLboolean viaCheckPTexHack( struct gl_context *ctx )
 {
    TNLcontext *tnl = TNL_CONTEXT(ctx);
    struct vertex_buffer *VB = &tnl->vb;
@@ -833,13 +832,13 @@ static GLboolean viaCheckPTexHack( GLcontext *ctx )
 
    RENDERINPUTS_COPY( index_bitset, tnl->render_inputs_bitset );
 
-   if (RENDERINPUTS_TEST( index_bitset, _TNL_ATTRIB_TEX0 ) && VB->TexCoordPtr[0]->size == 4) {
+   if (RENDERINPUTS_TEST( index_bitset, _TNL_ATTRIB_TEX0 ) && VB->AttribPtr[_TNL_ATTRIB_TEX0]->size == 4) {
       if (!RENDERINPUTS_TEST_RANGE( index_bitset, _TNL_ATTRIB_TEX1, _TNL_LAST_TEX ))
         ptexHack = GL_TRUE; 
       else
         fallback = GL_TRUE;
    }
-   if (RENDERINPUTS_TEST( index_bitset, _TNL_ATTRIB_TEX1 ) && VB->TexCoordPtr[1]->size == 4)
+   if (RENDERINPUTS_TEST( index_bitset, _TNL_ATTRIB_TEX1 ) && VB->AttribPtr[_TNL_ATTRIB_TEX1]->size == 4)
       fallback = GL_TRUE;
 
    FALLBACK(VIA_CONTEXT(ctx), VIA_FALLBACK_PROJ_TEXTURE, fallback);
@@ -854,7 +853,7 @@ static GLboolean viaCheckPTexHack( GLcontext *ctx )
 /**********************************************************************/
 
 
-static void viaRenderStart(GLcontext *ctx)
+static void viaRenderStart(struct gl_context *ctx)
 {
    struct via_context *vmesa = VIA_CONTEXT(ctx);
    TNLcontext *tnl = TNL_CONTEXT(ctx);
@@ -889,7 +888,7 @@ static void viaRenderStart(GLcontext *ctx)
    VB->AttribPtr[VERT_ATTRIB_POS] = VB->NdcPtr;
 }
 
-static void viaRenderFinish(GLcontext *ctx)
+static void viaRenderFinish(struct gl_context *ctx)
 {
    VIA_FINISH_PRIM(VIA_CONTEXT(ctx));
 }
@@ -898,7 +897,7 @@ static void viaRenderFinish(GLcontext *ctx)
 /* System to flush dma and emit state changes based on the rasterized
  * primitive.
  */
-void viaRasterPrimitive(GLcontext *ctx,
+void viaRasterPrimitive(struct gl_context *ctx,
                        GLenum glprim,
                        GLenum hwprim)
 {
@@ -1036,7 +1035,7 @@ void viaRasterPrimitive(GLcontext *ctx,
 
 /* Callback for mesa:
  */
-static void viaRenderPrimitive( GLcontext *ctx, GLuint prim )
+static void viaRenderPrimitive( struct gl_context *ctx, GLuint prim )
 {
    viaRasterPrimitive( ctx, prim, hwPrim[prim] );
 }
@@ -1104,7 +1103,7 @@ void viaFinishPrimitive(struct via_context *vmesa)
 
 void viaFallback(struct via_context *vmesa, GLuint bit, GLboolean mode)
 {
-    GLcontext *ctx = vmesa->glCtx;
+    struct gl_context *ctx = vmesa->glCtx;
     TNLcontext *tnl = TNL_CONTEXT(ctx);
     GLuint oldfallback = vmesa->Fallback;
     
@@ -1149,7 +1148,7 @@ void viaFallback(struct via_context *vmesa, GLuint bit, GLboolean mode)
     }    
 }
 
-static void viaRunPipeline( GLcontext *ctx )
+static void viaRunPipeline( struct gl_context *ctx )
 {
    struct via_context *vmesa = VIA_CONTEXT(ctx);
 
@@ -1167,7 +1166,7 @@ static void viaRunPipeline( GLcontext *ctx )
 /**********************************************************************/
 
 
-void viaInitTriFuncs(GLcontext *ctx)
+void viaInitTriFuncs(struct gl_context *ctx)
 {
     struct via_context *vmesa = VIA_CONTEXT(ctx);
     TNLcontext *tnl = TNL_CONTEXT(ctx);