diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/mesa/drivers/common/t_dd_dmatmp.h | 258 | ||||
-rw-r--r-- | src/mesa/drivers/common/t_dd_tritmp.h | 2 | ||||
-rw-r--r-- | src/mesa/drivers/common/t_dd_vb.c | 222 | ||||
-rw-r--r-- | src/mesa/drivers/common/t_dd_vbtmp.h | 323 | ||||
-rw-r--r-- | src/mesa/drivers/common/t_dd_vertex.h | 70 |
5 files changed, 593 insertions, 282 deletions
diff --git a/src/mesa/drivers/common/t_dd_dmatmp.h b/src/mesa/drivers/common/t_dd_dmatmp.h index 38406e408d..15568ee659 100644 --- a/src/mesa/drivers/common/t_dd_dmatmp.h +++ b/src/mesa/drivers/common/t_dd_dmatmp.h @@ -39,14 +39,21 @@ * render the primitive natively. */ -#if !defined(HAVE_TRI_STRIPS) || !defined(HAVE_TRIANGLES) -#error "must have at least tristrips and triangles to use render template" +#if !defined(HAVE_TRIANGLES) +#error "must have at least triangles to use render template" #endif #if !HAVE_ELTS #define ALLOC_ELTS( nr ) #define EMIT_ELT( offset, elt ) #define INCR_ELTS( nr ) +#define ELT_INIT(prim) +#define GET_CURRENT_VB_MAX_ELTS() 0 +#define GET_SUBSEQUENT_VB_MAX_ELTS() 0 +#define ALLOC_ELTS_NEW_PRIMITIVE(nr) +#define RELEASE_ELT_VERTS() +#define EMIT_INDEXED_VERTS( ctx, start, count ) + #endif #ifndef EMIT_TWO_ELTS @@ -67,9 +74,12 @@ static GLboolean TAG(emit_elt_verts)( GLcontext *ctx, GLuint start, GLuint count ) { if (HAVE_ELTS) { + LOCAL_VARS; GLuint nr = count - start; - if ( nr >= GET_SUBSEQUENT_VB_MAX_VERTS() ) + if ( nr >= GET_SUBSEQUENT_VB_MAX_VERTS() ) /* assumes same packing for + * indexed and regualar verts + */ return GL_FALSE; NEW_PRIMITIVE(); /* finish last prim */ @@ -80,10 +90,11 @@ static GLboolean TAG(emit_elt_verts)( GLcontext *ctx, } } +#if (HAVE_ELTS) static void TAG(emit_elts)( GLcontext *ctx, GLuint *elts, GLuint nr ) { - GLushort *dest; GLint i; + LOCAL_VARS; ELTS_VARS; ALLOC_ELTS( nr ); @@ -93,6 +104,7 @@ static void TAG(emit_elts)( GLcontext *ctx, GLuint *elts, GLuint nr ) INCR_ELTS( 2 ); } } +#endif /*********************************************************************** @@ -107,6 +119,7 @@ static void TAG(render_points_verts)( GLcontext *ctx, GLuint flags ) { if (HAVE_POINTS) { + LOCAL_VARS; int dmasz = GET_SUBSEQUENT_VB_MAX_VERTS(); int currentsz = GET_CURRENT_VB_MAX_VERTS(); GLuint j, nr; @@ -122,7 +135,7 @@ static void TAG(render_points_verts)( GLcontext *ctx, currentsz = dmasz; } } else { - FALLBACK( ctx, start, count, flags ); + VERT_FALLBACK( ctx, start, count, flags ); } } @@ -132,6 +145,7 @@ static void TAG(render_lines_verts)( GLcontext *ctx, GLuint flags ) { if (HAVE_LINES) { + LOCAL_VARS; int dmasz = GET_SUBSEQUENT_VB_MAX_VERTS(); int currentsz = GET_CURRENT_VB_MAX_VERTS(); GLuint j, nr; @@ -153,7 +167,7 @@ static void TAG(render_lines_verts)( GLcontext *ctx, currentsz = dmasz; } } else { - FALLBACK( ctx, start, count, flags ); + VERT_FALLBACK( ctx, start, count, flags ); } } @@ -164,6 +178,7 @@ static void TAG(render_line_strip_verts)( GLcontext *ctx, GLuint flags ) { if (HAVE_LINE_STRIPS) { + LOCAL_VARS; int dmasz = GET_SUBSEQUENT_VB_MAX_VERTS(); int currentsz = GET_CURRENT_VB_MAX_VERTS(); GLuint j, nr; @@ -180,7 +195,7 @@ static void TAG(render_line_strip_verts)( GLcontext *ctx, currentsz = dmasz; } } else { - FALLBACK( ctx, start, count, flags ); + VERT_FALLBACK( ctx, start, count, flags ); } } @@ -191,6 +206,7 @@ static void TAG(render_line_loop_verts)( GLcontext *ctx, GLuint flags ) { if (HAVE_LINE_STRIPS) { + LOCAL_VARS; int dmasz = GET_SUBSEQUENT_VB_MAX_VERTS(); int currentsz = GET_CURRENT_VB_MAX_VERTS(); GLuint j, nr; @@ -221,7 +237,7 @@ static void TAG(render_line_loop_verts)( GLcontext *ctx, EMIT_VERTS( ctx, start, 1 ); } else { - FALLBACK( ctx, start, count, flags ); + VERT_FALLBACK( ctx, start, count, flags ); } } @@ -231,6 +247,7 @@ static void TAG(render_triangles_verts)( GLcontext *ctx, GLuint count, GLuint flags ) { + LOCAL_VARS; int dmasz = (GET_SUBSEQUENT_VB_MAX_VERTS()/3) * 3; int currentsz = (GET_CURRENT_VB_MAX_VERTS()/3) * 3; GLuint j, nr; @@ -259,37 +276,42 @@ static void TAG(render_tri_strip_verts)( GLcontext *ctx, 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 (HAVE_TRI_STRIPS) { + LOCAL_VARS; + 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--; + if (currentsz < 8) { + FIRE_VERTICES(); + currentsz = dmasz; } - } - /* From here on emit even numbers of tris when wrapping over buffers: - */ - dmasz -= (dmasz & 1); - currentsz -= (currentsz & 1); + if (flags & PRIM_PARITY) { + if (HAVE_TRI_STRIP_1 && 0) { + } else { + EMIT_VERTS( ctx, start, 1 ); + currentsz--; + } + } - for (j = start ; j < count - 2; j += nr - 2 ) { - nr = MIN2( currentsz, count - j ); - EMIT_VERTS( ctx, j, nr ); - currentsz = dmasz; + /* 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; + } + } else { + VERT_FALLBACK( ctx, start, count, flags ); } } @@ -298,7 +320,8 @@ static void TAG(render_tri_fan_verts)( GLcontext *ctx, GLuint count, GLuint flags ) { - if (HAVE_TRI_FAN) { + if (HAVE_TRI_FANS) { + LOCAL_VARS; GLuint j, nr; int dmasz = GET_SUBSEQUENT_VB_MAX_VERTS(); int currentsz = GET_CURRENT_VB_MAX_VERTS(); @@ -307,7 +330,7 @@ static void TAG(render_tri_fan_verts)( GLcontext *ctx, INIT(GL_TRIANGLE_FAN); if (currentsz < 8) { - FIRE_VERTICES( ctx ); + FIRE_VERTICES(); currentsz = dmasz; } @@ -322,7 +345,7 @@ static void TAG(render_tri_fan_verts)( GLcontext *ctx, /* Could write code to emit these as indexed vertices (for the * g400, for instance). */ - FALLBACK( ctx, start, count, flags ); + VERT_FALLBACK( ctx, start, count, flags ); } } @@ -332,7 +355,8 @@ static void TAG(render_poly_verts)( GLcontext *ctx, GLuint count, GLuint flags ) { - if (HAVE_POLYGON) { + if (HAVE_POLYGONS) { + LOCAL_VARS; GLuint j, nr; int dmasz = GET_SUBSEQUENT_VB_MAX_VERTS(); int currentsz = GET_CURRENT_VB_MAX_VERTS(); @@ -341,7 +365,7 @@ static void TAG(render_poly_verts)( GLcontext *ctx, INIT(GL_POLYGON); if (currentsz < 8) { - FIRE_VERTICES( ctx ); + FIRE_VERTICES(); currentsz = dmasz; } @@ -352,10 +376,10 @@ static void TAG(render_poly_verts)( GLcontext *ctx, currentsz = dmasz; } } - else if (HAVE_TRIFAN && !(ctx->TriangleCaps & DD_FLATSHADE)) { + else if (HAVE_TRI_FANS && !(ctx->_TriangleCaps & DD_FLATSHADE)) { TAG(render_tri_fan_verts)( ctx, start, count, flags ); } else { - FALLBACK( ctx, start, count, flags ); + VERT_FALLBACK( ctx, start, count, flags ); } } @@ -370,8 +394,9 @@ static void TAG(render_quad_strip_verts)( GLcontext *ctx, /* TODO. */ } else if (ctx->_TriangleCaps & DD_FLATSHADE) { - if (emit_elt_verts( ctx, start, count )) { - int dmasz = SUBSEQUENT_VB_ELT_NR(); + if (TAG(emit_elt_verts)( ctx, start, count )) { + LOCAL_VARS; + int dmasz = GET_SUBSEQUENT_VB_MAX_ELTS(); int currentsz; GLuint j, nr; @@ -380,7 +405,7 @@ static void TAG(render_quad_strip_verts)( GLcontext *ctx, NEW_PRIMITIVE(); ELT_INIT( GL_TRIANGLES ); - currentsz = CURRENT_VB_ELT_NR_NEW_PRIMITIVE(); + currentsz = GET_CURRENT_VB_MAX_ELTS(); /* Emit whole number of quads in total, and in each buffer. */ @@ -420,14 +445,15 @@ static void TAG(render_quad_strip_verts)( GLcontext *ctx, } else { /* Vertices won't fit in a single buffer or elts not available, - * fallback. + * VERT_FALLBACK. */ - FALLBACK( ctx, start, count, flags ); + VERT_FALLBACK( ctx, start, count, flags ); } } - else { - int dmasz = GET_SUBSEQUENT_VB_SIZE(); - int currentsz = GET_CURRENT_VB_SIZE(); + else if (HAVE_TRI_STRIPS) { + LOCAL_VARS; + int dmasz = GET_SUBSEQUENT_VB_MAX_VERTS(); + int currentsz = GET_CURRENT_VB_MAX_VERTS(); /* Emit smooth-shaded quadstrips as tristrips: */ @@ -441,7 +467,7 @@ static void TAG(render_quad_strip_verts)( GLcontext *ctx, count -= (count-start) & 1; if (currentsz < 8) { - FIRE_VERTICES( ctx ); + FIRE_VERTICES(); currentsz = dmasz; } @@ -450,6 +476,8 @@ static void TAG(render_quad_strip_verts)( GLcontext *ctx, EMIT_VERTS( ctx, j, nr ); currentsz = dmasz; } + } else { + VERT_FALLBACK( ctx, start, count, flags ); } } @@ -460,18 +488,19 @@ static void TAG(render_quads_verts)( GLcontext *ctx, GLuint flags ) { if (HAVE_QUADS && 0) { - } else if (emit_elt_verts( ctx, start, count )) { + } else if (TAG(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: */ + LOCAL_VARS; 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(); + currentsz = GET_CURRENT_VB_MAX_ELTS(); /* Emit whole number of quads in total, and in each buffer. */ @@ -514,7 +543,7 @@ static void TAG(render_quads_verts)( GLcontext *ctx, else { /* Vertices won't fit in a single buffer, fallback. */ - FALLBACK( ctx, start, count, flags ); + VERT_FALLBACK( ctx, start, count, flags ); } } @@ -528,8 +557,7 @@ static void TAG(render_noop)( GLcontext *ctx, -static void (*TAG(render_tab_verts))( GLcontext *, GLuint, - GLuint, GLuint)[GL_POLYGON+2] = +static render_func TAG(render_tab_verts)[GL_POLYGON+2] = { TAG(render_points_verts), TAG(render_lines_verts), @@ -556,6 +584,7 @@ static void TAG(render_points_elts)( GLcontext *ctx, GLuint flags ) { if (HAVE_POINTS) { + LOCAL_VARS; int dmasz = GET_SUBSEQUENT_VB_MAX_ELTS(); int currentsz; GLuint *elts = TNL_CONTEXT(ctx)->vb.Elts; @@ -569,7 +598,7 @@ static void TAG(render_points_elts)( GLcontext *ctx, for (j = start; j < count; j += nr ) { nr = MIN2( currentsz, count - j ); - emit_elts( ctx, elts+j, nr ); + TAG(emit_elts)( ctx, elts+j, nr ); NEW_PRIMITIVE(); currentsz = dmasz; } @@ -586,6 +615,7 @@ static void TAG(render_lines_elts)( GLcontext *ctx, GLuint flags ) { if (HAVE_LINES) { + LOCAL_VARS; int dmasz = GET_SUBSEQUENT_VB_MAX_ELTS(); int currentsz; GLuint *elts = TNL_CONTEXT(ctx)->vb.Elts; @@ -605,7 +635,7 @@ static void TAG(render_lines_elts)( GLcontext *ctx, for (j = start; j < count; j += nr ) { nr = MIN2( currentsz, count - j ); - emit_elts( ctx, elts+j, nr ); + TAG(emit_elts)( ctx, elts+j, nr ); NEW_PRIMITIVE(); currentsz = dmasz; } @@ -621,6 +651,7 @@ static void TAG(render_line_strip_elts)( GLcontext *ctx, GLuint flags ) { if (HAVE_LINE_STRIPS) { + LOCAL_VARS; int dmasz = GET_SUBSEQUENT_VB_MAX_ELTS(); int currentsz; GLuint *elts = TNL_CONTEXT(ctx)->vb.Elts; @@ -629,13 +660,13 @@ static void TAG(render_line_strip_elts)( GLcontext *ctx, NEW_PRIMITIVE(); /* always a new primitive */ ELT_INIT( GL_LINE_STRIP ); - currentsz = GET_CURRENT_VB_MAX_ELTS_NEW_PRIM(); + currentsz = GET_CURRENT_VB_MAX_ELTS(); 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 ); + TAG(emit_elts)( ctx, elts+j, nr ); NEW_PRIMITIVE(); currentsz = dmasz; } @@ -653,6 +684,7 @@ static void TAG(render_line_loop_elts)( GLcontext *ctx, GLuint flags ) { if (HAVE_LINE_STRIPS) { + LOCAL_VARS; int dmasz = GET_SUBSEQUENT_VB_MAX_ELTS(); int currentsz; GLuint *elts = TNL_CONTEXT(ctx)->vb.Elts; @@ -666,9 +698,9 @@ static void TAG(render_line_loop_elts)( GLcontext *ctx, else j = start + 1; - currentsz = GET_CURRENT_VB_MAX_ELTS_NEW_PRIM(); + currentsz = GET_CURRENT_VB_MAX_ELTS(); if (currentsz < 8) { - FIRE_VERTICES( ctx ); + FIRE_VERTICES(); currentsz = dmasz; } @@ -680,12 +712,12 @@ static void TAG(render_line_loop_elts)( GLcontext *ctx, for ( ; j < count - 1; j += nr - 1 ) { nr = MIN2( currentsz, count - j ); /* NEW_PRIMITIVE(); */ - emit_elts( ctx, elts+j, nr ); + TAG(emit_elts)( ctx, elts+j, nr ); currentsz = dmasz; } if (flags & PRIM_END) - emit_elts( ctx, elts+start, 1 ); + TAG(emit_elts)( ctx, elts+start, 1 ); NEW_PRIMITIVE(); } else { @@ -704,6 +736,7 @@ static void TAG(render_triangles_elts)( GLcontext *ctx, GLuint count, GLuint flags ) { + LOCAL_VARS; GLuint *elts = TNL_CONTEXT(ctx)->vb.Elts; int dmasz = GET_SUBSEQUENT_VB_MAX_ELTS()/3*3; int currentsz; @@ -712,7 +745,7 @@ static void TAG(render_triangles_elts)( GLcontext *ctx, NEW_PRIMITIVE(); ELT_INIT( GL_TRIANGLES ); - currentsz = GET_CURRENT_VB_MAX_ELTS_NEW_PRIM(); + currentsz = GET_CURRENT_VB_MAX_ELTS(); /* Emit whole number of tris in total. dmasz is already a multiple * of 3. @@ -724,7 +757,7 @@ static void TAG(render_triangles_elts)( GLcontext *ctx, for (j = start; j < count; j += nr) { nr = MIN2( currentsz, count - j ); - emit_elts( ctx, elts+j, nr ); + TAG(emit_elts)( ctx, elts+j, nr ); NEW_PRIMITIVE(); currentsz = dmasz; } @@ -737,34 +770,40 @@ static void TAG(render_tri_strip_elts)( GLcontext *ctx, 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); + if (HAVE_TRI_STRIPS) { + LOCAL_VARS; + GLuint j, nr; + GLuint *elts = TNL_CONTEXT(ctx)->vb.Elts; + int dmasz = GET_SUBSEQUENT_VB_MAX_ELTS(); + int currentsz; - for (j = start ; j < count - 2; j += nr - 2 ) { - nr = MIN2( currentsz, count - j ); - emit_elts( ctx, elts+j, nr ); NEW_PRIMITIVE(); - currentsz = dmasz; + ELT_INIT( GL_TRIANGLE_STRIP ); + + currentsz = GET_CURRENT_VB_MAX_ELTS(); + if (currentsz < 8) { + FIRE_VERTICES(); + currentsz = dmasz; + } + + if (flags & PRIM_PARITY) { + TAG(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 ); + TAG(emit_elts)( ctx, elts+j, nr ); + NEW_PRIMITIVE(); + currentsz = dmasz; + } + } else { + /* TODO: try to emit as indexed triangles */ + ELT_FALLBACK( ctx, start, count, flags ); } } @@ -773,7 +812,8 @@ static void TAG(render_tri_fan_elts)( GLcontext *ctx, GLuint count, GLuint flags ) { - if (HAVE_TRI_FAN) { + if (HAVE_TRI_FANS) { + LOCAL_VARS; GLuint *elts = TNL_CONTEXT(ctx)->vb.Elts; GLuint j, nr; int dmasz = GET_SUBSEQUENT_VB_MAX_ELTS(); @@ -782,16 +822,16 @@ static void TAG(render_tri_fan_elts)( GLcontext *ctx, NEW_PRIMITIVE(); ELT_INIT( GL_TRIANGLE_FAN ); - currentsz = GET_CURRENT_VB_MAX_ELTS_NEW_PRIM(); + currentsz = GET_CURRENT_VB_MAX_ELTS(); if (currentsz < 8) { - FIRE_VERTICES( ctx ); + FIRE_VERTICES(); 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 ); + TAG(emit_elts)( ctx, elts+start, 1 ); + TAG(emit_elts)( ctx, elts+j, nr - 1 ); NEW_PRIMITIVE(); currentsz = dmasz; } @@ -807,8 +847,9 @@ static void TAG(render_poly_elts)( GLcontext *ctx, GLuint count, GLuint flags ) { - if (HAVE_POLYGON && 0) { - } else if (HAVE_TRI_FAN && !(ctx->_TriangleCaps & DD_FLATSHADE)) { + if (HAVE_POLYGONS && 0) { + } else if (HAVE_TRI_FANS && !(ctx->_TriangleCaps & DD_FLATSHADE)) { + LOCAL_VARS; GLuint *elts = TNL_CONTEXT(ctx)->vb.Elts; GLuint j, nr; int dmasz = GET_SUBSEQUENT_VB_MAX_ELTS(); @@ -817,16 +858,16 @@ static void TAG(render_poly_elts)( GLcontext *ctx, NEW_PRIMITIVE(); ELT_INIT( GL_TRIANGLE_FAN ); - currentsz = GET_CURRENT_VB_MAX_ELTS_NEW_PRIM(); + currentsz = GET_CURRENT_VB_MAX_ELTS(); if (currentsz < 8) { - FIRE_VERTICES( ctx ); + FIRE_VERTICES(); 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 ); + TAG(emit_elts)( ctx, elts+start, 1 ); + TAG(emit_elts)( ctx, elts+j, nr - 1 ); NEW_PRIMITIVE(); currentsz = dmasz; } @@ -842,13 +883,14 @@ static void TAG(render_quad_strip_elts)( GLcontext *ctx, { if (HAVE_QUAD_STRIPS && 0) { } else { + LOCAL_VARS; 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(); + currentsz = GET_CURRENT_VB_MAX_ELTS(); /* Emit whole number of quads in total, and in each buffer. */ @@ -896,7 +938,7 @@ static void TAG(render_quad_strip_elts)( GLcontext *ctx, for (j = start; j < count - 3; j += nr - 2 ) { nr = MIN2( currentsz, count - j ); - emit_elts( ctx, elts+j, nr ); + TAG(emit_elts)( ctx, elts+j, nr ); NEW_PRIMITIVE(); currentsz = dmasz; } @@ -912,13 +954,14 @@ static void TAG(render_quads_elts)( GLcontext *ctx, { if (HAVE_QUADS && 0) { } else { + LOCAL_VARS; 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(); + currentsz = GET_CURRENT_VB_MAX_ELTS(); /* Emit whole number of quads in total, and in each buffer. */ @@ -961,8 +1004,7 @@ static void TAG(render_quads_elts)( GLcontext *ctx, -static void (*TAG(render_tab_verts))( GLcontext *, GLuint, - GLuint, GLuint)[GL_POLYGON+2] = +static render_func TAG(render_tab_elts)[GL_POLYGON+2] = { TAG(render_points_elts), TAG(render_lines_elts), diff --git a/src/mesa/drivers/common/t_dd_tritmp.h b/src/mesa/drivers/common/t_dd_tritmp.h index 7cd7c756f9..7f573a5abc 100644 --- a/src/mesa/drivers/common/t_dd_tritmp.h +++ b/src/mesa/drivers/common/t_dd_tritmp.h @@ -88,6 +88,8 @@ static void TAG(triangle)( GLcontext *ctx, GLuint e0, GLuint e1, GLuint e2 ) GLuint facing; LOCAL_VARS(3); +/* fprintf(stderr, "%s\n", __FUNCTION__); */ + v[0] = (VERTEX *)GET_VERTEX(e0); v[1] = (VERTEX *)GET_VERTEX(e1); v[2] = (VERTEX *)GET_VERTEX(e2); diff --git a/src/mesa/drivers/common/t_dd_vb.c b/src/mesa/drivers/common/t_dd_vb.c index 1841346985..7b6f3bd25f 100644 --- a/src/mesa/drivers/common/t_dd_vb.c +++ b/src/mesa/drivers/common/t_dd_vb.c @@ -1,4 +1,224 @@ - /* + * 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 <keithw@valinux.com> + */ + +#if (HAVE_HW_VIEWPORT) +#define UNVIEWPORT_VARS +#define UNVIEWPORT_X(x) x +#define UNVIEWPORT_Y(x) x +#define UNVIEWPORT_Z(x) x +#endif + +/* These don't need to be duplicated, but there's currently nowhere + * really convenient to put them. Need to build some actual .o files in + * this directory? */ +static void copy_pv_rgba4_spec5( GLcontext *ctx, GLuint edst, GLuint esrc ) +{ + GLubyte *verts = GET_VERTEX_STORE(); + GLuint shift = GET_VERTEX_STRIDE_SHIFT(); + GLuint *dst = (GLuint *)(verts + (edst << shift)); + GLuint *src = (GLuint *)(verts + (esrc << shift)); + dst[4] = src[4]; + dst[5] = src[5]; +} + +static void copy_pv_rgba4( GLcontext *ctx, GLuint edst, GLuint esrc ) +{ + GLubyte *verts = GET_VERTEX_STORE(); + GLuint shift = GET_VERTEX_STRIDE_SHIFT(); + GLuint *dst = (GLuint *)(verts + (edst << shift)); + GLuint *src = (GLuint *)(verts + (esrc << shift)); + dst[4] = src[4]; +} + +static void copy_pv_rgba3( GLcontext *ctx, GLuint edst, GLuint esrc ) +{ + GLubyte *verts = GET_VERTEX_STORE(); + GLuint shift = GET_VERTEX_STRIDE_SHIFT(); + GLuint *dst = (GLuint *)(verts + (edst << shift)); + GLuint *src = (GLuint *)(verts + (esrc << shift)); + dst[3] = src[3]; +} + + +void TAG(translate_vertex)(GLcontext *ctx, + const VERTEX *src, + SWvertex *dst) +{ + GLuint format = GET_VERTEX_FORMAT(); + GLfloat *s = ctx->Viewport._WindowMap.m; + UNVIEWPORT_VARS; + + if (format == TINY_VERTEX_FORMAT) { + dst->win[0] = s[0] * src->v.x + s[12]; + dst->win[1] = s[5] * src->v.y + s[13]; + dst->win[2] = s[10] * src->v.z + s[14]; + 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 { + GLfloat oow = (HAVE_HW_DIVIDE) ? 1.0 / src->v.w : src->v.w; + + if (HAVE_HW_VIEWPORT) { + dst->win[0] = s[0] * src->v.x * oow + s[12]; + dst->win[1] = s[5] * src->v.y * oow + s[13]; + dst->win[2] = s[10] * src->v.z * oow + s[14]; + dst->win[3] = oow; + } else { + dst->win[0] = UNVIEWPORT_X( src->v.x ); + dst->win[1] = UNVIEWPORT_Y( src->v.y ); + dst->win[2] = UNVIEWPORT_Z( src->v.z ); + dst->win[3] = 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; + + dst->specular[0] = src->v.specular.red; + dst->specular[1] = src->v.specular.green; + dst->specular[2] = src->v.specular.blue; + + dst->fog = src->v.color.alpha/255.0; + + if (HAVE_PTEX_VERTICES && + ((HAVE_TEX2_VERTICES && format == PROJ_TEX3_VERTEX_FORMAT) || + (format == PROJ_TEX1_VERTEX_FORMAT))) { + + 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; + + if (HAVE_TEX2_VERTICES) { + dst->texcoord[2][0] = src->pv.u2; + dst->texcoord[2][1] = src->pv.v2; + dst->texcoord[2][3] = src->pv.q2; + } + + if (HAVE_TEX3_VERTICES) { + dst->texcoord[3][0] = src->pv.u3; + dst->texcoord[3][1] = src->pv.v3; + dst->texcoord[3][3] = src->pv.q3; + } + } + else { + dst->texcoord[0][0] = src->v.u0; + dst->texcoord[0][1] = src->v.v0; + dst->texcoord[0][3] = 1.0; + + dst->texcoord[1][0] = src->v.u1; + dst->texcoord[1][1] = src->v.v1; + dst->texcoord[1][3] = 1.0; + + if (HAVE_TEX2_VERTICES) { + dst->texcoord[2][0] = src->v.u2; + dst->texcoord[2][1] = src->v.v2; + dst->texcoord[2][3] = 1.0; + } + + if (HAVE_TEX3_VERTICES) { + dst->texcoord[3][0] = src->v.u3; + dst->texcoord[3][1] = src->v.v3; + dst->texcoord[3][3] = 1.0; + } + } + } + + dst->pointSize = ctx->Point._Size; +} + +#if 0 +static void +mga_translate_vertex( GLcontext *ctx, const mgaVertex *src, SWvertex *dst) +{ + mgaContextPtr mmesa = MGA_CONTEXT(ctx); + + dst->win[0] = src->v.x - mmesa->drawX - SUBPIXEL_X; + dst->win[1] = - src->v.y + mmesa->driDrawable->h + mmesa->drawY + SUBPIXEL_Y; + dst->win[2] = src->v.z / mmesa->depth_scale; + 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 (mmesa->tmu_source[0] == 0) { + dst->texcoord[0][0] = src->v.tu0; + dst->texcoord[0][1] = src->v.tv0; + dst->texcoord[0][3] = 1.0; + } else { + dst->texcoord[1][0] = src->v.tu0; + dst->texcoord[1][1] = src->v.tv0; + dst->texcoord[1][3] = 1.0; + } + + dst->texcoord[1][0] = src->v.tu1; + dst->texcoord[1][1] = src->v.tv1; + dst->texcoord[1][3] = 1.0; + + dst->pointSize = ctx->Point._Size; +} +#endif + + +void TAG(print_vertex)( GLcontext *ctx, const VERTEX *v ) +{ + GLuint format = GET_VERTEX_FORMAT(); + + if (format == TINY_VERTEX_FORMAT) { + fprintf(stderr, "x %f y %f z %f\n", v->v.x, v->v.y, v->v.z); + fprintf(stderr, "r %d g %d b %d a %d\n", + v->tv.color.red, + v->tv.color.green, + v->tv.color.blue, + v->tv.color.alpha); + } + else { + fprintf(stderr, "x %f y %f z %f oow %f\n", + v->v.x, v->v.y, v->v.z, v->v.w); + fprintf(stderr, "r %d g %d b %d a %d\n", + v->v.color.red, + v->v.color.green, + v->v.color.blue, + v->v.color.alpha); + } + + fprintf(stderr, "\n"); +} + +#undef TAG diff --git a/src/mesa/drivers/common/t_dd_vbtmp.h b/src/mesa/drivers/common/t_dd_vbtmp.h index 4490f099b7..4e769c48ac 100644 --- a/src/mesa/drivers/common/t_dd_vbtmp.h +++ b/src/mesa/drivers/common/t_dd_vbtmp.h @@ -70,8 +70,7 @@ * DO_TEX3: Emit tex3 u,v coordinates. * DO_PTEX: Emit tex0,1,2,3 q coordinates where possible. * - * HAVE_RGBA_COLOR: Hardware takes color in rgba order. - * HAVE_BGRA_COLOR: Hardware takes color in bgra order. + * HAVE_RGBA_COLOR: Hardware takes color in rgba order (else bgra). * * HAVE_HW_VIEWPORT: Hardware performs viewport transform. * HAVE_HW_DIVIDE: Hardware performs perspective divide. @@ -91,16 +90,20 @@ */ #if (HAVE_HW_VIEWPORT) -#define VIEWPORT_X(x) x -#define VIEWPORT_Y(x) x -#define VIEWPORT_Z(x) x +#define VIEWPORT_X(dst,x) dst = x +#define VIEWPORT_Y(dst,y) dst = y +#define VIEWPORT_Z(dst,z) dst = z #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]) +#define VIEWPORT_X(dst,x) dst = s[0] * x + s[12] +#define VIEWPORT_Y(dst,y) dst = s[5] * y + s[13] +#define VIEWPORT_Z(dst,z) dst = s[10] * z + s[14] #endif -#if (HAVE_HW_DIVIDE || DO_RGBA || DO_XYZW || !HAVE_TINY_VERTICES) +#if (HAVE_HW_DIVIDE && !HAVE_PTEX_VERTICES) +#error "can't cope with this combination" +#endif + +#if (HAVE_HW_DIVIDE || DO_SPEC || DO_TEX0 || DO_FOG || !HAVE_TINY_VERTICES) static void TAG(emit)( GLcontext *ctx, GLuint start, GLuint end, @@ -109,15 +112,21 @@ static void TAG(emit)( GLcontext *ctx, { struct vertex_buffer *VB = &TNL_CONTEXT(ctx)->vb; GLfloat (*tc0)[4], (*tc1)[4], *fog; + GLfloat (*tc2)[4], (*tc3)[4]; GLubyte (*col)[4], (*spec)[4]; GLuint tc0_stride, tc1_stride, col_stride, spec_stride, fog_stride; + GLuint tc2_stride, tc3_stride; GLuint tc0_size, tc1_size; + GLuint tc2_size, tc3_size; GLfloat (*coord)[4]; GLuint coord_stride; VERTEX *v = (VERTEX *)dest; const GLfloat *s = GET_VIEWPORT_MAT(); + const GLubyte *mask = VB->ClipMask; int i; +/* fprintf(stderr, "%s\n", __FUNCTION__); */ + if (HAVE_HW_VIEWPORT && HAVE_HW_DIVIDE) { (void) s; coord = VB->ClipPtr->data; @@ -128,52 +137,58 @@ static void TAG(emit)( GLcontext *ctx, 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_TEX3) { + const GLuint t3 = GET_TEXSOURCE(3); - if (DO_TEX1) { - if (VB->TexCoordPtr[0] == 0) - VB->TexCoordPtr[0] = VB->TexCoordPtr[1]; - - tc1 = VB->TexCoordPtr[1]->data; - tc1_stride = VB->TexCoordPtr[1]->stride; + if (VB->TexCoordPtr[2] == 0) { + if (VB->TexCoordPtr[1] == 0) { + if (VB->TexCoordPtr[0] == 0) + VB->TexCoordPtr[0] = VB->TexCoordPtr[t3]; + VB->TexCoordPtr[1] = VB->TexCoordPtr[t3]; + } + VB->TexCoordPtr[2] = VB->TexCoordPtr[t3]; + } + + tc3 = VB->TexCoordPtr[t3]->data; + tc3_stride = VB->TexCoordPtr[t3]->stride; if (DO_PTEX) - tc1_size = VB->TexCoordPtr[1]->size; + tc3_size = VB->TexCoordPtr[t3]->size; } if (DO_TEX2) { + const GLuint t2 = GET_TEXSOURCE(2); + if (VB->TexCoordPtr[1] == 0) { if (VB->TexCoordPtr[0] == 0) - VB->TexCoordPtr[0] = VB->TexCoordPtr[2]; - VB->TexCoordPtr[1] = VB->TexCoordPtr[2]; + VB->TexCoordPtr[0] = VB->TexCoordPtr[t2]; + VB->TexCoordPtr[1] = VB->TexCoordPtr[t2]; } - tc2 = VB->TexCoordPtr[2]->data; - tc2_stride = VB->TexCoordPtr[2]->stride; + tc2 = VB->TexCoordPtr[t2]->data; + tc2_stride = VB->TexCoordPtr[t2]->stride; if (DO_PTEX) - tc2_size = VB->TexCoordPtr[2]->size; + tc2_size = VB->TexCoordPtr[t2]->size; } - if (DO_TEX3) { - if (VB->TexCoordPtr[2] == 0) { - if (VB->TexCoordPtr[1] == 0) { - if (VB->TexCoordPtr[0] == 0) - VB->TexCoordPtr[0] = VB->TexCoordPtr[3]; - VB->TexCoordPtr[1] = VB->TexCoordPtr[3]; - } - VB->TexCoordPtr[2] = VB->TexCoordPtr[3]; - } - tc3 = VB->TexCoordPtr[3]->data; - tc3_stride = VB->TexCoordPtr[3]->stride; + if (DO_TEX1) { + const GLuint t1 = GET_TEXSOURCE(1); + if (VB->TexCoordPtr[0] == 0) + VB->TexCoordPtr[0] = VB->TexCoordPtr[t1]; + tc1 = VB->TexCoordPtr[1]->data; + tc1_stride = VB->TexCoordPtr[1]->stride; if (DO_PTEX) - tc3_size = VB->TexCoordPtr[3]->size; + tc1_size = VB->TexCoordPtr[1]->size; } - + + if (DO_TEX0) { + const GLuint t0 = GET_TEXSOURCE(0); + tc0_stride = VB->TexCoordPtr[t0]->stride; + tc0 = VB->TexCoordPtr[t0]->data; + if (DO_PTEX) + tc0_size = VB->TexCoordPtr[t0]->size; + } + if (DO_RGBA) { col = VB->ColorPtr[0]->data; col_stride = VB->ColorPtr[0]->stride; @@ -210,17 +225,16 @@ static void TAG(emit)( GLcontext *ctx, STRIDE_F(fog, start * fog_stride); } - for (i=start; i < end; i++, v = (ddVertex *)((GLubyte *)v + stride)) { + for (i=start; i < end; i++, v = (VERTEX *)((GLubyte *)v + stride)) { if (DO_XYZW) { if (HAVE_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]); + v->v.w = coord[0][3]; } coord = (GLfloat (*)[4])((GLubyte *)coord + coord_stride); } - NOTE_W; if (DO_RGBA) { if (HAVE_RGBA_COLOR) { *(GLuint *)&v->v.color = *(GLuint *)&col[0]; @@ -244,20 +258,20 @@ static void TAG(emit)( GLcontext *ctx, STRIDE_F(fog, fog_stride); } if (DO_TEX0) { - v->v.tu0 = tc0[0][0]; - v->v.tv0 = tc0[0][1]; + v->v.u0 = tc0[0][0]; + v->v.v0 = tc0[0][1]; if (DO_PTEX) { if (HAVE_PTEX_VERTICES) { if (tc0_size == 4) - v->pv.tq0 = tc0[0][3]; + v->pv.q0 = tc0[0][3]; else - v->pv.tq0 = 1.0; + v->pv.q0 = 1.0; } 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; + v->v.u0 *= rhw; + v->v.v0 *= rhw; } } tc0 = (GLfloat (*)[4])((GLubyte *)tc0 + tc0_stride); @@ -313,16 +327,15 @@ static void TAG(emit)( GLcontext *ctx, } } else { - for (i=start; i < end; i++, v = (ddVertex *)((GLubyte *)v + stride)) { + for (i=start; i < end; i++, v = (VERTEX *)((GLubyte *)v + stride)) { if (DO_XYZW) { if (HAVE_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]); + v->v.w = coord[i][3]; } } - NOTE_W; if (DO_RGBA) { if (HAVE_RGBA_COLOR) { *(GLuint *)&v->v.color = *(GLuint *)&col[i]; @@ -348,9 +361,9 @@ static void TAG(emit)( GLcontext *ctx, v->pv.v0 = tc0[i][1]; if (HAVE_PTEX_VERTICES) { if (tc0_size == 4) - v->pv.tq0 = tc0[i][3]; + v->pv.q0 = tc0[i][3]; else - v->pv.tq0 = 1.0; + v->pv.q0 = 1.0; v->pv.q1 = 0; /* radeon */ } @@ -388,6 +401,12 @@ static void TAG(emit)( GLcontext *ctx, } } #else +#if DO_XYZW + +#if HAVE_HW_DIVIDE +#error "cannot use tiny vertices with hw perspective divide" +#endif + static void TAG(emit)( GLcontext *ctx, GLuint start, GLuint end, void *dest, GLuint stride ) { @@ -397,8 +416,14 @@ static void TAG(emit)( GLcontext *ctx, GLuint start, GLuint end, GLfloat (*coord)[4] = VB->ProjectedClipPtr->data; GLuint coord_stride = VB->ProjectedClipPtr->stride; GLfloat *v = (GLfloat *)dest; + const GLubyte *mask = VB->ClipMask; + const GLfloat *s = GET_VIEWPORT_MAT(); int i; + (void) s; + +/* fprintf(stderr, "%s (template 2)\n", __FUNCTION__); */ + ASSERT(stride == 4); /* Pack what's left into a 4-dword vertex. Color is in a different @@ -412,9 +437,9 @@ static void TAG(emit)( GLcontext *ctx, GLuint start, GLuint end, for (i=start; i < end; i++, v+=4) { if (HAVE_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]); + VIEWPORT_X(v[0], coord[0][0]); + VIEWPORT_Y(v[1], coord[0][1]); + VIEWPORT_Z(v[2], coord[0][2]); } coord = (GLfloat (*)[4])((GLubyte *)coord + coord_stride); if (DO_RGBA) { @@ -435,9 +460,9 @@ static void TAG(emit)( GLcontext *ctx, GLuint start, GLuint end, else { for (i=start; i < end; i++, v+=4) { if (HAVE_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]); + VIEWPORT_X(v[0], coord[i][0]); + VIEWPORT_Y(v[1], coord[i][1]); + VIEWPORT_Z(v[2], coord[i][2]); } if (DO_RGBA) { if (HAVE_RGBA_COLOR) { @@ -454,7 +479,42 @@ static void TAG(emit)( GLcontext *ctx, GLuint start, GLuint end, } } } -#endif +#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 *v = (GLfloat *)dest; + int i; + + if (start) + STRIDE_4UB(col, col_stride * start); + + /* Need to figure out where color is: + */ + if (GET_VERTEX_FORMAT() == TINY_VERTEX_FORMAT) + v += 3; + else + v += 4; + + for (i=start; i < end; i++, STRIDE_F(v, stride)) { + if (HAVE_RGBA_COLOR) { + *(GLuint *)v = *(GLuint *)col[0]; + } + else { + GLubyte *b = (GLubyte *)v; + 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 ); + } +} +#endif /* emit */ +#endif /* emit */ #if (DO_XYZW) && (DO_RGBA) @@ -501,10 +561,9 @@ static GLboolean TAG(check_tex_sizes)( GLcontext *ctx ) return GL_TRUE; } -#endif +#endif /* ptex */ -#if (!DO_PTEX || HAVE_PTEX_VERTICES) static void TAG(interp)( GLcontext *ctx, GLfloat t, GLuint edst, GLuint eout, GLuint ein, @@ -517,14 +576,11 @@ static void TAG(interp)( GLcontext *ctx, GLfloat w; const GLfloat *s = GET_VIEWPORT_MAT(); - (void)s; - VERTEX *dst = (VERTEX *)(ddverts + (edst << shift)); VERTEX *in = (VERTEX *)(ddverts + (eout << shift)); VERTEX *out = (VERTEX *)(ddverts + (ein << shift)); - PREPARE_PROJIN; - PREPARE_PROJOUT; + (void)s; /* fprintf(stderr, "%s\n", __FUNCTION__); */ @@ -561,10 +617,29 @@ static void TAG(interp)( GLcontext *ctx, 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 ); + if (DO_PTEX) { + if (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 { + GLfloat wout = VB->ProjectedClipPtr->data[eout][3]; + GLfloat win = VB->ProjectedClipPtr->data[ein][3]; + GLfloat qout = out->pv.w / wout; + GLfloat qin = in->pv.w / win; + GLfloat qdst, rqdst; + + ASSERT( !HAVE_HW_DIVIDE ); + + INTERP_F( t, dst->v.u0, out->v.u0 * qout, in->v.u0 * qin ); + INTERP_F( t, dst->v.v0, out->v.v0 * qout, in->v.v0 * qin ); + INTERP_F( t, qdst, qout, qin ); + + rqdst = 1.0 / qdst; + dst->v.u0 *= rqdst; + dst->v.v0 *= rqdst; + dst->v.w *= rqdst; + } } else { INTERP_F( t, dst->v.u0, out->v.u0, in->v.u0 ); @@ -613,105 +688,8 @@ static void TAG(interp)( GLcontext *ctx, INTERP_UB( t, dst->ub4[3][3], out->ub4[3][3], in->ub4[3][3] ); } } -#endif -/* Build an SWvertex from a hardware vertex. - * - * This code is hit only when a mix of accelerated and unaccelerated - * primitives are being drawn, and only for the unaccelerated - * primitives. - */ -static void -TAG(translate_vertex)( GLcontext *ctx, const radeonVertex *src, SWvertex *dst) -{ - HW_CONTEXT; - GLfloat *s = ctx->Viewport._WindowMap.m; - - if (USE_TINY_VERT) { - if (HAVE_HW_VIEWPORT) { - dst->win[0] = s[0] * src->v.x + s[12]; - dst->win[1] = s[5] * src->v.y + s[13]; - dst->win[2] = s[10] * src->v.z + s[14]; - dst->win[3] = 1.0; - } else { - dst->win[0] = ADJ_X(src->v.x); - dst->win[1] = ADJ_Y(src->v.y); - dst->win[2] = ADJ_Z(src->v.z); - 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 { - if (HAVE_HW_VIEWPORT) { - if (HAVE_HW_DIVIDE) { - GLfloat oow = 1.0 / src->v.rhw; - dst->win[0] = s[0] * src->v.x * oow + s[12]; - dst->win[1] = s[5] * src->v.y * oow + s[13]; - dst->win[2] = s[10] * src->v.z * oow + s[14]; - dst->win[3] = oow; - } - else { - dst->win[0] = s[0] * src->v.x + s[12]; - dst->win[1] = s[5] * src->v.y + s[13]; - dst->win[2] = s[10] * src->v.z + s[14]; - dst->win[3] = src->v.rhw; - } - } else { - dst->win[0] = ADJ_X(src->v.x); - dst->win[1] = ADJ_Y(src->v.y); - dst->win[2] = ADJ_Z(src->v.z); - dst->win[3] = src->v.rhw; - } - - 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 (DO_SPEC) { - dst->specular[0] = src->v.specular.red; - dst->specular[1] = src->v.specular.green; - dst->specular[2] = src->v.specular.blue; - } - - if (DO_FOG) { - dst->fog = src->v.color.alpha/255.0; - } - - if (DO_PTEX) { - if (DO_TEX0) { - dst->texcoord[0][0] = src->pv.u0; - dst->texcoord[0][1] = src->pv.v0; - dst->texcoord[0][3] = src->pv.q0; - } - if (DO_TEX1) { - dst->texcoord[1][0] = src->pv.u1; - dst->texcoord[1][1] = src->pv.v1; - dst->texcoord[1][3] = src->pv.q1; - } - } else { - if (DO_TEX0) { - dst->texcoord[0][0] = src->v.u0; - dst->texcoord[0][1] = src->v.v0; - dst->texcoord[0][3] = 1.0; - } - if (DO_TEX1) { - dst->texcoord[1][0] = src->v.u1; - dst->texcoord[1][1] = src->v.v1; - dst->texcoord[1][3] = 1.0; - } - } - } - - dst->pointSize = ctx->Point._Size; -} - -#endif -#endif +#endif /* rgba && xyzw */ static void TAG(init)( void ) @@ -724,12 +702,12 @@ static void TAG(init)( void ) #endif if (DO_SPEC) - setup_tab[IND].copy_pv = _tnl_dd_copy_pv_rgba4_spec5; + setup_tab[IND].copy_pv = copy_pv_rgba4_spec5; else if (HAVE_HW_DIVIDE || DO_SPEC || DO_FOG || DO_TEX0 || DO_TEX1 || DO_TEX2 || DO_TEX3) - setup_tab[IND].copy_pv = _tnl_dd_copy_pv_rgba4; + setup_tab[IND].copy_pv = copy_pv_rgba4; else - setup_tab[IND].copy_pv = _tnl_dd_copy_pv_rgba3; + setup_tab[IND].copy_pv = copy_pv_rgba3; if (DO_TEX3) { if (DO_PTEX) { @@ -747,7 +725,6 @@ static void TAG(init)( void ) else if (DO_TEX2) { if (DO_PTEX) { ASSERT(HAVE_PTEX_VERTICES); - ASSERT(0); /* issue to resolve: odd vertex size */ setup_tab[IND].vertex_format = PROJ_TEX3_VERTEX_FORMAT; setup_tab[IND].vertex_size = 18; setup_tab[IND].vertex_stride_shift = 7; diff --git a/src/mesa/drivers/common/t_dd_vertex.h b/src/mesa/drivers/common/t_dd_vertex.h new file mode 100644 index 0000000000..fcb734072b --- /dev/null +++ b/src/mesa/drivers/common/t_dd_vertex.h @@ -0,0 +1,70 @@ +/* + * 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 <keithw@valinux.com> + */ + +#if (COLOR_IS_RBGA) +typedef struct { + GLubyte red; + GLubyte green; + GLubyte blue; + GLubyte alpha; +} TAG(_color); +#else +typedef struct { + GLubyte blue; + GLubyte green; + GLubyte red; + GLubyte alpha; +} TAG(_color); +#endif + +typedef union { + struct { + float x, y, z, w; + TAG(_color) color; + TAG(_color) specular; + float u0, v0; + float u1, v1; + float u2, v2; + float u3, v3; + } v; + struct { + float x, y, z, w; + TAG(_color) color; + TAG(_color) specular; + float u0, v0, q0; + float u1, v1, q1; + float u2, v2, q2; + float u3, v3, q3; + } pv; + struct { + float x, y, z; + TAG(_color) color; + } tv; + float f[16]; + unsigned int ui[16]; + unsigned char ub4[4][16]; +} TAG(Vertex), *TAG(VertexPtr); |