dri: Remove driver date from renderer string
[mesa.git] / src / mesa / drivers / dri / mach64 / mach64_tris.c
index 6b12ee92e24c20a393dd0cba19fe3ffb38afc10e..024ee2f43533a0803ff34ae0be85a4cd2a1896f5 100644 (file)
@@ -1,4 +1,4 @@
-/* $XFree86$ */ /* -*- mode: c; c-basic-offset: 3 -*- */
+/* -*- mode: c; c-basic-offset: 3 -*- */
 /*
  * Copyright 2000 Gareth Hughes
  * All Rights Reserved.
  *     José Fonseca <j_r_fonseca@yahoo.co.uk>
  */
 
-#include "glheader.h"
-#include "mtypes.h"
-#include "colormac.h"
-#include "macros.h"
+#include "main/glheader.h"
+#include "main/mtypes.h"
+#include "main/colormac.h"
+#include "main/macros.h"
 
 #include "swrast/swrast.h"
 #include "swrast_setup/swrast_setup.h"
@@ -59,8 +59,8 @@ static const GLuint hw_prim[GL_POLYGON+1] = {
    MACH64_PRIM_POLYGON,
 };
 
-static void mach64RasterPrimitive( GLcontext *ctx, GLuint hwprim );
-static void mach64RenderPrimitive( GLcontext *ctx, GLenum prim );
+static void mach64RasterPrimitive( struct gl_context *ctx, GLuint hwprim );
+static void mach64RenderPrimitive( struct gl_context *ctx, GLenum prim );
 
 
 /* FIXME: Remove this when native template is finished. */
