summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorKeith Whitwell <[email protected]>2001-02-16 18:14:41 +0000
committerKeith Whitwell <[email protected]>2001-02-16 18:14:41 +0000
commit46b0988c673b28e072fd0cbf477632a9ab6f9f18 (patch)
tree3463116da957c6f13dcb0b415ca8476640503fc7 /src
parent2448fc7deeaa870d879de17158f243f239c05b15 (diff)
Allow swrast to cope (fairly) cleanly with GL_SEPERATE_SPECULAR when
texturing is not enabled, and without requiring the two colors be added externally. As a part of this, collapsed the decomposition of quads into triangles inside swrast to be hardwired into _swrast_Quad; removed s_quads.[ch]. Removed checks on texture state from t_vb_light.c, which was previously required by swrast. Moved the t_dd_ templates to a new directory.
Diffstat (limited to 'src')
-rw-r--r--src/mesa/Makefile.X113
-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
-rw-r--r--src/mesa/main/Makefile.X113
-rw-r--r--src/mesa/main/enable.c19
-rw-r--r--src/mesa/main/light.c11
-rw-r--r--src/mesa/swrast/s_aatriangle.c17
-rw-r--r--src/mesa/swrast/s_context.c100
-rw-r--r--src/mesa/swrast/s_context.h15
-rw-r--r--src/mesa/swrast/s_lines.c24
-rw-r--r--src/mesa/swrast/s_lines.h7
-rw-r--r--src/mesa/swrast/s_points.c16
-rw-r--r--src/mesa/swrast/s_points.h5
-rw-r--r--src/mesa/swrast/s_triangle.c36
-rw-r--r--src/mesa/swrast/s_triangle.h8
-rw-r--r--src/mesa/swrast_setup/ss_context.c14
-rw-r--r--src/mesa/swrast_setup/ss_vbtmp.h8
-rw-r--r--src/mesa/tnl/t_vb_light.c13
-rw-r--r--src/mesa/tnl/t_vb_lighttmp.h60
-rw-r--r--src/mesa/tnl/t_vb_render.c20
26 files changed, 2994 insertions, 171 deletions
diff --git a/src/mesa/Makefile.X11 b/src/mesa/Makefile.X11
index eed597bb36e..fdab3399ce3 100644
--- a/src/mesa/Makefile.X11
+++ b/src/mesa/Makefile.X11
@@ -1,4 +1,4 @@
-# $Id: Makefile.X11,v 1.44 2001/02/16 00:35:34 keithw Exp $
+# $Id: Makefile.X11,v 1.45 2001/02/16 18:14:41 keithw Exp $
# Mesa 3-D graphics library
# Version: 3.5
@@ -143,7 +143,6 @@ CORE_SOURCES = \
swrast/s_pb.c \
swrast/s_pixeltex.c \
swrast/s_points.c \
- swrast/s_quads.c \
swrast/s_readpix.c \
swrast/s_scissor.c \
swrast/s_span.c \
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 */
diff --git a/src/mesa/main/Makefile.X11 b/src/mesa/main/Makefile.X11
index eed597bb36e..fdab3399ce3 100644
--- a/src/mesa/main/Makefile.X11
+++ b/src/mesa/main/Makefile.X11
@@ -1,4 +1,4 @@
-# $Id: Makefile.X11,v 1.44 2001/02/16 00:35:34 keithw Exp $
+# $Id: Makefile.X11,v 1.45 2001/02/16 18:14:41 keithw Exp $
# Mesa 3-D graphics library
# Version: 3.5
@@ -143,7 +143,6 @@ CORE_SOURCES = \
swrast/s_pb.c \
swrast/s_pixeltex.c \
swrast/s_points.c \
- swrast/s_quads.c \
swrast/s_readpix.c \
swrast/s_scissor.c \
swrast/s_span.c \
diff --git a/src/mesa/main/enable.c b/src/mesa/main/enable.c
index 37ada84a7df..f1870415f30 100644
--- a/src/mesa/main/enable.c
+++ b/src/mesa/main/enable.c
@@ -1,4 +1,4 @@
-/* $Id: enable.c,v 1.41 2001/02/13 23:51:34 brianp Exp $ */
+/* $Id: enable.c,v 1.42 2001/02/16 18:14:41 keithw Exp $ */
/*
* Mesa 3-D graphics library
@@ -273,6 +273,14 @@ void _mesa_set_enable( GLcontext *ctx, GLenum cap, GLboolean state )
FLUSH_VERTICES(ctx, _NEW_LIGHT);
ctx->Light.Enabled = state;
ctx->_Enabled ^= ENABLE_LIGHT;
+
+ if ((ctx->Light.Enabled &&
+ ctx->Light.Model.ColorControl==GL_SEPARATE_SPECULAR_COLOR)
+ || ctx->Fog.ColorSumEnabled)
+ ctx->_TriangleCaps |= DD_SEPERATE_SPECULAR;
+ else
+ ctx->_TriangleCaps &= ~DD_SEPERATE_SPECULAR;
+
break;
case GL_LINE_SMOOTH:
if (ctx->Line.SmoothFlag == state)
@@ -724,7 +732,14 @@ void _mesa_set_enable( GLcontext *ctx, GLenum cap, GLboolean state )
return;
FLUSH_VERTICES(ctx, _NEW_FOG);
ctx->Fog.ColorSumEnabled = state;
- ctx->_TriangleCaps ^= DD_SEPERATE_SPECULAR;
+
+ if ((ctx->Light.Enabled &&
+ ctx->Light.Model.ColorControl==GL_SEPARATE_SPECULAR_COLOR)
+ || ctx->Fog.ColorSumEnabled)
+ ctx->_TriangleCaps |= DD_SEPERATE_SPECULAR;
+ else
+ ctx->_TriangleCaps &= ~DD_SEPERATE_SPECULAR;
+
break;
/* GL_MESA_sprite_point */
diff --git a/src/mesa/main/light.c b/src/mesa/main/light.c
index 155792af52b..052c04618bc 100644
--- a/src/mesa/main/light.c
+++ b/src/mesa/main/light.c
@@ -1,4 +1,4 @@
-/* $Id: light.c,v 1.37 2001/02/15 01:33:52 keithw Exp $ */
+/* $Id: light.c,v 1.38 2001/02/16 18:14:41 keithw Exp $ */
/*
* Mesa 3-D graphics library
@@ -421,7 +421,14 @@ _mesa_LightModelfv( GLenum pname, const GLfloat *params )
return;
FLUSH_VERTICES(ctx, _NEW_LIGHT);
ctx->Light.Model.ColorControl = newenum;
- ctx->_TriangleCaps ^= DD_SEPERATE_SPECULAR;
+
+ if ((ctx->Light.Enabled &&
+ ctx->Light.Model.ColorControl==GL_SEPARATE_SPECULAR_COLOR)
+ || ctx->Fog.ColorSumEnabled)
+ ctx->_TriangleCaps |= DD_SEPERATE_SPECULAR;
+ else
+ ctx->_TriangleCaps &= ~DD_SEPERATE_SPECULAR;
+
break;
default:
gl_error( ctx, GL_INVALID_ENUM, "glLightModel" );
diff --git a/src/mesa/swrast/s_aatriangle.c b/src/mesa/swrast/s_aatriangle.c
index 219798d8c9e..d9a11b0cf66 100644
--- a/src/mesa/swrast/s_aatriangle.c
+++ b/src/mesa/swrast/s_aatriangle.c
@@ -1,4 +1,4 @@
-/* $Id: s_aatriangle.c,v 1.6 2001/01/23 23:39:37 brianp Exp $ */
+/* $Id: s_aatriangle.c,v 1.7 2001/02/16 18:14:41 keithw Exp $ */
/*
* Mesa 3-D graphics library
@@ -405,9 +405,7 @@ _mesa_set_aa_triangle_function(GLcontext *ctx)
ASSERT(ctx->Polygon.SmoothFlag);
if (ctx->Texture._ReallyEnabled) {
- if (ctx->Light.Enabled &&
- (ctx->Light.Model.ColorControl == GL_SEPARATE_SPECULAR_COLOR ||
- ctx->Fog.ColorSumEnabled)) {
+ if (ctx->_TriangleCaps & DD_SEPERATE_SPECULAR) {
if (swrast->_MultiTextureEnabled) {
SWRAST_CONTEXT(ctx)->Triangle = spec_multitex_aa_tri;
}
@@ -424,13 +422,12 @@ _mesa_set_aa_triangle_function(GLcontext *ctx)
}
}
}
+ else if (ctx->Visual.rgbMode) {
+ SWRAST_CONTEXT(ctx)->Triangle = rgba_aa_tri;
+ }
else {
- if (ctx->Visual.rgbMode) {
- SWRAST_CONTEXT(ctx)->Triangle = rgba_aa_tri;
- }
- else {
- SWRAST_CONTEXT(ctx)->Triangle = index_aa_tri;
- }
+ SWRAST_CONTEXT(ctx)->Triangle = index_aa_tri;
}
+
ASSERT(SWRAST_CONTEXT(ctx)->Triangle);
}
diff --git a/src/mesa/swrast/s_context.c b/src/mesa/swrast/s_context.c
index 55966a95a86..b78b9e34ff4 100644
--- a/src/mesa/swrast/s_context.c
+++ b/src/mesa/swrast/s_context.c
@@ -1,4 +1,4 @@
-/* $Id: s_context.c,v 1.12 2001/01/29 21:47:13 brianp Exp $ */
+/* $Id: s_context.c,v 1.13 2001/02/16 18:14:41 keithw Exp $ */
/*
* Mesa 3-D graphics library
@@ -35,7 +35,6 @@
#include "s_points.h"
#include "s_lines.h"
#include "s_triangle.h"
-#include "s_quads.h"
#include "s_blend.h"
#include "s_context.h"
#include "s_texture.h"
@@ -153,31 +152,32 @@ _swrast_update_hint( GLcontext *ctx )
swrast->AllowPixelFog));
}
-#define _SWRAST_NEW_TRIANGLE (_NEW_RENDERMODE| \
- _NEW_POLYGON| \
- _NEW_DEPTH| \
- _NEW_STENCIL| \
- _NEW_COLOR| \
- _NEW_TEXTURE| \
- _NEW_HINT| \
- _SWRAST_NEW_RASTERMASK| \
- _NEW_LIGHT| \
- _NEW_FOG)
-
-#define _SWRAST_NEW_LINE (_NEW_RENDERMODE| \
- _NEW_LINE| \
- _NEW_TEXTURE| \
- _NEW_LIGHT| \
- _NEW_FOG| \
- _NEW_DEPTH)
-
-#define _SWRAST_NEW_POINT (_NEW_RENDERMODE | \
- _NEW_POINT | \
- _NEW_TEXTURE | \
- _NEW_LIGHT | \
- _NEW_FOG)
-
-#define _SWRAST_NEW_QUAD 0
+#define _SWRAST_NEW_TRIANGLE (_NEW_RENDERMODE| \
+ _NEW_POLYGON| \
+ _NEW_DEPTH| \
+ _NEW_STENCIL| \
+ _NEW_COLOR| \
+ _NEW_TEXTURE| \
+ _NEW_HINT| \
+ _SWRAST_NEW_RASTERMASK| \
+ _NEW_LIGHT| \
+ _NEW_FOG | \
+ _DD_NEW_SEPERATE_SPECULAR)
+
+#define _SWRAST_NEW_LINE (_NEW_RENDERMODE| \
+ _NEW_LINE| \
+ _NEW_TEXTURE| \
+ _NEW_LIGHT| \
+ _NEW_FOG| \
+ _NEW_DEPTH | \
+ _DD_NEW_SEPERATE_SPECULAR)
+
+#define _SWRAST_NEW_POINT (_NEW_RENDERMODE | \
+ _NEW_POINT | \
+ _NEW_TEXTURE | \
+ _NEW_LIGHT | \
+ _NEW_FOG | \
+ _DD_NEW_SEPERATE_SPECULAR)
#define _SWRAST_NEW_TEXTURE_SAMPLE_FUNC _NEW_TEXTURE
@@ -189,19 +189,6 @@ _swrast_update_hint( GLcontext *ctx )
* after a state change.
*/
static void
-_swrast_validate_quad( GLcontext *ctx,
- const SWvertex *v0, const SWvertex *v1,
- const SWvertex *v2, const SWvertex *v3 )
-{
- SWcontext *swrast = SWRAST_CONTEXT(ctx);
-
- _swrast_validate_derived( ctx );
- swrast->choose_quad( ctx );
-
- swrast->Quad( ctx, v0, v1, v2, v3 );
-}
-
-static void
_swrast_validate_triangle( GLcontext *ctx,
const SWvertex *v0,
const SWvertex *v1,
@@ -212,6 +199,12 @@ _swrast_validate_triangle( GLcontext *ctx,
_swrast_validate_derived( ctx );
swrast->choose_triangle( ctx );
+ if ((ctx->_TriangleCaps & DD_SEPERATE_SPECULAR) &&
+ !ctx->Texture._ReallyEnabled) {
+ swrast->SpecTriangle = swrast->Triangle;
+ swrast->Triangle = _swrast_add_spec_terms_triangle;
+ }
+
swrast->Triangle( ctx, v0, v1, v2 );
}
@@ -223,6 +216,13 @@ _swrast_validate_line( GLcontext *ctx, const SWvertex *v0, const SWvertex *v1 )
_swrast_validate_derived( ctx );
swrast->choose_line( ctx );
+ if ((ctx->_TriangleCaps & DD_SEPERATE_SPECULAR) &&
+ !ctx->Texture._ReallyEnabled) {
+ swrast->SpecLine = swrast->Line;
+ swrast->Line = _swrast_add_spec_terms_line;
+ }
+
+
swrast->Line( ctx, v0, v1 );
}
@@ -234,6 +234,12 @@ _swrast_validate_point( GLcontext *ctx, const SWvertex *v0 )
_swrast_validate_derived( ctx );
swrast->choose_point( ctx );
+ if ((ctx->_TriangleCaps & DD_SEPERATE_SPECULAR) &&
+ !ctx->Texture._ReallyEnabled) {
+ swrast->SpecPoint = swrast->Point;
+ swrast->Point = _swrast_add_spec_terms_point;
+ }
+
swrast->Point( ctx, v0 );
}
@@ -302,9 +308,6 @@ _swrast_invalidate_state( GLcontext *ctx, GLuint new_state )
if (new_state & swrast->invalidate_point)
swrast->Point = _swrast_validate_point;
- if (new_state & swrast->invalidate_quad)
- swrast->Quad = _swrast_validate_quad;
-
if (new_state & _SWRAST_NEW_BLEND_FUNC)
swrast->BlendFunc = _swrast_validate_blend_func;
@@ -350,12 +353,8 @@ _swrast_Quad( GLcontext *ctx,
const SWvertex *v0, const SWvertex *v1,
const SWvertex *v2, const SWvertex *v3 )
{
-/* fprintf(stderr, "%s\n", __FUNCTION__); */
-/* _swrast_print_vertex( ctx, v0 ); */
-/* _swrast_print_vertex( ctx, v1 ); */
-/* _swrast_print_vertex( ctx, v2 ); */
-/* _swrast_print_vertex( ctx, v3 ); */
- SWRAST_CONTEXT(ctx)->Quad( ctx, v0, v1, v2, v3 );
+ SWRAST_CONTEXT(ctx)->Triangle( ctx, v0, v1, v2 );
+ SWRAST_CONTEXT(ctx)->Triangle( ctx, v0, v2, v3 );
}
void
@@ -432,17 +431,14 @@ _swrast_CreateContext( GLcontext *ctx )
swrast->choose_point = _swrast_choose_point;
swrast->choose_line = _swrast_choose_line;
swrast->choose_triangle = _swrast_choose_triangle;
- swrast->choose_quad = _swrast_choose_quad;
swrast->invalidate_point = _SWRAST_NEW_POINT;
swrast->invalidate_line = _SWRAST_NEW_LINE;
swrast->invalidate_triangle = _SWRAST_NEW_TRIANGLE;
- swrast->invalidate_quad = _SWRAST_NEW_QUAD;
swrast->Point = _swrast_validate_point;
swrast->Line = _swrast_validate_line;
swrast->Triangle = _swrast_validate_triangle;
- swrast->Quad = _swrast_validate_quad;
swrast->InvalidateState = _swrast_sleep;
swrast->BlendFunc = _swrast_validate_blend_func;
diff --git a/src/mesa/swrast/s_context.h b/src/mesa/swrast/s_context.h
index 86b71ecc459..6603b56e7df 100644
--- a/src/mesa/swrast/s_context.h
+++ b/src/mesa/swrast/s_context.h
@@ -63,10 +63,6 @@ typedef void (*swrast_line_func)( GLcontext *ctx,
typedef void (*swrast_tri_func)( GLcontext *ctx, const SWvertex *,
const SWvertex *, const SWvertex *);
-typedef void (*swrast_quad_func)( GLcontext *ctx,
- const SWvertex *, const SWvertex *,
- const SWvertex *, const SWvertex *);
-
/*
@@ -136,12 +132,10 @@ typedef struct
void (*choose_point)( GLcontext * );
void (*choose_line)( GLcontext * );
void (*choose_triangle)( GLcontext * );
- void (*choose_quad)( GLcontext * );
GLuint invalidate_point;
GLuint invalidate_line;
GLuint invalidate_triangle;
- GLuint invalidate_quad;
/* Function pointers for dispatch behind public entrypoints.
@@ -151,7 +145,14 @@ typedef struct
swrast_point_func Point;
swrast_line_func Line;
swrast_tri_func Triangle;
- swrast_quad_func Quad;
+
+ /* Placeholders for when seperate specular (or secondary color) is
+ * enabled but texturing is not.
+ */
+ swrast_point_func SpecPoint;
+ swrast_line_func SpecLine;
+ swrast_tri_func SpecTriangle;
+
/* Internal hooks, kept uptodate by the same mechanism as above.
*/
diff --git a/src/mesa/swrast/s_lines.c b/src/mesa/swrast/s_lines.c
index d448bd59e4e..af62dba3d99 100644
--- a/src/mesa/swrast/s_lines.c
+++ b/src/mesa/swrast/s_lines.c
@@ -1,4 +1,4 @@
-/* $Id: s_lines.c,v 1.10 2001/01/23 23:39:37 brianp Exp $ */
+/* $Id: s_lines.c,v 1.11 2001/02/16 18:14:41 keithw Exp $ */
/*
* Mesa 3-D graphics library
@@ -26,6 +26,7 @@
#include "glheader.h"
+#include "colormac.h"
#include "macros.h"
#include "mmath.h"
#include "s_aaline.h"
@@ -909,6 +910,22 @@ static void flat_multitextured_line( GLcontext *ctx,
}
+void _swrast_add_spec_terms_line( GLcontext *ctx,
+ const SWvertex *v0,
+ const SWvertex *v1 )
+{
+ SWvertex *ncv0 = (SWvertex *)v0;
+ SWvertex *ncv1 = (SWvertex *)v1;
+ GLchan c[2][4];
+ COPY_CHAN4( c[0], ncv0->color );
+ COPY_CHAN4( c[1], ncv1->color );
+ ACC_3V( ncv0->color, ncv0->specular );
+ ACC_3V( ncv1->color, ncv1->specular );
+ SWRAST_CONTEXT(ctx)->SpecLine( ctx, ncv0, ncv1 );
+ COPY_CHAN4( ncv0->color, c[0] );
+ COPY_CHAN4( ncv1->color, c[1] );
+}
+
#ifdef DEBUG
extern void
@@ -978,9 +995,8 @@ _swrast_choose_line( GLcontext *ctx )
ASSERT(swrast->Triangle);
}
else if (ctx->Texture._ReallyEnabled) {
- if (swrast->_MultiTextureEnabled
- || ctx->Light.Model.ColorControl==GL_SEPARATE_SPECULAR_COLOR
- || ctx->Fog.ColorSumEnabled) {
+ if (swrast->_MultiTextureEnabled ||
+ (ctx->_TriangleCaps & DD_SEPERATE_SPECULAR)) {
/* multi-texture and/or separate specular color */
if (ctx->Light.ShadeModel==GL_SMOOTH)
swrast->Line = smooth_multitextured_line;
diff --git a/src/mesa/swrast/s_lines.h b/src/mesa/swrast/s_lines.h
index ea660f69f05..110f536c488 100644
--- a/src/mesa/swrast/s_lines.h
+++ b/src/mesa/swrast/s_lines.h
@@ -1,4 +1,4 @@
-/* $Id: s_lines.h,v 1.3 2000/11/22 07:32:18 joukj Exp $ */
+/* $Id: s_lines.h,v 1.4 2001/02/16 18:14:41 keithw Exp $ */
/*
* Mesa 3-D graphics library
@@ -33,5 +33,10 @@
void
_swrast_choose_line( GLcontext *ctx );
+void
+_swrast_add_spec_terms_line( GLcontext *ctx,
+ const SWvertex *v0,
+ const SWvertex *v1 );
+
#endif
diff --git a/src/mesa/swrast/s_points.c b/src/mesa/swrast/s_points.c
index bb5de30975b..85001291e4d 100644
--- a/src/mesa/swrast/s_points.c
+++ b/src/mesa/swrast/s_points.c
@@ -1,4 +1,4 @@
-/* $Id: s_points.c,v 1.12 2001/01/23 23:39:37 brianp Exp $ */
+/* $Id: s_points.c,v 1.13 2001/02/16 18:14:41 keithw Exp $ */
/*
* Mesa 3-D graphics library
@@ -26,6 +26,7 @@
#include "glheader.h"
+#include "colormac.h"
#include "context.h"
#include "macros.h"
#include "mmath.h"
@@ -158,6 +159,18 @@
+void _swrast_add_spec_terms_point( GLcontext *ctx,
+ const SWvertex *v0 )
+{
+ SWvertex *ncv0 = (SWvertex *)v0;
+ GLchan c[1][4];
+ COPY_CHAN4( c[0], ncv0->color );
+ ACC_3V( ncv0->color, ncv0->specular );
+ SWRAST_CONTEXT(ctx)->SpecPoint( ctx, ncv0 );
+ COPY_CHAN4( ncv0->color, c[0] );
+}
+
+
/* record the current point function name */
#ifdef DEBUG
@@ -263,3 +276,4 @@ _swrast_choose_point( GLcontext *ctx )
USE(gl_select_point);
}
}
+
diff --git a/src/mesa/swrast/s_points.h b/src/mesa/swrast/s_points.h
index ead900f0165..1dd78cb8645 100644
--- a/src/mesa/swrast/s_points.h
+++ b/src/mesa/swrast/s_points.h
@@ -1,4 +1,4 @@
-/* $Id: s_points.h,v 1.3 2000/11/22 07:32:18 joukj Exp $ */
+/* $Id: s_points.h,v 1.4 2001/02/16 18:14:41 keithw Exp $ */
/*
* Mesa 3-D graphics library
@@ -33,5 +33,8 @@
void
_swrast_choose_point( GLcontext *ctx );
+void
+_swrast_add_spec_terms_point( GLcontext *ctx,
+ const SWvertex *v0 );
#endif
diff --git a/src/mesa/swrast/s_triangle.c b/src/mesa/swrast/s_triangle.c
index 9f3f2fe54b1..411c241684a 100644
--- a/src/mesa/swrast/s_triangle.c
+++ b/src/mesa/swrast/s_triangle.c
@@ -1,4 +1,4 @@
-/* $Id: s_triangle.c,v 1.12 2001/02/07 18:44:55 brianp Exp $ */
+/* $Id: s_triangle.c,v 1.13 2001/02/16 18:14:41 keithw Exp $ */
/*
* Mesa 3-D graphics library
@@ -34,6 +34,7 @@
#include "glheader.h"
#include "context.h"
+#include "colormac.h"
#include "macros.h"
#include "mem.h"
#include "mmath.h"
@@ -2232,6 +2233,27 @@ static void occlusion_zless_triangle( GLcontext *ctx,
+void _swrast_add_spec_terms_triangle( GLcontext *ctx,
+ const SWvertex *v0,
+ const SWvertex *v1,
+ const SWvertex *v2 )
+{
+ SWvertex *ncv0 = (SWvertex *)v0; /* drop const qualifier */
+ SWvertex *ncv1 = (SWvertex *)v1;
+ SWvertex *ncv2 = (SWvertex *)v2;
+ GLchan c[3][4];
+ COPY_CHAN4( c[0], ncv0->color );
+ COPY_CHAN4( c[1], ncv1->color );
+ COPY_CHAN4( c[2], ncv2->color );
+ ACC_3V( ncv0->color, ncv0->specular );
+ ACC_3V( ncv1->color, ncv1->specular );
+ ACC_3V( ncv2->color, ncv2->specular );
+ SWRAST_CONTEXT(ctx)->SpecTriangle( ctx, ncv0, ncv1, ncv2 );
+ COPY_CHAN4( ncv0->color, c[0] );
+ COPY_CHAN4( ncv1->color, c[1] );
+ COPY_CHAN4( ncv2->color, c[2] );
+}
+
#if 0
@@ -2358,9 +2380,7 @@ _swrast_choose_triangle( GLcontext *ctx )
swrast->Triangle = lambda_multitextured_triangle;
dputs("lambda_multitextured_triangle");
}
- else if ((ctx->Light.Enabled &&
- ctx->Light.Model.ColorControl==GL_SEPARATE_SPECULAR_COLOR)
- || ctx->Fog.ColorSumEnabled) {
+ else if (ctx->_TriangleCaps & DD_SEPERATE_SPECULAR) {
/* separate specular color interpolation */
if (needLambda) {
swrast->Triangle = lambda_textured_spec_triangle;
@@ -2387,8 +2407,8 @@ _swrast_choose_triangle( GLcontext *ctx )
if (ctx->Light.ShadeModel==GL_SMOOTH) {
/* smooth shaded, no texturing, stippled or some raster ops */
if (rgbmode) {
- dputs("smooth_rgba_triangle");
- swrast->Triangle = smooth_rgba_triangle;
+ dputs("smooth_rgba_triangle");
+ swrast->Triangle = smooth_rgba_triangle;
}
else {
dputs("smooth_ci_triangle");
@@ -2398,8 +2418,8 @@ _swrast_choose_triangle( GLcontext *ctx )
else {
/* flat shaded, no texturing, stippled or some raster ops */
if (rgbmode) {
- dputs("flat_rgba_triangle");
- swrast->Triangle = flat_rgba_triangle;
+ dputs("flat_rgba_triangle");
+ swrast->Triangle = flat_rgba_triangle;
}
else {
dputs("flat_ci_triangle");
diff --git a/src/mesa/swrast/s_triangle.h b/src/mesa/swrast/s_triangle.h
index c0064e8d46e..318b6a66716 100644
--- a/src/mesa/swrast/s_triangle.h
+++ b/src/mesa/swrast/s_triangle.h
@@ -1,4 +1,4 @@
-/* $Id: s_triangle.h,v 1.4 2000/11/22 07:32:18 joukj Exp $ */
+/* $Id: s_triangle.h,v 1.5 2001/02/16 18:14:41 keithw Exp $ */
/*
* Mesa 3-D graphics library
@@ -45,6 +45,12 @@ GLboolean gl_cull_triangle( GLcontext *ctx,
void
_swrast_choose_triangle( GLcontext *ctx );
+void
+_swrast_add_spec_terms_triangle( GLcontext *ctx,
+ const SWvertex *v0,
+ const SWvertex *v1,
+ const SWvertex *v2 );
+
#endif
diff --git a/src/mesa/swrast_setup/ss_context.c b/src/mesa/swrast_setup/ss_context.c
index 181be13f945..b15d7d98036 100644
--- a/src/mesa/swrast_setup/ss_context.c
+++ b/src/mesa/swrast_setup/ss_context.c
@@ -1,4 +1,4 @@
-/* $Id: ss_context.c,v 1.10 2001/02/16 00:35:35 keithw Exp $ */
+/* $Id: ss_context.c,v 1.11 2001/02/16 18:14:41 keithw Exp $ */
/*
* Mesa 3-D graphics library
@@ -152,17 +152,7 @@ _swsetup_RenderStart( GLcontext *ctx )
if (VB->ClipMask && VB->importable_data)
VB->import_data( ctx,
VB->importable_data,
- VEC_NOT_WRITEABLE|VEC_BAD_STRIDE);
-
- /* Ugly hack: Tie up some dangling pointers for flat/twoside code
- * in ss_tritmp.h and ss_interptmp.h
- */
- if ((ctx->_TriangleCaps & DD_SEPERATE_SPECULAR) == 0 ||
- ctx->Texture._ReallyEnabled == 0) {
- VB->SecondaryColorPtr[0] = VB->ColorPtr[0];
- VB->SecondaryColorPtr[1] = VB->ColorPtr[1];
- }
-
+ VEC_NOT_WRITEABLE|VEC_BAD_STRIDE);
}
void
diff --git a/src/mesa/swrast_setup/ss_vbtmp.h b/src/mesa/swrast_setup/ss_vbtmp.h
index ab5417ffe5b..6197f5bdb56 100644
--- a/src/mesa/swrast_setup/ss_vbtmp.h
+++ b/src/mesa/swrast_setup/ss_vbtmp.h
@@ -78,6 +78,14 @@ static void TAG(rs)(GLcontext *ctx, GLuint start, GLuint end, GLuint newinputs )
}
}
+ /* Tie up some dangling pointers for flat/twoside code in ss_tritmp.h
+ */
+ if ((ctx->_TriangleCaps & DD_SEPERATE_SPECULAR) == 0) {
+ VB->SecondaryColorPtr[0] = VB->ColorPtr[0];
+ VB->SecondaryColorPtr[1] = VB->ColorPtr[1];
+ }
+
+
proj = VB->ProjectedClipPtr->data;
if (IND & FOG)
fog = VB->FogCoordPtr->data;
diff --git a/src/mesa/tnl/t_vb_light.c b/src/mesa/tnl/t_vb_light.c
index 00beb531232..ce180880fb0 100644
--- a/src/mesa/tnl/t_vb_light.c
+++ b/src/mesa/tnl/t_vb_light.c
@@ -1,4 +1,4 @@
-/* $Id: t_vb_light.c,v 1.7 2001/02/16 00:35:35 keithw Exp $ */
+/* $Id: t_vb_light.c,v 1.8 2001/02/16 18:14:42 keithw Exp $ */
/*
* Mesa 3-D graphics library
@@ -174,8 +174,7 @@ static GLboolean run_validate_lighting( GLcontext *ctx,
if (ctx->Visual.rgbMode) {
if (ctx->Light._NeedVertices) {
- if (ctx->Light.Model.ColorControl == GL_SEPARATE_SPECULAR_COLOR &&
- ctx->Texture._ReallyEnabled)
+ if (ctx->Light.Model.ColorControl == GL_SEPARATE_SPECULAR_COLOR)
tab = _tnl_light_spec_tab;
else
tab = _tnl_light_tab;
@@ -271,8 +270,7 @@ static void check_lighting( GLcontext *ctx, struct gl_pipeline_stage *stage )
stage->inputs |= VERT_RGBA;
stage->outputs = VERT_RGBA;
- if (ctx->Light.Model.ColorControl == GL_SEPARATE_SPECULAR_COLOR &&
- ctx->Texture._ReallyEnabled)
+ if (ctx->Light.Model.ColorControl == GL_SEPARATE_SPECULAR_COLOR)
stage->outputs |= VERT_SPEC_RGB;
}
}
@@ -309,9 +307,8 @@ static void dtr( struct gl_pipeline_stage *stage )
const struct gl_pipeline_stage _tnl_lighting_stage =
{
"lighting",
- _NEW_LIGHT|_NEW_TEXTURE, /* recheck; texture for seperate_specular */
- _NEW_LIGHT|_NEW_MODELVIEW|
- _NEW_TEXTURE, /* recalc -- modelview dependency
+ _NEW_LIGHT, /* recheck */
+ _NEW_LIGHT|_NEW_MODELVIEW, /* recalc -- modelview dependency
* otherwise not captured by inputs
* (which may be VERT_OBJ) */
0,0,0, /* active, inputs, outputs */
diff --git a/src/mesa/tnl/t_vb_lighttmp.h b/src/mesa/tnl/t_vb_lighttmp.h
index 50bbedd8a0c..b9b50219b32 100644
--- a/src/mesa/tnl/t_vb_lighttmp.h
+++ b/src/mesa/tnl/t_vb_lighttmp.h
@@ -1,4 +1,4 @@
-/* $Id: t_vb_lighttmp.h,v 1.7 2001/02/16 00:35:35 keithw Exp $ */
+/* $Id: t_vb_lighttmp.h,v 1.8 2001/02/16 18:14:42 keithw Exp $ */
/*
* Mesa 3-D graphics library
@@ -524,19 +524,20 @@ static void TAG(light_fast_rgba_single)( GLcontext *ctx,
if (stage->changed_inputs == 0)
return;
- if ( CHECK_COLOR_MATERIAL(j) )
- gl_update_color_material( ctx, (GLchan *)CMcolor[j] );
+ do {
- if ( CHECK_MATERIAL(j) )
- gl_update_material( ctx, new_material[j], new_material_mask[j] );
+ if ( CHECK_COLOR_MATERIAL(j) )
+ gl_update_color_material( ctx, (GLchan *)CMcolor[j] );
+
+ if ( CHECK_MATERIAL(j) )
+ gl_update_material( ctx, new_material[j], new_material_mask[j] );
- if ( CHECK_VALIDATE(j) )
- gl_validate_all_lighting_tables( ctx );
+ if ( CHECK_VALIDATE(j) )
+ gl_validate_all_lighting_tables( ctx );
- baseubyte[0][3] = ctx->Light._BaseAlpha[0];
- baseubyte[1][3] = ctx->Light._BaseAlpha[1];
+ baseubyte[0][3] = ctx->Light._BaseAlpha[0];
+ baseubyte[1][3] = ctx->Light._BaseAlpha[1];
- do {
/* No attenuation, so incoporate _MatAmbient into base color.
*/
{
@@ -596,17 +597,6 @@ static void TAG(light_fast_rgba_single)( GLcontext *ctx,
STRIDE_F(normal, NSTRIDE);
}
- /* Have to recompute our base colors on material change.
- */
- if ( CHECK_MATERIAL(j) )
- gl_update_material( ctx, new_material[j], new_material_mask[j] );
-
- if ( CHECK_COLOR_MATERIAL(j) )
- gl_update_color_material( ctx, (GLchan *)CMcolor[j] );
-
- if ( CHECK_VALIDATE(j) )
- gl_validate_all_lighting_tables( ctx );
-
} while (!CHECK_END_VB(j));
}
@@ -651,19 +641,20 @@ static void TAG(light_fast_rgba)( GLcontext *ctx,
if (stage->changed_inputs == 0)
return;
- if ( CHECK_COLOR_MATERIAL(j) )
- gl_update_color_material( ctx, *CMcolor );
-
- if ( CHECK_MATERIAL(j) )
- gl_update_material( ctx, new_material[j], new_material_mask[j] );
-
- if ( CHECK_VALIDATE(j) )
- gl_validate_all_lighting_tables( ctx );
-
do {
do {
GLfloat sum[2][3];
+ if ( CHECK_COLOR_MATERIAL(j) )
+ gl_update_color_material( ctx, CMcolor[j] );
+
+ if ( CHECK_MATERIAL(j) )
+ gl_update_material( ctx, new_material[j], new_material_mask[j] );
+
+ if ( CHECK_VALIDATE(j) )
+ gl_validate_all_lighting_tables( ctx );
+
+
COPY_3V(sum[0], ctx->Light._BaseColor[0]);
if (IDX & LIGHT_TWOSIDE)
COPY_3V(sum[1], ctx->Light._BaseColor[1]);
@@ -721,15 +712,6 @@ static void TAG(light_fast_rgba)( GLcontext *ctx,
STRIDE_F(normal, NSTRIDE);
}
- if ( CHECK_COLOR_MATERIAL(j) )
- gl_update_color_material( ctx, CMcolor[j] );
-
- if ( CHECK_MATERIAL(j) )
- gl_update_material( ctx, new_material[j], new_material_mask[j] );
-
- if ( CHECK_VALIDATE(j) )
- gl_validate_all_lighting_tables( ctx );
-
} while (!CHECK_END_VB(j));
}
diff --git a/src/mesa/tnl/t_vb_render.c b/src/mesa/tnl/t_vb_render.c
index 9412a0fcb99..25e03a8c4e8 100644
--- a/src/mesa/tnl/t_vb_render.c
+++ b/src/mesa/tnl/t_vb_render.c
@@ -1,4 +1,4 @@
-/* $Id: t_vb_render.c,v 1.13 2001/02/16 00:35:35 keithw Exp $ */
+/* $Id: t_vb_render.c,v 1.14 2001/02/16 18:14:42 keithw Exp $ */
/*
* Mesa 3-D graphics library
@@ -63,18 +63,6 @@
-/* typedef void (*clip_line_func)( GLcontext *ctx, */
-/* GLuint i, GLuint j, */
-/* GLubyte mask); */
-
-/* typedef void (*clip_poly_func)( GLcontext *ctx, */
-/* GLuint n, GLuint vlist[], */
-/* GLubyte mask ); */
-
-
-
-
-
/**********************************************************************/
/* Clip single primitives */
/**********************************************************************/
@@ -184,7 +172,7 @@ do { \
#define TAG(x) clip_##x##_verts
#define INIT(x) ctx->Driver.RenderPrimitive( ctx, x )
#define RESET_STIPPLE if (stipple) ctx->Driver.ResetLineStipple( ctx )
-#define RESET_OCCLUSION ctx->OcclusionResult = GL_TRUE;
+#define RESET_OCCLUSION ctx->OcclusionResult = GL_TRUE
#define PRESERVE_VB_DEFS
#include "t_vb_rendertmp.h"
@@ -268,7 +256,7 @@ static void clip_elt_triangles( GLcontext *ctx,
(void) elt;
#define RESET_STIPPLE ctx->Driver.ResetLineStipple( ctx )
-#define RESET_OCCLUSION ctx->OcclusionResult = GL_TRUE;
+#define RESET_OCCLUSION ctx->OcclusionResult = GL_TRUE
#define INIT(x) ctx->Driver.RenderPrimitive( ctx, x )
#define RENDER_TAB_QUALIFIER
#define PRESERVE_VB_DEFS
@@ -337,8 +325,6 @@ static GLboolean run_render( GLcontext *ctx,
length= VB->PrimitiveLength[i];
ASSERT(length || (flags & PRIM_LAST));
ASSERT((flags & PRIM_MODE_MASK) <= GL_POLYGON+1);
-/* fprintf(stderr, "Render %s %d..%d\n", */
-/* _mesa_prim_name[flags&PRIM_MODE_MASK], i, i+length); */
if (length)
tab[flags & PRIM_MODE_MASK]( ctx, i, i + length, flags );
}