From 719344b23ed7b1947af1db9281389f3fc74c3fc5 Mon Sep 17 00:00:00 2001 From: Keith Whitwell Date: Wed, 27 Dec 2000 19:57:37 +0000 Subject: Fixes for compiling assembly (disable unused 'masked' versions) Fixes for compiling without debug. Fix line clipping Fix unfilled polygon clipping (should be correct now). --- src/mesa/tnl/t_array_import.c | 5 +- src/mesa/tnl/t_vb_cliptmp.h | 130 +++++++++++++++++++++++++++--------------- src/mesa/tnl/t_vb_light.c | 4 +- src/mesa/tnl/t_vb_normals.c | 3 +- src/mesa/tnl/t_vb_render.c | 3 +- src/mesa/tnl/t_vb_rendertmp.h | 75 ++++++++++++------------ 6 files changed, 128 insertions(+), 92 deletions(-) (limited to 'src/mesa/tnl') diff --git a/src/mesa/tnl/t_array_import.c b/src/mesa/tnl/t_array_import.c index 16a669dc28..1cfed06764 100644 --- a/src/mesa/tnl/t_array_import.c +++ b/src/mesa/tnl/t_array_import.c @@ -1,4 +1,4 @@ -/* $Id: t_array_import.c,v 1.1 2000/12/26 05:09:32 keithw Exp $ */ +/* $Id: t_array_import.c,v 1.2 2000/12/27 19:57:37 keithw Exp $ */ /* * Mesa 3-D graphics library @@ -248,9 +248,10 @@ static void _tnl_upgrade_client_data( GLcontext *ctx, { GLuint i; struct vertex_buffer *VB = &TNL_CONTEXT(ctx)->vb; - struct vertex_arrays *inputs = &TNL_CONTEXT(ctx)->array_inputs; GLboolean writeable = (flags & VEC_NOT_WRITEABLE) != 0; GLboolean stride = (flags & VEC_BAD_STRIDE) != 0; + struct vertex_arrays *inputs = &TNL_CONTEXT(ctx)->array_inputs; + (void) inputs; if ((required & VERT_CLIP) && VB->ClipPtr == VB->ObjPtr) required |= VERT_OBJ; diff --git a/src/mesa/tnl/t_vb_cliptmp.h b/src/mesa/tnl/t_vb_cliptmp.h index 8a73e87de3..34f0a4f1e1 100644 --- a/src/mesa/tnl/t_vb_cliptmp.h +++ b/src/mesa/tnl/t_vb_cliptmp.h @@ -1,4 +1,4 @@ -/* $Id: t_vb_cliptmp.h,v 1.1 2000/12/26 05:09:33 keithw Exp $ */ +/* $Id: t_vb_cliptmp.h,v 1.2 2000/12/27 19:57:37 keithw Exp $ */ /* * Mesa 3-D graphics library @@ -60,10 +60,14 @@ static GLuint TAG(userclip_line)( GLcontext *ctx, if (flagI ^ flagJ) { if (flagJ) { GLfloat t = dpI / (dpI - dpJ); + VB->ClipMask[jj] |= CLIP_USER_BIT; jj = interp( ctx, t, ii, jj, GL_FALSE ); + VB->ClipMask[jj] = 0; } else { GLfloat t = dpJ / (dpJ - dpI); + VB->ClipMask[ii] |= CLIP_USER_BIT; ii = interp( ctx, t, jj, ii, GL_FALSE ); + VB->ClipMask[ii] = 0; } } else if (flagI) @@ -86,8 +90,15 @@ static GLuint TAG(userclip_polygon)( GLcontext *ctx, GLfloat (*coord)[4] = VB->ClipPtr->data; GLuint vlist2[MAX_CLIPPED_VERTICES]; GLuint *inlist = vlist, *outlist = vlist2; + GLubyte *clipmask = VB->ClipMask; GLuint p; - + +#define CLIP_DOTPROD(xx) d*W(xx) + c*Z(xx) + b*Y(xx) + a*X(xx) + + /* Can be speeded up to if vertex_stage actually saves the + * UserClipMask, and if it is used in this loop (after computing a + * UserClipOrMask). + */ for (p=0;pTransform.ClipEnabled[p]) { register float a = ctx->Transform._ClipUserPlane[p][0]; @@ -96,47 +107,63 @@ static GLuint TAG(userclip_polygon)( GLcontext *ctx, register float d = ctx->Transform._ClipUserPlane[p][3]; /* initialize prev to be last in the input list */ - GLuint prevj = inlist[0]; - GLfloat dpJ = d*W(prevj) + c*Z(prevj) + b*Y(prevj) + a*X(prevj); + GLuint idxPrev = inlist[n-1]; + GLfloat dpPrev = CLIP_DOTPROD(idxPrev); GLuint outcount = 0; - GLuint curri; - - inlist[n] = inlist[0]; - - for (curri=1;curriClipMask[prevj] &= ~CLIP_USER_BIT; + GLuint i; + + for (i = 0 ; i < n ; i++) { + GLuint idx = inlist[i]; + GLfloat dp = CLIP_DOTPROD(idx); + + if (!NEGATIVE(dpPrev)) { + outlist[outcount++] = idxPrev; + clipmask[idxPrev] &= ~CLIP_USER_BIT; } else { - VB->ClipMask[prevj] |= CLIP_USER_BIT; + clipmask[idxPrev] |= CLIP_USER_BIT; } - if (DIFFERENT_SIGNS(dpI, dpJ)) { - if (NEGATIVE(dpI)) { - GLfloat t = dpI/(dpI-dpJ); - outlist[outcount++] = interp( ctx, t, currj, prevj, GL_TRUE); + + if (DIFFERENT_SIGNS(dp, dpPrev)) { + GLuint newvert; + if (NEGATIVE(dp)) { + /* Going out of bounds. Avoid division by zero as we + * know dp != dpPrev from DIFFERENT_SIGNS, above. + */ + GLfloat t = dp / (dp - dpPrev); + newvert = interp( ctx, t, idx, idxPrev, GL_TRUE ); +/* fprintf(stderr,"Goint out: in: %d/%d out: %d/%d new: %d/%d\n", */ +/* idxPrev, VB->EdgeFlagPtr->data[idxPrev], */ +/* idx, VB->EdgeFlagPtr->data[idx], */ +/* newvert, VB->EdgeFlagPtr->data[newvert]); */ } else { - GLfloat t = dpJ/(dpJ-dpI); - outlist[outcount++] = interp( ctx, t, prevj, currj, GL_FALSE); - } + /* Coming back in. + */ + GLfloat t = dpPrev / (dpPrev - dp); + newvert = interp( ctx, t, idxPrev, idx, GL_FALSE ); +/* fprintf(stderr,"coming in: in: %d/%d out: %d/%d new: %d/%d\n", */ +/* idx, VB->EdgeFlagPtr->data[idx], */ +/* idxPrev, VB->EdgeFlagPtr->data[idxPrev], */ +/* newvert, VB->EdgeFlagPtr->data[newvert]); */ + } + clipmask[newvert] = 0; + outlist[outcount++] = newvert; } - - prevj = currj; - dpJ = dpI; - } + + idxPrev = idx; + dpPrev = dp; + } if (outcount < 3) return 0; - else { + + { GLuint *tmp; tmp = inlist; inlist = outlist; outlist = tmp; n = outcount; } - } /* if */ } /* for p */ @@ -146,6 +173,10 @@ static GLuint TAG(userclip_polygon)( GLcontext *ctx, vlist[i] = inlist[i]; } +/* fprintf(stderr, "%s: finally:\n", __FUNCTION__); */ +/* for (i = 0 ; i < n ; i++) */ +/* fprintf(stderr, "%d: %d\n", vlist[i], VB->EdgeFlagPtr->data[vlist[i]]); */ + return n; } @@ -168,25 +199,29 @@ static void TAG(viewclip_line)( GLcontext *ctx, /* * We use 6 instances of this code to clip against the 6 planes. */ -#define GENERAL_CLIP \ - if (mask & PLANE) { \ - GLfloat dpI = CLIP_DOTPROD( ii ); \ - GLfloat dpJ = CLIP_DOTPROD( jj ); \ - \ - if (DIFFERENT_SIGNS(dpI, dpJ)) { \ - if (NEGATIVE(dpJ)) { \ - GLfloat t = dpI / (dpI - dpJ); \ - jj = interp( ctx, t, ii, jj, GL_FALSE ); \ - } else { \ - GLfloat t = dpJ / (dpJ - dpI); \ - ii = interp( ctx, t, jj, ii, GL_FALSE ); \ - } \ - } \ - else if (NEGATIVE(dpI)) \ - return; \ - } - +#define GENERAL_CLIP \ + if (mask & PLANE) { \ + GLfloat dpI = CLIP_DOTPROD( ii ); \ + GLfloat dpJ = CLIP_DOTPROD( jj ); \ + \ + if (DIFFERENT_SIGNS(dpI, dpJ)) { \ + if (NEGATIVE(dpJ)) { \ + GLfloat t = dpI / (dpI - dpJ); \ + VB->ClipMask[jj] |= PLANE; \ + jj = interp( ctx, t, ii, jj, GL_FALSE ); \ + VB->ClipMask[jj] = 0; \ + } else { \ + GLfloat t = dpJ / (dpJ - dpI); \ + VB->ClipMask[ii] |= PLANE; \ + ii = interp( ctx, t, jj, ii, GL_FALSE ); \ + VB->ClipMask[ii] = 0; \ + } \ + } \ + else if (NEGATIVE(dpI)) \ + return; \ + } +#undef CLIP_DOTPROD #define PLANE CLIP_RIGHT_BIT #define CLIP_DOTPROD(K) (- X(K) + W(K)) @@ -271,11 +306,12 @@ static void TAG(viewclip_line)( GLcontext *ctx, } } - if (ctx->Driver.BuildProjectedVertices) + if (ctx->Driver.BuildProjectedVertices) ctx->Driver.BuildProjectedVertices(ctx, VB->FirstClipped, VB->LastClipped, ~0); + /* Render the new line. */ diff --git a/src/mesa/tnl/t_vb_light.c b/src/mesa/tnl/t_vb_light.c index b55cda3858..043eb7302f 100644 --- a/src/mesa/tnl/t_vb_light.c +++ b/src/mesa/tnl/t_vb_light.c @@ -1,4 +1,4 @@ -/* $Id: t_vb_light.c,v 1.1 2000/12/26 05:09:33 keithw Exp $ */ +/* $Id: t_vb_light.c,v 1.2 2000/12/27 19:57:37 keithw Exp $ */ /* * Mesa 3-D graphics library @@ -176,6 +176,8 @@ static GLboolean run_validate_lighting( GLcontext *ctx, } /* tab = _tnl_light_tab; */ } + else + tab = _tnl_light_ci_tab; if (ctx->Light.ColorMaterialEnabled) ind |= LIGHT_COLORMATERIAL; diff --git a/src/mesa/tnl/t_vb_normals.c b/src/mesa/tnl/t_vb_normals.c index 97e7b9bb35..e55520cb5c 100644 --- a/src/mesa/tnl/t_vb_normals.c +++ b/src/mesa/tnl/t_vb_normals.c @@ -1,4 +1,4 @@ -/* $Id: t_vb_normals.c,v 1.1 2000/12/26 05:09:33 keithw Exp $ */ +/* $Id: t_vb_normals.c,v 1.2 2000/12/27 19:57:37 keithw Exp $ */ /* * Mesa 3-D graphics library @@ -64,6 +64,7 @@ static GLboolean run_normal_stage( GLcontext *ctx, if (VB->NormalLengthPtr) { GLfloat diff = VB->NormalLengthPtr[0] - 1.0/LEN_3FV(VB->NormalPtr->data[0]); + (void)diff; ASSERT((diff*diff) < .01); } diff --git a/src/mesa/tnl/t_vb_render.c b/src/mesa/tnl/t_vb_render.c index 5707f21c90..15afe6118d 100644 --- a/src/mesa/tnl/t_vb_render.c +++ b/src/mesa/tnl/t_vb_render.c @@ -1,4 +1,4 @@ -/* $Id: t_vb_render.c,v 1.1 2000/12/26 05:09:33 keithw Exp $ */ +/* $Id: t_vb_render.c,v 1.2 2000/12/27 19:57:37 keithw Exp $ */ /* * Mesa 3-D graphics library @@ -630,6 +630,7 @@ static void check_render( GLcontext *ctx, struct gl_pipeline_stage *stage ) if (ctx->_TriangleCaps & DD_TRI_UNFILLED) { inputs |= VERT_EDGE; + interp |= INTERP_EDGE; } if (ctx->RenderMode==GL_FEEDBACK) { diff --git a/src/mesa/tnl/t_vb_rendertmp.h b/src/mesa/tnl/t_vb_rendertmp.h index de8adb23ec..bd77b9668a 100644 --- a/src/mesa/tnl/t_vb_rendertmp.h +++ b/src/mesa/tnl/t_vb_rendertmp.h @@ -1,4 +1,4 @@ -/* $Id: t_vb_rendertmp.h,v 1.1 2000/12/26 05:09:33 keithw Exp $ */ +/* $Id: t_vb_rendertmp.h,v 1.2 2000/12/27 19:57:37 keithw Exp $ */ /* * Mesa 3-D graphics library @@ -105,9 +105,8 @@ static void TAG(render_line_strip)( GLcontext *ctx, RESET_OCCLUSION; INIT(GL_LINES); - for (j=start+1; j