diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/mesa/drivers/dri/r200/r200_context.c | 6 | ||||
-rw-r--r-- | src/mesa/drivers/dri/r200/r200_maos_arrays.c | 76 | ||||
-rw-r--r-- | src/mesa/drivers/dri/r200/r200_state.c | 26 | ||||
-rw-r--r-- | src/mesa/drivers/dri/r200/r200_swtcl.c | 41 | ||||
-rw-r--r-- | src/mesa/drivers/dri/r200/r200_tcl.c | 27 | ||||
-rw-r--r-- | src/mesa/drivers/dri/r200/r200_vtxfmt.c | 22 | ||||
-rw-r--r-- | src/mesa/drivers/dri/r200/r200_vtxfmt_c.c | 17 | ||||
-rw-r--r-- | src/mesa/tnl_dd/t_dd_dmatmp.h | 12 | ||||
-rw-r--r-- | src/mesa/tnl_dd/t_dd_dmatmp2.h | 20 | ||||
-rw-r--r-- | src/mesa/tnl_dd/t_dd_tritmp.h | 42 | ||||
-rw-r--r-- | src/mesa/tnl_dd/t_dd_vb.c | 66 | ||||
-rw-r--r-- | src/mesa/tnl_dd/t_dd_vbtmp.h | 417 |
12 files changed, 279 insertions, 493 deletions
diff --git a/src/mesa/drivers/dri/r200/r200_context.c b/src/mesa/drivers/dri/r200/r200_context.c index ec95f05e6ef..ca6ce4974ae 100644 --- a/src/mesa/drivers/dri/r200/r200_context.c +++ b/src/mesa/drivers/dri/r200/r200_context.c @@ -151,10 +151,10 @@ static const char * const card_extensions[] = NULL }; -extern const struct gl_pipeline_stage _r200_render_stage; -extern const struct gl_pipeline_stage _r200_tcl_stage; +extern const struct tnl_pipeline_stage _r200_render_stage; +extern const struct tnl_pipeline_stage _r200_tcl_stage; -static const struct gl_pipeline_stage *r200_pipeline[] = { +static const struct tnl_pipeline_stage *r200_pipeline[] = { /* Try and go straight to t&l */ diff --git a/src/mesa/drivers/dri/r200/r200_maos_arrays.c b/src/mesa/drivers/dri/r200/r200_maos_arrays.c index f2abaff3afb..0263d009026 100644 --- a/src/mesa/drivers/dri/r200/r200_maos_arrays.c +++ b/src/mesa/drivers/dri/r200/r200_maos_arrays.c @@ -43,7 +43,6 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. #include "math/m_translate.h" #include "tnl/tnl.h" #include "tnl/t_context.h" -#include "tnl/t_imm_debug.h" #include "r200_context.h" #include "r200_ioctl.h" @@ -316,9 +315,6 @@ void r200EmitArrays( GLcontext *ctx, GLuint inputs ) GLuint vfmt0 = 0, vfmt1 = 0; GLuint count = VB->Count; - if (R200_DEBUG & DEBUG_VERTS) - _tnl_print_vert_flags( __FUNCTION__, inputs ); - if (1) { if (!rmesa->tcl.obj.buf) emit_vector( ctx, @@ -333,7 +329,7 @@ void r200EmitArrays( GLcontext *ctx, GLuint inputs ) case 3: vfmt0 |= R200_VTX_Z0; case 2: default: - break; + break; } component[nr++] = &rmesa->tcl.obj; } @@ -353,60 +349,44 @@ void r200EmitArrays( GLcontext *ctx, GLuint inputs ) } if (inputs & VERT_BIT_COLOR0) { - if (VB->ColorPtr[0]->Type == GL_UNSIGNED_BYTE) { - if (!rmesa->tcl.rgba.buf) - emit_ubyte_rgba( ctx, - &rmesa->tcl.rgba, - (char *)VB->ColorPtr[0]->Ptr, - VB->ColorPtr[0]->Size, - VB->ColorPtr[0]->StrideB, - count); - - vfmt0 |= R200_VTX_PK_RGBA << R200_VTX_COLOR_0_SHIFT; + int emitsize; + + if (VB->ColorPtr[0]->size == 4 && + (VB->ColorPtr[0]->stride != 0 || + VB->ColorPtr[0]->data[0][3] != 1.0)) { + vfmt0 |= R200_VTX_FP_RGBA << R200_VTX_COLOR_0_SHIFT; + emitsize = 4; } - else { - int emitsize; - - if (VB->ColorPtr[0]->Size == 4 && - (VB->ColorPtr[0]->StrideB != 0 || - ((GLfloat *)VB->ColorPtr[0]->Ptr)[3] != 1.0)) { - vfmt0 |= R200_VTX_FP_RGBA << R200_VTX_COLOR_0_SHIFT; - emitsize = 4; - } - else { - vfmt0 |= R200_VTX_FP_RGB << R200_VTX_COLOR_0_SHIFT; - emitsize = 3; - } - - if (!rmesa->tcl.rgba.buf) - emit_vector( ctx, - &(rmesa->tcl.rgba), - (char *)VB->ColorPtr[0]->Ptr, - emitsize, - VB->ColorPtr[0]->StrideB, - count); + else { + vfmt0 |= R200_VTX_FP_RGB << R200_VTX_COLOR_0_SHIFT; + emitsize = 3; } + if (!rmesa->tcl.rgba.buf) + emit_vector( ctx, + &(rmesa->tcl.rgba), + (char *)VB->ColorPtr[0]->data, + emitsize, + VB->ColorPtr[0]->stride, + count); + component[nr++] = &rmesa->tcl.rgba; } if (inputs & VERT_BIT_COLOR1) { if (!rmesa->tcl.spec.buf) { - if (VB->SecondaryColorPtr[0]->Type != GL_UNSIGNED_BYTE) - r200_import_float_spec_colors( ctx ); - - emit_ubyte_rgba( ctx, - &rmesa->tcl.spec, - (char *)VB->SecondaryColorPtr[0]->Ptr, - 3, - VB->SecondaryColorPtr[0]->StrideB, - count); + emit_vector( ctx, + &rmesa->tcl.spec, + (char *)VB->SecondaryColorPtr[0]->data, + 3, + VB->SecondaryColorPtr[0]->stride, + count); } /* How does this work? */ - vfmt0 |= R200_VTX_PK_RGBA << R200_VTX_COLOR_1_SHIFT; + vfmt0 |= R200_VTX_FP_RGB << R200_VTX_COLOR_1_SHIFT; component[nr++] = &rmesa->tcl.spec; } @@ -455,8 +435,8 @@ void r200ReleaseArrays( GLcontext *ctx, GLuint newinputs ) { r200ContextPtr rmesa = R200_CONTEXT( ctx ); - if (R200_DEBUG & DEBUG_VERTS) - _tnl_print_vert_flags( __FUNCTION__, newinputs ); +/* if (R200_DEBUG & DEBUG_VERTS) */ +/* _tnl_print_vert_flags( __FUNCTION__, newinputs ); */ if (newinputs & VERT_BIT_POS) r200ReleaseDmaRegion( rmesa, &rmesa->tcl.obj, __FUNCTION__ ); diff --git a/src/mesa/drivers/dri/r200/r200_state.c b/src/mesa/drivers/dri/r200/r200_state.c index 55a00cd4de7..27dc6fd1f2b 100644 --- a/src/mesa/drivers/dri/r200/r200_state.c +++ b/src/mesa/drivers/dri/r200/r200_state.c @@ -2089,10 +2089,30 @@ static void r200InvalidateState( GLcontext *ctx, GLuint new_state ) r200VtxfmtInvalidate( ctx ); } +/* A hack. The r200 can actually cope just fine with materials + * between begin/ends, so fix this. + */ +static GLboolean check_material( GLcontext *ctx ) +{ + TNLcontext *tnl = TNL_CONTEXT(ctx); + GLint i; + + for (i = _TNL_ATTRIB_MAT_FRONT_AMBIENT; + i < _TNL_ATTRIB_MAT_BACK_INDEXES; + i++) + if (tnl->vb.AttribPtr[i] && + tnl->vb.AttribPtr[i]->stride) + return GL_TRUE; + + return GL_FALSE; +} + + static void r200WrapRunPipeline( GLcontext *ctx ) { r200ContextPtr rmesa = R200_CONTEXT(ctx); TNLcontext *tnl = TNL_CONTEXT(ctx); + GLboolean has_material; if (0) fprintf(stderr, "%s, newstate: %x\n", __FUNCTION__, rmesa->NewGLState); @@ -2102,7 +2122,9 @@ static void r200WrapRunPipeline( GLcontext *ctx ) if (rmesa->NewGLState) r200ValidateState( ctx ); - if (tnl->vb.Material) { + has_material = (ctx->Light.Enabled && check_material( ctx )); + + if (has_material) { TCL_FALLBACK( ctx, R200_TCL_FALLBACK_MATERIAL, GL_TRUE ); } @@ -2110,7 +2132,7 @@ static void r200WrapRunPipeline( GLcontext *ctx ) */ _tnl_run_pipeline( ctx ); - if (tnl->vb.Material) { + if (has_material) { TCL_FALLBACK( ctx, R200_TCL_FALLBACK_MATERIAL, GL_FALSE ); r200UpdateMaterial( ctx ); /* not needed any more? */ } diff --git a/src/mesa/drivers/dri/r200/r200_swtcl.c b/src/mesa/drivers/dri/r200/r200_swtcl.c index dd4025235b6..48b438cc292 100644 --- a/src/mesa/drivers/dri/r200/r200_swtcl.c +++ b/src/mesa/drivers/dri/r200/r200_swtcl.c @@ -48,7 +48,6 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. #include "math/m_translate.h" #include "tnl/tnl.h" #include "tnl/t_context.h" -#include "tnl/t_imm_exec.h" #include "tnl/t_pipeline.h" #include "r200_context.h" @@ -538,7 +537,7 @@ static void VERT_FALLBACK( GLcontext *ctx, tnl->Driver.Render.PrimitiveNotify( ctx, flags & PRIM_MODE_MASK ); tnl->Driver.Render.BuildVertices( ctx, start, count, ~0 ); tnl->Driver.Render.PrimTabVerts[flags&PRIM_MODE_MASK]( ctx, start, count, flags ); - R200_CONTEXT(ctx)->swtcl.SetupNewInputs = VERT_BIT_CLIP; + R200_CONTEXT(ctx)->swtcl.SetupNewInputs = _TNL_BIT_POS; } static void ELT_FALLBACK( GLcontext *ctx, @@ -550,7 +549,7 @@ static void ELT_FALLBACK( GLcontext *ctx, tnl->Driver.Render.PrimitiveNotify( ctx, flags & PRIM_MODE_MASK ); tnl->Driver.Render.BuildVertices( ctx, start, count, ~0 ); tnl->Driver.Render.PrimTabElts[flags&PRIM_MODE_MASK]( ctx, start, count, flags ); - R200_CONTEXT(ctx)->swtcl.SetupNewInputs = VERT_BIT_CLIP; + R200_CONTEXT(ctx)->swtcl.SetupNewInputs = _TNL_BIT_POS; } @@ -632,7 +631,7 @@ do { \ static GLboolean r200_run_render( GLcontext *ctx, - struct gl_pipeline_stage *stage ) + struct tnl_pipeline_stage *stage ) { r200ContextPtr rmesa = R200_CONTEXT(ctx); TNLcontext *tnl = TNL_CONTEXT(ctx); @@ -660,18 +659,22 @@ static GLboolean r200_run_render( GLcontext *ctx, tnl->Driver.Render.Start( ctx ); - for (i = 0 ; !(flags & PRIM_LAST) ; i += length) + for (i = 0 ; i < VB->PrimitiveCount ; i++) { - flags = VB->Primitive[i]; - length = VB->PrimitiveLength[i]; + GLuint prim = VB->Primitive[i].mode; + GLuint start = VB->Primitive[i].start; + GLuint length = VB->Primitive[i].count; + + if (!length) + continue; if (R200_DEBUG & DEBUG_PRIMS) fprintf(stderr, "r200_render.c: prim %s %d..%d\n", - _mesa_lookup_enum_by_nr(flags & PRIM_MODE_MASK), - i, i+length); + _mesa_lookup_enum_by_nr(prim & PRIM_MODE_MASK), + start, start+length); if (length) - tab[flags & PRIM_MODE_MASK]( ctx, i, i + length, flags ); + tab[prim & PRIM_MODE_MASK]( ctx, start, start + length, flags ); } tnl->Driver.Render.Finish( ctx ); @@ -682,35 +685,35 @@ static GLboolean r200_run_render( GLcontext *ctx, static void r200_check_render( GLcontext *ctx, - struct gl_pipeline_stage *stage ) + struct tnl_pipeline_stage *stage ) { - GLuint inputs = VERT_BIT_POS | VERT_BIT_CLIP | VERT_BIT_COLOR0; + GLuint inputs = _TNL_BIT_POS | _TNL_BIT_COLOR0; if (ctx->RenderMode == GL_RENDER) { if (ctx->_TriangleCaps & DD_SEPARATE_SPECULAR) - inputs |= VERT_BIT_COLOR1; + inputs |= _TNL_BIT_COLOR1; if (ctx->Texture.Unit[0]._ReallyEnabled) - inputs |= VERT_BIT_TEX0; + inputs |= _TNL_BIT_TEX0; if (ctx->Texture.Unit[1]._ReallyEnabled) - inputs |= VERT_BIT_TEX1; + inputs |= _TNL_BIT_TEX1; if (ctx->Fog.Enabled) - inputs |= VERT_BIT_FOG; + inputs |= _TNL_BIT_FOG; } stage->inputs = inputs; } -static void dtr( struct gl_pipeline_stage *stage ) +static void dtr( struct tnl_pipeline_stage *stage ) { (void)stage; } -const struct gl_pipeline_stage _r200_render_stage = +const struct tnl_pipeline_stage _r200_render_stage = { "r200 render", (_DD_NEW_SEPARATE_SPECULAR | @@ -1231,7 +1234,7 @@ r200PointsBitmap( GLcontext *ctx, GLint px, GLint py, void r200FlushVertices( GLcontext *ctx, GLuint flags ) { - _tnl_flush_vertices( ctx, flags ); + _tnl_FlushVertices( ctx, flags ); if (flags & FLUSH_STORED_VERTICES) R200_NEWPRIM( R200_CONTEXT( ctx ) ); diff --git a/src/mesa/drivers/dri/r200/r200_tcl.c b/src/mesa/drivers/dri/r200/r200_tcl.c index 9869ad61963..71e3d5256a9 100644 --- a/src/mesa/drivers/dri/r200/r200_tcl.c +++ b/src/mesa/drivers/dri/r200/r200_tcl.c @@ -255,7 +255,7 @@ void r200TclPrimitive( GLcontext *ctx, /* TCL render. */ static GLboolean r200_run_tcl_render( GLcontext *ctx, - struct gl_pipeline_stage *stage ) + struct tnl_pipeline_stage *stage ) { r200ContextPtr rmesa = R200_CONTEXT(ctx); TNLcontext *tnl = TNL_CONTEXT(ctx); @@ -278,24 +278,19 @@ static GLboolean r200_run_tcl_render( GLcontext *ctx, rmesa->tcl.Elts = VB->Elts; - for (i = VB->FirstPrimitive ; !(flags & PRIM_LAST) ; i += length) + for (i = 0 ; i < VB->PrimitiveCount ; i++) { - flags = VB->Primitive[i]; - length = VB->PrimitiveLength[i]; - - if (R200_DEBUG & DEBUG_PRIMS) - fprintf(stderr, "%s: prim %s %d..%d\n", - __FUNCTION__, - _mesa_lookup_enum_by_nr(flags & PRIM_MODE_MASK), - i, i+length); + GLuint prim = VB->Primitive[i].mode; + GLuint start = VB->Primitive[i].start; + GLuint length = VB->Primitive[i].count; if (!length) continue; if (rmesa->tcl.Elts) - r200EmitEltPrimitive( ctx, i, i+length, flags ); + r200EmitEltPrimitive( ctx, start, start+length, prim ); else - r200EmitPrimitive( ctx, i, i+length, flags ); + r200EmitPrimitive( ctx, start, start+length, prim ); } return GL_FALSE; /* finished the pipe */ @@ -304,7 +299,7 @@ static GLboolean r200_run_tcl_render( GLcontext *ctx, static void r200_check_tcl_render( GLcontext *ctx, - struct gl_pipeline_stage *stage ) + struct tnl_pipeline_stage *stage ) { r200ContextPtr rmesa = R200_CONTEXT(ctx); GLuint inputs = VERT_BIT_POS; @@ -360,13 +355,13 @@ static void r200_check_tcl_render( GLcontext *ctx, } static void r200_init_tcl_render( GLcontext *ctx, - struct gl_pipeline_stage *stage ) + struct tnl_pipeline_stage *stage ) { stage->check = r200_check_tcl_render; stage->check( ctx, stage ); } -static void dtr( struct gl_pipeline_stage *stage ) +static void dtr( struct tnl_pipeline_stage *stage ) { (void)stage; } @@ -374,7 +369,7 @@ static void dtr( struct gl_pipeline_stage *stage ) /* Initial state for tcl stage. */ -const struct gl_pipeline_stage _r200_tcl_stage = +const struct tnl_pipeline_stage _r200_tcl_stage = { "r200 render", (_DD_NEW_SEPARATE_SPECULAR | diff --git a/src/mesa/drivers/dri/r200/r200_vtxfmt.c b/src/mesa/drivers/dri/r200/r200_vtxfmt.c index 5a4f59d9763..824216eb350 100644 --- a/src/mesa/drivers/dri/r200/r200_vtxfmt.c +++ b/src/mesa/drivers/dri/r200/r200_vtxfmt.c @@ -75,10 +75,10 @@ static void count_funcs( r200ContextPtr rmesa ) count_func( "Vertex2fv", &rmesa->vb.dfn_cache.Vertex2fv ); count_func( "Vertex3f", &rmesa->vb.dfn_cache.Vertex3f ); count_func( "Vertex3fv", &rmesa->vb.dfn_cache.Vertex3fv ); - count_func( "Color4ub", &rmesa->vb.dfn_cache.Color4ub ); - count_func( "Color4ubv", &rmesa->vb.dfn_cache.Color4ubv ); - count_func( "Color3ub", &rmesa->vb.dfn_cache.Color3ub ); - count_func( "Color3ubv", &rmesa->vb.dfn_cache.Color3ubv ); + count_func( "Color4ub", &rmesa->vb.dfn_cache.Color4ub ); + count_func( "Color4ubv", &rmesa->vb.dfn_cache.Color4ubv ); + count_func( "Color3ub", &rmesa->vb.dfn_cache.Color3ub ); + count_func( "Color3ubv", &rmesa->vb.dfn_cache.Color3ubv ); count_func( "Color4f", &rmesa->vb.dfn_cache.Color4f ); count_func( "Color4fv", &rmesa->vb.dfn_cache.Color4fv ); count_func( "Color3f", &rmesa->vb.dfn_cache.Color3f ); @@ -468,7 +468,10 @@ static void VFMT_FALLBACK( const char *caller ) glNormal3fv( rmesa->vb.normalptr ); if (VTX_COLOR(ind0, 0) == R200_VTX_PK_RGBA) - glColor4ub( rmesa->vb.colorptr->red, rmesa->vb.colorptr->green, rmesa->vb.colorptr->blue, rmesa->vb.colorptr->alpha ); + glColor4ub( rmesa->vb.colorptr->red, + rmesa->vb.colorptr->green, + rmesa->vb.colorptr->blue, + rmesa->vb.colorptr->alpha ); else if (VTX_COLOR(ind0, 0) == R200_VTX_FP_RGBA) glColor4fv( rmesa->vb.floatcolorptr ); else if (VTX_COLOR(ind0, 0) == R200_VTX_FP_RGB) { @@ -482,7 +485,9 @@ static void VFMT_FALLBACK( const char *caller ) } if (VTX_COLOR(ind0, 1) == R200_VTX_PK_RGBA) - _glapi_Dispatch->SecondaryColor3ubEXT( rmesa->vb.specptr->red, rmesa->vb.specptr->green, rmesa->vb.specptr->blue ); + _glapi_Dispatch->SecondaryColor3ubEXT( rmesa->vb.specptr->red, + rmesa->vb.specptr->green, + rmesa->vb.specptr->blue ); if (ind1 & (7 << R200_VTX_TEX0_COMP_CNT_SHIFT)) glTexCoord2fv( rmesa->vb.texcoordptr[0] ); @@ -1006,13 +1011,14 @@ void r200VtxfmtInit( GLcontext *ctx ) vfmt->FogCoordfEXT = _mesa_noop_FogCoordfEXT; vfmt->EdgeFlag = _mesa_noop_EdgeFlag; vfmt->EdgeFlagv = _mesa_noop_EdgeFlagv; - vfmt->Indexi = _mesa_noop_Indexi; - vfmt->Indexiv = _mesa_noop_Indexiv; + vfmt->Indexf = _mesa_noop_Indexf; + vfmt->Indexfv = _mesa_noop_Indexfv; /* Active but unsupported -- fallback if we receive these: */ vfmt->CallList = r200_fallback_CallList; + vfmt->CallLists = r200_fallback_CallLists; vfmt->EvalCoord1f = r200_fallback_EvalCoord1f; vfmt->EvalCoord1fv = r200_fallback_EvalCoord1fv; vfmt->EvalCoord2f = r200_fallback_EvalCoord2f; diff --git a/src/mesa/drivers/dri/r200/r200_vtxfmt_c.c b/src/mesa/drivers/dri/r200/r200_vtxfmt_c.c index b7f3fec43e0..bdda60eea09 100644 --- a/src/mesa/drivers/dri/r200/r200_vtxfmt_c.c +++ b/src/mesa/drivers/dri/r200/r200_vtxfmt_c.c @@ -827,16 +827,10 @@ void r200VtxfmtInitChoosers( GLvertexformat *vfmt ) { vfmt->Color3f = choose_Color3f; vfmt->Color3fv = choose_Color3fv; - vfmt->Color3ub = choose_Color3ub; - vfmt->Color3ubv = choose_Color3ubv; vfmt->Color4f = choose_Color4f; vfmt->Color4fv = choose_Color4fv; - vfmt->Color4ub = choose_Color4ub; - vfmt->Color4ubv = choose_Color4ubv; vfmt->SecondaryColor3fEXT = choose_SecondaryColor3fEXT; vfmt->SecondaryColor3fvEXT = choose_SecondaryColor3fvEXT; - vfmt->SecondaryColor3ubEXT = choose_SecondaryColor3ubEXT; - vfmt->SecondaryColor3ubvEXT = choose_SecondaryColor3ubvEXT; vfmt->MultiTexCoord1fARB = choose_MultiTexCoord1fARB; vfmt->MultiTexCoord1fvARB = choose_MultiTexCoord1fvARB; vfmt->MultiTexCoord2fARB = choose_MultiTexCoord2fARB; @@ -851,6 +845,17 @@ void r200VtxfmtInitChoosers( GLvertexformat *vfmt ) vfmt->Vertex2fv = choose_Vertex2fv; vfmt->Vertex3f = choose_Vertex3f; vfmt->Vertex3fv = choose_Vertex3fv; + + /* TODO: restore ubyte colors to vtxfmt. + */ +#if 0 + vfmt->Color3ub = choose_Color3ub; + vfmt->Color3ubv = choose_Color3ubv; + vfmt->Color4ub = choose_Color4ub; + vfmt->Color4ubv = choose_Color4ubv; + vfmt->SecondaryColor3ubEXT = choose_SecondaryColor3ubEXT; + vfmt->SecondaryColor3ubvEXT = choose_SecondaryColor3ubvEXT; +#endif } diff --git a/src/mesa/tnl_dd/t_dd_dmatmp.h b/src/mesa/tnl_dd/t_dd_dmatmp.h index d9f709389d1..10ff1df5f0b 100644 --- a/src/mesa/tnl_dd/t_dd_dmatmp.h +++ b/src/mesa/tnl_dd/t_dd_dmatmp.h @@ -318,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); @@ -869,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/tnl_dd/t_dd_dmatmp2.h b/src/mesa/tnl_dd/t_dd_dmatmp2.h index 3f58d24c952..dd0286b453b 100644 --- a/src/mesa/tnl_dd/t_dd_dmatmp2.h +++ b/src/mesa/tnl_dd/t_dd_dmatmp2.h @@ -323,9 +323,6 @@ static void TAG(render_tri_strip_verts)( GLcontext *ctx, ELT_INIT( GL_TRIANGLES, HW_TRIANGLES ); - if (flags & PRIM_PARITY) - parity = 1; - /* Emit even number of tris in each full buffer. */ dmasz = dmasz/3; @@ -348,8 +345,6 @@ static void TAG(render_tri_strip_verts)( GLcontext *ctx, 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 { @@ -757,18 +752,9 @@ static void TAG(render_tri_strip_elts)( GLcontext *ctx, for (j = start ; j + 2 < count; j += nr - 2 ) { nr = MIN2( dmasz, count - j ); - if (flags & PRIM_PARITY) { - dest = ALLOC_ELTS( nr ); - dest = TAG(emit_elts)( ctx, dest, elts+j, 1 ); - dest = TAG(emit_elts)( ctx, dest, elts+j, nr-1 ); - nr--; flags &= ~PRIM_PARITY; - CLOSE_ELTS(); - } - else { - dest = ALLOC_ELTS( nr ); - dest = TAG(emit_elts)( ctx, dest, elts+j, nr ); - CLOSE_ELTS(); - } + dest = ALLOC_ELTS( nr ); + dest = TAG(emit_elts)( ctx, dest, elts+j, nr ); + CLOSE_ELTS(); } } diff --git a/src/mesa/tnl_dd/t_dd_tritmp.h b/src/mesa/tnl_dd/t_dd_tritmp.h index e6e90170e9c..b26347b77eb 100644 --- a/src/mesa/tnl_dd/t_dd_tritmp.h +++ b/src/mesa/tnl_dd/t_dd_tritmp.h @@ -176,9 +176,8 @@ static void TAG(triangle)( GLcontext *ctx, GLuint e0, GLuint e1, GLuint e2 ) } } else { - GLchan (*vbcolor)[4] = (GLchan (*)[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) { @@ -191,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] = (GLchan (*)[4])VB->SecondaryColorPtr[1]->Ptr; + GLfloat (*vbspec)[4] = VB->SecondaryColorPtr[1]->data; if (!DO_FLAT) { VERT_SAVE_SPEC( 0 ); @@ -205,11 +204,14 @@ static void TAG(triangle)( GLcontext *ctx, GLuint e0, GLuint e1, GLuint e2 ) } } else { - GLfloat *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] ); } } @@ -308,12 +310,11 @@ static void TAG(triangle)( GLcontext *ctx, GLuint e0, GLuint e1, GLuint e2 ) } } else { - GLfloat *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 ); } } @@ -384,7 +385,7 @@ static void TAG(quad)( GLcontext *ctx, if (DO_TWOSIDE && facing == 1) { if (HAVE_RGBA) { - GLchan (*vbcolor)[4] = (GLchan (*)[4])VB->ColorPtr[1]->Ptr; + GLfloat (*vbcolor)[4] = VB->ColorPtr[1]->data; (void)vbcolor; if (HAVE_BACK_COLORS) { @@ -424,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] = (GLchan (*)[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 ); @@ -441,12 +442,16 @@ static void TAG(quad)( GLcontext *ctx, } } else { - GLfloat *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] ); } } @@ -557,13 +562,12 @@ static void TAG(quad)( GLcontext *ctx, } } else { - GLfloat *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 ); } } @@ -611,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/tnl_dd/t_dd_vb.c b/src/mesa/tnl_dd/t_dd_vb.c index 4a742bcbbee..380b0424b4f 100644 --- a/src/mesa/tnl_dd/t_dd_vb.c +++ b/src/mesa/tnl_dd/t_dd_vb.c @@ -271,56 +271,7 @@ void TAG(print_vertex)( GLcontext *ctx, const VERTEX *v ) fprintf(stderr, "\n"); } -static void do_import( struct vertex_buffer *VB, - struct gl_client_array *to, - struct gl_client_array *from ) -{ - GLuint count = VB->Count; - - if (!to->Ptr) { - to->Ptr = ALIGN_MALLOC( VB->Size * 4 * sizeof(GLubyte), 32 ); - to->Type = GL_UNSIGNED_BYTE; - } - - /* No need to transform the same value 3000 times. - */ - if (!from->StrideB) { - to->StrideB = 0; - count = 1; - } - else - to->StrideB = 4 * sizeof(GLubyte); - - _math_trans_4ub( (GLubyte (*)[4]) to->Ptr, - from->Ptr, - from->StrideB, - from->Type, - from->Size, - 0, - count); -} - -#ifndef IMPORT_QUALIFIER -#define IMPORT_QUALIFIER static -#endif - -IMPORT_QUALIFIER void TAG(import_float_colors)( GLcontext *ctx ) -{ - LOCALVARS - struct vertex_buffer *VB = &TNL_CONTEXT(ctx)->vb; - struct gl_client_array *to = GET_UBYTE_COLOR_STORE(); - do_import( VB, to, VB->ColorPtr[0] ); - VB->ColorPtr[0] = to; -} -IMPORT_QUALIFIER void TAG(import_float_spec_colors)( GLcontext *ctx ) -{ - LOCALVARS - struct vertex_buffer *VB = &TNL_CONTEXT(ctx)->vb; - struct gl_client_array *to = GET_UBYTE_SPEC_COLOR_STORE(); - do_import( VB, to, VB->SecondaryColorPtr[0] ); - VB->SecondaryColorPtr[0] = to; -} /* Interpolate the elements of the VB not included in typical hardware * vertices. @@ -332,7 +283,7 @@ IMPORT_QUALIFIER void TAG(import_float_spec_colors)( GLcontext *ctx ) #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, @@ -344,13 +295,15 @@ INTERP_QUALIFIER void TAG(interp_extras)( GLcontext *ctx, struct vertex_buffer *VB = &TNL_CONTEXT(ctx)->vb; if (VB->ColorPtr[1]) { - INTERP_4CHAN( t, + 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) ); if (VB->SecondaryColorPtr[1]) { - INTERP_3CHAN( t, + INTERP_3F( t, GET_COLOR(VB->SecondaryColorPtr[1], dst), GET_COLOR(VB->SecondaryColorPtr[1], out), GET_COLOR(VB->SecondaryColorPtr[1], in) ); @@ -371,12 +324,12 @@ INTERP_QUALIFIER void TAG(copy_pv_extras)( GLcontext *ctx, struct vertex_buffer *VB = &TNL_CONTEXT(ctx)->vb; if (VB->ColorPtr[1]) { - COPY_CHAN4( GET_COLOR(VB->ColorPtr[1], dst), - GET_COLOR(VB->ColorPtr[1], src) ); + COPY_4FV( GET_COLOR(VB->ColorPtr[1], dst), + GET_COLOR(VB->ColorPtr[1], src) ); if (VB->SecondaryColorPtr[1]) { - COPY_CHAN4( GET_COLOR(VB->SecondaryColorPtr[1], dst), - GET_COLOR(VB->SecondaryColorPtr[1], src) ); + COPY_4FV( GET_COLOR(VB->SecondaryColorPtr[1], dst), + GET_COLOR(VB->SecondaryColorPtr[1], src) ); } } @@ -385,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/tnl_dd/t_dd_vbtmp.h b/src/mesa/tnl_dd/t_dd_vbtmp.h index 5aad0b56222..230edf055f9 100644 --- a/src/mesa/tnl_dd/t_dd_vbtmp.h +++ b/src/mesa/tnl_dd/t_dd_vbtmp.h @@ -123,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; @@ -184,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; } } @@ -215,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, col[0][0]); + UNCLAMPED_FLOAT_TO_UBYTE(v->v.specular.green, col[0][1]); + UNCLAMPED_FLOAT_TO_UBYTE(v->v.specular.blue, col[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" @@ -418,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; @@ -432,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); */ @@ -445,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) |