summaryrefslogtreecommitdiffstats
path: root/src/mesa/drivers/common/t_dd_unfilled.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/mesa/drivers/common/t_dd_unfilled.h')
-rw-r--r--src/mesa/drivers/common/t_dd_unfilled.h237
1 files changed, 141 insertions, 96 deletions
diff --git a/src/mesa/drivers/common/t_dd_unfilled.h b/src/mesa/drivers/common/t_dd_unfilled.h
index c1f3a92b00f..59c9bfdc5ab 100644
--- a/src/mesa/drivers/common/t_dd_unfilled.h
+++ b/src/mesa/drivers/common/t_dd_unfilled.h
@@ -1,135 +1,180 @@
+#if HAVE_RGBA
+#define VERT_SET_IND( v, c )
+#define VERT_COPY_IND( v0, v1 )
+#define VERT_SAVE_IND( idx )
+#define VERT_RESTORE_IND( idx )
+#endif
-static void tdfx_unfilled_tri( GLcontext *ctx,
+#if !HAVE_SPEC
+#define VERT_SET_SPEC( v, c )
+#define VERT_COPY_SPEC( v0, v1 )
+#define VERT_SAVE_SPEC( idx )
+#define VERT_RESTORE_SPEC( idx )
+#endif
+
+static void TAG(unfilled_tri)( GLcontext *ctx,
GLenum mode,
GLuint e0, GLuint e1, GLuint e2 )
{
- tdfxContextPtr imesa = TDFX_CONTEXT(ctx);
struct vertex_buffer *VB = &TNL_CONTEXT(ctx)->vb;
GLubyte *ef = VB->EdgeFlag;
- GLubyte *tdfxverts = (GLubyte *)imesa->verts;
- GLuint shift = imesa->vertex_stride_shift;
- tdfxVertex *v0 = (tdfxVertex *)(tdfxverts + (e0 << shift));
- tdfxVertex *v1 = (tdfxVertex *)(tdfxverts + (e1 << shift));
- tdfxVertex *v2 = (tdfxVertex *)(tdfxverts + (e2 << shift));
- GLuint c[2];
- GLuint s[2];
- GLuint coloroffset = 0;
-
-/* fprintf(stderr, "%s %s %d %d %d (vertsize %d)\n", __FUNCTION__, */
-/* gl_lookup_enum_by_nr(mode), e0, e1, e2, imesa->vertsize); */
-
- if (ctx->_TriangleCaps & DD_FLATSHADE) {
- coloroffset = (imesa->vertsize == 4) ? 3 : 4;
- TDFX_COPY_COLOR(c[0], v0->ui[coloroffset]);
- TDFX_COPY_COLOR(c[1], v1->ui[coloroffset]);
- TDFX_COPY_COLOR(v0->ui[coloroffset], v2->ui[coloroffset]);
- TDFX_COPY_COLOR(v1->ui[coloroffset], v2->ui[coloroffset]);
-
- if (coloroffset == 4) {
- TDFX_COPY_COLOR(s[0], v0->v.specular);
- TDFX_COPY_COLOR(s[1], v1->v.specular);
- TDFX_COPY_COLOR(v0->v.specular, v2->v.specular);
- TDFX_COPY_COLOR(v1->v.specular, v2->v.specular);
+ VERTEX *v[3];
+ LOCAL_VARS(3);
+
+ v[0] = (VERTEX *)GET_VERTEX(e0);
+ v[1] = (VERTEX *)GET_VERTEX(e1);
+ v[2] = (VERTEX *)GET_VERTEX(e2);
+
+ if ((ctx->_TriangleCaps & DD_FLATSHADE) && HAVE_HW_FLATSHADE) {
+ if (HAVE_RGBA) {
+ VERT_SAVE_RGBA(0);
+ VERT_SAVE_RGBA(1);
+ VERT_COPY_RGBA(v[0], v[2]);
+ VERT_COPY_RGBA(v[1], v[2]);
+
+ if (HAVE_SPEC) {
+ VERT_SAVE_SPEC(0);
+ VERT_SAVE_SPEC(1);
+ VERT_COPY_SPEC(v[0], v[2]);
+ VERT_COPY_SPEC(v[1], v[2]);
+ }
+ } else {
+ VERT_SAVE_IND(0);
+ VERT_SAVE_IND(1);
+ VERT_COPY_IND(v[0], v[2]);
+ VERT_COPY_IND(v[1], v[2]);
}
}
if (mode == GL_POINT) {
- tdfxRasterPrimitive( ctx, GL_POINTS, PR_LINES );
- if (ef[e0]) imesa->draw_point( imesa, v0 );
- if (ef[e1]) imesa->draw_point( imesa, v1 );
- if (ef[e2]) imesa->draw_point( imesa, v2 );
+ RASTERIZE(GL_POINTS);
+ if (ef[e0]) POINT( v[0] );
+ if (ef[e1]) POINT( v[1] );
+ if (ef[e2]) POINT( v[2] );
}
else {
- tdfxRasterPrimitive( ctx, GL_LINES, PR_LINES );
-
- if (imesa->render_primitive == GL_POLYGON) {
- if (ef[e2]) imesa->draw_line( imesa, v2, v0 );
- if (ef[e0]) imesa->draw_line( imesa, v0, v1 );
- if (ef[e1]) imesa->draw_line( imesa, v1, v2 );
+ RASTERIZE(GL_LINES);
+ if (RENDER_PRIMITIVE == GL_POLYGON) {
+ if (ef[e2]) LINE( v[2], v[0] );
+ if (ef[e0]) LINE( v[0], v[1] );
+ if (ef[e1]) LINE( v[1], v[2] );
}
else {
- if (ef[e0]) imesa->draw_line( imesa, v0, v1 );
- if (ef[e1]) imesa->draw_line( imesa, v1, v2 );
- if (ef[e2]) imesa->draw_line( imesa, v2, v0 );
+ if (ef[e0]) LINE( v[0], v[1] );
+ if (ef[e1]) LINE( v[1], v[2] );
+ if (ef[e2]) LINE( v[2], v[0] );
}
}
- if (ctx->_TriangleCaps & DD_FLATSHADE) {
- TDFX_COPY_COLOR(v0->ui[coloroffset], c[0]);
- TDFX_COPY_COLOR(v1->ui[coloroffset], c[1]);
- if (coloroffset == 4) {
- TDFX_COPY_COLOR(v0->v.specular, s[0]);
- TDFX_COPY_COLOR(v1->v.specular, s[1]);
+ if ((ctx->_TriangleCaps & DD_FLATSHADE) && HAVE_HW_FLATSHADE) {
+ if (HAVE_RGBA) {
+ VERT_RESTORE_RGBA(0);
+ VERT_RESTORE_RGBA(1);
+
+ if (HAVE_SPEC) {
+ VERT_RESTORE_SPEC(0);
+ VERT_RESTORE_SPEC(1);
+ }
+ } else {
+ VERT_RESTORE_IND(0);
+ VERT_RESTORE_IND(1);
}
}
}
-static void tdfx_unfilled_quad( GLcontext *ctx,
+static void TAG(unfilled_quad)( GLcontext *ctx,
GLenum mode,
GLuint e0, GLuint e1,
GLuint e2, GLuint e3 )
{
- tdfxContextPtr imesa = TDFX_CONTEXT(ctx);
struct vertex_buffer *VB = &TNL_CONTEXT(ctx)->vb;
GLubyte *ef = VB->EdgeFlag;
- GLubyte *tdfxverts = (GLubyte *)imesa->verts;
- GLuint shift = imesa->vertex_stride_shift;
- tdfxVertex *v0 = (tdfxVertex *)(tdfxverts + (e0 << shift));
- tdfxVertex *v1 = (tdfxVertex *)(tdfxverts + (e1 << shift));
- tdfxVertex *v2 = (tdfxVertex *)(tdfxverts + (e2 << shift));
- tdfxVertex *v3 = (tdfxVertex *)(tdfxverts + (e3 << shift));
- GLuint c[3];
- GLuint s[3];
- GLuint coloroffset = 0;
-
- if (ctx->_TriangleCaps & DD_FLATSHADE) {
- coloroffset = (imesa->vertsize == 4) ? 3 : 4;
-
- TDFX_COPY_COLOR(c[0], v0->ui[coloroffset]);
- TDFX_COPY_COLOR(c[1], v1->ui[coloroffset]);
- TDFX_COPY_COLOR(c[2], v2->ui[coloroffset]);
- TDFX_COPY_COLOR(v0->ui[coloroffset], v3->ui[coloroffset]);
- TDFX_COPY_COLOR(v1->ui[coloroffset], v3->ui[coloroffset]);
- TDFX_COPY_COLOR(v2->ui[coloroffset], v3->ui[coloroffset]);
-
- if (coloroffset == 4) {
- TDFX_COPY_COLOR(s[0], v0->v.specular);
- TDFX_COPY_COLOR(s[1], v1->v.specular);
- TDFX_COPY_COLOR(s[2], v2->v.specular);
- TDFX_COPY_COLOR(v0->v.specular, v3->v.specular);
- TDFX_COPY_COLOR(v1->v.specular, v3->v.specular);
- TDFX_COPY_COLOR(v2->v.specular, v3->v.specular);
+ VERTEX *v[4];
+ LOCAL_VARS(4);
+
+ v[0] = (VERTEX *)GET_VERTEX(e0);
+ v[1] = (VERTEX *)GET_VERTEX(e1);
+ v[2] = (VERTEX *)GET_VERTEX(e2);
+ v[3] = (VERTEX *)GET_VERTEX(e3);
+
+ /* Hardware flatshading breaks down here. If the hardware doesn't
+ * support flatshading, this will already have been done:
+ */
+ if ((ctx->_TriangleCaps & DD_FLATSHADE) && HAVE_HW_FLATSHADE) {
+ if (HAVE_RGBA) {
+ VERT_SAVE_RGBA(0);
+ VERT_SAVE_RGBA(1);
+ VERT_SAVE_RGBA(2);
+ VERT_COPY_RGBA(v[0], v[3]);
+ VERT_COPY_RGBA(v[1], v[3]);
+ VERT_COPY_RGBA(v[2], v[3]);
+
+ if (HAVE_SPEC) {
+ VERT_SAVE_SPEC(0);
+ VERT_SAVE_SPEC(1);
+ VERT_SAVE_SPEC(2);
+ VERT_COPY_SPEC(v[0], v[3]);
+ VERT_COPY_SPEC(v[1], v[3]);
+ VERT_COPY_SPEC(v[2], v[3]);
+ }
+ } else {
+ VERT_SAVE_IND(0);
+ VERT_SAVE_IND(1);
+ VERT_SAVE_IND(2);
+ VERT_COPY_IND(v[0], v[3]);
+ VERT_COPY_IND(v[1], v[3]);
+ VERT_COPY_IND(v[2], v[3]);
}
}
if (mode == GL_POINT) {
- if (imesa->reduced_primitive != GL_POINTS)
- tdfxRasterPrimitive( ctx, GL_POINTS, PR_LINES );
-
- if (ef[e0]) imesa->draw_point( imesa, v0 );
- if (ef[e1]) imesa->draw_point( imesa, v1 );
- if (ef[e2]) imesa->draw_point( imesa, v2 );
- if (ef[e3]) imesa->draw_point( imesa, v3 );
+ RASTERIZE(GL_POINTS);
+ if (ef[e0]) POINT( v[0] );
+ if (ef[e1]) POINT( v[1] );
+ if (ef[e2]) POINT( v[2] );
+ if (ef[e3]) POINT( v[3] );
}
else {
- if (imesa->reduced_primitive != GL_LINES)
- tdfxRasterPrimitive( ctx, GL_LINES, PR_LINES );
-
- if (ef[e0]) imesa->draw_line( imesa, v0, v1 );
- if (ef[e1]) imesa->draw_line( imesa, v1, v2 );
- if (ef[e2]) imesa->draw_line( imesa, v2, v3 );
- if (ef[e3]) imesa->draw_line( imesa, v3, v0 );
+ RASTERIZE(GL_LINES);
+ if (ef[e0]) LINE( v[0], v[1] );
+ if (ef[e1]) LINE( v[1], v[2] );
+ if (ef[e2]) LINE( v[2], v[3] );
+ if (ef[e3]) LINE( v[3], v[0] );
}
- if (ctx->_TriangleCaps & DD_FLATSHADE) {
- TDFX_COPY_COLOR(v0->ui[coloroffset], c[0]);
- TDFX_COPY_COLOR(v1->ui[coloroffset], c[1]);
- TDFX_COPY_COLOR(v2->ui[coloroffset], c[2]);
- if (coloroffset == 4) {
- TDFX_COPY_COLOR(v0->v.specular, s[0]);
- TDFX_COPY_COLOR(v1->v.specular, s[1]);
- TDFX_COPY_COLOR(v2->v.specular, s[2]);
+ if ((ctx->_TriangleCaps & DD_FLATSHADE) && HAVE_HW_FLATSHADE) {
+ if (HAVE_RGBA) {
+ VERT_RESTORE_RGBA(0);
+ VERT_RESTORE_RGBA(1);
+ VERT_RESTORE_RGBA(2);
+
+ if (HAVE_SPEC) {
+ VERT_RESTORE_SPEC(0);
+ VERT_RESTORE_SPEC(1);
+ VERT_RESTORE_SPEC(2);
+ }
+ } else {
+ VERT_RESTORE_IND(0);
+ VERT_RESTORE_IND(1);
+ VERT_RESTORE_IND(2);
}
}
}
+
+
+#if HAVE_RGBA
+#undef VERT_SET_IND
+#undef VERT_COPY_IND
+#undef VERT_SAVE_IND
+#undef VERT_RESTORE_IND
+#endif
+
+#if !HAVE_SPEC
+#undef VERT_SET_SPEC
+#undef VERT_COPY_SPEC
+#undef VERT_SAVE_SPEC
+#undef VERT_RESTORE_SPEC
+#endif
+
+#undef TAG