diff options
author | Keith Whitwell <keith@tungstengraphics.com> | 2003-12-09 19:35:45 +0000 |
---|---|---|
committer | Keith Whitwell <keith@tungstengraphics.com> | 2003-12-09 19:35:45 +0000 |
commit | b44fb3577089d4cab7d0f3ff87c6d9f4a7c42a35 (patch) | |
tree | 952164d16383fb15db9567009607ab821ae95950 /src/mesa | |
parent | 10637fed2229586fb81a2bd1ff2f0247ae51499d (diff) |
In fact, bring all the changes from mesa/tnl_dd to mesa/drivers/common.
Diffstat (limited to 'src/mesa')
-rw-r--r-- | src/mesa/drivers/common/t_dd.c | 1 | ||||
-rw-r--r-- | src/mesa/drivers/common/t_dd_dmatmp.h | 13 | ||||
-rw-r--r-- | src/mesa/drivers/common/t_dd_dmatmp2.h | 554 | ||||
-rw-r--r-- | src/mesa/drivers/common/t_dd_rendertmp.h | 4 | ||||
-rw-r--r-- | src/mesa/drivers/common/t_dd_tritmp.h | 43 | ||||
-rw-r--r-- | src/mesa/drivers/common/t_dd_unfilled.h | 1 | ||||
-rw-r--r-- | src/mesa/drivers/common/t_dd_vb.c | 17 | ||||
-rw-r--r-- | src/mesa/drivers/common/t_dd_vbtmp.h | 418 | ||||
-rw-r--r-- | src/mesa/drivers/common/t_dd_vertex.h | 1 |
9 files changed, 360 insertions, 692 deletions
diff --git a/src/mesa/drivers/common/t_dd.c b/src/mesa/drivers/common/t_dd.c index 84957c1e0d..731da5c320 100644 --- a/src/mesa/drivers/common/t_dd.c +++ b/src/mesa/drivers/common/t_dd.c @@ -1,4 +1,3 @@ -/* $Id: t_dd.c,v 1.3 2002/10/29 20:29:05 brianp Exp $ */ /* * Mesa 3-D graphics library diff --git a/src/mesa/drivers/common/t_dd_dmatmp.h b/src/mesa/drivers/common/t_dd_dmatmp.h index 5d0fabe149..10ff1df5f0 100644 --- a/src/mesa/drivers/common/t_dd_dmatmp.h +++ b/src/mesa/drivers/common/t_dd_dmatmp.h @@ -1,4 +1,3 @@ -/* $Id: t_dd_dmatmp.h,v 1.15 2002/10/29 20:29:05 brianp Exp $ */ /* * Mesa 3-D graphics library @@ -319,14 +318,6 @@ static void TAG(render_tri_strip_verts)( GLcontext *ctx, currentsz = dmasz; } - if ((flags & PRIM_PARITY) && count - start > 2) { - 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); @@ -870,10 +861,6 @@ static void TAG(render_tri_strip_elts)( GLcontext *ctx, currentsz = dmasz; } - if ((flags & PRIM_PARITY) && count - start > 2) { - TAG(emit_elts)( ctx, elts+start, 1 ); - } - /* Keep the same winding over multiple buffers: */ dmasz -= (dmasz & 1); diff --git a/src/mesa/drivers/common/t_dd_dmatmp2.h b/src/mesa/drivers/common/t_dd_dmatmp2.h index 1d2614fbc2..dd0286b453 100644 --- a/src/mesa/drivers/common/t_dd_dmatmp2.h +++ b/src/mesa/drivers/common/t_dd_dmatmp2.h @@ -56,10 +56,10 @@ #ifndef EMIT_TWO_ELTS -#define EMIT_TWO_ELTS( offset, elt0, elt1 ) \ +#define EMIT_TWO_ELTS( dest, offset, elt0, elt1 ) \ do { \ - EMIT_ELT( offset, elt0 ); \ - EMIT_ELT( offset+1, elt1 ); \ + (dest)[offset] = (elt0); \ + (dest)[offset+1] = (elt1); \ } while (0) #endif @@ -69,36 +69,42 @@ do { \ /**********************************************************************/ -static void TAG(emit_elts)( GLcontext *ctx, GLuint *elts, GLuint nr ) +static ELT_TYPE *TAG(emit_elts)( GLcontext *ctx, + ELT_TYPE *dest, + GLuint *elts, GLuint nr ) { GLint i; LOCAL_VARS; - ELTS_VARS; - ALLOC_ELTS( nr ); - - for ( i = 0 ; i < nr ; i+=2, elts += 2 ) { - EMIT_TWO_ELTS( 0, elts[0], elts[1] ); - INCR_ELTS( 2 ); + for ( i = 0 ; i+1 < nr ; i+=2, elts += 2 ) { + EMIT_TWO_ELTS( dest, 0, elts[0], elts[1] ); + dest += 2; + } + if (i < nr) { + EMIT_ELT( dest, 0, elts[0] ); + dest += 1; } + + return dest; } -static void TAG(emit_consecutive_elts)( GLcontext *ctx, GLuint start, GLuint nr ) +static ELT_TYPE *TAG(emit_consecutive_elts)( GLcontext *ctx, + ELT_TYPE *dest, + GLuint start, GLuint nr ) { GLint i; LOCAL_VARS; - ELTS_VARS; - - ALLOC_ELTS( nr ); for ( i = 0 ; i+1 < nr ; i+=2, start += 2 ) { - EMIT_TWO_ELTS( 0, start, start+1 ); - INCR_ELTS( 2 ); + EMIT_TWO_ELTS( dest, 0, start, start+1 ); + dest += 2; } if (i < nr) { - EMIT_ELT( 0, start ); - INCR_ELTS( 1 ); + EMIT_ELT( dest, 0, start ); + dest += 1; } + + return dest; } /*********************************************************************** @@ -160,8 +166,7 @@ static void TAG(render_line_strip_verts)( GLcontext *ctx, if (PREFER_DISCRETE_ELT_PRIM( count-start, HW_LINES )) { - int dmasz = GET_SUBSEQUENT_VB_MAX_ELTS(); - int currentsz; + int dmasz = GET_MAX_HW_ELTS(); GLuint j, nr; ELT_INIT( GL_LINES, HW_LINES ); @@ -169,30 +174,21 @@ static void TAG(render_line_strip_verts)( GLcontext *ctx, /* Emit whole number of lines in each full buffer. */ dmasz = dmasz/2; - currentsz = GET_CURRENT_VB_MAX_ELTS(); - currentsz = currentsz/2; - if (currentsz < 4) { - NEW_BUFFER(); - currentsz = dmasz; - } for (j = start; j + 1 < count; j += nr - 1 ) { + ELT_TYPE *dest; GLint i; - ELTS_VARS; - nr = MIN2( currentsz, count - j ); - - ALLOC_ELTS( (nr-1)*2 ); + + nr = MIN2( dmasz, count - j ); + dest = ALLOC_ELTS( (nr-1)*2 ); for ( i = j ; i+1 < j+nr ; i+=1 ) { - EMIT_TWO_ELTS( 0, (i+0), (i+1) ); - INCR_ELTS( 2 ); + EMIT_TWO_ELTS( dest, 0, (i+0), (i+1) ); + dest += 2; } - if (nr == currentsz) { - NEW_BUFFER(); - currentsz = dmasz; - } + CLOSE_ELTS(); } } else @@ -223,96 +219,61 @@ static void TAG(render_line_loop_verts)( GLcontext *ctx, return; if (PREFER_DISCRETE_ELT_PRIM( count-start, HW_LINES )) { - int dmasz = GET_SUBSEQUENT_VB_MAX_ELTS(); - int currentsz; + int dmasz = GET_MAX_HW_ELTS(); ELT_INIT( GL_LINES, HW_LINES ); /* Emit whole number of lines in each full buffer. */ dmasz = dmasz/2; - currentsz = GET_CURRENT_VB_MAX_ELTS(); - currentsz = currentsz/2; - - if (currentsz < 4) { - NEW_BUFFER(); - currentsz = dmasz; - } /* Ensure last vertex doesn't wrap: */ - currentsz--; dmasz--; for (; j + 1 < count; ) { GLint i; - ELTS_VARS; - nr = MIN2( currentsz, count - j ); - - ALLOC_ELTS( (nr-1)*2 ); - for ( i = j ; i+1 < j+nr ; i+=1 ) { - EMIT_TWO_ELTS( 0, (i+0), (i+1) ); - INCR_ELTS( 2 ); + ELT_TYPE *dest; + + nr = MIN2( dmasz, count - j ); + dest = ALLOC_ELTS( nr*2 ); /* allocs room for 1 more line */ + + for ( i = 0 ; i < nr - 1 ; i+=1 ) { + EMIT_TWO_ELTS( dest, 0, (j+i), (j+i+1) ); + dest += 2; } j += nr - 1; - if (j + 1 < count) { - NEW_BUFFER(); - currentsz = dmasz; - } - else { - ALLOC_ELTS( 2 ); - EMIT_TWO_ELTS( 0, (j), (start) ); - INCR_ELTS( 2 ); - } + + /* Emit 1 more line into space alloced above */ + if (j + 1 >= count) { + EMIT_TWO_ELTS( dest, 0, (j), (start) ); + dest += 2; + } + + CLOSE_ELTS(); } } else { - int dmasz = GET_SUBSEQUENT_VB_MAX_ELTS(); - int currentsz; + int dmasz = GET_MAX_HW_ELTS() - 1; ELT_INIT( GL_LINE_STRIP, HW_LINE_STRIP ); - currentsz = GET_CURRENT_VB_MAX_ELTS(); - - if (currentsz < 8) { - NEW_BUFFER(); - currentsz = dmasz; - } - - /* Ensure last vertex doesn't wrap: - */ - currentsz--; - dmasz--; - for ( ; j + 1 < count; ) { - nr = MIN2( currentsz, count - j ); + nr = MIN2( dmasz, count - j ); if (j + nr < count) { - TAG(emit_consecutive_elts)( ctx, j, nr ); - currentsz = dmasz; + ELT_TYPE *dest = ALLOC_ELTS( nr ); + dest = TAG(emit_consecutive_elts)( ctx, dest, j, nr ); j += nr - 1; - NEW_BUFFER(); + CLOSE_ELTS(); } else if (nr) { - ELTS_VARS; - int i; - - ALLOC_ELTS( nr + 1 ); - for ( i = 0 ; i+1 < nr ; i+=2, j += 2 ) { - EMIT_TWO_ELTS( 0, j, j+1 ); - INCR_ELTS( 2 ); - } - if (i < nr) { - EMIT_ELT( 0, j ); j++; - INCR_ELTS( 1 ); - } - EMIT_ELT( 0, start ); - INCR_ELTS( 1 ); - NEW_BUFFER(); - } - else { - fprintf(stderr, "warining nr==0\n"); + ELT_TYPE *dest = ALLOC_ELTS( nr + 1 ); + dest = TAG(emit_consecutive_elts)( ctx, dest, j, nr ); + dest = TAG(emit_consecutive_elts)( ctx, dest, start, 1 ); + j += nr; + CLOSE_ELTS(); } } } @@ -356,65 +317,49 @@ static void TAG(render_tri_strip_verts)( GLcontext *ctx, if (PREFER_DISCRETE_ELT_PRIM( count-start, HW_TRIANGLES )) { - int dmasz = GET_SUBSEQUENT_VB_MAX_ELTS(); - int currentsz; + int dmasz = GET_MAX_HW_ELTS(); int parity = 0; GLuint j, nr; ELT_INIT( GL_TRIANGLES, HW_TRIANGLES ); - if (flags & PRIM_PARITY) - parity = 1; - /* Emit even number of tris in each full buffer. */ dmasz = dmasz/3; dmasz -= dmasz & 1; - currentsz = GET_CURRENT_VB_MAX_ELTS(); - currentsz = currentsz/3; - currentsz -= currentsz & 1; - - if (currentsz < 4) { - NEW_BUFFER(); - currentsz = dmasz; - } for (j = start; j + 2 < count; j += nr - 2 ) { + ELT_TYPE *dest; GLint i; - ELTS_VARS; - nr = MIN2( currentsz, count - j ); - - ALLOC_ELTS( (nr-2)*3 ); + + nr = MIN2( dmasz, count - j ); + dest = ALLOC_ELTS( (nr-2)*3 ); for ( i = j ; i+2 < j+nr ; i++, parity^=1 ) { - EMIT_ELT( 0, (i+0+parity) ); - EMIT_ELT( 1, (i+1-parity) ); - EMIT_ELT( 2, (i+2) ); - INCR_ELTS( 3 ); + EMIT_ELT( dest, 0, (i+0+parity) ); + EMIT_ELT( dest, 1, (i+1-parity) ); + EMIT_ELT( dest, 2, (i+2) ); + dest += 3; } - if (nr == currentsz) { - NEW_BUFFER(); - currentsz = dmasz; - } + CLOSE_ELTS(); } } - else if ((flags & PRIM_PARITY) == 0) - EMIT_PRIM( ctx, GL_TRIANGLE_STRIP, HW_TRIANGLE_STRIP_0, start, count ); else if (HAVE_TRI_STRIP_1) EMIT_PRIM( ctx, GL_TRIANGLE_STRIP, HW_TRIANGLE_STRIP_1, start, count ); else { /* Emit the first triangle with elts, then the rest as a regular strip. * TODO: Make this unlikely in t_imm_api.c */ - ELTS_VARS; + ELT_TYPE *dest; + ELT_INIT( GL_TRIANGLES, HW_TRIANGLES ); - ALLOC_ELTS( 3 ); - EMIT_ELT( 0, (start+1) ); - EMIT_ELT( 1, (start+0) ); - EMIT_ELT( 2, (start+2) ); - INCR_ELTS( 3 ); - NEW_PRIMITIVE(); + dest = ALLOC_ELTS( 3 ); + EMIT_ELT( dest, 0, (start+1) ); + EMIT_ELT( dest, 1, (start+0) ); + EMIT_ELT( dest, 2, (start+2) ); + dest += 3; + CLOSE_ELTS(); start++; if (start + 2 >= count) @@ -438,39 +383,28 @@ static void TAG(render_tri_fan_verts)( GLcontext *ctx, if (PREFER_DISCRETE_ELT_PRIM( count-start, HW_TRIANGLES )) { - int dmasz = GET_SUBSEQUENT_VB_MAX_ELTS(); - int currentsz; + int dmasz = GET_MAX_HW_ELTS(); GLuint j, nr; ELT_INIT( GL_TRIANGLES, HW_TRIANGLES ); dmasz = dmasz/3; - currentsz = GET_CURRENT_VB_MAX_ELTS(); - currentsz = currentsz/3; - - if (currentsz < 4) { - NEW_BUFFER(); - currentsz = dmasz; - } for (j = start + 1; j + 1 < count; j += nr - 1 ) { + ELT_TYPE *dest; GLint i; - ELTS_VARS; - nr = MIN2( currentsz, count - j ); - - ALLOC_ELTS( (nr-1)*3 ); + + nr = MIN2( dmasz, count - j ); + dest = ALLOC_ELTS( (nr-1)*3 ); for ( i = j ; i+1 < j+nr ; i++ ) { - EMIT_ELT( 0, (start) ); - EMIT_ELT( 1, (i) ); - EMIT_ELT( 2, (i+1) ); - INCR_ELTS( 3 ); - } - - if (nr == currentsz) { - NEW_BUFFER(); - currentsz = dmasz; + EMIT_ELT( dest, 0, (start) ); + EMIT_ELT( dest, 1, (i) ); + EMIT_ELT( dest, 2, (i+1) ); + dest += 3; } + + CLOSE_ELTS(); } } else { @@ -511,44 +445,31 @@ static void TAG(render_quad_strip_verts)( GLcontext *ctx, } else if (ctx->_TriangleCaps & DD_FLATSHADE) { LOCAL_VARS; - int dmasz = GET_SUBSEQUENT_VB_MAX_ELTS(); - int currentsz; + int dmasz = GET_MAX_HW_ELTS(); GLuint j, nr; ELT_INIT( GL_TRIANGLES, HW_TRIANGLES ); - currentsz = GET_CURRENT_VB_MAX_ELTS(); - /* Emit whole number of quads in total, and in each buffer. */ - currentsz = (currentsz/6)*2; dmasz = (dmasz/6)*2; - if (currentsz < 4) { - NEW_BUFFER(); - currentsz = dmasz; - } - for (j = start; j + 3 < count; j += nr - 2 ) { - ELTS_VARS; + ELT_TYPE *dest; GLint quads, i; - nr = MIN2( currentsz, count - j ); + nr = MIN2( dmasz, count - j ); quads = (nr/2)-1; - - ALLOC_ELTS( quads*6 ); + dest = ALLOC_ELTS( quads*6 ); for ( i = j ; i < j+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 ); + EMIT_TWO_ELTS( dest, 0, (i+0), (i+1) ); + EMIT_TWO_ELTS( dest, 2, (i+2), (i+1) ); + EMIT_TWO_ELTS( dest, 4, (i+3), (i+2) ); + dest += 6; } - if (nr == currentsz) { - NEW_BUFFER(); - currentsz = dmasz; - } + CLOSE_ELTS(); } } else { @@ -577,42 +498,31 @@ static void TAG(render_quads_verts)( GLcontext *ctx, * using indexed vertices and the triangle primitive: */ LOCAL_VARS; - int dmasz = GET_SUBSEQUENT_VB_MAX_ELTS(); - int currentsz; + int dmasz = GET_MAX_HW_ELTS(); GLuint j, nr; ELT_INIT( GL_TRIANGLES, HW_TRIANGLES ); - currentsz = GET_CURRENT_VB_MAX_ELTS(); /* Adjust for rendering as triangles: */ - currentsz = (currentsz/6)*4; dmasz = (dmasz/6)*4; - if (currentsz < 8) { - NEW_BUFFER(); - currentsz = dmasz; - } - for (j = start; j < count; j += nr ) { - ELTS_VARS; + ELT_TYPE *dest; GLint quads, i; - nr = MIN2( currentsz, count - j ); - quads = nr/4; - ALLOC_ELTS( quads*6 ); + nr = MIN2( dmasz, count - j ); + quads = nr/4; + dest = ALLOC_ELTS( quads*6 ); for ( i = j ; i < j+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 ); + EMIT_TWO_ELTS( dest, 0, (i+0), (i+1) ); + EMIT_TWO_ELTS( dest, 2, (i+3), (i+1) ); + EMIT_TWO_ELTS( dest, 4, (i+2), (i+3) ); + dest += 6; } - if (nr == currentsz) { - NEW_BUFFER(); - currentsz = dmasz; - } + CLOSE_ELTS(); } } } @@ -653,22 +563,18 @@ static void TAG(render_points_elts)( GLcontext *ctx, GLuint flags ) { LOCAL_VARS; - int dmasz = GET_SUBSEQUENT_VB_MAX_ELTS(); - int currentsz; - GLuint *elts = GET_ELTS(); + int dmasz = GET_MAX_HW_ELTS(); + GLuint *elts = GET_MESA_ELTS(); GLuint j, nr; + ELT_TYPE *dest; ELT_INIT( GL_POINTS, HW_POINTS ); - currentsz = GET_CURRENT_VB_MAX_ELTS(); - if (currentsz < 8) - currentsz = dmasz; - for (j = start; j < count; j += nr ) { - nr = MIN2( currentsz, count - j ); - TAG(emit_elts)( ctx, elts+j, nr ); - NEW_PRIMITIVE(); - currentsz = dmasz; + nr = MIN2( dmasz, count - j ); + dest = ALLOC_ELTS( nr ); + dest = TAG(emit_elts)( ctx, dest, elts+j, nr ); + CLOSE_ELTS(); } } @@ -680,10 +586,10 @@ static void TAG(render_lines_elts)( GLcontext *ctx, GLuint flags ) { LOCAL_VARS; - int dmasz = GET_SUBSEQUENT_VB_MAX_ELTS(); - int currentsz; - GLuint *elts = GET_ELTS(); + int dmasz = GET_MAX_HW_ELTS(); + GLuint *elts = GET_MESA_ELTS(); GLuint j, nr; + ELT_TYPE *dest; if (start+1 >= count) return; @@ -698,18 +604,13 @@ static void TAG(render_lines_elts)( GLcontext *ctx, /* 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 ); - TAG(emit_elts)( ctx, elts+j, nr ); - NEW_PRIMITIVE(); - currentsz = dmasz; + nr = MIN2( dmasz, count - j ); + dest = ALLOC_ELTS( nr ); + dest = TAG(emit_elts)( ctx, dest, elts+j, nr ); + CLOSE_ELTS(); } if ((flags & PRIM_END) && ctx->Line.StippleFlag) @@ -723,10 +624,10 @@ static void TAG(render_line_strip_elts)( GLcontext *ctx, GLuint flags ) { LOCAL_VARS; - int dmasz = GET_SUBSEQUENT_VB_MAX_ELTS(); - int currentsz; - GLuint *elts = GET_ELTS(); + int dmasz = GET_MAX_HW_ELTS(); + GLuint *elts = GET_MESA_ELTS(); GLuint j, nr; + ELT_TYPE *dest; if (start+1 >= count) return; @@ -736,15 +637,11 @@ static void TAG(render_line_strip_elts)( GLcontext *ctx, if ((flags & PRIM_BEGIN) && ctx->Line.StippleFlag) RESET_STIPPLE(); - currentsz = GET_CURRENT_VB_MAX_ELTS(); - if (currentsz < 8) - currentsz = dmasz; - for (j = start; j + 1 < count; j += nr - 1 ) { - nr = MIN2( currentsz, count - j ); - TAG(emit_elts)( ctx, elts+j, nr ); - NEW_PRIMITIVE(); - currentsz = dmasz; + nr = MIN2( dmasz, count - j ); + dest = ALLOC_ELTS( nr ); + dest = TAG(emit_elts)( ctx, dest, elts+j, nr ); + CLOSE_ELTS(); } } @@ -755,10 +652,10 @@ static void TAG(render_line_loop_elts)( GLcontext *ctx, GLuint flags ) { LOCAL_VARS; - int dmasz = GET_SUBSEQUENT_VB_MAX_ELTS(); - int currentsz; - GLuint *elts = GET_ELTS(); + int dmasz = GET_MAX_HW_ELTS(); + GLuint *elts = GET_MESA_ELTS(); GLuint j, nr; + ELT_TYPE *dest; if (0) fprintf(stderr, "%s\n", __FUNCTION__); @@ -783,27 +680,20 @@ static void TAG(render_line_loop_elts)( GLcontext *ctx, RESET_STIPPLE(); - currentsz = GET_CURRENT_VB_MAX_ELTS(); - if (currentsz < 8) { - NEW_BUFFER(); - currentsz = dmasz; - } - /* Ensure last vertex doesn't wrap: */ - currentsz--; dmasz--; - for ( ; j + 1 < count; j += nr - 1 ) { - nr = MIN2( currentsz, count - j ); - TAG(emit_elts)( ctx, elts+j, nr ); - currentsz = dmasz; + for ( ; j + 1 < count; ) { + nr = MIN2( dmasz, count - j ); + dest = ALLOC_ELTS( nr+1 ); /* Reserve possible space for last elt */ + dest = TAG(emit_elts)( ctx, dest, elts+j, nr ); + j += nr - 1; + if (j + 1 >= count && (flags & PRIM_END)) { + dest = TAG(emit_elts)( ctx, dest, elts+start, 1 ); + } + CLOSE_ELTS(); } - - if (flags & PRIM_END) - TAG(emit_elts)( ctx, elts+start, 1 ); - - NEW_PRIMITIVE(); } @@ -813,32 +703,27 @@ static void TAG(render_triangles_elts)( GLcontext *ctx, GLuint flags ) { LOCAL_VARS; - GLuint *elts = GET_ELTS(); - int dmasz = GET_SUBSEQUENT_VB_MAX_ELTS()/3*3; - int currentsz; + GLuint *elts = GET_MESA_ELTS(); + int dmasz = GET_MAX_HW_ELTS()/3*3; GLuint j, nr; + ELT_TYPE *dest; if (start+2 >= count) return; -/* NEW_PRIMITIVE(); */ ELT_INIT( GL_TRIANGLES, HW_TRIANGLES ); - currentsz = GET_CURRENT_VB_MAX_ELTS(); /* 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 ); - TAG(emit_elts)( ctx, elts+j, nr ); - NEW_PRIMITIVE(); - currentsz = dmasz; + nr = MIN2( dmasz, count - j ); + dest = ALLOC_ELTS( nr ); + dest = TAG(emit_elts)( ctx, dest, elts+j, nr ); + CLOSE_ELTS(); } } @@ -851,36 +736,25 @@ static void TAG(render_tri_strip_elts)( GLcontext *ctx, { LOCAL_VARS; GLuint j, nr; - GLuint *elts = GET_ELTS(); - int dmasz = GET_SUBSEQUENT_VB_MAX_ELTS(); - int currentsz; + GLuint *elts = GET_MESA_ELTS(); + int dmasz = GET_MAX_HW_ELTS(); + ELT_TYPE *dest; if (start+2 >= count) return; ELT_INIT( GL_TRIANGLE_STRIP, HW_TRIANGLE_STRIP_0 ); - currentsz = GET_CURRENT_VB_MAX_ELTS(); - if (currentsz < 8) { - NEW_BUFFER(); - currentsz = dmasz; - } - - if ((flags & PRIM_PARITY) && count - start > 2) { - TAG(emit_elts)( ctx, elts+start, 1 ); - currentsz--; - } - /* Keep the same winding over multiple buffers: */ dmasz -= (dmasz & 1); - currentsz -= (currentsz & 1); for (j = start ; j + 2 < count; j += nr - 2 ) { - nr = MIN2( currentsz, count - j ); - TAG(emit_elts)( ctx, elts+j, nr ); - NEW_PRIMITIVE(); - currentsz = dmasz; + nr = MIN2( dmasz, count - j ); + + dest = ALLOC_ELTS( nr ); + dest = TAG(emit_elts)( ctx, dest, elts+j, nr ); + CLOSE_ELTS(); } } @@ -890,28 +764,22 @@ static void TAG(render_tri_fan_elts)( GLcontext *ctx, GLuint flags ) { LOCAL_VARS; - GLuint *elts = GET_ELTS(); + GLuint *elts = GET_MESA_ELTS(); GLuint j, nr; - int dmasz = GET_SUBSEQUENT_VB_MAX_ELTS(); - int currentsz; + int dmasz = GET_MAX_HW_ELTS(); + ELT_TYPE *dest; if (start+2 >= count) return; ELT_INIT( GL_TRIANGLE_FAN, HW_TRIANGLE_FAN ); - currentsz = GET_CURRENT_VB_MAX_ELTS(); - if (currentsz < 8) { - NEW_BUFFER(); - currentsz = dmasz; - } - for (j = start + 1 ; j + 1 < count; j += nr - 1 ) { - nr = MIN2( currentsz, count - j + 1 ); - TAG(emit_elts)( ctx, elts+start, 1 ); - TAG(emit_elts)( ctx, elts+j, nr - 1 ); - NEW_PRIMITIVE(); - currentsz = dmasz; + nr = MIN2( dmasz, count - j + 1 ); + dest = ALLOC_ELTS( nr ); + dest = TAG(emit_elts)( ctx, dest, elts+start, 1 ); + dest = TAG(emit_elts)( ctx, dest, elts+j, nr - 1 ); + CLOSE_ELTS(); } } @@ -922,28 +790,22 @@ static void TAG(render_poly_elts)( GLcontext *ctx, GLuint flags ) { LOCAL_VARS; - GLuint *elts = GET_ELTS(); + GLuint *elts = GET_MESA_ELTS(); GLuint j, nr; - int dmasz = GET_SUBSEQUENT_VB_MAX_ELTS(); - int currentsz; + int dmasz = GET_MAX_HW_ELTS(); + ELT_TYPE *dest; if (start+2 >= count) return; ELT_INIT( GL_POLYGON, HW_POLYGON ); - currentsz = GET_CURRENT_VB_MAX_ELTS(); - if (currentsz < 8) { - NEW_BUFFER(); - currentsz = dmasz; - } - for (j = start + 1 ; j + 1 < count ; j += nr - 1 ) { - nr = MIN2( currentsz, count - j + 1 ); - TAG(emit_elts)( ctx, elts+start, 1 ); - TAG(emit_elts)( ctx, elts+j, nr - 1 ); - NEW_PRIMITIVE(); - currentsz = dmasz; + nr = MIN2( dmasz, count - j + 1 ); + dest = ALLOC_ELTS( nr ); + dest = TAG(emit_elts)( ctx, dest, elts+start, 1 ); + dest = TAG(emit_elts)( ctx, dest, elts+j, nr - 1 ); + CLOSE_ELTS(); } } @@ -959,61 +821,49 @@ static void TAG(render_quad_strip_elts)( GLcontext *ctx, } else { LOCAL_VARS; - GLuint *elts = GET_ELTS(); - int dmasz = GET_SUBSEQUENT_VB_MAX_ELTS(); - int currentsz; + GLuint *elts = GET_MESA_ELTS(); + int dmasz = GET_MAX_HW_ELTS(); GLuint j, nr; - - NEW_PRIMITIVE(); - currentsz = GET_CURRENT_VB_MAX_ELTS(); + ELT_TYPE *dest; /* 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, HW_TRIANGLES ); - currentsz = currentsz/6*2; dmasz = dmasz/6*2; for (j = start; j + 3 < count; j += nr - 2 ) { - nr = MIN2( currentsz, count - j ); + nr = MIN2( dmasz, count - j ); if (nr >= 4) { - GLint i; GLint quads = (nr/2)-1; - ELTS_VARS; - - ALLOC_ELTS( quads*6 ); + ELT_TYPE *dest = ALLOC_ELTS( quads*6 ); + GLint i; for ( i = j-start ; i < j-start+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 ); + EMIT_TWO_ELTS( dest, 0, elts[0], elts[1] ); + EMIT_TWO_ELTS( dest, 2, elts[2], elts[1] ); + EMIT_TWO_ELTS( dest, 4, elts[3], elts[2] ); + dest += 6; } - NEW_PRIMITIVE(); + CLOSE_ELTS(); } - - currentsz = dmasz; } } else { ELT_INIT( GL_TRIANGLE_STRIP, HW_TRIANGLE_STRIP_0 ); for (j = start; j + 3 < count; j += nr - 2 ) { - nr = MIN2( currentsz, count - j ); - TAG(emit_elts)( ctx, elts+j, nr ); - NEW_PRIMITIVE(); - currentsz = dmasz; + nr = MIN2( dmasz, count - j ); + dest = ALLOC_ELTS( nr ); + dest = TAG(emit_elts)( ctx, dest, elts+j, nr ); + CLOSE_ELTS(); } } } @@ -1031,48 +881,38 @@ static void TAG(render_quads_elts)( GLcontext *ctx, if (HAVE_QUADS && 0) { } else { LOCAL_VARS; - GLuint *elts = GET_ELTS(); - int dmasz = GET_SUBSEQUENT_VB_MAX_ELTS(); - int currentsz; + GLuint *elts = GET_MESA_ELTS(); + int dmasz = GET_MAX_HW_ELTS(); GLuint j, nr; ELT_INIT( GL_TRIANGLES, HW_TRIANGLES ); - currentsz = GET_CURRENT_VB_MAX_ELTS(); /* 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 + 3 < count; j += nr ) { + nr = MIN2( dmasz, count - j ); - for (j = start; j + 3 < count; j += nr - 2 ) { - nr = MIN2( currentsz, count - j ); - - if (nr >= 4) { GLint quads = nr/4; + ELT_TYPE *dest = ALLOC_ELTS( quads * 6 ); GLint i; - ELTS_VARS; - ALLOC_ELTS( quads * 6 ); for ( i = j-start ; i < j-start+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 ); + EMIT_TWO_ELTS( dest, 0, elts[0], elts[1] ); + EMIT_TWO_ELTS( dest, 2, elts[3], elts[1] ); + EMIT_TWO_ELTS( dest, 4, elts[2], elts[3] ); + dest += 6; } - } - NEW_PRIMITIVE(); - currentsz = dmasz; + CLOSE_ELTS(); + } } } } diff --git a/src/mesa/drivers/common/t_dd_rendertmp.h b/src/mesa/drivers/common/t_dd_rendertmp.h index 7be7d8ac4c..b9f030195d 100644 --- a/src/mesa/drivers/common/t_dd_rendertmp.h +++ b/src/mesa/drivers/common/t_dd_rendertmp.h @@ -1,4 +1,3 @@ -/* $Id: t_dd_rendertmp.h,v 1.3 2002/10/29 20:29:05 brianp Exp $ */ /* * Mesa 3-D graphics library @@ -187,9 +186,6 @@ static void TAG(render_tri_strip)( GLcontext *ctx, 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) { diff --git a/src/mesa/drivers/common/t_dd_tritmp.h b/src/mesa/drivers/common/t_dd_tritmp.h index 01f0ee28bf..b26347b77e 100644 --- a/src/mesa/drivers/common/t_dd_tritmp.h +++ b/src/mesa/drivers/common/t_dd_tritmp.h @@ -1,4 +1,3 @@ -/* $Id: t_dd_tritmp.h,v 1.13 2002/10/29 20:29:05 brianp Exp $ */ /* * Mesa 3-D graphics library @@ -177,9 +176,8 @@ static void TAG(triangle)( GLcontext *ctx, GLuint e0, GLuint e1, GLuint e2 ) } } else { - GLchan (*vbcolor)[4] = VB->ColorPtr[1]->Ptr; - ASSERT(VB->ColorPtr[1]->Type == CHAN_TYPE); - ASSERT(VB->ColorPtr[1]->StrideB == 4*sizeof(GLchan)); + GLfloat (*vbcolor)[4] = VB->ColorPtr[1]->data; + ASSERT(VB->ColorPtr[1]->stride == 4*sizeof(GLfloat)); (void) vbcolor; if (!DO_FLAT) { @@ -192,7 +190,7 @@ static void TAG(triangle)( GLcontext *ctx, GLuint e0, GLuint e1, GLuint e2 ) VERT_SET_RGBA( v[2], vbcolor[e2] ); if (HAVE_SPEC && VB->SecondaryColorPtr[1]) { - GLchan (*vbspec)[4] = VB->SecondaryColorPtr[1]->Ptr; + GLfloat (*vbspec)[4] = VB->SecondaryColorPtr[1]->data; if (!DO_FLAT) { VERT_SAVE_SPEC( 0 ); @@ -206,11 +204,14 @@ static void TAG(triangle)( GLcontext *ctx, GLuint e0, GLuint e1, GLuint e2 ) } } else { - GLuint *vbindex = VB->IndexPtr[1]->data; + GLfloat (*vbindex) = (GLfloat *)VB->IndexPtr[1]->data; if (!DO_FLAT) { + VERT_SAVE_IND( 0 ); + VERT_SAVE_IND( 1 ); VERT_SET_IND( v[0], vbindex[e0] ); VERT_SET_IND( v[1], vbindex[e1] ); } + VERT_SAVE_IND( 2 ); VERT_SET_IND( v[2], vbindex[e2] ); } } @@ -309,12 +310,11 @@ static void TAG(triangle)( GLcontext *ctx, GLuint e0, GLuint e1, GLuint 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_RESTORE_IND( 0 ); + VERT_RESTORE_IND( 1 ); } - VERT_SET_IND( v[2], vbindex[e2] ); + VERT_RESTORE_IND( 2 ); } } @@ -385,7 +385,7 @@ static void TAG(quad)( GLcontext *ctx, if (DO_TWOSIDE && facing == 1) { if (HAVE_RGBA) { - GLchan (*vbcolor)[4] = VB->ColorPtr[1]->Ptr; + GLfloat (*vbcolor)[4] = VB->ColorPtr[1]->data; (void)vbcolor; if (HAVE_BACK_COLORS) { @@ -425,8 +425,8 @@ static void TAG(quad)( GLcontext *ctx, VERT_SET_RGBA( v[3], vbcolor[e3] ); if (HAVE_SPEC && VB->SecondaryColorPtr[1]) { - GLchan (*vbspec)[4] = VB->SecondaryColorPtr[1]->Ptr; - ASSERT(VB->SecondaryColorPtr[1]->StrideB==4*sizeof(GLchan)); + GLfloat (*vbspec)[4] = VB->SecondaryColorPtr[1]->data; + ASSERT(VB->SecondaryColorPtr[1]->stride==4*sizeof(GLfloat)); if (!DO_FLAT) { VERT_SAVE_SPEC( 0 ); @@ -442,12 +442,16 @@ static void TAG(quad)( GLcontext *ctx, } } else { - GLuint *vbindex = VB->IndexPtr[1]->data; + GLfloat *vbindex = (GLfloat *)VB->IndexPtr[1]->data; if (!DO_FLAT) { + VERT_SAVE_IND( 0 ); + VERT_SAVE_IND( 1 ); + VERT_SAVE_IND( 2 ); VERT_SET_IND( v[0], vbindex[e0] ); VERT_SET_IND( v[1], vbindex[e1] ); VERT_SET_IND( v[2], vbindex[e2] ); } + VERT_SAVE_IND( 3 ); VERT_SET_IND( v[3], vbindex[e3] ); } } @@ -558,13 +562,12 @@ static void TAG(quad)( GLcontext *ctx, } } 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_RESTORE_IND( 0 ); + VERT_RESTORE_IND( 1 ); + VERT_RESTORE_IND( 2 ); } - VERT_SET_IND( v[3], vbindex[e3] ); + VERT_RESTORE_IND( 3 ); } } @@ -612,7 +615,7 @@ static void TAG(quad)( GLcontext *ctx, GLuint e0, #if DO_LINE static void TAG(line)( GLcontext *ctx, GLuint e0, GLuint e1 ) { - TNLvertexbuffer *VB = &TNL_CONTEXT(ctx)->vb; + struct vertex_buffer *VB = &TNL_CONTEXT(ctx)->vb; VERTEX *v[2]; LOCAL_VARS(2); diff --git a/src/mesa/drivers/common/t_dd_unfilled.h b/src/mesa/drivers/common/t_dd_unfilled.h index 7c85012e11..46415ea5f6 100644 --- a/src/mesa/drivers/common/t_dd_unfilled.h +++ b/src/mesa/drivers/common/t_dd_unfilled.h @@ -1,4 +1,3 @@ -/* $Id: t_dd_unfilled.h,v 1.5 2002/10/29 20:29:05 brianp Exp $ */ /* * Mesa 3-D graphics library diff --git a/src/mesa/drivers/common/t_dd_vb.c b/src/mesa/drivers/common/t_dd_vb.c index f19de2def6..380b0424b4 100644 --- a/src/mesa/drivers/common/t_dd_vb.c +++ b/src/mesa/drivers/common/t_dd_vb.c @@ -283,7 +283,7 @@ void TAG(print_vertex)( GLcontext *ctx, const VERTEX *v ) #define INTERP_QUALIFIER static #endif -#define GET_COLOR(ptr, idx) (((GLchan (*)[4])((ptr)->Ptr))[idx]) +#define GET_COLOR(ptr, idx) ((ptr)->data[idx]) INTERP_QUALIFIER void TAG(interp_extras)( GLcontext *ctx, @@ -295,16 +295,18 @@ INTERP_QUALIFIER void TAG(interp_extras)( GLcontext *ctx, struct vertex_buffer *VB = &TNL_CONTEXT(ctx)->vb; if (VB->ColorPtr[1]) { + assert(VB->ColorPtr[1]->stride == 4 * sizeof(GLfloat)); + INTERP_4F( t, - GET_COLOR(VB->ColorPtr[1], dst), - GET_COLOR(VB->ColorPtr[1], out), - GET_COLOR(VB->ColorPtr[1], in) ); + GET_COLOR(VB->ColorPtr[1], dst), + GET_COLOR(VB->ColorPtr[1], out), + GET_COLOR(VB->ColorPtr[1], in) ); if (VB->SecondaryColorPtr[1]) { INTERP_3F( t, - GET_COLOR(VB->SecondaryColorPtr[1], dst), - GET_COLOR(VB->SecondaryColorPtr[1], out), - GET_COLOR(VB->SecondaryColorPtr[1], in) ); + GET_COLOR(VB->SecondaryColorPtr[1], dst), + GET_COLOR(VB->SecondaryColorPtr[1], out), + GET_COLOR(VB->SecondaryColorPtr[1], in) ); } } @@ -336,7 +338,6 @@ INTERP_QUALIFIER void TAG(copy_pv_extras)( GLcontext *ctx, #undef INTERP_QUALIFIER -#undef IMPORT_QUALIFIER #undef GET_COLOR #undef IND diff --git a/src/mesa/drivers/common/t_dd_vbtmp.h b/src/mesa/drivers/common/t_dd_vbtmp.h index 9c062c45d9..14b4a28651 100644 --- a/src/mesa/drivers/common/t_dd_vbtmp.h +++ b/src/mesa/drivers/common/t_dd_vbtmp.h @@ -1,4 +1,3 @@ -/* $Id: t_dd_vbtmp.h,v 1.24 2003/01/13 15:47:52 brianp Exp $ */ /* * Mesa 3-D graphics library @@ -124,10 +123,10 @@ static void TAG(emit)( GLcontext *ctx, GLuint stride ) { LOCALVARS - struct vertex_buffer *VB = &TNL_CONTEXT(ctx)->vb; + struct vertex_buffer *VB = &TNL_CONTEXT(ctx)->vb; GLfloat (*tc0)[4], (*tc1)[4], (*fog)[4]; GLfloat (*tc2)[4], (*tc3)[4]; - GLubyte (*col)[4], (*spec)[4]; + GLfloat (*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; @@ -185,21 +184,16 @@ static void TAG(emit)( GLcontext *ctx, } if (DO_RGBA) { - if (VB->ColorPtr[0]->Type != GL_UNSIGNED_BYTE) - IMPORT_FLOAT_COLORS( ctx ); - col = (GLubyte (*)[4])VB->ColorPtr[0]->Ptr; - col_stride = VB->ColorPtr[0]->StrideB; + col_stride = VB->ColorPtr[0]->stride; + col = VB->ColorPtr[0]->data; } if (DO_SPEC) { if (VB->SecondaryColorPtr[0]) { - if (VB->SecondaryColorPtr[0]->Type != GL_UNSIGNED_BYTE) - IMPORT_FLOAT_SPEC_COLORS( ctx ); - spec = (GLubyte (*)[4])VB->SecondaryColorPtr[0]->Ptr; - spec_stride = VB->SecondaryColorPtr[0]->StrideB; + spec_stride = VB->SecondaryColorPtr[0]->stride; + spec = VB->SecondaryColorPtr[0]->data; } else { - GLubyte tmp[4]; - spec = &tmp; + spec = (GLfloat (*)[4])ctx->Current.Attrib[VERT_ATTRIB_COLOR1]; spec_stride = 0; } } @@ -216,200 +210,124 @@ static void TAG(emit)( GLcontext *ctx, } } - if (VB->importable_data || (DO_SPEC && !spec_stride) || (DO_FOG && !fog_stride)) { - /* 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) - tc1 = (GLfloat (*)[4])((GLubyte *)tc1 + start * tc1_stride); - if (DO_TEX2) - tc2 = (GLfloat (*)[4])((GLubyte *)tc2 + start * tc2_stride); - if (DO_TEX3) - tc3 = (GLfloat (*)[4])((GLubyte *)tc3 + start * tc3_stride); - if (DO_RGBA) - STRIDE_4UB(col, start * col_stride); - if (DO_SPEC) - STRIDE_4UB(spec, start * spec_stride); - if (DO_FOG) - /*STRIDE_F(fog, start * fog_stride);*/ - fog = (GLfloat (*)[4])((GLubyte *)fog + start * fog_stride); - } + /* May have nonstandard strides: + */ + if (start) { + STRIDE_4F(coord, start * coord_stride); + if (DO_TEX0) + STRIDE_4F(tc0, start * tc0_stride); + if (DO_TEX1) + STRIDE_4F(tc1, start * tc1_stride); + if (DO_TEX2) + STRIDE_4F(tc2, start * tc2_stride); + if (DO_TEX3) + STRIDE_4F(tc3, start * tc3_stride); + if (DO_RGBA) + STRIDE_4F(col, start * col_stride); + if (DO_SPEC) + STRIDE_4F(spec, start * spec_stride); + if (DO_FOG) + STRIDE_4F(fog, start * fog_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]); - v->v.w = coord[0][3]; - } -/* fprintf(stderr, "vert %d: %.2f %.2f %.2f %.2f\n", */ -/* i, v->v.x, v->v.y, v->v.z, v->v.w); */ - coord = (GLfloat (*)[4])((GLubyte *)coord + coord_stride); - } - if (DO_RGBA) { - if (HAVE_RGBA_COLOR) { - *(GLuint *)&v->v.color = LE32_TO_CPU(*(GLuint *)&col[0]); - STRIDE_4UB(col, col_stride); - } else { - 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][0] * 255.0; - /*STRIDE_F(fog, fog_stride);*/ - fog = (GLfloat (*)[4])((GLubyte *)fog + fog_stride); - } - if (DO_TEX0) { - 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.q0 = tc0[0][3]; - else - 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 *= rhw; - v->v.v0 *= rhw; - } - } - tc0 = (GLfloat (*)[4])((GLubyte *)tc0 + tc0_stride); - } - if (DO_TEX1) { - if (DO_PTEX) { - v->pv.u1 = tc1[0][0]; - v->pv.v1 = tc1[0][1]; - if (tc1_size == 4) - v->pv.q1 = tc1[0][3]; - else - v->pv.q1 = 1.0; - } - else { - v->v.u1 = tc1[0][0]; - v->v.v1 = tc1[0][1]; - } - tc1 = (GLfloat (*)[4])((GLubyte *)tc1 + tc1_stride); - } - else if (DO_PTEX) { - *(GLuint *)&v->pv.q1 = 0; /* avoid culling on radeon */ + 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]); + v->v.w = coord[0][3]; } - if (DO_TEX2) { - if (DO_PTEX) { - v->pv.u2 = tc2[0][0]; - v->pv.v2 = tc2[0][1]; - if (tc2_size == 4) - v->pv.q2 = tc2[0][3]; + STRIDE_4F(coord, coord_stride); + } + if (DO_RGBA) { + UNCLAMPED_FLOAT_TO_UBYTE(v->v.color.red, col[0][0]); + UNCLAMPED_FLOAT_TO_UBYTE(v->v.color.green, col[0][1]); + UNCLAMPED_FLOAT_TO_UBYTE(v->v.color.blue, col[0][2]); + UNCLAMPED_FLOAT_TO_UBYTE(v->v.color.alpha, col[0][3]); + STRIDE_4F(col, col_stride); + } + if (DO_SPEC) { + UNCLAMPED_FLOAT_TO_UBYTE(v->v.specular.red, spec[0][0]); + UNCLAMPED_FLOAT_TO_UBYTE(v->v.specular.green, spec[0][1]); + UNCLAMPED_FLOAT_TO_UBYTE(v->v.specular.blue, spec[0][2]); + STRIDE_4F(spec, spec_stride); + } + if (DO_FOG) { + UNCLAMPED_FLOAT_TO_UBYTE(v->v.specular.alpha, fog[0][0]); + STRIDE_4F(fog, fog_stride); + } + if (DO_TEX0) { + 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.q0 = tc0[0][3]; else - v->pv.q2 = 1.0; + v->pv.q0 = 1.0; } - else { - v->v.u2 = tc2[0][0]; - v->v.v2 = tc2[0][1]; - } - tc2 = (GLfloat (*)[4])((GLubyte *)tc2 + tc2_stride); - } - if (DO_TEX3) { - if (DO_PTEX) { - v->pv.u3 = tc3[0][0]; - v->pv.v3 = tc3[0][1]; - if (tc3_size == 4) - v->pv.q3 = tc3[0][3]; - else - v->pv.q3 = 1.0; + else if (tc0_size == 4) { + float rhw = 1.0 / tc0[0][3]; + v->v.w *= tc0[0][3]; + v->v.u0 *= rhw; + v->v.v0 *= rhw; } - else { - v->v.u3 = tc3[0][0]; - v->v.v3 = tc3[0][1]; - } - tc3 = (GLfloat (*)[4])((GLubyte *)tc3 + tc3_stride); } + STRIDE_4F(tc0, tc0_stride); } - } - else { - 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]); - v->v.w = coord[i][3]; - } - } - if (DO_RGBA) { - if (HAVE_RGBA_COLOR) { - *(GLuint *)&v->v.color = LE32_TO_CPU(*(GLuint *)&col[i]); - } - else { - 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][0] * 255.0; + if (DO_TEX1) { + if (DO_PTEX) { + v->pv.u1 = tc1[0][0]; + v->pv.v1 = tc1[0][1]; + if (tc1_size == 4) + v->pv.q1 = tc1[0][3]; + else + v->pv.q1 = 1.0; + } + else { + v->v.u1 = tc1[0][0]; + v->v.v1 = tc1[0][1]; } - if (DO_TEX0) { - v->v.u0 = tc0[i][0]; - v->v.v0 = tc0[i][1]; - if (DO_PTEX) { - if (HAVE_PTEX_VERTICES) { - if (tc0_size == 4) - v->pv.q0 = tc0[i][3]; - else - v->pv.q0 = 1.0; - - v->pv.q1 = 0; /* radeon */ - } - else if (tc0_size == 4) { - float rhw = 1.0 / tc0[i][3]; - v->v.w *= tc0[i][3]; - v->v.u0 *= rhw; - v->v.v0 *= rhw; - } - } + STRIDE_4F(tc1, tc1_stride); + } + else if (DO_PTEX) { + *(GLuint *)&v->pv.q1 = 0; /* avoid culling on radeon */ + } + if (DO_TEX2) { + if (DO_PTEX) { + v->pv.u2 = tc2[0][0]; + v->pv.v2 = tc2[0][1]; + if (tc2_size == 4) + v->pv.q2 = tc2[0][3]; + else + v->pv.q2 = 1.0; + } + else { + v->v.u2 = tc2[0][0]; + v->v.v2 = tc2[0][1]; } - if (DO_TEX1) { - if (DO_PTEX) { - v->pv.u1 = tc1[i][0]; - v->pv.v1 = tc1[i][1]; - if (tc1_size == 4) - v->pv.q1 = tc1[i][3]; - else - v->pv.q1 = 1.0; - } - else { - v->v.u1 = tc1[i][0]; - v->v.v1 = tc1[i][1]; - } + STRIDE_4F(tc2, tc2_stride); + } + if (DO_TEX3) { + if (DO_PTEX) { + v->pv.u3 = tc3[0][0]; + v->pv.v3 = tc3[0][1]; + if (tc3_size == 4) + v->pv.q3 = tc3[0][3]; + else + v->pv.q3 = 1.0; + } + else { + v->v.u3 = tc3[0][0]; + v->v.v3 = tc3[0][1]; } - } + STRIDE_4F(tc3, tc3_stride); + } } + } #else -#if DO_XYZW #if HAVE_HW_DIVIDE #error "cannot use tiny vertices with hw perspective divide" @@ -419,8 +337,8 @@ static void TAG(emit)( GLcontext *ctx, GLuint start, GLuint end, void *dest, GLuint stride ) { LOCALVARS - struct vertex_buffer *VB = &TNL_CONTEXT(ctx)->vb; - GLubyte (*col)[4]; + struct vertex_buffer *VB = &TNL_CONTEXT(ctx)->vb; + GLfloat (*col)[4]; GLuint col_stride; GLfloat (*coord)[4] = VB->NdcPtr->data; GLuint coord_stride = VB->NdcPtr->stride; @@ -433,12 +351,8 @@ static void TAG(emit)( GLcontext *ctx, GLuint start, GLuint end, ASSERT(stride == 4); - if (VB->ColorPtr[0]->Type != GL_UNSIGNED_BYTE) - IMPORT_FLOAT_COLORS( ctx ); - - col = (GLubyte (*)[4])VB->ColorPtr[0]->Ptr; - col_stride = VB->ColorPtr[0]->StrideB; - ASSERT(VB->ColorPtr[0]->Type == GL_UNSIGNED_BYTE); + col = VB->ColorPtr[0]->data; + col_stride = VB->ColorPtr[0]->stride; /* fprintf(stderr, "%s(small) importable %x\n", */ /* __FUNCTION__, VB->importable_data); */ @@ -446,103 +360,33 @@ static void TAG(emit)( GLcontext *ctx, GLuint start, GLuint end, /* 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); - } + if (start) { + STRIDE_4F(coord, start * coord_stride); + STRIDE_4F(col, start * col_stride); + } - for (i=start; i < end; i++, v+=4) { + for (i=start; i < end; i++, v+=4) { + if (DO_XYZW) { if (HAVE_HW_VIEWPORT || mask[i] == 0) { 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) { - if (HAVE_RGBA_COLOR) { - *(GLuint *)&v[3] = LE32_TO_CPU(*(GLuint *)col); - } - else { - VERTEX_COLOR *c = (VERTEX_COLOR *)&v[3]; - c->blue = col[0][2]; - c->green = col[0][1]; - c->red = col[0][0]; - c->alpha = col[0][3]; - } - STRIDE_4UB( col, col_stride ); - } -/* fprintf(stderr, "vert %d: %.2f %.2f %.2f %x\n", */ -/* i, v[0], v[1], v[2], *(int *)&v[3]); */ + STRIDE_4F( coord, coord_stride ); + } + if (DO_RGBA) { + VERTEX_COLOR *c = (VERTEX_COLOR *)&v[3]; + UNCLAMPED_FLOAT_TO_UBYTE(c->red, col[0][0]); + UNCLAMPED_FLOAT_TO_UBYTE(c->green, col[0][1]); + UNCLAMPED_FLOAT_TO_UBYTE(c->blue, col[0][2]); + UNCLAMPED_FLOAT_TO_UBYTE(c->alpha, col[0][3]); + STRIDE_4F( col, col_stride ); } - } - else { - for (i=start; i < end; i++, v+=4) { - if (HAVE_HW_VIEWPORT || mask[i] == 0) { - 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) { - *(GLuint *)&v[3] = LE32_TO_CPU(*(GLuint *)&col[i]); - } - else { - VERTEX_COLOR *c = (VERTEX_COLOR *)&v[3]; - c->blue = col[i][2]; - c->green = col[i][1]; - c->red = col[i][0]; - c->alpha = col[i][3]; - } - } /* fprintf(stderr, "vert %d: %.2f %.2f %.2f %x\n", */ /* i, v[0], v[1], v[2], *(int *)&v[3]); */ - - } } } -#else -static void TAG(emit)( GLcontext *ctx, GLuint start, GLuint end, - void *dest, GLuint stride ) -{ - LOCALVARS - struct vertex_buffer *VB = &TNL_CONTEXT(ctx)->vb; - GLubyte (*col)[4]; - GLuint col_stride; - GLfloat *v = (GLfloat *)dest; - int i; - if (VB->ColorPtr[0]->Type != GL_UNSIGNED_BYTE) - IMPORT_FLOAT_COLORS( ctx ); - - col = VB->ColorPtr[0]->Ptr; - col_stride = VB->ColorPtr[0]->StrideB; - - 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 = LE32_TO_CPU(*(GLuint *)col[0]); - } - else { - VERTEX_COLOR *c = (VERTEX_COLOR *)v; - c->blue = col[0][2]; - c->green = col[0][1]; - c->red = col[0][0]; - c->alpha = col[0][3]; - } - STRIDE_4UB( col, col_stride ); - } -} -#endif /* emit */ #endif /* emit */ #if (DO_XYZW) && (DO_RGBA) diff --git a/src/mesa/drivers/common/t_dd_vertex.h b/src/mesa/drivers/common/t_dd_vertex.h index acd35aafad..d45dd09fbd 100644 --- a/src/mesa/drivers/common/t_dd_vertex.h +++ b/src/mesa/drivers/common/t_dd_vertex.h @@ -1,4 +1,3 @@ -/* $Id: t_dd_vertex.h,v 1.13 2002/10/29 20:29:05 brianp Exp $ */ /* * Mesa 3-D graphics library |