dri: Store the loader private passed in at dri context creation
[mesa.git] / src / mesa / drivers / dri / mga / mgatris.c
index 739619edf0f30b41d9599d547177065afe9dddde..4c58c3bdb04c71c2fdf27d025c8e7365c80d96b6 100644 (file)
  * Authors:
  *    Keith Whitwell <keith@tungstengraphics.com>
  */
-/* $XFree86: xc/lib/GL/mesa/src/drv/mga/mgatris.c,v 1.10 2002/10/30 12:51:36 alanh Exp $ */
 
-#include "mtypes.h"
-#include "macros.h"
-#include "colormac.h"
+#include "main/mtypes.h"
+#include "main/macros.h"
+#include "main/colormac.h"
+#include "main/mm.h"
 #include "swrast/swrast.h"
 #include "swrast_setup/swrast_setup.h"
 #include "tnl/t_context.h"
 #include "tnl/t_pipeline.h"
 
-#include "mm.h"
 #include "mgacontext.h"
 #include "mgaioctl.h"
 #include "mgatris.h"
 #include "mgavb.h"
-#include "mgastate.h"
 
 
 static void mgaRenderPrimitive( GLcontext *ctx, GLenum prim );
@@ -67,7 +65,7 @@ do {                                          \
 } while (0)
 #endif
 
-static void __inline__ mga_draw_triangle( mgaContextPtr mmesa,
+static void INLINE mga_draw_triangle( mgaContextPtr mmesa,
                                           mgaVertexPtr v0,
                                           mgaVertexPtr v1,
                                           mgaVertexPtr v2 )
@@ -82,7 +80,7 @@ static void __inline__ mga_draw_triangle( mgaContextPtr mmesa,
 }
 
 
-static void __inline__ mga_draw_quad( mgaContextPtr mmesa,
+static void INLINE mga_draw_quad( mgaContextPtr mmesa,
                                       mgaVertexPtr v0,
                                       mgaVertexPtr v1,
                                       mgaVertexPtr v2,
@@ -101,11 +99,13 @@ static void __inline__ mga_draw_quad( mgaContextPtr mmesa,
 }
 
 
-static __inline__ void mga_draw_point( mgaContextPtr mmesa,
+static INLINE void mga_draw_point( mgaContextPtr mmesa,
                                        mgaVertexPtr tmp )
 {
-   GLfloat sz = mmesa->glCtx->Point._Size * .5;
-   int vertex_size = mmesa->vertex_size;
+   const GLfloat sz = 0.5 * CLAMP(mmesa->glCtx->Point.Size,
+                                  mmesa->glCtx->Const.MinPointSize,
+                                  mmesa->glCtx->Const.MaxPointSize);
+   const int vertex_size = mmesa->vertex_size;
    GLuint *vb = mgaAllocDmaLow( mmesa, 6 * 4 * vertex_size );
    int j;
    
@@ -158,14 +158,16 @@ static __inline__ void mga_draw_point( mgaContextPtr mmesa,
 }
 
 
-static __inline__ void mga_draw_line( mgaContextPtr mmesa,
+static INLINE void mga_draw_line( mgaContextPtr mmesa,
                                      mgaVertexPtr v0,
                                      mgaVertexPtr v1 )
 {
    GLuint vertex_size = mmesa->vertex_size;
    GLuint *vb = mgaAllocDmaLow( mmesa, 6 * 4 * vertex_size );
    GLfloat dx, dy, ix, iy;
-   GLfloat width = mmesa->glCtx->Line._Width;
+   const GLfloat width = CLAMP(mmesa->glCtx->Line.Width,
+                               mmesa->glCtx->Const.MinLineWidth,
+                               mmesa->glCtx->Const.MaxLineWidth);
    GLint j;
 
 #if 0
@@ -328,10 +330,10 @@ mga_fallback_point( mgaContextPtr mmesa,
 #define MGA_MAX_TRIFUNC     0x20
 
 static struct {
-   points_func         points;
-   line_func           line;
-   triangle_func       triangle;
-   quad_func           quad;
+   tnl_points_func             points;
+   tnl_line_func               line;
+   tnl_triangle_func   triangle;
+   tnl_quad_func               quad;
 } rast_tab[MGA_MAX_TRIFUNC];
 
 #define DO_FALLBACK (IND & MGA_FALLBACK_BIT)
@@ -360,7 +362,7 @@ static struct {
 #define VERT_Y(_v) _v->v.y
 #define VERT_Z(_v) _v->v.z
 #define AREA_IS_CCW( a ) (a > 0)
-#define GET_VERTEX(e) (mmesa->verts + (e<<mmesa->vertex_stride_shift))
+#define GET_VERTEX(e) (mmesa->verts + (e * mmesa->vertex_size * sizeof(int)))
 
 #define VERT_SET_RGBA( v, c )                                          \
 do {                                                           \
@@ -394,7 +396,8 @@ do {                                                \
 
 #define LOCAL_VARS(n)                                  \
    mgaContextPtr mmesa = MGA_CONTEXT(ctx);             \
-   GLuint color[n], spec[n];                           \
+   GLuint color[n] = { 0 };                            \
+   GLuint spec[n] = { 0 };                             \
    (void) color; (void) spec;
 
 
@@ -591,7 +594,7 @@ static void init_rast_tab( void )
 /**********************************************************************/
 
 
-#define VERT(x) (mgaVertex *)(vertptr + ((x)<<vertshift))
+#define VERT(x) (mgaVertex *)(vertptr + ((x)*vertex_size*sizeof(int)))
 #define RENDER_POINTS( start, count )          \
    for ( ; start < count ; start++)            \
       mga_draw_point( mmesa, VERT(ELT(start)) );
@@ -606,7 +609,7 @@ static void init_rast_tab( void )
 #define LOCAL_VARS                                             \
     mgaContextPtr mmesa = MGA_CONTEXT(ctx);                    \
     GLubyte *vertptr = (GLubyte *)mmesa->verts;                        \
-    const GLuint vertshift = mmesa->vertex_stride_shift;               \
+    const GLuint vertex_size = mmesa->vertex_size;             \
     const GLuint * const elt = TNL_CONTEXT(ctx)->vb.Elts;      \
     (void) elt;
 #define RESET_STIPPLE 
@@ -663,7 +666,6 @@ static void mgaFastRenderClippedPoly( GLcontext *ctx, const GLuint *elts,
    GLuint vertex_size = mmesa->vertex_size;
    GLuint *vb = mgaAllocDmaLow( mmesa, (n-2) * 3 * 4 * vertex_size );
    GLubyte *vertptr = (GLubyte *)mmesa->verts;                 
-   const GLuint vertshift = mmesa->vertex_stride_shift;        
    const GLuint *start = (const GLuint *)VERT(elts[0]);
    int i,j;
 
@@ -840,7 +842,8 @@ static const char * const fallbackStrings[] = {
    "glRenderMode(selection or feedback)",
    "No hardware stencil",
    "glDepthFunc( GL_NEVER )",
-   "Mixing GL_CLAMP_TO_EDGE and GL_CLAMP"
+   "Mixing GL_CLAMP_TO_EDGE and GL_CLAMP",
+   "rasterization fallback option"
 };
 
 static const char *getFallbackString(GLuint bit)