Make nouveau actually compile
[mesa.git] / src / mesa / drivers / dri / nouveau / nv10_swtcl.c
index 0b061876cb3c72f5dbd93edb11c3f486814d58e3..65c24f3779cd9ef475030b54396c6b2821ef952b 100644 (file)
 /* XXX hack for now */
 #define channel 1
 
-static void nv10RenderPrimitive( GLcontext *ctx, GLenum prim );
 static void nv10RasterPrimitive( GLcontext *ctx, GLenum rprim, GLuint hwprim );
+static void nv10RenderPrimitive( GLcontext *ctx, GLenum prim );
+static void nv10ResetLineStipple( GLcontext *ctx );
+
 
 
 /***********************************************************************
@@ -87,7 +89,7 @@ static inline void nv10StartPrimitive(struct nouveau_context* nmesa)
                BEGIN_RING_PRIM(channel,NV20_BEGIN_VERTICES,NOUVEAU_MIN_PRIM_SIZE);
 }
 
-static inline void nv10FinishPrimitive(struct nouveau_context *nmesa)
+inline void nv10FinishPrimitive(struct nouveau_context *nmesa)
 {
        FINISH_RING_PRIM();
        if (nmesa->screen->card_type==NV_10)
@@ -165,6 +167,18 @@ static inline void nv10_draw_point(nouveauContextPtr nmesa,
 
 
 
+#define CTX_ARG nouveauContextPtr nmesa
+#define GET_VERTEX_DWORDS() nmesa->vertex_size
+#define LOCAL_VARS                                             \
+   nouveauContextPtr nmesa = NOUVEAU_CONTEXT(ctx);             \
+   const char *nouveauverts = (char *)nmesa->verts;
+#define VERT(x) (nouveauVertex *)(nouveauverts + ((x) * vertsize * sizeof(int)))
+#define VERTEX nouveauVertex
+
+#undef TAG
+#define TAG(x) nouveau_##x
+#include "tnl_dd/t_dd_triemit.h"
+
 /***********************************************************************
  *          Macros for nouveau_dd_tritmp.h to draw basic primitives        *
  ***********************************************************************/
@@ -203,6 +217,7 @@ static inline void nv10_draw_point(nouveauContextPtr nmesa,
                nv10_draw_point(nmesa, v0);                 \
        } while (0)
 
