Make nouveau actually compile
[mesa.git] / src / mesa / drivers / dri / nouveau / nv10_swtcl.c
index 7f3d275c402d706e83834c0d422dc5ad01fc9cfd..65c24f3779cd9ef475030b54396c6b2821ef952b 100644 (file)
@@ -52,8 +52,9 @@
 /* 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 );
 
 
 
@@ -166,53 +167,55 @@ static inline void nv10_draw_point(nouveauContextPtr nmesa,
 
 
 
-/***********************************************************************
- *          Macros for nouveau_dd_tritmp.h to draw basic primitives        *
- ***********************************************************************/
-
 #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"
 
-static __inline void TAG(quad)( CTX_ARG,
-                               VERTEX *v0,
-                               VERTEX *v1,
-                               VERTEX *v2,
-                               VERTEX *v3 )
-{
-       (*nmesa->draw_tri)(nmesa, v0, v1, v3);
-       (*nmesa->draw_tri)(nmesa, v1, v2, v3);
-       /* FIXME: Need to add nmesa->draw_quad in nouveau_context ? */
-       /* nv10_draw_quad(nmesa, v0, v1, v2, v3); */
-}
+/***********************************************************************
+ *          Macros for nouveau_dd_tritmp.h to draw basic primitives        *
+ ***********************************************************************/
 
-static __inline void TAG(triangle)( CTX_ARG,
-                                   VERTEX *v0,
-                                   VERTEX *v1,
-                                   VERTEX *v2 )
-{
-       (*nmesa->draw_tri)(nmesa, v0, v1, v2);
-}
+#define TRI(a, b, c)                                        \
+       do {                                                \
+               if (DO_FALLBACK)                            \
+               nmesa->draw_tri(nmesa, a, b, c);            \
+               else                                        \
+               nv10_draw_triangle(nmesa, a, b, c);         \
+       } while (0)
 
-static __inline void TAG(line)( CTX_ARG,
-                               VERTEX *v0,
-                               VERTEX *v1 )
-{
-       (*nmesa->draw_line)(nmesa, v0, v1);
-}
+#define QUAD(a, b, c, d)                                    \
+       do {                                                \
+               if (DO_FALLBACK) {                          \
+                       nmesa->draw_tri(nmesa, a, b, d);    \
+                       nmesa->draw_tri(nmesa, b, c, d);    \
+               }                                           \
+               else                                        \
+               nv10_draw_quad(nmesa, a, b, c, d);          \
+       } while (0)
 
-static __inline void TAG(point)( CTX_ARG,
-                                VERTEX *v0 )
-{
-       (*nmesa->draw_point)(nmesa, v0);
-}
+#define LINE(v0, v1)                                        \
+       do {                                                \
+               if (DO_FALLBACK)                            \
+               nmesa->draw_line(nmesa, v0, v1);            \
+               else                                        \
+               nv10_draw_line(nmesa, v0, v1);              \
+       } while (0)
 
-#define QUAD( a, b, c, d ) nouveau_quad( nmesa, a, b, c, d )
-#define TRI( a, b, c )     nouveau_triangle( nmesa, a, b, c )
-#define LINE( a, b )       nouveau_line( nmesa, a, b )
-#define POINT( a )         nouveau_point( nmesa, a )
+#define POINT(v0)                                           \
+       do {                                                \
+               if (DO_FALLBACK)                            \
+               nmesa->draw_point(nmesa, v0);               \
+               else                                        \
+               nv10_draw_point(nmesa, v0);                 \
+       } while (0)
 
 #undef TAG
 
@@ -286,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)
 
@@ -299,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];                                                      \
@@ -325,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"
@@ -461,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
@@ -491,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.
         */
@@ -645,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;
@@ -694,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++)
                {
@@ -723,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);
        }
 }
@@ -740,6 +768,7 @@ static void nv10ChooseVertexState( GLcontext *ctx )
 
 static void nv10RenderStart(GLcontext *ctx)
 {
+       TNLcontext *tnl = TNL_CONTEXT(ctx);
        struct nouveau_context *nmesa = NOUVEAU_CONTEXT(ctx);
 
        if (nmesa->new_state) {
@@ -790,6 +819,11 @@ static void nv10RenderPrimitive( GLcontext *ctx, GLuint prim )
        nv10RasterPrimitive( ctx, prim, hw_prim[prim] );
 }
 
+static void nv10ResetLineStipple( GLcontext *ctx )
+{
+       /* FIXME do something here */
+}
+
 
 /**********************************************************************/
 /*                            Initialization.                         */
@@ -810,7 +844,7 @@ void nv10TriInitFunctions(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;