/* 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 );
-/***********************************************************************
- * 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
#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)
#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]; \
};
#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"
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
{
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.
*/
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;
* 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++)
{
{
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);
}
}
static void nv10RenderStart(GLcontext *ctx)
{
+ TNLcontext *tnl = TNL_CONTEXT(ctx);
struct nouveau_context *nmesa = NOUVEAU_CONTEXT(ctx);
if (nmesa->new_state) {
nv10RasterPrimitive( ctx, prim, hw_prim[prim] );
}
+static void nv10ResetLineStipple( GLcontext *ctx )
+{
+ /* FIXME do something here */
+}
+
/**********************************************************************/
/* Initialization. */
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;