+#undef TAG
 
 /***********************************************************************
  *              Build render functions from dd templates               *
@@ -260,15 +275,7 @@ static struct {
                color->alpha=(c)[3];                                    \
        } while (0)
 
-#define VERT_COPY_RGBA( v0, v1 )                                       \
-       do {                                                            \
-               if (coloroffset) {                                      \
-                       v0->f[coloroffset][0] = v1->f[coloroffset][0];  \
-                       v0->f[coloroffset][1] = v1->f[coloroffset][1];  \
-                       v0->f[coloroffset][2] = v1->f[coloroffset][2];  \
-                       v0->f[coloroffset][3] = v1->f[coloroffset][3];  \
-               }                                                       \
-       } while (0)
+#define VERT_COPY_RGBA( v0, v1 ) v0->ui[coloroffset] = v1->ui[coloroffset]
 
 #define VERT_SET_SPEC( v, c )                                                  \
        do {                                                                    \
@@ -282,9 +289,11 @@ static struct {
 #define VERT_COPY_SPEC( v0, v1 )                       \
        do {                                                    \
                if (specoffset) {                                       \
-                       v0->f[specoffset][0] = v1->f[specoffset][0];    \
-                       v0->f[specoffset][1] = v1->f[specoffset][1];    \
-                       v0->f[specoffset][2] = v1->f[specoffset][2];    \
+                       nouveau_color_t *spec0 = (nouveau_color_t *)&((v0)->ui[specoffset]);    \
+                       nouveau_color_t *spec1 = (nouveau_color_t *)&((v1)->ui[specoffset]);    \
+                       spec0->red   = spec1->red;      \
+                       spec0->green = spec1->green;    \
+                       spec0->blue  = spec1->blue;     \
                }                                                       \
        } while (0)
 
@@ -295,6 +304,7 @@ static struct {
 #define VERT_RESTORE_SPEC( idx ) if (specoffset) v[idx]->f[specoffset] = spec[idx]
 
 
+#undef LOCAL_VARS
 #define LOCAL_VARS(n)                                                          \
        struct nouveau_context *nmesa = NOUVEAU_CONTEXT(ctx);                  \
 GLuint color[n], spec[n];                                                      \
@@ -321,7 +331,7 @@ static const GLuint hw_prim[GL_POLYGON+1] = {
 };
 
 #define RASTERIZE(x) nv10RasterPrimitive( ctx, x, hw_prim[x] )
-#define RENDER_PRIMITIVE nmesa->renderPrimitive
+#define RENDER_PRIMITIVE nmesa->current_primitive
 #define TAG(x) x
 #define IND NOUVEAU_FALLBACK_BIT
 #include "tnl_dd/t_dd_unfilled.h"
@@ -457,7 +467,7 @@ const GLuint vertsize = nmesa->vertex_size;          \
 const GLuint * const elt = TNL_CONTEXT(ctx)->vb.Elts;       \
 const GLboolean stipple = ctx->Line.StippleFlag;               \
 (void) elt; (void) stipple;
-#define RESET_STIPPLE  if ( stipple ) nouveauResetLineStipple( ctx );
+#define RESET_STIPPLE  if ( stipple ) nv10ResetLineStipple( ctx );
 #define RESET_OCCLUSION
 #define PRESERVE_VB_DEFS
 #define ELT(x) x
@@ -487,7 +497,7 @@ static void nouveauRenderClippedPoly(GLcontext *ctx, const GLuint *elts,
 {
        TNLcontext *tnl = TNL_CONTEXT(ctx);
        struct vertex_buffer *VB = &TNL_CONTEXT(ctx)->vb;
-       GLuint prim = NOUVEAU_CONTEXT(ctx)->renderPrimitive;
+       GLuint prim = NOUVEAU_CONTEXT(ctx)->current_primitive;
 
        /* Render the new vertices as an unclipped polygon.
         */
@@ -592,8 +602,8 @@ static void nv10ChooseRenderState(GLcontext *ctx)
                index = NOUVEAU_MAX_TRIFUNC;    /* flat specular */
        }
 