@@ -113,14 +113,14 @@ do {                                                                      \
 #define COPY_VERTEX_OOA( vb, vertsize, v, n )  DO_COPY_VERTEX( vb, vertsize, v, n, 1 )
 
 
-static __inline void mach64_draw_quad( mach64ContextPtr mmesa,
+static INLINE void mach64_draw_quad( mach64ContextPtr mmesa,
                                       mach64VertexPtr v0,
                                       mach64VertexPtr v1,
                                       mach64VertexPtr v2,
                                       mach64VertexPtr v3 )
 {
 #if MACH64_NATIVE_VTXFMT
-   GLcontext *ctx = mmesa->glCtx;
+   struct gl_context *ctx = mmesa->glCtx;
    const GLuint vertsize = mmesa->vertex_size;
    GLint a;
    GLfloat ooa;
@@ -419,13 +419,13 @@ static __inline void mach64_draw_quad( mach64ContextPtr mmesa,
 #endif
 }
 
-static __inline void mach64_draw_triangle( mach64ContextPtr mmesa,
+static INLINE void mach64_draw_triangle( mach64ContextPtr mmesa,
                                           mach64VertexPtr v0,
                                           mach64VertexPtr v1,
                                           mach64VertexPtr v2 )
 {
 #if MACH64_NATIVE_VTXFMT
-   GLcontext *ctx = mmesa->glCtx;
+   struct gl_context *ctx = mmesa->glCtx;
    GLuint vertsize = mmesa->vertex_size;
    GLint a;
    GLfloat ooa;
@@ -666,14 +666,17 @@ static __inline void mach64_draw_triangle( mach64ContextPtr mmesa,
 #endif
 }
 
-static __inline void mach64_draw_line( mach64ContextPtr mmesa,
+static INLINE void mach64_draw_line( mach64ContextPtr mmesa,
                                     mach64VertexPtr v0,
                                     mach64VertexPtr v1 )
 {
 #if MACH64_NATIVE_VTXFMT
-   GLcontext *ctx = mmesa->glCtx;
+   struct gl_context *ctx = mmesa->glCtx;
    const GLuint vertsize = mmesa->vertex_size;
-   GLint width = (GLint)(mmesa->glCtx->Line._Width * 2.0); /* 2 fractional bits for hardware */
+   /* 2 fractional bits for hardware: */
+   const int width = (int) (2.0 * CLAMP(mmesa->glCtx->Line.Width,
+                                        mmesa->glCtx->Const.MinLineWidth,
+                                        mmesa->glCtx->Const.MaxLineWidth));
    GLfloat ooa;
    GLuint *pxy0, *pxy1;
    GLuint xy0old, xy0, xy1old, xy1;
@@ -691,9 +694,6 @@ static __inline void mach64_draw_line( mach64ContextPtr mmesa,
       mach64_print_vertex( ctx, v1 );
    }
   
-   if( !width )
-      width = 1;       /* round to the nearest supported width */
-      
    pxy0 = &v0->ui[xyoffset];
    xy0old = *pxy0;
    xy0 = LE32_IN( &xy0old );
@@ -955,13 +955,16 @@ static __inline void mach64_draw_line( mach64ContextPtr mmesa,
 #endif
 }
 
-static __inline void mach64_draw_point( mach64ContextPtr mmesa,
+static INLINE void mach64_draw_point( mach64ContextPtr mmesa,
                                      mach64VertexPtr v0 )
 {
 #if MACH64_NATIVE_VTXFMT
-   GLcontext *ctx = mmesa->glCtx;
+   struct gl_context *ctx = mmesa->glCtx;
    const GLuint vertsize = mmesa->vertex_size;
-   GLint sz = (GLint)(mmesa->glCtx->Point._Size * 2.0); /* 2 fractional bits for hardware */
+   /* 2 fractional bits for hardware: */
+   GLint sz = (GLint) (2.0 * CLAMP(mmesa->glCtx->Point.Size,
+                                   ctx->Const.MinPointSize,
+                                   ctx->Const.MaxPointSize));
    GLfloat ooa;
    GLuint *pxy;
    GLuint xyold, xy;
@@ -1245,7 +1248,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
@@ -1294,7 +1296,8 @@ do {                                              \
 
 #define LOCAL_VARS(n)                                          \
    mach64ContextPtr mmesa = MACH64_CONTEXT(ctx);               \
-   GLuint color[n], spec[n];                                   \
+   GLuint color[n] = { 0 };                                    \
+   GLuint spec[n] = { 0 };                                     \
    GLuint vertex_size = mmesa->vertex_size;                    \
    const GLuint xyoffset = 9;                                  \
    const GLuint coloroffset = 8;                               \
@@ -1470,7 +1473,7 @@ mach64_fallback_tri( mach64ContextPtr mmesa,
                     mach64Vertex *v1,
                     mach64Vertex *v2 )
 {
-   GLcontext *ctx = mmesa->glCtx;
+   struct gl_context *ctx = mmesa->glCtx;
    SWvertex v[3];
    mach64_translate_vertex( ctx, v0, &v[0] );
    mach64_translate_vertex( ctx, v1, &v[1] );
@@ -1484,7 +1487,7 @@ mach64_fallback_line( mach64ContextPtr mmesa,
                    mach64Vertex *v0,
                    mach64Vertex *v1 )
 {
-   GLcontext *ctx = mmesa->glCtx;
+   struct gl_context *ctx = mmesa->glCtx;
    SWvertex v[2];
    mach64_translate_vertex( ctx, v0, &v[0] );
    mach64_translate_vertex( ctx, v1, &v[1] );
@@ -1496,7 +1499,7 @@ static void
 mach64_fallback_point( mach64ContextPtr mmesa,
                     mach64Vertex *v0 )
 {
-   GLcontext *ctx = mmesa->glCtx;
+   struct gl_context *ctx = mmesa->glCtx;
    SWvertex v[1];
    mach64_translate_vertex( ctx, v0, &v[0] );
    _swrast_Point( ctx, &v[0] );
@@ -1546,7 +1549,7 @@ mach64_fallback_point( mach64ContextPtr mmesa,
 /*                    Render clipped primitives                       */
 /**********************************************************************/
 
-static void mach64RenderClippedPoly( GLcontext *ctx, const GLuint *elts,
+static void mach64RenderClippedPoly( struct gl_context *ctx, const GLuint *elts,
                                     GLuint n )
 {
    mach64ContextPtr mmesa = MACH64_CONTEXT( ctx );
@@ -1570,20 +1573,23 @@ static void mach64RenderClippedPoly( GLcontext *ctx, const GLuint *elts,
 
 }
 
-static void mach64RenderClippedLine( GLcontext *ctx, GLuint ii, GLuint jj )
+static void mach64RenderClippedLine( struct gl_context *ctx, GLuint ii, GLuint jj )
 {
    TNLcontext *tnl = TNL_CONTEXT(ctx);
    tnl->Driver.Render.Line( ctx, ii, jj );
 }
 
 #if MACH64_NATIVE_VTXFMT
-static void mach64FastRenderClippedPoly( GLcontext *ctx, const GLuint *elts,
+static void mach64FastRenderClippedPoly( struct gl_context *ctx, const GLuint *elts,
                                         GLuint n )
 {
    mach64ContextPtr mmesa = MACH64_CONTEXT( ctx );
    const GLuint vertsize = mmesa->vertex_size;
    GLint a;
-   GLfloat ooa;
+   union {
+      GLfloat f;
+      CARD32 u;
+   } ooa;
    GLuint xy;
    const GLuint xyoffset = 9;
    GLint xx[3], yy[3]; /* 2 fractional bits for hardware */
@@ -1621,7 +1627,7 @@ static void mach64FastRenderClippedPoly( GLcontext *ctx, const GLuint *elts,
       return;
    }
    
-   ooa = 16.0 / a;
+   ooa.f = 16.0 / a;
    
    vb = (CARD32 *)mach64AllocDmaLow( mmesa, vbsiz * sizeof(CARD32) );
    vbchk = vb + vbsiz;
@@ -1629,7 +1635,7 @@ static void mach64FastRenderClippedPoly( GLcontext *ctx, const GLuint *elts,
    COPY_VERTEX( vb, vertsize, v0, 1 );
    COPY_VERTEX( vb, vertsize, v1, 2 );
    COPY_VERTEX_OOA( vb, vertsize, v2, 3 );
-   LE32_OUT( vb++, *(CARD32 *)&ooa );
+   LE32_OUT( vb++, ooa.u );
 
    i = 3;
    while (1) {
@@ -1644,10 +1650,10 @@ static void mach64FastRenderClippedPoly( GLcontext *ctx, const GLuint *elts,
              
       a = (xx[0] - xx[2]) * (yy[1] - yy[2]) -
          (yy[0] - yy[2]) * (xx[1] - xx[2]);
-      ooa = 16.0 / a;
+      ooa.f = 16.0 / a;
    
       COPY_VERTEX_OOA( vb, vertsize, v0, 1 );
-      LE32_OUT( vb++, *(CARD32 *)&ooa );
+      LE32_OUT( vb++, ooa.u );
       
       if (i >= n)
         break;
@@ -1660,16 +1666,16 @@ static void mach64FastRenderClippedPoly( GLcontext *ctx, const GLuint *elts,
              
       a = (xx[0] - xx[2]) * (yy[1] - yy[2]) -
          (yy[0] - yy[2]) * (xx[1] - xx[2]);
-      ooa = 16.0 / a;
+      ooa.f = 16.0 / a;
    
       COPY_VERTEX_OOA( vb, vertsize, v1, 2 );
-      LE32_OUT( vb++, *(CARD32 *)&ooa );
+      LE32_OUT( vb++, ooa.u );
    }
 
    assert( vb == vbchk );
 }
 #else
-static void mach64FastRenderClippedPoly( GLcontext *ctx, const GLuint *elts,
+static void mach64FastRenderClippedPoly( struct gl_context *ctx, const GLuint *elts,
                                         GLuint n )
 {
    mach64ContextPtr mmesa = MACH64_CONTEXT( ctx );
@@ -1709,7 +1715,7 @@ static void mach64FastRenderClippedPoly( GLcontext *ctx, const GLuint *elts,
 #define ANY_RASTER_FLAGS (DD_TRI_LIGHT_TWOSIDE|DD_TRI_OFFSET|DD_TRI_UNFILLED)
 
 
-static void mach64ChooseRenderState(GLcontext *ctx)
+static void mach64ChooseRenderState(struct gl_context *ctx)
 {
    mach64ContextPtr mmesa = MACH64_CONTEXT(ctx);
    GLuint flags = ctx->_TriangleCaps;
@@ -1763,7 +1769,7 @@ static void mach64ChooseRenderState(GLcontext *ctx)
 /*                 Validate state at pipeline start                   */
 /**********************************************************************/
 
-static void mach64RunPipeline( GLcontext *ctx )
+static void mach64RunPipeline( struct gl_context *ctx )
 {
    mach64ContextPtr mmesa = MACH64_CONTEXT(ctx);
 
@@ -1792,7 +1798,7 @@ static void mach64RunPipeline( GLcontext *ctx )
  * and lines, points and bitmaps.
  */
 
-static void mach64RasterPrimitive( GLcontext *ctx, GLuint hwprim )
+static void mach64RasterPrimitive( struct gl_context *ctx, GLuint hwprim )
 {
    mach64ContextPtr mmesa = MACH64_CONTEXT(ctx);
 
@@ -1805,7 +1811,7 @@ static void mach64RasterPrimitive( GLcontext *ctx, GLuint hwprim )
    }
 }
 
-static void mach64RenderPrimitive( GLcontext *ctx, GLenum prim )
+static void mach64RenderPrimitive( struct gl_context *ctx, GLenum prim )
 {
    mach64ContextPtr mmesa = MACH64_CONTEXT(ctx);
    GLuint hw = hw_prim[prim];
@@ -1819,7 +1825,7 @@ static void mach64RenderPrimitive( GLcontext *ctx, GLenum prim )
 }
 
 
-static void mach64RenderStart( GLcontext *ctx )
+static void mach64RenderStart( struct gl_context *ctx )
 {
    /* Check for projective texturing.  Make sure all texcoord
     * pointers point to something.  (fix in mesa?)
@@ -1827,7 +1833,7 @@ static void mach64RenderStart( GLcontext *ctx )
    mach64CheckTexSizes( ctx );
 }
 
-static void mach64RenderFinish( GLcontext *ctx )
+static void mach64RenderFinish( struct gl_context *ctx )
 {
    if (MACH64_CONTEXT(ctx)->RenderIndex & MACH64_FALLBACK_BIT)
       _swrast_flush( ctx );
@@ -1838,25 +1844,49 @@ static void mach64RenderFinish( GLcontext *ctx )
 /*           Transition to/from hardware rasterization.               */
 /**********************************************************************/
 
-void mach64Fallback( GLcontext *ctx, GLuint bit, GLboolean mode )
+static const char * const fallbackStrings[] = {
+   "Texture mode",
+   "glDrawBuffer(GL_FRONT_AND_BACK)",
+   "glReadBuffer",
+   "glEnable(GL_STENCIL) without hw stencil buffer",
+   "glRenderMode(selection or feedback)",
+   "glLogicOp (mode != GL_COPY)",
+   "GL_SEPARATE_SPECULAR_COLOR",
+   "glBlendEquation (mode != ADD)",
+   "glBlendFunc",
+   "Rasterization disable",
+};
+
+
+static const char *getFallbackString(GLuint bit)
+{
+   int i = 0;
+   while (bit > 1) {
+      i++;
+      bit >>= 1;
+   }
+   return fallbackStrings[i];
+}
+
+void mach64Fallback( struct gl_context *ctx, GLuint bit, GLboolean mode )
 {
    TNLcontext *tnl = TNL_CONTEXT(ctx);
    mach64ContextPtr mmesa = MACH64_CONTEXT(ctx);
    GLuint oldfallback = mmesa->Fallback;
 
    if (mode) {
-      if (MACH64_DEBUG & DEBUG_VERBOSE_MSG)
-        fprintf(stderr,"Set Fallback: %d\n", bit);
       mmesa->Fallback |= bit;
       if (oldfallback == 0) {
         FLUSH_BATCH( mmesa );
         _swsetup_Wakeup( ctx );
         mmesa->RenderIndex = ~0;
+        if (MACH64_DEBUG & DEBUG_VERBOSE_FALLBACK) {
+           fprintf(stderr, "Mach64 begin rasterization fallback: 0x%x %s\n",
+                   bit, getFallbackString(bit));
+        }
       }
    }
    else {
-      if (MACH64_DEBUG & DEBUG_VERBOSE_MSG)
-        fprintf(stderr,"Clear Fallback: %d\n", bit);
       mmesa->Fallback &= ~bit;
       if (oldfallback == bit) {
         _swrast_flush( ctx );
@@ -1866,6 +1896,10 @@ void mach64Fallback( GLcontext *ctx, GLuint bit, GLboolean mode )
         tnl->Driver.Render.BuildVertices = mach64BuildVertices;
         mmesa->NewGLState |= (_MACH64_NEW_RENDER_STATE|
                               _MACH64_NEW_VERTEX_STATE);
+        if (MACH64_DEBUG & DEBUG_VERBOSE_FALLBACK) {
+           fprintf(stderr, "Mach64 end rasterization fallback: 0x%x %s\n",
+                   bit, getFallbackString(bit));
+        }
       }
    }
 }
@@ -1874,7 +1908,7 @@ void mach64Fallback( GLcontext *ctx, GLuint bit, GLboolean mode )
 /*                            Initialization.                         */
 /**********************************************************************/
 
-void mach64InitTriFuncs( GLcontext *ctx )
+void mach64InitTriFuncs( struct gl_context *ctx )
 {
    TNLcontext *tnl = TNL_CONTEXT(ctx);
    static int firsttime = 1;
@@ -1890,6 +1924,4 @@ void mach64InitTriFuncs( GLcontext *ctx )
    tnl->Driver.Render.PrimitiveNotify = mach64RenderPrimitive;
    tnl->Driver.Render.ResetLineStipple = _swrast_ResetLineStipple;
    tnl->Driver.Render.BuildVertices = mach64BuildVertices;
-
-/*     mach64Fallback( ctx, 0x100000, 1 ); */
 }