summaryrefslogtreecommitdiffstats
path: root/src/mesa/drivers
diff options
context:
space:
mode:
Diffstat (limited to 'src/mesa/drivers')
-rw-r--r--src/mesa/drivers/common/t_dd.c32
-rw-r--r--src/mesa/drivers/common/t_dd_dmatmp.h980
-rw-r--r--src/mesa/drivers/common/t_dd_rendertmp.h439
-rw-r--r--src/mesa/drivers/common/t_dd_tritmp.h569
-rw-r--r--src/mesa/drivers/common/t_dd_unfilled.h135
-rw-r--r--src/mesa/drivers/common/t_dd_vb.c99
-rw-r--r--src/mesa/drivers/common/t_dd_vbtmp.h529
-rw-r--r--src/mesa/drivers/glide/fxdd.c3
8 files changed, 2784 insertions, 2 deletions
diff --git a/src/mesa/drivers/common/t_dd.c b/src/mesa/drivers/common/t_dd.c
new file mode 100644
index 00000000000..27db3058755
--- /dev/null
+++ b/src/mesa/drivers/common/t_dd.c
@@ -0,0 +1,32 @@
+
+static void copy_pv_rgba4_spec5( GLcontext *ctx, GLuint edst, GLuint esrc )
+{
+ i810ContextPtr imesa = I810_CONTEXT( ctx );
+ GLubyte *i810verts = (GLubyte *)imesa->verts;
+ GLuint shift = imesa->vertex_stride_shift;
+ i810Vertex *dst = (i810Vertex *)(i810verts + (edst << shift));
+ i810Vertex *src = (i810Vertex *)(i810verts + (esrc << shift));
+ dst->ui[4] = src->ui[4];
+ dst->ui[5] = src->ui[5];
+}
+
+static void copy_pv_rgba4( GLcontext *ctx, GLuint edst, GLuint esrc )
+{
+ i810ContextPtr imesa = I810_CONTEXT( ctx );
+ GLubyte *i810verts = (GLubyte *)imesa->verts;
+ GLuint shift = imesa->vertex_stride_shift;
+ i810Vertex *dst = (i810Vertex *)(i810verts + (edst << shift));
+ i810Vertex *src = (i810Vertex *)(i810verts + (esrc << shift));
+ dst->ui[4] = src->ui[4];
+}
+
+static void copy_pv_rgba3( GLcontext *ctx, GLuint edst, GLuint esrc )
+{
+ i810ContextPtr imesa = I810_CONTEXT( ctx );
+ GLubyte *i810verts = (GLubyte *)imesa->verts;
+ GLuint shift = imesa->vertex_stride_shift;
+ i810Vertex *dst = (i810Vertex *)(i810verts + (edst << shift));
+ i810Vertex *src = (i810Vertex *)(i810verts + (esrc << shift));
+ dst->ui[3] = src->ui[3];
+}
+
diff --git a/src/mesa/drivers/common/t_dd_dmatmp.h b/src/mesa/drivers/common/t_dd_dmatmp.h
new file mode 100644
index 00000000000..38406e408d7
--- /dev/null
+++ b/src/mesa/drivers/common/t_dd_dmatmp.h
@@ -0,0 +1,980 @@
+/*
+ * Mesa 3-D graphics library
+ * Version: 3.5
+ *
+ * Copyright (C) 1999 Brian Paul All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ * Author:
+ * Keith Whitwell <[email protected]>
+ */
+
+
+/* Template for render stages which build and emit vertices directly
+ * to fixed-size dma buffers. Useful for rendering strips and other
+ * native primitives where clipping and per-vertex tweaks such as
+ * those in t_dd_tritmp.h are not required.
+ *
+ * Produces code for both inline triangles and indexed triangles.
+ * Where various primitive types are unaccelerated by hardware, the
+ * code attempts to fallback to other primitive types (quadstrips to
+ * tristrips, lineloops to linestrips), or to indexed vertices.
+ * Ultimately, a FALLBACK() macro is invoked if there is no way to
+ * render the primitive natively.
+ */
+
+#if !defined(HAVE_TRI_STRIPS) || !defined(HAVE_TRIANGLES)
+#error "must have at least tristrips and triangles to use render template"
+#endif
+
+#if !HAVE_ELTS
+#define ALLOC_ELTS( nr )
+#define EMIT_ELT( offset, elt )
+#define INCR_ELTS( nr )
+#endif
+
+#ifndef EMIT_TWO_ELTS
+#define EMIT_TWO_ELTS( offset, elt0, elt1 ) \
+do { \
+ EMIT_ELT( offset, elt0 ); \
+ EMIT_ELT( offset+1, elt1 ); \
+} while (0)
+#endif
+
+/**********************************************************************/
+/* Render whole begin/end objects */
+/**********************************************************************/
+
+
+
+static GLboolean TAG(emit_elt_verts)( GLcontext *ctx,
+ GLuint start, GLuint count )
+{
+ if (HAVE_ELTS) {
+ GLuint nr = count - start;
+
+ if ( nr >= GET_SUBSEQUENT_VB_MAX_VERTS() )
+ return GL_FALSE;
+
+ NEW_PRIMITIVE(); /* finish last prim */
+ EMIT_INDEXED_VERTS( ctx, start, count );
+ return GL_TRUE;
+ } else {
+ return GL_FALSE;
+ }
+}
+
+static void TAG(emit_elts)( GLcontext *ctx, GLuint *elts, GLuint nr )
+{
+ GLushort *dest;
+ GLint i;
+ ELTS_VARS;
+
+ ALLOC_ELTS( nr );
+
+ for ( i = 0 ; i < nr ; i++, elts += 2 ) {
+ EMIT_TWO_ELTS( 0, elts[0], elts[1] );
+ INCR_ELTS( 2 );
+ }
+}
+
+
+/***********************************************************************
+ * Render non-indexed primitives.
+ ***********************************************************************/
+
+
+
+static void TAG(render_points_verts)( GLcontext *ctx,
+ GLuint start,
+ GLuint count,
+ GLuint flags )
+{
+ if (HAVE_POINTS) {
+ int dmasz = GET_SUBSEQUENT_VB_MAX_VERTS();
+ int currentsz = GET_CURRENT_VB_MAX_VERTS();
+ GLuint j, nr;
+
+ INIT( GL_POINTS );
+
+ if (currentsz < 8)
+ currentsz = dmasz;
+
+ for (j = start; j < count; j += nr ) {
+ nr = MIN2( currentsz, count - j );
+ EMIT_VERTS( ctx, j, nr );
+ currentsz = dmasz;
+ }
+ } else {
+ FALLBACK( ctx, start, count, flags );
+ }
+}
+
+static void TAG(render_lines_verts)( GLcontext *ctx,
+ GLuint start,
+ GLuint count,
+ GLuint flags )
+{
+ if (HAVE_LINES) {
+ int dmasz = GET_SUBSEQUENT_VB_MAX_VERTS();
+ int currentsz = GET_CURRENT_VB_MAX_VERTS();
+ GLuint j, nr;
+
+ INIT( GL_LINES );
+
+ /* Emit whole number of lines in total and in each buffer:
+ */
+ count -= (count-start) & 1;
+ currentsz -= currentsz & 1;
+ dmasz -= dmasz & 1;
+
+ if (currentsz < 8)
+ currentsz = dmasz;
+
+ for (j = start; j < count; j += nr ) {
+ nr = MIN2( currentsz, count - j );
+ EMIT_VERTS( ctx, j, nr );
+ currentsz = dmasz;
+ }
+ } else {
+ FALLBACK( ctx, start, count, flags );
+ }
+}
+
+
+static void TAG(render_line_strip_verts)( GLcontext *ctx,
+ GLuint start,
+ GLuint count,
+ GLuint flags )
+{
+ if (HAVE_LINE_STRIPS) {
+ int dmasz = GET_SUBSEQUENT_VB_MAX_VERTS();
+ int currentsz = GET_CURRENT_VB_MAX_VERTS();
+ GLuint j, nr;
+
+ NEW_PRIMITIVE(); /* always a new primitive */
+ INIT( GL_LINE_STRIP );
+
+ if (currentsz < 8)
+ currentsz = dmasz;
+
+ for (j = start; j < count - 1; j += nr - 1 ) {
+ nr = MIN2( currentsz, count - j );
+ EMIT_VERTS( ctx, j, nr );
+ currentsz = dmasz;
+ }
+ } else {
+ FALLBACK( ctx, start, count, flags );
+ }
+}
+
+
+static void TAG(render_line_loop_verts)( GLcontext *ctx,
+ GLuint start,
+ GLuint count,
+ GLuint flags )
+{
+ if (HAVE_LINE_STRIPS) {
+ int dmasz = GET_SUBSEQUENT_VB_MAX_VERTS();
+ int currentsz = GET_CURRENT_VB_MAX_VERTS();
+ GLuint j, nr;
+
+ NEW_PRIMITIVE();
+ INIT( GL_LINE_STRIP );
+
+ if (flags & PRIM_BEGIN)
+ j = start;
+ else
+ j = start + 1;
+
+ /* Ensure last vertex won't wrap buffers:
+ */
+ currentsz--;
+ dmasz--;
+
+ if (currentsz < 8)
+ currentsz = dmasz;
+
+ for ( ; j < count - 1; j += nr - 1 ) {
+ nr = MIN2( currentsz, count - j );
+ EMIT_VERTS( ctx, j, nr );
+ currentsz = dmasz;
+ }
+
+ if (flags & PRIM_END)
+ EMIT_VERTS( ctx, start, 1 );
+
+ } else {
+ FALLBACK( ctx, start, count, flags );
+ }
+}
+
+
+static void TAG(render_triangles_verts)( GLcontext *ctx,
+ GLuint start,
+ GLuint count,
+ GLuint flags )
+{
+ int dmasz = (GET_SUBSEQUENT_VB_MAX_VERTS()/3) * 3;
+ int currentsz = (GET_CURRENT_VB_MAX_VERTS()/3) * 3;
+ GLuint j, nr;
+
+ INIT(GL_TRIANGLES);
+
+ /* Emit whole number of tris in total. dmasz is already a multiple
+ * of 3.
+ */
+ count -= (count-start)%3;
+
+ if (currentsz < 8)
+ currentsz = dmasz;
+
+ for (j = start; j < count; j += nr) {
+ nr = MIN2( currentsz, count - j );
+ EMIT_VERTS( ctx, j, nr );
+ currentsz = dmasz;
+ }
+}
+
+
+
+static void TAG(render_tri_strip_verts)( GLcontext *ctx,
+ GLuint start,
+ GLuint count,
+ GLuint flags )
+{
+ GLuint j, nr;
+ int dmasz = GET_SUBSEQUENT_VB_MAX_VERTS();
+ int currentsz;
+
+ INIT(GL_TRIANGLE_STRIP);
+ NEW_PRIMITIVE();
+
+ currentsz = GET_CURRENT_VB_MAX_VERTS();
+
+ if (currentsz < 8) {
+ FIRE_VERTICES( ctx );
+ currentsz = dmasz;
+ }
+
+ if (flags & PRIM_PARITY) {
+ if (HAVE_TRI_STRIP_1 && 0) {
+ } else {
+ EMIT_VERTS( ctx, start, 1 );
+ currentsz--;
+ }
+ }
+
+ /* From here on emit even numbers of tris when wrapping over buffers:
+ */
+ dmasz -= (dmasz & 1);
+ currentsz -= (currentsz & 1);
+
+ for (j = start ; j < count - 2; j += nr - 2 ) {
+ nr = MIN2( currentsz, count - j );
+ EMIT_VERTS( ctx, j, nr );
+ currentsz = dmasz;
+ }
+}
+
+static void TAG(render_tri_fan_verts)( GLcontext *ctx,
+ GLuint start,
+ GLuint count,
+ GLuint flags )
+{
+ if (HAVE_TRI_FAN) {
+ GLuint j, nr;
+ int dmasz = GET_SUBSEQUENT_VB_MAX_VERTS();
+ int currentsz = GET_CURRENT_VB_MAX_VERTS();
+
+ NEW_PRIMITIVE();
+ INIT(GL_TRIANGLE_FAN);
+
+ if (currentsz < 8) {
+ FIRE_VERTICES( ctx );
+ currentsz = dmasz;
+ }
+
+ for (j = start + 1 ; j < count - 1; j += nr - 1 ) {
+ nr = MIN2( currentsz, count - j + 1 );
+ EMIT_VERTS( ctx, start, 1 );
+ EMIT_VERTS( ctx, j, nr - 1 );
+ currentsz = dmasz;
+ }
+ }
+ else {
+ /* Could write code to emit these as indexed vertices (for the
+ * g400, for instance).
+ */
+ FALLBACK( ctx, start, count, flags );
+ }
+}
+
+
+static void TAG(render_poly_verts)( GLcontext *ctx,
+ GLuint start,
+ GLuint count,
+ GLuint flags )
+{
+ if (HAVE_POLYGON) {
+ GLuint j, nr;
+ int dmasz = GET_SUBSEQUENT_VB_MAX_VERTS();
+ int currentsz = GET_CURRENT_VB_MAX_VERTS();
+
+ NEW_PRIMITIVE();
+ INIT(GL_POLYGON);
+
+ if (currentsz < 8) {
+ FIRE_VERTICES( ctx );
+ currentsz = dmasz;
+ }
+
+ for (j = start + 1 ; j < count - 1 ; j += nr - 1 ) {
+ nr = MIN2( currentsz, count - j + 1 );
+ EMIT_VERTS( ctx, start, 1 );
+ EMIT_VERTS( ctx, j, nr - 1 );
+ currentsz = dmasz;
+ }
+ }
+ else if (HAVE_TRIFAN && !(ctx->TriangleCaps & DD_FLATSHADE)) {
+ TAG(render_tri_fan_verts)( ctx, start, count, flags );
+ } else {
+ FALLBACK( ctx, start, count, flags );
+ }
+}
+
+static void TAG(render_quad_strip_verts)( GLcontext *ctx,
+ GLuint start,
+ GLuint count,
+ GLuint flags )
+{
+ GLuint j, nr;
+
+ if (HAVE_QUAD_STRIPS && 0) {
+ /* TODO.
+ */
+ } else if (ctx->_TriangleCaps & DD_FLATSHADE) {
+ if (emit_elt_verts( ctx, start, count )) {
+ int dmasz = SUBSEQUENT_VB_ELT_NR();
+ int currentsz;
+ GLuint j, nr;
+
+ /* Simulate flat-shaded quadstrips using indexed vertices:
+ */
+ NEW_PRIMITIVE();
+ ELT_INIT( GL_TRIANGLES );
+
+ currentsz = CURRENT_VB_ELT_NR_NEW_PRIMITIVE();
+
+ /* Emit whole number of quads in total, and in each buffer.
+ */
+ dmasz -= dmasz & 1;
+ count -= (count-start) & 1;
+ currentsz -= currentsz & 1;
+
+ if (currentsz < 12)
+ currentsz = dmasz;
+
+ currentsz = currentsz/6*2;
+ dmasz = dmasz/6*2;
+
+ for (j = start; j < count - 3; j += nr - 2 ) {
+ nr = MIN2( currentsz, count - j );
+ if (nr >= 4) {
+ GLint quads = (nr/2)-1;
+ GLint i;
+ ELTS_VARS;
+
+ NEW_PRIMITIVE();
+ ALLOC_ELTS_NEW_PRIMITIVE( quads*6 );
+
+ for ( i = 0 ; i < quads*2 ; i+=2 ) {
+ EMIT_TWO_ELTS( 0, (i+0), (i+1) );
+ EMIT_TWO_ELTS( 2, (i+2), (i+1) );
+ EMIT_TWO_ELTS( 4, (i+3), (i+2) );
+ INCR_ELTS( 6 );
+ }
+
+ NEW_PRIMITIVE();
+ }
+ currentsz = dmasz;
+ }
+
+ RELEASE_ELT_VERTS();
+ }
+ else {
+ /* Vertices won't fit in a single buffer or elts not available,
+ * fallback.
+ */
+ FALLBACK( ctx, start, count, flags );
+ }
+ }
+ else {
+ int dmasz = GET_SUBSEQUENT_VB_SIZE();
+ int currentsz = GET_CURRENT_VB_SIZE();
+
+ /* Emit smooth-shaded quadstrips as tristrips:
+ */
+ NEW_PRIMITIVE();
+ INIT( GL_TRIANGLE_STRIP );
+
+ /* Emit whole number of quads in total, and in each buffer.
+ */
+ dmasz -= dmasz & 1;
+ currentsz -= currentsz & 1;
+ count -= (count-start) & 1;
+
+ if (currentsz < 8) {
+ FIRE_VERTICES( ctx );
+ currentsz = dmasz;
+ }
+
+ for (j = start; j < count - 3; j += nr - 2 ) {
+ nr = MIN2( currentsz, count - j );
+ EMIT_VERTS( ctx, j, nr );
+ currentsz = dmasz;
+ }
+ }
+}
+
+
+static void TAG(render_quads_verts)( GLcontext *ctx,
+ GLuint start,
+ GLuint count,
+ GLuint flags )
+{
+ if (HAVE_QUADS && 0) {
+ } else if (emit_elt_verts( ctx, start, count )) {
+ /* Hardware doesn't have a quad primitive type -- try to
+ * simulate it using indexed vertices and the triangle
+ * primitive:
+ */
+ int dmasz = GET_SUBSEQUENT_VB_MAX_ELTS();
+ int currentsz;
+ GLuint j, nr;
+
+ NEW_PRIMITIVE();
+ ELT_INIT( GL_TRIANGLES );
+ currentsz = GET_CURRENT_VB_MAX_ELTS_NEW_PRIM();
+
+ /* Emit whole number of quads in total, and in each buffer.
+ */
+ dmasz -= dmasz & 3;
+ count -= (count-start) & 3;
+ currentsz -= currentsz & 3;
+
+ /* Adjust for rendering as triangles:
+ */
+ currentsz = currentsz/6*4;
+ dmasz = dmasz/6*4;
+
+ if (currentsz < 8)
+ currentsz = dmasz;
+
+ for (j = start; j < count; j += nr ) {
+ nr = MIN2( currentsz, count - j );
+ if (nr >= 4) {
+ GLint quads = nr/4;
+ GLint i;
+ ELTS_VARS;
+
+ NEW_PRIMITIVE();
+ ALLOC_ELTS_NEW_PRIMITIVE( quads*6 );
+
+ for ( i = 0 ; i < quads*4 ; i+=4 ) {
+ EMIT_TWO_ELTS( 0, (i+0), (i+1) );
+ EMIT_TWO_ELTS( 2, (i+3), (i+1) );
+ EMIT_TWO_ELTS( 4, (i+2), (i+3) );
+ INCR_ELTS( 6 );
+ }
+
+ NEW_PRIMITIVE();
+ }
+ currentsz = dmasz;
+ }
+
+ RELEASE_ELT_VERTS();
+ }
+ else {
+ /* Vertices won't fit in a single buffer, fallback.
+ */
+ FALLBACK( ctx, start, count, flags );
+ }
+}
+
+static void TAG(render_noop)( GLcontext *ctx,
+ GLuint start,
+ GLuint count,
+ GLuint flags )
+{
+}
+
+
+
+
+static void (*TAG(render_tab_verts))( GLcontext *, GLuint,
+ GLuint, GLuint)[GL_POLYGON+2] =
+{
+ TAG(render_points_verts),
+ TAG(render_lines_verts),
+ TAG(render_line_loop_verts),
+ TAG(render_line_strip_verts),
+ TAG(render_triangles_verts),
+ TAG(render_tri_strip_verts),
+ TAG(render_tri_fan_verts),
+ TAG(render_quads_verts),
+ TAG(render_quad_strip_verts),
+ TAG(render_poly_verts),
+ TAG(render_noop),
+};
+
+
+/****************************************************************************
+ * Render elts using hardware indexed verts *
+ ****************************************************************************/
+
+#if (HAVE_ELTS)
+static void TAG(render_points_elts)( GLcontext *ctx,
+ GLuint start,
+ GLuint count,
+ GLuint flags )
+{
+ if (HAVE_POINTS) {
+ int dmasz = GET_SUBSEQUENT_VB_MAX_ELTS();
+ int currentsz;
+ GLuint *elts = TNL_CONTEXT(ctx)->vb.Elts;
+ GLuint j, nr;
+
+ ELT_INIT( GL_POINTS );
+
+ currentsz = GET_CURRENT_VB_MAX_ELTS();
+ if (currentsz < 8)
+ currentsz = dmasz;
+
+ for (j = start; j < count; j += nr ) {
+ nr = MIN2( currentsz, count - j );
+ emit_elts( ctx, elts+j, nr );
+ NEW_PRIMITIVE();
+ currentsz = dmasz;
+ }
+ } else {
+ ELT_FALLBACK( ctx, start, count, flags );
+ }
+}
+
+
+
+static void TAG(render_lines_elts)( GLcontext *ctx,
+ GLuint start,
+ GLuint count,
+ GLuint flags )
+{
+ if (HAVE_LINES) {
+ int dmasz = GET_SUBSEQUENT_VB_MAX_ELTS();
+ int currentsz;
+ GLuint *elts = TNL_CONTEXT(ctx)->vb.Elts;
+ GLuint j, nr;
+
+ ELT_INIT( GL_LINES );
+
+ /* Emit whole number of lines in total and in each buffer:
+ */
+ count -= (count-start) & 1;
+ currentsz -= currentsz & 1;
+ dmasz -= dmasz & 1;
+
+ currentsz = GET_CURRENT_VB_MAX_ELTS();
+ if (currentsz < 8)
+ currentsz = dmasz;
+
+ for (j = start; j < count; j += nr ) {
+ nr = MIN2( currentsz, count - j );
+ emit_elts( ctx, elts+j, nr );
+ NEW_PRIMITIVE();
+ currentsz = dmasz;
+ }
+ } else {
+ ELT_FALLBACK( ctx, start, count, flags );
+ }
+}
+
+
+static void TAG(render_line_strip_elts)( GLcontext *ctx,
+ GLuint start,
+ GLuint count,
+ GLuint flags )
+{
+ if (HAVE_LINE_STRIPS) {
+ int dmasz = GET_SUBSEQUENT_VB_MAX_ELTS();
+ int currentsz;
+ GLuint *elts = TNL_CONTEXT(ctx)->vb.Elts;
+ GLuint j, nr;
+
+ NEW_PRIMITIVE(); /* always a new primitive */
+ ELT_INIT( GL_LINE_STRIP );
+
+ currentsz = GET_CURRENT_VB_MAX_ELTS_NEW_PRIM();
+ if (currentsz < 8)
+ currentsz = dmasz;
+
+ for (j = start; j < count - 1; j += nr - 1 ) {
+ nr = MIN2( currentsz, count - j );
+ emit_elts( ctx, elts+j, nr );
+ NEW_PRIMITIVE();
+ currentsz = dmasz;
+ }
+ } else {
+ /* TODO: Try to emit as indexed lines.
+ */
+ ELT_FALLBACK( ctx, start, count, flags );
+ }
+}
+
+
+static void TAG(render_line_loop_elts)( GLcontext *ctx,
+ GLuint start,
+ GLuint count,
+ GLuint flags )
+{
+ if (HAVE_LINE_STRIPS) {
+ int dmasz = GET_SUBSEQUENT_VB_MAX_ELTS();
+ int currentsz;
+ GLuint *elts = TNL_CONTEXT(ctx)->vb.Elts;
+ GLuint j, nr;
+
+ NEW_PRIMITIVE();
+ ELT_INIT( GL_LINE_STRIP );
+
+ if (flags & PRIM_BEGIN)
+ j = start;
+ else
+ j = start + 1;
+
+ currentsz = GET_CURRENT_VB_MAX_ELTS_NEW_PRIM();
+ if (currentsz < 8) {
+ FIRE_VERTICES( ctx );
+ currentsz = dmasz;
+ }
+
+ /* Ensure last vertex doesn't wrap:
+ */
+ currentsz--;
+ dmasz--;
+
+ for ( ; j < count - 1; j += nr - 1 ) {
+ nr = MIN2( currentsz, count - j );
+/* NEW_PRIMITIVE(); */
+ emit_elts( ctx, elts+j, nr );
+ currentsz = dmasz;
+ }
+
+ if (flags & PRIM_END)
+ emit_elts( ctx, elts+start, 1 );
+
+ NEW_PRIMITIVE();
+ } else {
+ /* TODO: Try to emit as indexed lines */
+ ELT_FALLBACK( ctx, start, count, flags );
+ }
+}
+
+
+/* For verts, we still eliminate the copy from main memory to dma
+ * buffers. For elts, this is probably no better (worse?) than the
+ * standard path.
+ */
+static void TAG(render_triangles_elts)( GLcontext *ctx,
+ GLuint start,
+ GLuint count,
+ GLuint flags )
+{
+ GLuint *elts = TNL_CONTEXT(ctx)->vb.Elts;
+ int dmasz = GET_SUBSEQUENT_VB_MAX_ELTS()/3*3;
+ int currentsz;
+ GLuint j, nr;
+
+ NEW_PRIMITIVE();
+ ELT_INIT( GL_TRIANGLES );
+
+ currentsz = GET_CURRENT_VB_MAX_ELTS_NEW_PRIM();
+
+ /* Emit whole number of tris in total. dmasz is already a multiple
+ * of 3.
+ */
+ count -= (count-start)%3;
+ currentsz -= currentsz%3;
+ if (currentsz < 8)
+ currentsz = dmasz;
+
+ for (j = start; j < count; j += nr) {
+ nr = MIN2( currentsz, count - j );
+ emit_elts( ctx, elts+j, nr );
+ NEW_PRIMITIVE();
+ currentsz = dmasz;
+ }
+}
+
+
+
+static void TAG(render_tri_strip_elts)( GLcontext *ctx,
+ GLuint start,
+ GLuint count,
+ GLuint flags )
+{
+ GLuint j, nr;
+ GLuint *elts = TNL_CONTEXT(ctx)->vb.Elts;
+ int dmasz = GET_SUBSEQUENT_VB_MAX_ELTS();
+ int currentsz;
+
+ NEW_PRIMITIVE();
+ ELT_INIT( GL_TRIANGLE_STRIP );
+
+ currentsz = GET_CURRENT_VB_MAX_ELTS_NEW_PRIM();
+ if (currentsz < 8) {
+ FIRE_VERTICES( ctx );
+ currentsz = dmasz;
+ }
+
+ if (flags & PRIM_PARITY) {
+ emit_elts( ctx, elts+start, 1 );
+ }
+
+ /* Keep the same winding over multiple buffers:
+ */
+ dmasz -= (dmasz & 1);
+ currentsz -= (currentsz & 1);
+
+ for (j = start ; j < count - 2; j += nr - 2 ) {
+ nr = MIN2( currentsz, count - j );
+ emit_elts( ctx, elts+j, nr );
+ NEW_PRIMITIVE();
+ currentsz = dmasz;
+ }
+}
+
+static void TAG(render_tri_fan_elts)( GLcontext *ctx,
+ GLuint start,
+ GLuint count,
+ GLuint flags )
+{
+ if (HAVE_TRI_FAN) {
+ GLuint *elts = TNL_CONTEXT(ctx)->vb.Elts;
+ GLuint j, nr;
+ int dmasz = GET_SUBSEQUENT_VB_MAX_ELTS();
+ int currentsz;
+
+ NEW_PRIMITIVE();
+ ELT_INIT( GL_TRIANGLE_FAN );
+
+ currentsz = GET_CURRENT_VB_MAX_ELTS_NEW_PRIM();
+ if (currentsz < 8) {
+ FIRE_VERTICES( ctx );
+ currentsz = dmasz;
+ }
+
+ for (j = start + 1 ; j < count - 1; j += nr - 1 ) {
+ nr = MIN2( currentsz, count - j + 1 );
+ emit_elts( ctx, elts+start, 1 );
+ emit_elts( ctx, elts+j, nr - 1 );
+ NEW_PRIMITIVE();
+ currentsz = dmasz;
+ }
+ } else {
+ /* TODO: try to emit as indexed triangles */
+ ELT_FALLBACK( ctx, start, count, flags );
+ }
+}
+
+
+static void TAG(render_poly_elts)( GLcontext *ctx,
+ GLuint start,
+ GLuint count,
+ GLuint flags )
+{
+ if (HAVE_POLYGON && 0) {
+ } else if (HAVE_TRI_FAN && !(ctx->_TriangleCaps & DD_FLATSHADE)) {
+ GLuint *elts = TNL_CONTEXT(ctx)->vb.Elts;
+ GLuint j, nr;
+ int dmasz = GET_SUBSEQUENT_VB_MAX_ELTS();
+ int currentsz;
+
+ NEW_PRIMITIVE();
+ ELT_INIT( GL_TRIANGLE_FAN );
+
+ currentsz = GET_CURRENT_VB_MAX_ELTS_NEW_PRIM();
+ if (currentsz < 8) {
+ FIRE_VERTICES( ctx );
+ currentsz = dmasz;
+ }
+
+ for (j = start + 1 ; j < count - 1 ; j += nr - 1 ) {
+ nr = MIN2( currentsz, count - j + 1 );
+ emit_elts( ctx, elts+start, 1 );
+ emit_elts( ctx, elts+j, nr - 1 );
+ NEW_PRIMITIVE();
+ currentsz = dmasz;
+ }
+ } else {
+ ELT_FALLBACK( ctx, start, count, flags );
+ }
+}
+
+static void TAG(render_quad_strip_elts)( GLcontext *ctx,
+ GLuint start,
+ GLuint count,
+ GLuint flags )
+{
+ if (HAVE_QUAD_STRIPS && 0) {
+ } else {
+ GLuint *elts = TNL_CONTEXT(ctx)->vb.Elts;
+ int dmasz = GET_SUBSEQUENT_VB_MAX_ELTS();
+ int currentsz;
+ GLuint j, nr;
+
+ NEW_PRIMITIVE();
+ currentsz = GET_CURRENT_VB_MAX_ELTS_NEW_PRIM();
+
+ /* Emit whole number of quads in total, and in each buffer.
+ */
+ dmasz -= dmasz & 1;
+ count -= (count-start) & 1;
+ currentsz -= currentsz & 1;
+
+ if (currentsz < 12)
+ currentsz = dmasz;
+
+ if (ctx->_TriangleCaps & DD_FLATSHADE) {
+ ELT_INIT( GL_TRIANGLES );
+
+ currentsz = currentsz/6*2;
+ dmasz = dmasz/6*2;
+
+ for (j = start; j < count - 3; j += nr - 2 ) {
+ nr = MIN2( currentsz, count - j );
+
+ if (nr >= 4)
+ {
+ GLint i;
+ GLint quads = (nr/2)-1;
+ ELTS_VARS;
+
+
+ NEW_PRIMITIVE();
+ ALLOC_ELTS_NEW_PRIMITIVE( quads*6 );
+
+ for ( i = 0 ; i < quads ; i++, elts += 2 ) {
+ EMIT_TWO_ELTS( 0, elts[0], elts[1] );
+ EMIT_TWO_ELTS( 2, elts[2], elts[1] );
+ EMIT_TWO_ELTS( 4, elts[3], elts[2] );
+ INCR_ELTS( 6 );
+ }
+
+ NEW_PRIMITIVE();
+ }
+
+ currentsz = dmasz;
+ }
+ }
+ else {
+ ELT_INIT( GL_TRIANGLE_STRIP );
+
+ for (j = start; j < count - 3; j += nr - 2 ) {
+ nr = MIN2( currentsz, count - j );
+ emit_elts( ctx, elts+j, nr );
+ NEW_PRIMITIVE();
+ currentsz = dmasz;
+ }
+ }
+ }
+}
+
+
+static void TAG(render_quads_elts)( GLcontext *ctx,
+ GLuint start,
+ GLuint count,
+ GLuint flags )
+{
+ if (HAVE_QUADS && 0) {
+ } else {
+ GLuint *elts = TNL_CONTEXT(ctx)->vb.Elts;
+ int dmasz = GET_SUBSEQUENT_VB_MAX_ELTS();
+ int currentsz;
+ GLuint j, nr;
+
+ ELT_INIT( GL_TRIANGLES );
+ currentsz = GET_CURRENT_VB_MAX_ELTS_NEW_PRIM();
+
+ /* Emit whole number of quads in total, and in each buffer.
+ */
+ dmasz -= dmasz & 3;
+ count -= (count-start) & 3;
+ currentsz -= currentsz & 3;
+
+ /* Adjust for rendering as triangles:
+ */
+ currentsz = currentsz/6*4;
+ dmasz = dmasz/6*4;
+
+ if (currentsz < 8)
+ currentsz = dmasz;
+
+ for (j = start; j < count - 3; j += nr - 2 ) {
+ nr = MIN2( currentsz, count - j );
+
+ if (nr >= 4)
+ {
+ GLint quads = nr/4;
+ GLint i;
+ ELTS_VARS;
+ NEW_PRIMITIVE();
+ ALLOC_ELTS_NEW_PRIMITIVE( quads * 6 );
+
+ for ( i = 0 ; i < quads ; i++, elts += 4 ) {
+ EMIT_TWO_ELTS( 0, elts[0], elts[1] );
+ EMIT_TWO_ELTS( 2, elts[3], elts[1] );
+ EMIT_TWO_ELTS( 4, elts[2], elts[3] );
+ INCR_ELTS( 6 );
+ }
+ }
+
+ NEW_PRIMITIVE();
+ currentsz = dmasz;
+ }
+ }
+}
+
+
+
+static void (*TAG(render_tab_verts))( GLcontext *, GLuint,
+ GLuint, GLuint)[GL_POLYGON+2] =
+{
+ TAG(render_points_elts),
+ TAG(render_lines_elts),
+ TAG(render_line_loop_elts),
+ TAG(render_line_strip_elts),
+ TAG(render_triangles_elts),
+ TAG(render_tri_strip_elts),
+ TAG(render_tri_fan_elts),
+ TAG(render_quads_elts),
+ TAG(render_quad_strip_elts),
+ TAG(render_poly_elts),
+ TAG(render_noop),
+};
+#endif
+
diff --git a/src/mesa/drivers/common/t_dd_rendertmp.h b/src/mesa/drivers/common/t_dd_rendertmp.h
new file mode 100644
index 00000000000..2524bf44b8d
--- /dev/null
+++ b/src/mesa/drivers/common/t_dd_rendertmp.h
@@ -0,0 +1,439 @@
+/* $Id: t_dd_rendertmp.h,v 1.1 2001/02/16 18:14:42 keithw Exp $ */
+
+/*
+ * Mesa 3-D graphics library
+ * Version: 3.5
+ *
+ * Copyright (C) 1999 Brian Paul All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ * Author:
+ * Keith Whitwell <[email protected]>
+ */
+
+
+#ifndef POSTFIX
+#define POSTFIX
+#endif
+
+#ifndef INIT
+#define INIT(x)
+#endif
+
+#ifndef NEED_EDGEFLAG_SETUP
+#define NEED_EDGEFLAG_SETUP 0
+#define EDGEFLAG_GET(a) 0
+#define EDGEFLAG_SET(a,b) (void)b
+#endif
+
+#ifndef RESET_STIPPLE
+#define RESET_STIPPLE
+#endif
+
+#ifndef RESET_OCCLUSION
+#define RESET_OCCLUSION
+#endif
+
+#ifndef TEST_PRIM_END
+#define TEST_PRIM_END(flags) (flags & PRIM_END)
+#define TEST_PRIM_BEGIN(flags) (flags & PRIM_BEGIN)
+#define TEST_PRIM_PARITY(flags) (flags & PRIM_PARITY)
+#endif
+
+#ifndef ELT
+#define ELT(x) x
+#endif
+
+#ifndef RENDER_TAB_QUALIFIER
+#define RENDER_TAB_QUALIFIER static
+#endif
+
+static void TAG(render_points)( GLcontext *ctx,
+ GLuint start,
+ GLuint count,
+ GLuint flags )
+{
+ LOCAL_VARS;
+ (void) flags;
+
+ RESET_OCCLUSION;
+ INIT(GL_POINTS);
+ RENDER_POINTS( start, count );
+ POSTFIX;
+}
+
+static void TAG(render_lines)( GLcontext *ctx,
+ GLuint start,
+ GLuint count,
+ GLuint flags )
+{
+ GLuint j;
+ LOCAL_VARS;
+ (void) flags;
+
+ RESET_OCCLUSION;
+ INIT(GL_LINES);
+ for (j=start+1; j<count; j+=2 ) {
+ RENDER_LINE( ELT(j-1), ELT(j) );
+ RESET_STIPPLE;
+ }
+ POSTFIX;
+}
+
+
+static void TAG(render_line_strip)( GLcontext *ctx,
+ GLuint start,
+ GLuint count,
+ GLuint flags )
+{
+ GLuint j;
+ LOCAL_VARS;
+ (void) flags;
+
+ RESET_OCCLUSION;
+ INIT(GL_LINE_STRIP);
+
+ for (j=start+1; j<count; j++ )
+ RENDER_LINE( ELT(j-1), ELT(j) );
+
+ if (TEST_PRIM_END(flags))
+ RESET_STIPPLE;
+
+ POSTFIX;
+}
+
+
+static void TAG(render_line_loop)( GLcontext *ctx,
+ GLuint start,
+ GLuint count,
+ GLuint flags )
+{
+ GLuint i;
+ LOCAL_VARS;
+
+ (void) flags;
+
+ RESET_OCCLUSION;
+ INIT(GL_LINE_LOOP);
+
+ if (start+1 < count) {
+ if (TEST_PRIM_BEGIN(flags)) {
+ RENDER_LINE( ELT(start), ELT(start+1) );
+ }
+
+ for ( i = start+2 ; i < count ; i++) {
+ RENDER_LINE( ELT(i-1), ELT(i) );
+ }
+
+ if ( TEST_PRIM_END(flags)) {
+ RENDER_LINE( ELT(count-1), ELT(start) );
+ RESET_STIPPLE;
+ }
+ }
+
+ POSTFIX;
+}
+
+
+static void TAG(render_triangles)( GLcontext *ctx,
+ GLuint start,
+ GLuint count,
+ GLuint flags )
+{
+ GLuint j;
+ LOCAL_VARS;
+ (void) flags;
+
+ INIT(GL_TRIANGLES);
+ if (NEED_EDGEFLAG_SETUP) {
+ for (j=start+2; j<count; j+=3) {
+ /* Leave the edgeflags as supplied by the user.
+ */
+ RENDER_TRI( ELT(j-2), ELT(j-1), ELT(j) );
+ RESET_STIPPLE;
+ }
+ } else {
+ for (j=start+2; j<count; j+=3) {
+ RENDER_TRI( ELT(j-2), ELT(j-1), ELT(j) );
+ }
+ }
+ POSTFIX;
+}
+
+
+
+static void TAG(render_tri_strip)( GLcontext *ctx,
+ GLuint start,
+ GLuint count,
+ GLuint flags )
+{
+ GLuint j;
+ GLuint parity = 0;
+ LOCAL_VARS;
+
+ if (TEST_PRIM_PARITY(flags))
+ parity = 1;
+
+ INIT(GL_TRIANGLE_STRIP);
+ if (NEED_EDGEFLAG_SETUP) {
+ for (j=start+2;j<count;j++,parity^=1) {
+ GLuint ej2 = ELT(j-2+parity);
+ GLuint ej1 = ELT(j-1-parity);
+ GLuint ej = ELT(j);
+ GLboolean ef2 = EDGEFLAG_GET( ej2 );
+ GLboolean ef1 = EDGEFLAG_GET( ej1 );
+ GLboolean ef = EDGEFLAG_GET( ej );
+ EDGEFLAG_SET( ej2, GL_TRUE );
+ EDGEFLAG_SET( ej1, GL_TRUE );
+ EDGEFLAG_SET( ej, GL_TRUE );
+ RENDER_TRI( ej2, ej1, ej );
+ EDGEFLAG_SET( ej2, ef2 );
+ EDGEFLAG_SET( ej1, ef1 );
+ EDGEFLAG_SET( ej, ef );
+ RESET_STIPPLE;
+ }
+ } else {
+ for (j=start+2; j<count ; j++, parity^=1) {
+ RENDER_TRI( ELT(j-2+parity), ELT(j-1-parity), ELT(j) );
+ }
+ }
+ POSTFIX;
+}
+
+
+static void TAG(render_tri_fan)( GLcontext *ctx,
+ GLuint start,
+ GLuint count,
+ GLuint flags )
+{
+ GLuint j;
+ LOCAL_VARS;
+ (void) flags;
+
+ INIT(GL_TRIANGLE_FAN);
+ if (NEED_EDGEFLAG_SETUP) {
+ for (j=start+2;j<count;j++) {
+ /* For trifans, all edges are boundary.
+ */
+ GLuint ejs = ELT(start);
+ GLuint ej1 = ELT(j-1);
+ GLuint ej = ELT(j);
+ GLboolean efs = EDGEFLAG_GET( ejs );
+ GLboolean ef1 = EDGEFLAG_GET( ej1 );
+ GLboolean ef = EDGEFLAG_GET( ej );
+ EDGEFLAG_SET( ejs, GL_TRUE );
+ EDGEFLAG_SET( ej1, GL_TRUE );
+ EDGEFLAG_SET( ej, GL_TRUE );
+ RENDER_TRI( ejs, ej1, ej);
+ EDGEFLAG_SET( ejs, efs );
+ EDGEFLAG_SET( ej1, ef1 );
+ EDGEFLAG_SET( ej, ef );
+ RESET_STIPPLE;
+ }
+ } else {
+ for (j=start+2;j<count;j++) {
+ RENDER_TRI( ELT(start), ELT(j-1), ELT(j) );
+ }
+ }
+
+ POSTFIX;
+}
+
+
+static void TAG(render_poly)( GLcontext *ctx,
+ GLuint start,
+ GLuint count,
+ GLuint flags )
+{
+ GLuint j = start+2;
+ LOCAL_VARS;
+ (void) flags;
+
+ INIT(GL_POLYGON);
+ if (NEED_EDGEFLAG_SETUP) {
+ GLboolean efstart = EDGEFLAG_GET( ELT(start) );
+ GLboolean efcount = EDGEFLAG_GET( ELT(count-1) );
+
+ /* If the primitive does not begin here, the first edge
+ * is non-boundary.
+ */
+ if (!TEST_PRIM_BEGIN(flags))
+ EDGEFLAG_SET( ELT(start), GL_FALSE );
+
+ /* If the primitive does not end here, the final edge is
+ * non-boundary.
+ */
+ if (!TEST_PRIM_END(flags))
+ EDGEFLAG_SET( ELT(count-1), GL_FALSE );
+
+ /* Draw the first triangles (possibly zero)
+ */
+ if (j<count-1) {
+ GLboolean ef = EDGEFLAG_GET( ELT(j) );
+ EDGEFLAG_SET( ELT(j), GL_FALSE );
+ RENDER_TRI( ELT(j-1), ELT(j), ELT(start) );
+ EDGEFLAG_SET( ELT(j), ef );
+ j++;
+
+ /* Don't render the first edge again:
+ */
+ EDGEFLAG_SET( ELT(start), GL_FALSE );
+
+ for (;j<count-1;j++) {
+ GLboolean efj = EDGEFLAG_GET( ELT(j) );
+ EDGEFLAG_SET( ELT(j), GL_FALSE );
+ RENDER_TRI( ELT(j-1), ELT(j), ELT(start) );
+ EDGEFLAG_SET( ELT(j), efj );
+ }
+ }
+
+ /* Draw the last or only triangle
+ */
+ if (j < count)
+ RENDER_TRI( ELT(j-1), ELT(j), ELT(start) );
+
+ /* Restore the first and last edgeflags:
+ */
+ EDGEFLAG_SET( ELT(count-1), efcount );
+ EDGEFLAG_SET( ELT(start), efstart );
+
+ if (TEST_PRIM_END(flags)) {
+ RESET_STIPPLE;
+ }
+ }
+ else {
+ for (j=start+2;j<count;j++) {
+ RENDER_TRI( ELT(j-1), ELT(j), ELT(start) );
+ }
+ }
+ POSTFIX;
+}
+
+static void TAG(render_quads)( GLcontext *ctx,
+ GLuint start,
+ GLuint count,
+ GLuint flags )
+{
+ GLuint j;
+ LOCAL_VARS;
+ (void) flags;
+
+ INIT(GL_QUADS);
+ if (NEED_EDGEFLAG_SETUP) {
+ for (j=start+3; j<count; j+=4) {
+ /* Use user-specified edgeflags for quads.
+ */
+ RENDER_QUAD( ELT(j-3), ELT(j-2), ELT(j-1), ELT(j) );
+ RESET_STIPPLE;
+ }
+ } else {
+ for (j=start+3; j<count; j+=4) {
+ RENDER_QUAD( ELT(j-3), ELT(j-2), ELT(j-1), ELT(j) );
+ }
+ }
+ POSTFIX;
+}
+
+static void TAG(render_quad_strip)( GLcontext *ctx,
+ GLuint start,
+ GLuint count,
+ GLuint flags )
+{
+ GLuint j;
+ LOCAL_VARS;
+ (void) flags;
+
+ INIT(GL_QUAD_STRIP);
+ if (NEED_EDGEFLAG_SETUP) {
+ for (j=start+3;j<count;j+=2) {
+ /* All edges are boundary. Set edgeflags to 1, draw the
+ * quad, and restore them to the original values.
+ */
+ GLboolean ef3 = EDGEFLAG_GET( ELT(j-3) );
+ GLboolean ef2 = EDGEFLAG_GET( ELT(j-2) );
+ GLboolean ef1 = EDGEFLAG_GET( ELT(j-1) );
+ GLboolean ef = EDGEFLAG_GET( ELT(j) );
+ EDGEFLAG_SET( ELT(j-3), GL_TRUE );
+ EDGEFLAG_SET( ELT(j-2), GL_TRUE );
+ EDGEFLAG_SET( ELT(j-1), GL_TRUE );
+ EDGEFLAG_SET( ELT(j), GL_TRUE );
+ RENDER_QUAD( ELT(j-1), ELT(j-3), ELT(j-2), ELT(j) );
+ EDGEFLAG_SET( ELT(j-3), ef3 );
+ EDGEFLAG_SET( ELT(j-2), ef2 );
+ EDGEFLAG_SET( ELT(j-1), ef1 );
+ EDGEFLAG_SET( ELT(j), ef );
+ RESET_STIPPLE;
+ }
+ } else {
+ for (j=start+3;j<count;j+=2) {
+ RENDER_QUAD( ELT(j-1), ELT(j-3), ELT(j-2), ELT(j) );
+ }
+ }
+ POSTFIX;
+}
+
+static void TAG(render_noop)( GLcontext *ctx,
+ GLuint start,
+ GLuint count,
+ GLuint flags )
+{
+ (void)(ctx && start && count && flags);
+}
+
+RENDER_TAB_QUALIFIER void (*TAG(render_tab)[GL_POLYGON+2])(GLcontext *,
+ GLuint,
+ GLuint,
+ GLuint) =
+{
+ TAG(render_points),
+ TAG(render_lines),
+ TAG(render_line_loop),
+ TAG(render_line_strip),
+ TAG(render_triangles),
+ TAG(render_tri_strip),
+ TAG(render_tri_fan),
+ TAG(render_quads),
+ TAG(render_quad_strip),
+ TAG(render_poly),
+ TAG(render_noop),
+};
+
+
+
+#ifndef PRESERVE_VB_DEFS
+#undef RENDER_TRI
+#undef RENDER_QUAD
+#undef RENDER_LINE
+#undef RENDER_POINTS
+#undef LOCAL_VARS
+#undef INIT
+#undef POSTFIX
+#undef RESET_STIPPLE
+#undef DBG
+#undef ELT
+#undef RENDER_TAB_QUALIFIER
+#endif
+
+#ifndef PRESERVE_TAG
+#undef TAG
+#endif
+
+#undef PRESERVE_VB_DEFS
+#undef PRESERVE_TAG
+
diff --git a/src/mesa/drivers/common/t_dd_tritmp.h b/src/mesa/drivers/common/t_dd_tritmp.h
new file mode 100644
index 00000000000..7690d09ecf9
--- /dev/null
+++ b/src/mesa/drivers/common/t_dd_tritmp.h
@@ -0,0 +1,569 @@
+
+/*
+ * Mesa 3-D graphics library
+ * Version: 3.5
+ *
+ * Copyright (C) 1999 Brian Paul All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ * Author:
+ * Keith Whitwell <[email protected]>
+ */
+
+
+/* Template for building functions to plug into the driver interface
+ * of t_vb_render.c:
+ * ctx->Driver.QuadFunc
+ * ctx->Driver.TriangleFunc
+ * ctx->Driver.LineFunc
+ * ctx->Driver.PointsFunc
+ *
+ * DO_TWOSIDE: Plug back-color values from the VB into backfacing triangles,
+ * and restore vertices afterwards.
+ * DO_OFFSET: Calculate offset for triangles and adjust vertices. Restore
+ * vertices after rendering.
+ * DO_FLAT: For hardware without native flatshading, copy provoking colors
+ * into the other vertices. Restore after rendering.
+ * DO_UNFILLED: Decompose triangles to lines and points where appropriate.
+ *
+ * HAVE_RGBA: Vertices have rgba values (otherwise index values).
+ */
+
+
+
+static void TAG(triangle)( GLcontext *ctx, GLuint e0, GLuint e1, GLuint e2 )
+{
+ struct vertex_buffer *VB = &TNL_CONTEXT( ctx )->vb;
+ VERTEX *v[3];
+ GLfloat offset;
+ GLfloat z[3];
+ GLenum mode = GL_FILL;
+ GLuint facing;
+ LOCAL_VARS(3);
+
+ v[0] = GET_VERTEX(e0);
+ v[1] = GET_VERTEX(e1);
+ v[2] = GET_VERTEX(e2);
+
+ if (DO_TWOSIDE || DO_OFFSET || DO_UNFILLED)
+ {
+ GLfloat ex = VERT_X(v[0]) - VERT_X(v[2]);
+ GLfloat ey = VERT_Y(v[0]) - VERT_Y(v[2]);
+ GLfloat fx = VERT_X(v[1]) - VERT_X(v[2]);
+ GLfloat fy = VERT_Y(v[1]) - VERT_Y(v[2]);
+ GLfloat cc = ex*fy - ey*fx;
+
+ if (DO_TWOSIDE || DO_UNFILLED)
+ {
+ facing = AREA_IS_CCW( cc ) ^ ctx->Polygon._FrontBit;
+
+ if (DO_UNFILLED) {
+ if (facing) {
+ mode = ctx->Polygon.BackMode;
+ if (ctx->Polygon.CullFlag &&
+ ctx->Polygon.CullFaceMode != GL_FRONT) {
+ return;
+ }
+ } else {
+ mode = ctx->Polygon.FrontMode;
+ if (ctx->Polygon.CullFlag &&
+ ctx->Polygon.CullFaceMode != GL_BACK) {
+ return;
+ }
+ }
+ }
+
+ if (DO_TWOSIDE && facing == 1)
+ {
+ if (HAVE_RGBA) {
+ GLubyte (*vbcolor)[4] = VB->ColorPtr[1]->data;
+ ASSERT(VB->ColorPtr[1]->stride == 4*sizeof(GLubyte));
+
+ if (!DO_FLAT) {
+ VERT_SET_COLOR( v[0], vbcolor[e0] );
+ VERT_SET_COLOR( v[1], vbcolor[e1] );
+ }
+ VERT_SET_COLOR( v[2], vbcolor[e2] );
+
+ if (VB->SecondaryColorPtr[1]) {
+ GLubyte (*vbspec)[4] = VB->SecondaryColorPtr[1]->data;
+ ASSERT(VB->SecondaryColorPtr[1]->stride == 4*sizeof(GLubyte));
+
+ if (!DO_FLAT) {
+ VERT_SET_SPEC( v[0], vbspec[e0] );
+ VERT_SET_SPEC( v[1], vbspec[e1] );
+ }
+ VERT_SET_SPEC( v[2], vbspec[e2] );
+ }
+ }
+ else {
+ GLuint *vbindex = VB->IndexPtr[1]->data;
+ if (!DO_FLAT) {
+ VERT_SET_IND( v[0], vbindex[e0] );
+ VERT_SET_IND( v[1], vbindex[e1] );
+ }
+ VERT_SET_IND( v[2], vbindex[e2] );
+ }
+ }
+ }
+
+
+ if (DO_OFFSET)
+ {
+ offset = ctx->Polygon.OffsetUnits * DEPTH_SCALE;
+ z[0] = VERT_Z(v[0]);
+ z[1] = VERT_Z(v[1]);
+ z[2] = VERT_Z(v[2]);
+ if (cc * cc > 1e-16) {
+ GLfloat ic = 1.0 / cc;
+ GLfloat ez = z[0] - z[2];
+ GLfloat fz = z[1] - z[2];
+ GLfloat a = ey*fz - ez*fy;
+ GLfloat b = ez*fx - ex*fz;
+ GLfloat ac = a * ic;
+ GLfloat bc = b * ic;
+ if ( ac < 0.0f ) ac = -ac;
+ if ( bc < 0.0f ) bc = -bc;
+ offset += MAX2( ac, bc ) * ctx->Polygon.OffsetFactor;
+ }
+ offset *= ctx->MRD;
+ }
+ }
+
+ if (DO_FLAT) {
+ if (HAVE_RGBA) {
+ VERT_SAVE_VERT_RGBA( 0 );
+ VERT_SAVE_VERT_RGBA( 1 );
+ VERT_COPY_VERT_RGBA( v[0], v[2] );
+ VERT_COPY_VERT_RGBA( v[1], v[2] );
+ if (VB->SecondaryColorPtr[0]) {
+ VERT_SAVE_VERT_SPEC( 0 );
+ VERT_SAVE_VERT_SPEC( 1 );
+ VERT_COPY_VERT_SPEC( v[0], v[2] );
+ VERT_COPY_VERT_SPEC( v[1], v[2] );
+ }
+ }
+ else {
+ VERT_SAVE_VERT_IND( 0 );
+ VERT_SAVE_VERT_IND( 1 );
+ VERT_COPY_VERT_IND( v[0], v[2] );
+ VERT_COPY_VERT_IND( v[1], v[2] );
+ }
+ }
+
+ if (mode == GL_POINT) {
+ if (DO_OFFSET && ctx->Polygon.OffsetPoint) {
+ VERT_Z(v[0]) += offset;
+ VERT_Z(v[1]) += offset;
+ VERT_Z(v[2]) += offset;
+ }
+ UNFILLED_POINT_TRI( ctx, e0, e1, e2 );
+ } else if (mode == GL_LINE) {
+ if (DO_OFFSET && ctx->Polygon.OffsetLine) {
+ VERT_Z(v[0]) += offset;
+ VERT_Z(v[1]) += offset;
+ VERT_Z(v[2]) += offset;
+ }
+ UNFILLED_LINE_TRI( ctx, e0, e1, e2 );
+ } else {
+ if (DO_OFFSET && ctx->Polygon.OffsetFill) {
+ VERT_Z(v[0]) += offset;
+ VERT_Z(v[1]) += offset;
+ VERT_Z(v[2]) += offset;
+ }
+ if (DO_UNFILLED)
+ SET_REDUCED_PRIM( GL_TRIANGLES, GL_TRIANGLES );
+ TRI( ctx, v[0], v[1], v[2] );
+ }
+
+ if (DO_OFFSET)
+ {
+ VERT_Z(v[0]) = z[0];
+ VERT_Z(v[1]) = z[1];
+ VERT_Z(v[2]) = z[2];
+ }
+
+ /* ==> Need to import Color, SecondaryColor, Index to meet assertions
+ * in DO_FLAT case.
+ *
+ * ==> Copy/Restore vertex data instead?
+ */
+ if (DO_TWOSIDE && facing == 1)
+ {
+ if (HAVE_RGBA) {
+ GLubyte (*vbcolor)[4] = VB->ColorPtr[0]->data;
+ ASSERT(VB->ColorPtr[0]->stride == 4*sizeof(GLubyte));
+
+ if (!DO_FLAT) {
+ VERT_SET_COLOR( v[0], vbcolor[e0] );
+ VERT_SET_COLOR( v[1], vbcolor[e1] );
+ }
+ VERT_SET_COLOR( v[2], vbcolor[e2] );
+
+ if (VB->SecondaryColorPtr[0]) {
+ GLubyte (*vbspec)[4] = VB->SecondaryColorPtr[0]->data;
+ ASSERT(VB->SecondaryColorPtr[0]->stride == 4*sizeof(GLubyte));
+
+ if (!DO_FLAT) {
+ VERT_SET_SPEC( v[0], vbspec[e0] );
+ VERT_SET_SPEC( v[1], vbspec[e1] );
+ }
+ VERT_SET_SPEC( v[2], vbspec[e2] );
+ }
+ }
+ else {
+ GLuint *vbindex = VB->IndexPtr[0]->data;
+ if (!DO_FLAT) {
+ VERT_SET_IND( v[0], vbindex[e0] );
+ VERT_SET_IND( v[1], vbindex[e1] );
+ }
+ VERT_SET_IND( v[2], vbindex[e2] );
+ }
+ }
+
+
+ if (DO_FLAT) {
+ if (HAVE_RGBA) {
+ VERT_RESTORE_VERT_RGBA( 0 );
+ VERT_RESTORE_VERT_RGBA( 1 );
+ if (VB->SecondaryColorPtr[0]) {
+ VERT_RESTORE_VERT_SPEC( 0 );
+ VERT_RESTORE_VERT_SPEC( 1 );
+ }
+ }
+ else {
+ VERT_RESTORE_VERT_IND( 0 );
+ VERT_RESTORE_VERT_IND( 1 );
+ }
+ }
+
+
+}
+
+#if (DO_FULL_QUAD)
+static void TAG(quad)( GLcontext *ctx,
+ GLuint e0, GLuint e1, GLuint e2, GLuint e3 )
+{
+ struct vertex_buffer *VB = &TNL_CONTEXT( ctx )->vb;
+ VERTEX *v[4];
+ GLfloat offset;
+ GLfloat z[4];
+ GLenum mode = GL_FILL;
+ GLuint facing;
+ LOCAL_VARS(4);
+
+ v[0] = GET_VERTEX(e0);
+ v[1] = GET_VERTEX(e1);
+ v[2] = GET_VERTEX(e2);
+ v[3] = GET_VERTEX(e3);
+
+ if (DO_TWOSIDE || DO_OFFSET || DO_UNFILLED)
+ {
+ GLfloat ex = VERT_X(v[2]) - VERT_X(v[0]);
+ GLfloat ey = VERT_Y(v[2]) - VERT_Y(v[0]);
+ GLfloat fx = VERT_X(v[3]) - VERT_X(v[1]);
+ GLfloat fy = VERT_Y(v[3]) - VERT_Y(v[1]);
+ GLfloat cc = ex*fy - ey*fx;
+
+ if (DO_TWOSIDE || DO_UNFILLED)
+ {
+ facing = AREA_IS_CCW( cc ) ^ ctx->Polygon._FrontBit;
+
+ if (DO_UNFILLED) {
+ if (facing) {
+ mode = ctx->Polygon.BackMode;
+ if (ctx->Polygon.CullFlag &&
+ ctx->Polygon.CullFaceMode != GL_FRONT) {
+ return;
+ }
+ } else {
+ mode = ctx->Polygon.FrontMode;
+ if (ctx->Polygon.CullFlag &&
+ ctx->Polygon.CullFaceMode != GL_BACK) {
+ return;
+ }
+ }
+ }
+
+ if (DO_TWOSIDE && facing == 1)
+ {
+ if (HAVE_RGBA) {
+ GLubyte (*vbcolor)[4] = VB->ColorPtr[1]->data;
+
+ if (!DO_FLAT) {
+ VERT_SET_COLOR( v[0], vbcolor[e0] );
+ VERT_SET_COLOR( v[1], vbcolor[e1] );
+ VERT_SET_COLOR( v[2], vbcolor[e2] );
+ }
+ VERT_SET_COLOR( v[3], vbcolor[e3] );
+
+ if (VB->SecondaryColorPtr[facing]) {
+ GLubyte (*vbspec)[4] = VB->SecondaryColorPtr[1]->data;
+ ASSERT(VB->SecondaryColorPtr[1]->stride == 4*sizeof(GLubyte));
+
+ if (!DO_FLAT) {
+ VERT_SET_SPEC( v[0], vbspec[e0] );
+ VERT_SET_SPEC( v[1], vbspec[e1] );
+ VERT_SET_SPEC( v[2], vbspec[e2] );
+ }
+ VERT_SET_SPEC( v[3], vbspec[e3] );
+ }
+ }
+ else {
+ GLuint *vbindex = VB->IndexPtr[1]->data;
+ if (!DO_FLAT) {
+ VERT_SET_IND( v[0], vbindex[e0] );
+ VERT_SET_IND( v[1], vbindex[e1] );
+ VERT_SET_IND( v[2], vbindex[e2] );
+ }
+ VERT_SET_IND( v[3], vbindex[e3] );
+ }
+ }
+ }
+
+
+ if (DO_OFFSET)
+ {
+ offset = ctx->Polygon.OffsetUnits * DEPTH_SCALE;
+ z[0] = VERT_Z(v[0]);
+ z[1] = VERT_Z(v[1]);
+ z[2] = VERT_Z(v[2]);
+ z[3] = VERT_Z(v[3]);
+ if (cc * cc > 1e-16) {
+ GLfloat ez = z[2] - z[0];
+ GLfloat fz = z[3] - z[1];
+ GLfloat a = ey*fz - ez*fy;
+ GLfloat b = ez*fx - ex*fz;
+ GLfloat ic = 1.0 / cc;
+ GLfloat ac = a * ic;
+ GLfloat bc = b * ic;
+ if ( ac < 0.0f ) ac = -ac;
+ if ( bc < 0.0f ) bc = -bc;
+ offset += MAX2( ac, bc ) * ctx->Polygon.OffsetFactor;
+ }
+ offset *= ctx->MRD;
+ }
+ }
+
+ if (DO_FLAT) {
+ if (HAVE_RGBA) {
+ VERT_SAVE_VERT_RGBA( 0 );
+ VERT_SAVE_VERT_RGBA( 1 );
+ VERT_SAVE_VERT_RGBA( 2 );
+ VERT_COPY_VERT_RGBA( v[0], v[3] );
+ VERT_COPY_VERT_RGBA( v[1], v[3] );
+ VERT_COPY_VERT_RGBA( v[2], v[3] );
+ if (VB->SecondaryColorPtr[0]) {
+ VERT_SAVE_VERT_SPEC( 0 );
+ VERT_SAVE_VERT_SPEC( 1 );
+ VERT_SAVE_VERT_SPEC( 2 );
+ VERT_COPY_VERT_SPEC( v[0], v[3] );
+ VERT_COPY_VERT_SPEC( v[1], v[3] );
+ VERT_COPY_VERT_SPEC( v[2], v[3] );
+ }
+ }
+ else {
+ VERT_SAVE_VERT_IND( 0 );
+ VERT_SAVE_VERT_IND( 1 );
+ VERT_SAVE_VERT_IND( 2 );
+ VERT_COPY_VERT_IND( v[0], v[3] );
+ VERT_COPY_VERT_IND( v[1], v[3] );
+ VERT_COPY_VERT_IND( v[2], v[3] );
+ }
+ }
+
+ if (mode == GL_POINT) {
+ if (( DO_OFFSET) && ctx->Polygon.OffsetPoint) {
+ VERT_Z(v[0]) += offset;
+ VERT_Z(v[1]) += offset;
+ VERT_Z(v[2]) += offset;
+ VERT_Z(v[3]) += offset;
+ }
+ UNFILLED_POINT_QUAD( ctx, e0, e1, e2, e3 );
+ } else if (mode == GL_LINE) {
+ if (DO_OFFSET && ctx->Polygon.OffsetLine) {
+ VERT_Z(v[0]) += offset;
+ VERT_Z(v[1]) += offset;
+ VERT_Z(v[2]) += offset;
+ VERT_Z(v[3]) += offset;
+ }
+ UNFILLED_LINE_QUAD( ctx, e0, e1, e2, e3 );
+ } else {
+ if (DO_OFFSET && ctx->Polygon.OffsetFill) {
+ VERT_Z(v[0]) += offset;
+ VERT_Z(v[1]) += offset;
+ VERT_Z(v[2]) += offset;
+ VERT_Z(v[3]) += offset;
+ }
+ if (DO_UNFILLED)
+ SET_REDUCED_PRIM( GL_QUADS, GL_TRIANGLES );
+ QUAD( (v[0]), (v[1]), (v[2]), (v[3]) );
+ }
+
+ if (DO_OFFSET)
+ {
+ VERT_Z(v[0]) = z[0];
+ VERT_Z(v[1]) = z[1];
+ VERT_Z(v[2]) = z[2];
+ VERT_Z(v[3]) = z[3];
+ }
+
+ if (DO_TWOSIDE && facing == 1)
+ {
+ if (HAVE_RGBA) {
+ GLubyte (*vbcolor)[4] = VB->ColorPtr[0]->data;
+ ASSERT(VB->ColorPtr[0]->stride == 4*sizeof(GLubyte));
+
+ if (!DO_FLAT) {
+ VERT_SET_COLOR( v[0], vbcolor[e0] );
+ VERT_SET_COLOR( v[1], vbcolor[e1] );
+ VERT_SET_COLOR( v[2], vbcolor[e2] );
+ }
+ VERT_SET_COLOR( v[3], vbcolor[e3] );
+
+ if (VB->SecondaryColorPtr[0]) {
+ GLubyte (*vbspec)[4] = VB->SecondaryColorPtr[0]->data;
+ ASSERT(VB->SecondaryColorPtr[0]->stride == 4*sizeof(GLubyte));
+
+ if (!DO_FLAT) {
+ VERT_SET_SPEC( v[0], vbspec[e0] );
+ VERT_SET_SPEC( v[1], vbspec[e1] );
+ VERT_SET_SPEC( v[2], vbspec[e2] );
+ }
+ VERT_SET_SPEC( v[3], vbspec[e3] );
+ }
+ }
+ else {
+ GLuint *vbindex = VB->IndexPtr[0]->data;
+ if (!DO_FLAT) {
+ VERT_SET_IND( v[0], vbindex[e0] );
+ VERT_SET_IND( v[1], vbindex[e1] );
+ VERT_SET_IND( v[2], vbindex[e2] );
+ }
+ VERT_SET_IND( v[3], vbindex[e3] );
+ }
+ }
+
+
+ if (DO_FLAT) {
+ if (HAVE_RGBA) {
+ VERT_RESTORE_VERT_RGBA( 0 );
+ VERT_RESTORE_VERT_RGBA( 1 );
+ VERT_RESTORE_VERT_RGBA( 2 );
+ if (VB->SecondaryColorPtr[0]) {
+ VERT_RESTORE_VERT_SPEC( 0 );
+ VERT_RESTORE_VERT_SPEC( 1 );
+ VERT_RESTORE_VERT_SPEC( 2 );
+ }
+ }
+ else {
+ VERT_RESTORE_VERT_IND( 0 );
+ VERT_RESTORE_VERT_IND( 1 );
+ VERT_RESTORE_VERT_IND( 2 );
+ }
+ }
+}
+#else
+static void TAG(quad)( GLcontext *ctx, GLuint e0,
+ GLuint e1, GLuint e2, GLuint e3 )
+{
+ if (IND & SS_UNFILLED_BIT) {
+ struct vertex_buffer *VB = &TNL_CONTEXT(ctx)->vb;
+ GLubyte ef1 = VB->EdgeFlag[e1];
+ GLubyte ef3 = VB->EdgeFlag[e3];
+ VB->EdgeFlag[e1] = 0;
+ TAG(triangle)( ctx, e0, e1, e3 );
+ VB->EdgeFlag[e1] = ef1;
+ VB->EdgeFlag[e3] = 0;
+ TAG(triangle)( ctx, e1, e2, e3 );
+ VB->EdgeFlag[e3] = ef3;
+ } else {
+ TAG(triangle)( ctx, e0, e1, e3 );
+ TAG(triangle)( ctx, e1, e2, e3 );
+ }
+}
+#endif
+
+
+static void TAG(line)( GLcontext *ctx, GLuint e0, GLuint e1 )
+{
+ VERTEX *v[2];
+ LOCAL_VARS(2);
+
+ v[0] = GET_VERTEX(e0);
+ v[1] = GET_VERTEX(e1);
+
+ if (DO_FLAT) {
+ if (HAVE_RGBA) {
+ VERT_SAVE_VERT_RGBA( 0 );
+ VERT_COPY_VERT_RGBA( v[0], v[1] );
+ if (VB->SecondaryColorPtr[0]) {
+ VERT_SAVE_VERT_SPEC( 0 );
+ VERT_COPY_VERT_SPEC( v[0], v[1] );
+ }
+ }
+ else {
+ VERT_SAVE_VERT_IND( 0 );
+ VERT_COPY_VERT_IND( v[0], v[1] );
+ }
+ }
+
+ LINE( v[0], v[1] );
+
+ if (DO_FLAT) {
+ if (HAVE_RGBA) {
+ VERT_RESTORE_VERT_RGBA( 0 );
+
+ if (VB->SecondaryColorPtr[0]) {
+ VERT_RESTORE_VERT_SPEC( 0 );
+ }
+ }
+ else {
+ VERT_RESTORE_VERT_IND( 0 );
+ }
+ }
+}
+
+
+static void TAG(points)( GLcontext *ctx, GLuint first, GLuint last )
+{
+ struct vertex_buffer *VB = &TNL_CONTEXT( ctx )->vb;
+ int i;
+ LOCAL_VARS(1);
+
+ if (VB->Elts == 0) {
+ for ( i = first ; i < last ; i++ ) {
+ if ( VB->ClipMask[i] == 0 ) {
+ VERTEX *v = GET_VERTEX(i);
+ POINT( v );
+ }
+ }
+ } else {
+ for ( i = first ; i < last ; i++ ) {
+ GLuint e = VB->Elts[i];
+ if ( VB->ClipMask[e] == 0 ) {
+ VERTEX *v = GET_VERTEX(e);
+ POINT( v );
+ }
+ }
+ }
+}
+
+#undef IND
+#undef TAG
diff --git a/src/mesa/drivers/common/t_dd_unfilled.h b/src/mesa/drivers/common/t_dd_unfilled.h
new file mode 100644
index 00000000000..c1f3a92b00f
--- /dev/null
+++ b/src/mesa/drivers/common/t_dd_unfilled.h
@@ -0,0 +1,135 @@
+
+static void tdfx_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);
+ }
+ }
+
+ 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 );
+ }
+ 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 );
+ }
+ 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 (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]);
+ }
+ }
+}
+
+
+static void tdfx_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);
+ }
+ }
+
+ 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 );
+ }
+ 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 );
+ }
+
+ 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]);
+ }
+ }
+}
diff --git a/src/mesa/drivers/common/t_dd_vb.c b/src/mesa/drivers/common/t_dd_vb.c
new file mode 100644
index 00000000000..9c23900c55d
--- /dev/null
+++ b/src/mesa/drivers/common/t_dd_vb.c
@@ -0,0 +1,99 @@
+/* Build an SWvertex from an tdfxVertex. This is workable because in
+ * states where the GrVertex is insufficent (eg seperate-specular),
+ * the driver initiates a total fallback, and builds SWvertices
+ * directly -- it recognizes that it will never have use for the
+ * tdfxVertex.
+ *
+ * This code is hit only when a mix of accelerated and unaccelerated
+ * primitives are being drawn, and only for the unaccelerated
+ * primitives.
+ */
+static void
+tdfx_translate_vertex(GLcontext *ctx, const tdfxVertex *src, SWvertex *dst)
+{
+ tdfxContextPtr imesa = TDFX_CONTEXT( ctx );
+
+ if (imesa->vertsize == 4) {
+ dst->win[0] = src->tv.x + .5;
+ dst->win[1] = - src->tv.y + imesa->driDrawable->h - .5;
+ dst->win[2] = src->tv.z * (GLfloat)0x10000;
+ dst->win[3] = 1.0;
+
+ dst->color[0] = src->tv.color.red;
+ dst->color[1] = src->tv.color.green;
+ dst->color[2] = src->tv.color.blue;
+ dst->color[3] = src->tv.color.alpha;
+ }
+ else {
+ dst->win[0] = src->v.x + .5;
+ dst->win[1] = - src->v.y + imesa->driDrawable->h - .5;
+ dst->win[2] = src->v.z * (GLfloat)0x10000;
+ dst->win[3] = src->v.oow;
+
+ dst->color[0] = src->v.color.red;
+ dst->color[1] = src->v.color.green;
+ dst->color[2] = src->v.color.blue;
+ dst->color[3] = src->v.color.alpha;
+
+ if (fxMesa->xxx) {
+ dst->texcoord[0][0] = src->v.tu0;
+ dst->texcoord[0][1] = src->v.tv0;
+ dst->texcoord[0][3] = 1.0;
+
+ dst->texcoord[1][0] = src->v.tu1;
+ dst->texcoord[1][1] = src->v.tv1;
+ dst->texcoord[1][3] = 1.0;
+ }
+ else {
+ dst->texcoord[0][0] = src->pv.u0;
+ dst->texcoord[0][1] = src->pv.v0;
+ dst->texcoord[0][3] = src->pv.q0;
+
+ dst->texcoord[1][0] = src->pv.u1;
+ dst->texcoord[1][1] = src->pv.v1;
+ dst->texcoord[1][3] = src->pv.q1;
+ }
+ }
+
+ dst->pointSize = ctx->Point._Size;
+}
+
+
+static void
+tdfx_fallback_tri( tdfxContextPtr imesa,
+ tdfxVertex *v0,
+ tdfxVertex *v1,
+ tdfxVertex *v2 )
+{
+ GLcontext *ctx = imesa->glCtx;
+ SWvertex v[3];
+ tdfx_translate_vertex( ctx, v0, &v[0] );
+ tdfx_translate_vertex( ctx, v1, &v[1] );
+ tdfx_translate_vertex( ctx, v2, &v[2] );
+ _swrast_Triangle( ctx, &v[0], &v[1], &v[2] );
+}
+
+
+static void
+tdfx_fallback_line( tdfxContextPtr imesa,
+ tdfxVertex *v0,
+ tdfxVertex *v1 )
+{
+ GLcontext *ctx = imesa->glCtx;
+ SWvertex v[2];
+ tdfx_translate_vertex( ctx, v0, &v[0] );
+ tdfx_translate_vertex( ctx, v1, &v[1] );
+ _swrast_Line( ctx, &v[0], &v[1] );
+}
+
+
+static void
+tdfx_fallback_point( tdfxContextPtr imesa,
+ tdfxVertex *v0 )
+{
+ GLcontext *ctx = imesa->glCtx;
+ SWvertex v[1];
+ tdfx_translate_vertex( ctx, v0, &v[0] );
+ _swrast_Point( ctx, &v[0] );
+}
+
diff --git a/src/mesa/drivers/common/t_dd_vbtmp.h b/src/mesa/drivers/common/t_dd_vbtmp.h
new file mode 100644
index 00000000000..979a2d39677
--- /dev/null
+++ b/src/mesa/drivers/common/t_dd_vbtmp.h
@@ -0,0 +1,529 @@
+/*
+ * Mesa 3-D graphics library
+ * Version: 3.5
+ *
+ * Copyright (C) 1999 Brian Paul All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ * Author:
+ * Keith Whitwell <[email protected]>
+ */
+
+
+/* Unlike the other templates here, this assumes quite a bit about the
+ * underlying hardware. Specifically it assumes a d3d-like vertex
+ * format, with a layout more or less constrained to look like the
+ * following:
+ *
+ * union {
+ * struct {
+ * float x, y, z, w;
+ * struct { char r, g, b, a; } color;
+ * struct { char r, g, b, fog; } spec;
+ * float u0, v0;
+ * float u1, v1;
+ * } v;
+ * struct {
+ * float x, y, z, w;
+ * struct { char r, g, b, a; } color;
+ * struct { char r, g, b, fog; } spec;
+ * float u0, v0, q0;
+ * float u1, v1, q1;
+ * } pv;
+ * struct {
+ * float x, y, z;
+ * struct { char r, g, b, a; } color;
+ * } tv;
+ * float f[16];
+ * unsigned int ui[16];
+ * unsigned char ub4[4][16];
+ * }
+ *
+ * HW_VIEWPORT: Hardware performs viewport transform.
+ * HW_DIVIDE: Hardware performs perspective divide.
+ *
+ * DO_XYZW: Emit xyz and maybe w coordinates.
+ * DO_RGBA: Emit color, v.color is in RGBA order.
+ * DO_BGRA: Emit color, v.color is in BGRA order.
+ * DO_SPEC: Emit specular color.
+ * DO_TEX0: Emit tex0 u,v coordinates.
+ * DO_TEX1: Emit tex1 u,v coordinates.
+ * DO_PTEX: Emit tex0, tex1 q coordinates where possible.
+ *
+ * HAVE_TINY_VERTICES: Hardware understands v.tv format.
+ * HAVE_PTEX_VERTICES: Hardware understands v.pv format.
+ * HAVE_NOTEX_VERTICES: Hardware understands v.v format with texcount 0.
+ *
+ * Additionally, this template assumes it is emitting *transformed*
+ * vertices; the modifications to emit untransformed vertices (ie. to
+ * t&l hardware) are probably too great to cooexist with the code
+ * already in this file.
+ *
+ * NOTE: The PTEX vertex format always includes TEX0 and TEX1, even if
+ * only TEX0 is enabled, in order to maintain a vertex size which is
+ * an exact number of quadwords.
+ */
+
+#if (HW_VIEWPORT)
+#define VIEWPORT_X(x) x
+#define VIEWPORT_Y(x) x
+#define VIEWPORT_Z(x) x
+#else
+#define VIEWPORT_X(x) (s[0] * x + s[12])
+#define VIEWPORT_Y(y) (s[5] * y + s[13])
+#define VIEWPORT_Z(z) (s[10] * z + s[14])
+#endif
+
+#if (HW_DIVIDE || DO_RGBA || DO_XYZW || !HAVE_TINY_VERTICES)
+
+static void TAG(emit)( GLcontext *ctx,
+ GLuint start, GLuint end,
+ void *dest,
+ GLuint stride )
+{
+ struct vertex_buffer *VB = &TNL_CONTEXT(ctx)->vb;
+ GLfloat (*tc0)[4], (*tc1)[4], *fog;
+ GLubyte (*col)[4], (*spec)[4];
+ GLuint tc0_stride, tc1_stride, col_stride, spec_stride, fog_stride;
+ GLuint tc0_size, tc1_size;
+ GLfloat (*coord)[4];
+ GLuint coord_stride;
+ VERTEX *v = (VERTEX *)dest;
+ int i;
+
+ if (HW_VIEWPORT && HW_DIVIDE) {
+ coord = VB->ClipPtr->data;
+ coord_stride = VB->ClipPtr->stride;
+ }
+ else {
+ coord = VB->ProjectedClipPtr->data;
+ coord_stride = VB->ProjectedClipPtr->stride;
+ }
+
+ if (DO_TEX0) {
+ tc0_stride = VB->TexCoordPtr[0]->stride;
+ tc0 = VB->TexCoordPtr[0]->data;
+ if (DO_PTEX)
+ tc0_size = VB->TexCoordPtr[0]->size;
+ }
+
+ if (DO_TEX1) {
+ tc1 = VB->TexCoordPtr[1]->data;
+ tc1_stride = VB->TexCoordPtr[1]->stride;
+ if (DO_PTEX)
+ tc1_size = VB->TexCoordPtr[1]->size;
+ }
+
+ if (DO_RGBA || DO_BGRA) {
+ col = VB->ColorPtr[0]->data;
+ col_stride = VB->ColorPtr[0]->stride;
+ }
+
+ if (DO_SPEC) {
+ spec = VB->SecondaryColorPtr[0]->data;
+ spec_stride = VB->SecondaryColorPtr[0]->stride;
+ }
+
+ if (DO_FOG) {
+ fog = VB->FogCoordPtr->data;
+ fog_stride = VB->FogCoordPtr->stride;
+ }
+
+ if (VB->importable_data) {
+ /* May have nonstandard strides:
+ */
+ if (start) {
+ coord = (GLfloat (*)[4])((GLubyte *)coord + start * coord_stride);
+ if (DO_TEX0)
+ tc0 = (GLfloat (*)[4])((GLubyte *)tc0 + start * tc0_stride);
+ if (DO_TEX1)
+ tc0 = (GLfloat (*)[4])((GLubyte *)tc1 + start * tc1_stride);
+ if (DO_RGBA || DO_BGRA)
+ STRIDE_4UB(col, start * col_stride);
+ if (DO_SPEC)
+ STRIDE_4UB(spec, start * spec_stride);
+ if (DO_FOG)
+ STRIDE_F(fog, start * fog_stride);
+ }
+
+ for (i=start; i < end; i++, v = (ddVertex *)((GLubyte *)v + stride)) {
+ if (DO_XYZW) {
+ if (HW_VIEWPORT || mask[i] == 0) {
+ VIEWPORT_X(v->v.x, coord[0][0]);
+ VIEWPORT_Y(v->v.y, coord[0][1]);
+ VIEWPORT_Z(v->v.z, coord[0][2]);
+ VIEWPORT_W(v->v.w, coord[0][3]);
+ }
+ coord = (GLfloat (*)[4])((GLubyte *)coord + coord_stride);
+ }
+ if (DO_RGBA) {
+ *(GLuint *)&v->v.color = *(GLuint *)&col[0];
+ STRIDE_4UB(col, col_stride);
+ }
+ if (DO_BGRA) {
+ v->v.color.blue = col[0][2];
+ v->v.color.green = col[0][1];
+ v->v.color.red = col[0][0];
+ v->v.color.alpha = col[0][3];
+ STRIDE_4UB(col, col_stride);
+ }
+ if (DO_SPEC) {
+ v->v.specular.red = spec[0][0];
+ v->v.specular.green = spec[0][1];
+ v->v.specular.blue = spec[0][2];
+ STRIDE_4UB(spec, spec_stride);
+ }
+ if (DO_FOG) {
+ v->v.specular.alpha = fog[0] * 255.0;
+ STRIDE_F(fog, fog_stride);
+ }
+ if (DO_TEX0) {
+ *(GLuint *)&v->v.tu0 = *(GLuint *)&tc0[0][0];
+ *(GLuint *)&v->v.tv0 = *(GLuint *)&tc0[0][1];
+ if (DO_PTEX) {
+ if (HAVE_PTEX_VERTICES) {
+ if (tc0_size == 4)
+ *(GLuint *)&v->pv.tq0 = *(GLuint *)&tc0[0][3];
+ else
+ *(GLuint *)&v->pv.tq0 = IEEE_ONE;
+ }
+ else if (tc0_size == 4) {
+ float rhw = 1.0 / tc0[0][3];
+ v->v.w *= tc0[0][3];
+ v->v.u0 *= w;
+ v->v.v0 *= w;
+ }
+ }
+ tc0 = (GLfloat (*)[4])((GLubyte *)tc0 + tc0_stride);
+ }
+ if (DO_TEX1) {
+ if (DO_PTEX) {
+ *(GLuint *)&v->pv.u1 = *(GLuint *)&tc1[0][0];
+ *(GLuint *)&v->pv.v1 = *(GLuint *)&tc1[0][1];
+ *(GLuint *)&v->pv.q1 = IEEE_ONE;
+ if (tc1_size == 4)
+ *(GLuint *)&v->pv.q1 = *(GLuint *)&tc1[0][3];
+ }
+ else {
+ *(GLuint *)&v->v.u1 = *(GLuint *)&tc1[0][0];
+ *(GLuint *)&v->v.v1 = *(GLuint *)&tc1[0][1];
+ }
+ tc1 = (GLfloat (*)[4])((GLubyte *)tc1 + tc1_stride);
+ }
+ else if (DO_PTEX) {
+ *(GLuint *)&v->pv.q1 = 0; /* avoid culling on radeon */
+ }
+ }
+ }
+ else {
+ for (i=start; i < end; i++, v = (ddVertex *)((GLubyte *)v + stride)) {
+ if (DO_XYZW) {
+ if (HW_VIEWPORT || mask[i] == 0) {
+ VIEWPORT_X(v->v.x, coord[i][0]);
+ VIEWPORT_Y(v->v.y, coord[i][1]);
+ VIEWPORT_Z(v->v.z, coord[i][2]);
+ VIEWPORT_W(v->v.w, coord[i][3]);
+ }
+ }
+ if (DO_RGBA) {
+ *(GLuint *)&v->v.color = *(GLuint *)&col[i];
+ }
+ if (DO_BGRA) {
+ v->v.color.blue = col[i][2];
+ v->v.color.green = col[i][1];
+ v->v.color.red = col[i][0];
+ v->v.color.alpha = col[i][3];
+ }
+ if (DO_SPEC) {
+ v->v.specular.red = spec[i][0];
+ v->v.specular.green = spec[i][1];
+ v->v.specular.blue = spec[i][2];
+ }
+ if (DO_FOG) {
+ v->v.specular.alpha = fog[i] * 255.0;
+ }
+ if (DO_TEX0) {
+ if (DO_PTEX) {
+ *(GLuint *)&v->pv.u0 = *(GLuint *)&tc0[i][0];
+ *(GLuint *)&v->pv.v0 = *(GLuint *)&tc0[i][1];
+ *(GLuint *)&v->pv.q0 = IEEE_ONE;
+ if (tc0_size == 4)
+ *(GLuint *)&v->pv.q0 = *(GLuint *)&tc0[i][3];
+ }
+ else {
+ *(GLuint *)&v->v.u0 = *(GLuint *)&tc0[i][0];
+ *(GLuint *)&v->v.v0 = *(GLuint *)&tc0[i][1];
+ }
+ }
+ if (DO_TEX1) {
+ if (DO_PTEX) {
+ *(GLuint *)&v->pv.u1 = *(GLuint *)&tc1[i][0];
+ *(GLuint *)&v->pv.v1 = *(GLuint *)&tc1[i][1];
+ *(GLuint *)&v->pv.q1 = IEEE_ONE;
+ if (tc1_size == 4)
+ *(GLuint *)&v->pv.q1 = *(GLuint *)&tc1[i][3];
+ }
+ else {
+ *(GLuint *)&v->v.u1 = *(GLuint *)&tc1[i][0];
+ *(GLuint *)&v->v.v1 = *(GLuint *)&tc1[i][1];
+ }
+ }
+ else if (DO_PTEX) {
+ *(GLuint *)&v->pv.q1 = 0; /* must be valid float to avoid culling? */
+ }
+ }
+ }
+
+ if (DO_PTEX && !HAVE_PTEX_VERTICES) {
+ INVALIDATE_STORED_VERTICES();
+ }
+}
+#else
+static void TAG(emit)( GLcontext *ctx, GLuint start, GLuint end,
+ void *dest, GLuint stride )
+{
+ struct vertex_buffer *VB = &TNL_CONTEXT(ctx)->vb;
+ GLubyte (*col)[4] = VB->ColorPtr[0]->data;
+ GLuint col_stride = VB->ColorPtr[0]->stride;
+ GLfloat (*coord)[4] = VB->ProjectedClipPtr->data;
+ GLuint coord_stride = VB->ProjectedClipPtr->stride;
+ GLfloat *v = (GLfloat *)dest;
+ int i;
+
+ ASSERT(stride == 4);
+
+ /* Pack what's left into a 4-dword vertex. Color is in a different
+ * place, and there is no 'w' coordinate.
+ */
+ if (VB->importable_data) {
+ if (start) {
+ coord = (GLfloat (*)[4])((GLubyte *)coord + start * coord_stride);
+ STRIDE_4UB(col, start * col_stride);
+ }
+
+ for (i=start; i < end; i++, v+=4) {
+ if (HW_VIEWPORT || mask[i] == 0) {
+ v[0] = VIEWPORT_X(coord[0][0]);
+ v[1] = VIEWPORT_Y(coord[0][1]);
+ v[2] = VIEWPORT_Z(coord[0][2]);
+ }
+ coord = (GLfloat (*)[4])((GLubyte *)coord + coord_stride);
+ if (DO_RGBA) {
+ *(GLuint *)&v[3] = *(GLuint *)col;
+ }
+ else if (DO_BGRA) {
+ GLubyte *b = (GLubyte *)&v[3];
+ b[0] = col[0][2];
+ b[1] = col[0][1];
+ b[2] = col[0][0];
+ b[3] = col[0][3];
+ }
+ STRIDE_4UB( col, col_stride );
+ }
+ }
+ else {
+ for (i=start; i < end; i++, v+=4) {
+ if (HW_VIEWPORT || mask[i] == 0) {
+ v[0] = VIEWPORT_X(coord[i][0]);
+ v[1] = VIEWPORT_Y(coord[i][1]);
+ v[2] = VIEWPORT_Z(coord[i][2]);
+ }
+ if (DO_RGBA) {
+ *(GLuint *)&v[3] = *(GLuint *)&col[i];
+ }
+ else if (DO_BGRA) {
+ GLubyte *b = (GLubyte *)&v[3];
+ b[0] = col[i][2];
+ b[1] = col[i][1];
+ b[2] = col[i][0];
+ b[3] = col[i][3];
+ }
+ }
+ }
+}
+#endif
+
+#if (DO_XYZW) && (DO_RGBA)
+
+static GLboolean TAG(check_tex_sizes)( GLcontext *ctx )
+{
+ if (DO_PTEX)
+ return GL_TRUE;
+
+ if (DO_TEX0) {
+ struct vertex_buffer *VB = &TNL_CONTEXT(ctx)->vb;
+
+ if (DO_TEX1) {
+ if (VB->TexCoordPtr[0] == 0)
+ VB->TexCoordPtr[0] = VB->TexCoordPtr[1];
+
+ if (VB->TexCoordPtr[1]->size == 4)
+ return GL_FALSE;
+ }
+
+ if (VB->TexCoordPtr[0]->size == 4)
+ return GL_FALSE;
+ }
+
+ return GL_TRUE;
+}
+#if (!DO_PTEX || HAVE_PTEX_VERTICES)
+static void TAG(interp)( GLcontext *ctx,
+ GLfloat t,
+ GLuint edst, GLuint eout, GLuint ein,
+ GLboolean force_boundary )
+{
+ struct vertex_buffer *VB = &TNL_CONTEXT(ctx)->vb;
+ GLubyte *ddverts = GET_VERTEX_STORE();
+ GLuint shift = GET_VERTEX_STRIDE_SHIFT();
+ const GLfloat *dstclip = VB->ClipPtr->data[edst];
+ GLfloat w;
+
+ VERTEX *dst = (VERTEX *)(ddverts + (edst << shift));
+ VERTEX *in = (VERTEX *)(ddverts + (eout << shift));
+ VERTEX *out = (VERTEX *)(ddverts + (ein << shift));
+
+/* fprintf(stderr, "%s\n", __FUNCTION__); */
+
+ if (!HW_DIVIDE) {
+ w = 1.0 / dstclip[3];
+ VIEWPORT_X( dst->v.x, dstclip[0] * w );
+ VIEWPORT_Y( dst->v.y, dstclip[1] * w );
+ VIEWPORT_Z( dst->v.z, dstclip[2] * w );
+ }
+ else {
+ VIEWPORT_X( dst->v.x, dstclip[0] );
+ VIEWPORT_Y( dst->v.y, dstclip[1] );
+ VIEWPORT_Z( dst->v.z, dstclip[2] );
+ w = dstclip[3];
+ }
+
+ if (HW_DIVIDE || DO_FOG || DO_SPEC || DO_TEX0 || DO_TEX1) {
+
+ if (!HW_VIEWPORT || !HW_DIVIDE)
+ dst->v.w = w;
+
+ INTERP_UB( t, dst->ub4[4][0], out->ub4[4][0], in->ub4[4][0] );
+ INTERP_UB( t, dst->ub4[4][1], out->ub4[4][1], in->ub4[4][1] );
+ INTERP_UB( t, dst->ub4[4][2], out->ub4[4][2], in->ub4[4][2] );
+ INTERP_UB( t, dst->ub4[4][3], out->ub4[4][3], in->ub4[4][3] );
+
+ if (DO_SPEC) {
+ INTERP_UB( t, dst->ub4[5][0], out->ub4[5][0], in->ub4[5][0] );
+ INTERP_UB( t, dst->ub4[5][1], out->ub4[5][1], in->ub4[5][1] );
+ INTERP_UB( t, dst->ub4[5][2], out->ub4[5][2], in->ub4[5][2] );
+ }
+ if (DO_FOG) {
+ INTERP_UB( t, dst->ub4[5][3], out->ub4[5][3], in->ub4[5][3] );
+ }
+ if (DO_TEX0) {
+ if (DO_PTEX && HAVE_PTEX_VERTICES) {
+ INTERP_F( t, dst->pv.u0, out->pv.u0, in->pv.u0 );
+ INTERP_F( t, dst->pv.v0, out->pv.v0, in->pv.v0 );
+ INTERP_F( t, dst->pv.q0, out->pv.q0, in->pv.q0 );
+ }
+ else {
+ INTERP_F( t, dst->v.u0, out->v.u0, in->v.u0 );
+ INTERP_F( t, dst->v.v0, out->v.v0, in->v.v0 );
+ }
+ }
+ if (DO_TEX1) {
+ if (DO_PTEX) {
+ INTERP_F( t, dst->pv.u1, out->pv.u1, in->pv.u1 );
+ INTERP_F( t, dst->pv.v1, out->pv.v1, in->pv.v1 );
+ INTERP_F( t, dst->pv.q1, out->pv.q1, in->pv.q1 );
+ } else {
+ INTERP_F( t, dst->v.u1, out->v.u1, in->v.u1 );
+ INTERP_F( t, dst->v.v1, out->v.v1, in->v.v1 );
+ }
+ }
+ else if (DO_PTEX) {
+ dst->pv.q0 = 0.0; /* must be a valid float on radeon */
+ }
+ } else {
+ /* 4-dword vertex. Color is in v[3] and there is no oow coordinate.
+ */
+ INTERP_UB( t, dst->ub4[3][0], out->ub4[3][0], in->ub4[3][0] );
+ INTERP_UB( t, dst->ub4[3][1], out->ub4[3][1], in->ub4[3][1] );
+ INTERP_UB( t, dst->ub4[3][2], out->ub4[3][2], in->ub4[3][2] );
+ INTERP_UB( t, dst->ub4[3][3], out->ub4[3][3], in->ub4[3][3] );
+ }
+}
+#endif
+#endif
+
+
+static void TAG(init)( void )
+{
+ setup_tab[IND].emit = TAG(emit);
+
+#if (DO_XYZW && DO_RGBA)
+ setup_tab[IND].check_tex_sizes = TAG(check_tex_sizes);
+ setup_tab[IND].interp = TAG(interp);
+#endif
+
+ if (DO_SPEC)
+ setup_tab[IND].copy_pv = _tnl_dd_copy_pv_rgba4_spec5;
+ else if (HW_DIVIDE || DO_SPEC || DO_FOG || DO_TEX0 || DO_TEX1)
+ setup_tab[IND].copy_pv = _tnl_dd_copy_pv_rgba4;
+ else
+ setup_tab[IND].copy_pv = _tnl_dd_copy_pv_rgba3;
+
+ if (DO_TEX1) {
+ if (DO_PTEX) {
+ ASSERT(HAVE_PTEX_VERTICES);
+ setup_tab[IND].vc_format = PROJ_TEX_VERTEX_FORMAT;
+ setup_tab[IND].vertex_size = 12;
+ setup_tab[IND].vertex_stride_shift = 6;
+ }
+ else {
+ setup_tab[IND].vc_format = TEX1_VERTEX_FORMAT;
+ setup_tab[IND].vertex_size = 10;
+ setup_tab[IND].vertex_stride_shift = 6;
+ }
+ }
+ else if (DO_TEX0) {
+ if (DO_PTEX && HAVE_PTEX_VERTICES) {
+ setup_tab[IND].vc_format = PROJ_TEX_VERTEX_FORMAT;
+ setup_tab[IND].vertex_size = 12;
+ setup_tab[IND].vertex_stride_shift = 6;
+ } else {
+ setup_tab[IND].vc_format = TEX0_VERTEX_FORMAT;
+ setup_tab[IND].vertex_size = 8;
+ setup_tab[IND].vertex_stride_shift = 5;
+ }
+ }
+ else if (!HW_DIVIDE && !DO_SPEC && !DO_FOG && HAVE_TINY_VERTICES) {
+ setup_tab[IND].vertex_format = TINY_VERTEX_FORMAT;
+ setup_tab[IND].vertex_size = 4;
+ setup_tab[IND].vertex_stride_shift = 4;
+ } else if (HAVE_NOTEX_VERTICES) {
+ setup_tab[IND].vertex_format = NOTEX_VERTEX_FORMAT;
+ setup_tab[IND].vertex_size = 6;
+ setup_tab[IND].vertex_stride_shift = 5;
+ } else {
+ setup_tab[IND].vc_format = TEX0_VERTEX_FORMAT;
+ setup_tab[IND].vertex_size = 8;
+ setup_tab[IND].vertex_stride_shift = 5;
+ }
+}
+
+
+#undef IND
+#undef TAG
diff --git a/src/mesa/drivers/glide/fxdd.c b/src/mesa/drivers/glide/fxdd.c
index eea8e328f33..2de53b95d5c 100644
--- a/src/mesa/drivers/glide/fxdd.c
+++ b/src/mesa/drivers/glide/fxdd.c
@@ -654,8 +654,7 @@ static const GLubyte *fxDDGetString(GLcontext *ctx, GLenum name)
}
static const struct gl_pipeline_stage *fx_pipeline[] = {
- &_tnl_update_material_stage, /* TODO: Add the fastpath here */
- &_tnl_vertex_transform_stage,
+ &_tnl_vertex_transform_stage, /* TODO: Add the fastpath here */
&_tnl_normal_transform_stage,
&_tnl_lighting_stage,
&_tnl_fog_coordinate_stage, /* TODO: Omit fog stage */