-       if (nmesa->renderIndex != index) {
-               nmesa->renderIndex = index;
+       if (nmesa->render_index != index) {
+               nmesa->render_index = index;
 
                tnl->Driver.Render.Points = rast_tab[index].points;
                tnl->Driver.Render.Line = rast_tab[index].line;
@@ -641,6 +651,7 @@ static inline void nv10OutputVertexFormat(struct nouveau_context* nmesa, GLuint
        for(i=8;i<16;i++)
        {
                if (index&(1<<i))
+                       /* FIXME that is very dubious */
                        attr_size[i]=VB->TexCoordPtr[i];
                else
                        attr_size[i]=0;
@@ -690,7 +701,28 @@ static inline void nv10OutputVertexFormat(struct nouveau_context* nmesa, GLuint
         * Tell the hardware about the vertex format
         */
        if (nmesa->screen->card_type==NV_10) {
-               // XXX needs some love
+               int size;
+
+#define NV10_SET_VERTEX_ATTRIB(i,j) \
+       do {    \
+               size = attr_size[j] << 4;       \
+               size |= (attr_size[j]*4) << 8;  \
+               size |= NV20_VERTEX_ATTRIBUTE_TYPE_FLOAT;       \
+               BEGIN_RING_SIZE(channel, NV10_VERTEX_ATTRIBUTE(i),1);   \
+               OUT_RING(size); \
+       } while (0)
+
+               NV10_SET_VERTEX_ATTRIB(0, _TNL_ATTRIB_POS);
+               NV10_SET_VERTEX_ATTRIB(1, _TNL_ATTRIB_COLOR0);
+               NV10_SET_VERTEX_ATTRIB(2, _TNL_ATTRIB_COLOR1);
+               NV10_SET_VERTEX_ATTRIB(3, _TNL_ATTRIB_TEX0);
+               NV10_SET_VERTEX_ATTRIB(4, _TNL_ATTRIB_TEX1);
+               NV10_SET_VERTEX_ATTRIB(5, _TNL_ATTRIB_NORMAL);
+               NV10_SET_VERTEX_ATTRIB(6, _TNL_ATTRIB_WEIGHT);
+               NV10_SET_VERTEX_ATTRIB(7, _TNL_ATTRIB_FOG);
+
+               BEGIN_RING_SIZE(channel, NV10_VERTEX_SET_FORMAT,1);
+               OUT_RING(0);
        } else if (nmesa->screen->card_type==NV_20) {
                for(i=0;i<16;i++)
                {
@@ -719,11 +751,11 @@ static void nv10ChooseVertexState( GLcontext *ctx )
 {
        struct nouveau_context *nmesa = NOUVEAU_CONTEXT(ctx);
        TNLcontext *tnl = TNL_CONTEXT(ctx);
-       GLuint index = tnl->render_inputs;
+       GLuint index = tnl->render_inputs_bitset;
 
-       if (index!=nmesa->render_inputs)
+       if (index!=nmesa->render_inputs_bitset)
        {
-               nmesa->render_inputs=index;
+               nmesa->render_inputs_bitset=index;
                nv10OutputVertexFormat(nmesa,index);
        }
 }
@@ -736,10 +768,11 @@ static void nv10ChooseVertexState( GLcontext *ctx )
 
 static void nv10RenderStart(GLcontext *ctx)
 {
+       TNLcontext *tnl = TNL_CONTEXT(ctx);
        struct nouveau_context *nmesa = NOUVEAU_CONTEXT(ctx);
 
-       if (nmesa->newState) {
-               nmesa->newRenderState |= nmesa->newState;
+       if (nmesa->new_state) {
+               nmesa->new_render_state |= nmesa->new_state;
        }
 
        if (nmesa->Fallback) {
@@ -747,10 +780,10 @@ static void nv10RenderStart(GLcontext *ctx)
                return;
        }
 
-       if (nmesa->newRenderState) {
+       if (nmesa->new_render_state) {
                nv10ChooseVertexState(ctx);
                nv10ChooseRenderState(ctx);
-               nmesa->newRenderState = 0;
+               nmesa->new_render_state = 0;
        }
 }
 
@@ -770,7 +803,7 @@ void nv10RasterPrimitive(GLcontext *ctx,
 {
        struct nouveau_context *nmesa = NOUVEAU_CONTEXT(ctx);
 
-       assert (!nmesa->newState);
+       assert (!nmesa->new_state);
 
        if (hwprim != nmesa->current_primitive)
        {
@@ -786,14 +819,17 @@ static void nv10RenderPrimitive( GLcontext *ctx, GLuint prim )
        nv10RasterPrimitive( ctx, prim, hw_prim[prim] );
 }
 
+static void nv10ResetLineStipple( GLcontext *ctx )
+{
+       /* FIXME do something here */
+}
 
 
 /**********************************************************************/
 /*                            Initialization.                         */
 /**********************************************************************/
 
-
-void nouveauInitTriFuncs(GLcontext *ctx)
+void nv10TriInitFunctions(GLcontext *ctx)
 {
        struct nouveau_context *nmesa = NOUVEAU_CONTEXT(ctx);
        TNLcontext *tnl = TNL_CONTEXT(ctx);
@@ -808,7 +844,7 @@ void nouveauInitTriFuncs(GLcontext *ctx)
        tnl->Driver.Render.Start = nv10RenderStart;
        tnl->Driver.Render.Finish = nv10RenderFinish;
        tnl->Driver.Render.PrimitiveNotify = nv10RenderPrimitive;
-       tnl->Driver.Render.ResetLineStipple = nouveauResetLineStipple;
+       tnl->Driver.Render.ResetLineStipple = nv10ResetLineStipple;
        tnl->Driver.Render.BuildVertices = _tnl_build_vertices;
        tnl->Driver.Render.CopyPV = _tnl_copy_pv;
        tnl->Driver.Render.Interp = _tnl_interp;
@@ -820,3 +856,4 @@ void nouveauInitTriFuncs(GLcontext *ctx)
 
 }
 
+