diff options
author | Keith Whitwell <[email protected]> | 2001-06-28 17:34:14 +0000 |
---|---|---|
committer | Keith Whitwell <[email protected]> | 2001-06-28 17:34:14 +0000 |
commit | 47a28c0b4d4ca27592e3cbb8e4b17d1cd8f7997d (patch) | |
tree | 0fdce5799b53ba8efcb3b30190fa746123cbee3e | |
parent | 206eda8b69ab3c63e9597015189f49d1bda9356f (diff) |
restore normal length optimization in dlists
-rw-r--r-- | src/mesa/math/m_norm_tmp.h | 12 | ||||
-rw-r--r-- | src/mesa/tnl/t_context.c | 12 | ||||
-rw-r--r-- | src/mesa/tnl/t_context.h | 5 | ||||
-rw-r--r-- | src/mesa/tnl/t_imm_alloc.c | 5 | ||||
-rw-r--r-- | src/mesa/tnl/t_imm_dlist.c | 66 | ||||
-rw-r--r-- | src/mesa/tnl/t_imm_exec.c | 5 | ||||
-rw-r--r-- | src/mesa/tnl/t_imm_fixup.c | 5 | ||||
-rw-r--r-- | src/mesa/tnl/t_vb_normals.c | 5 | ||||
-rw-r--r-- | src/mesa/tnl/tnl.h | 7 |
9 files changed, 101 insertions, 21 deletions
diff --git a/src/mesa/math/m_norm_tmp.h b/src/mesa/math/m_norm_tmp.h index bab84d24f57..cc5ff00b3de 100644 --- a/src/mesa/math/m_norm_tmp.h +++ b/src/mesa/math/m_norm_tmp.h @@ -1,4 +1,4 @@ -/* $Id: m_norm_tmp.h,v 1.7 2001/03/30 14:44:43 gareth Exp $ */ +/* $Id: m_norm_tmp.h,v 1.8 2001/06/28 17:34:14 keithw Exp $ */ /* * Mesa 3-D graphics library @@ -140,13 +140,9 @@ TAG(transform_normalize_normals_no_rot)( const GLmatrix *mat, } } else { - /* scale has been snapped to 1.0 if it is close. - */ - if (scale != 1.0) { - m0 *= scale; - m5 *= scale; - m10 *= scale; - } + m0 *= scale; + m5 *= scale; + m10 *= scale; STRIDE_LOOP { GLfloat tx, ty, tz; diff --git a/src/mesa/tnl/t_context.c b/src/mesa/tnl/t_context.c index e842bd14224..0acb9f9db20 100644 --- a/src/mesa/tnl/t_context.c +++ b/src/mesa/tnl/t_context.c @@ -1,4 +1,4 @@ -/* $Id: t_context.c,v 1.19 2001/06/04 16:09:28 keithw Exp $ */ +/* $Id: t_context.c,v 1.20 2001/06/28 17:34:14 keithw Exp $ */ /* * Mesa 3-D graphics library @@ -104,6 +104,7 @@ _tnl_CreateContext( GLcontext *ctx ) tnl->NeedProjCoords = GL_TRUE; tnl->LoopbackDListCassettes = GL_FALSE; + tnl->CalcDListNormalLengths = GL_TRUE; /* Hook our functions into exec and compile dispatch tables. */ @@ -222,3 +223,12 @@ _tnl_need_dlist_loopback( GLcontext *ctx, GLboolean mode ) tnl->LoopbackDListCassettes = mode; } } + +void +_tnl_need_dlist_norm_lengths( GLcontext *ctx, GLboolean mode ) +{ + TNLcontext *tnl = TNL_CONTEXT(ctx); + if (tnl->CalcDListNormalLengths != mode) { + tnl->CalcDListNormalLengths = mode; + } +} diff --git a/src/mesa/tnl/t_context.h b/src/mesa/tnl/t_context.h index 226b877d852..a7ecb346b70 100644 --- a/src/mesa/tnl/t_context.h +++ b/src/mesa/tnl/t_context.h @@ -1,4 +1,4 @@ -/* $Id: t_context.h,v 1.28 2001/06/04 16:09:28 keithw Exp $ */ +/* $Id: t_context.h,v 1.29 2001/06/28 17:34:14 keithw Exp $ */ /* * Mesa 3-D graphics library @@ -207,6 +207,7 @@ struct immediate GLfloat Color[IMM_SIZE][4]; GLfloat Obj[IMM_SIZE][4]; GLfloat Normal[IMM_SIZE][3]; + GLfloat *NormalLengthPtr; GLfloat TexCoord0[IMM_SIZE][4]; /* just VERT_TEX0 */ GLuint Elt[IMM_SIZE]; GLubyte EdgeFlag[IMM_SIZE]; @@ -256,6 +257,7 @@ typedef struct vertex_buffer GLubyte ClipOrMask; /* VERT_CLIP (3) */ GLubyte *ClipMask; /* VERT_CLIP (4) */ GLvector3f *NormalPtr; /* VERT_NORM */ + GLfloat *NormalLengthPtr; /* VERT_NORM */ GLboolean *EdgeFlag; /* VERT_EDGE */ GLvector4f *TexCoordPtr[MAX_TEXTURE_UNITS]; /* VERT_TEX_0..n */ GLvector1ui *IndexPtr[2]; /* VERT_INDEX */ @@ -525,6 +527,7 @@ typedef struct { */ GLboolean NeedProjCoords; GLboolean LoopbackDListCassettes; + GLboolean CalcDListNormalLengths; /* Derived state and storage for _tnl_eval_vb: */ diff --git a/src/mesa/tnl/t_imm_alloc.c b/src/mesa/tnl/t_imm_alloc.c index 22bdb7a7bb3..5cf0d1ea142 100644 --- a/src/mesa/tnl/t_imm_alloc.c +++ b/src/mesa/tnl/t_imm_alloc.c @@ -1,4 +1,4 @@ -/* $Id: t_imm_alloc.c,v 1.8 2001/05/09 13:53:36 keithw Exp $ */ +/* $Id: t_imm_alloc.c,v 1.9 2001/06/28 17:34:14 keithw Exp $ */ /* * Mesa 3-D graphics library @@ -57,6 +57,7 @@ static struct immediate *real_alloc_immediate( GLcontext *ctx ) IM->MaterialMask = 0; IM->MaxTextureUnits = ctx->Const.MaxTextureUnits; IM->TexSize = 0; + IM->NormalLengthPtr = 0; IM->CopyTexSize = 0; IM->CopyStart = IM->Start; @@ -96,6 +97,8 @@ static void real_free_immediate( struct immediate *IM ) for (j = 1; j < IM->MaxTextureUnits; j++) ALIGN_FREE( IM->TexCoord[j] ); + if (IM->NormalLengthPtr) + ALIGN_FREE( IM->NormalLengthPtr ); ALIGN_FREE( IM ); freed++; diff --git a/src/mesa/tnl/t_imm_dlist.c b/src/mesa/tnl/t_imm_dlist.c index 722d67b1435..9c22ed3e7b7 100644 --- a/src/mesa/tnl/t_imm_dlist.c +++ b/src/mesa/tnl/t_imm_dlist.c @@ -1,4 +1,4 @@ -/* $Id: t_imm_dlist.c,v 1.20 2001/06/04 16:09:28 keithw Exp $ */ +/* $Id: t_imm_dlist.c,v 1.21 2001/06/28 17:34:14 keithw Exp $ */ /* * Mesa 3-D graphics library @@ -66,6 +66,55 @@ static void execute_compiled_cassette( GLcontext *ctx, void *data ); static void loopback_compiled_cassette( GLcontext *ctx, struct immediate *IM ); +static void build_normal_lengths( struct immediate *IM ) +{ + GLuint i; + GLfloat len; + GLfloat (*data)[3] = IM->Normal + IM->Start; + GLfloat *dest = IM->NormalLengthPtr; + GLuint *flags = IM->Flag + IM->Start; + GLuint count = IM->Count - IM->Start; + + if (!dest) { + dest = IM->NormalLengthPtr = ALIGN_MALLOC( IMM_SIZE*sizeof(GLfloat), 32 ); + if (!dest) return; + } + dest += IM->Start; + + len = (GLfloat) LEN_3FV( data[0] ); + if (len > 0.0) len = 1.0/len; + + for (i = 0 ; i < count ; ) { + dest[i] = len; + if (flags[++i] & VERT_NORM) { + len = (GLfloat) LEN_3FV( data[i] ); + if (len > 0.0) len = 1.0/len; + } + } +} + +static void fixup_normal_lengths( struct immediate *IM ) +{ + GLuint i; + GLfloat len; + GLfloat (*data)[3] = IM->Normal; + GLfloat *dest = IM->NormalLengthPtr; + GLuint *flags = IM->Flag; + + for (i = IM->CopyStart ; i <= IM->Start ; i++) { + len = (GLfloat) LEN_3FV( data[i] ); + if (len > 0.0) len = 1.0/len; + dest[i] = len; + } + + while (!(flags[i] & (VERT_NORM|VERT_END_VB))) { + dest[i] = len; + i++; + } +} + + + /* Insert the active immediate struct onto the display list currently * being built. */ @@ -84,14 +133,14 @@ _tnl_compile_cassette( GLcontext *ctx, struct immediate *IM ) _tnl_compute_orflag( IM, IM->Start ); - /* Need to clear this flag, or fixup gets confused. (The elements - * have been translated away by now.) + /* Need to clear this flag, or fixup gets confused. (The + * array-elements have been translated away by now, so it's ok to + * remove it.) */ IM->OrFlag &= ~VERT_ELT; IM->AndFlag &= ~VERT_ELT; _tnl_fixup_input( ctx, IM ); -/* _tnl_print_cassette( IM ); */ node = (TNLvertexcassette *) _mesa_alloc_instruction(ctx, @@ -113,6 +162,10 @@ _tnl_compile_cassette( GLcontext *ctx, struct immediate *IM ) node->LastMaterial = im->LastMaterial; node->MaterialOrMask = im->MaterialOrMask; node->MaterialAndMask = im->MaterialAndMask; + + if (tnl->CalcDListNormalLengths) { + build_normal_lengths( im ); + } if (ctx->ExecuteFlag) { execute_compiled_cassette( ctx, (void *)node ); @@ -308,6 +361,10 @@ execute_compiled_cassette( GLcontext *ctx, void *data ) IM->Primitive[IM->LastPrimitive] & PRIM_MODE_MASK; _tnl_get_exec_copy_verts( ctx, IM ); + + if (IM->NormalLengthPtr) + fixup_normal_lengths( IM ); + _tnl_run_cassette( ctx, IM ); restore_compiled_primitives( ctx, IM ); @@ -365,6 +422,7 @@ _tnl_BeginCallList( GLcontext *ctx, GLuint list ) void _tnl_EndCallList( GLcontext *ctx ) { + (void) ctx; } diff --git a/src/mesa/tnl/t_imm_exec.c b/src/mesa/tnl/t_imm_exec.c index 37dd1597a54..547af43a397 100644 --- a/src/mesa/tnl/t_imm_exec.c +++ b/src/mesa/tnl/t_imm_exec.c @@ -1,4 +1,4 @@ -/* $Id: t_imm_exec.c,v 1.26 2001/05/16 09:28:32 keithw Exp $ */ +/* $Id: t_imm_exec.c,v 1.27 2001/06/28 17:34:14 keithw Exp $ */ /* * Mesa 3-D graphics library @@ -244,6 +244,7 @@ static void _tnl_vb_bind_immediate( GLcontext *ctx, struct immediate *IM ) /* TexCoordPtr's are zeroed in loop below. */ VB->NormalPtr = 0; + VB->NormalLengthPtr = 0; VB->FogCoordPtr = 0; VB->EdgeFlag = 0; VB->IndexPtr[0] = 0; @@ -280,6 +281,8 @@ static void _tnl_vb_bind_immediate( GLcontext *ctx, struct immediate *IM ) tmp->Normal.start = (GLfloat *)(IM->Normal + start); tmp->Normal.count = count; VB->NormalPtr = &tmp->Normal; + if (IM->NormalLengthPtr) + VB->NormalLengthPtr = IM->NormalLengthPtr + start; } if (inputs & VERT_INDEX) { diff --git a/src/mesa/tnl/t_imm_fixup.c b/src/mesa/tnl/t_imm_fixup.c index 7f6ae403041..0336a9779e8 100644 --- a/src/mesa/tnl/t_imm_fixup.c +++ b/src/mesa/tnl/t_imm_fixup.c @@ -1,4 +1,4 @@ -/* $Id: t_imm_fixup.c,v 1.21 2001/06/13 14:57:55 brianp Exp $ */ +/* $Id: t_imm_fixup.c,v 1.22 2001/06/28 17:34:14 keithw Exp $ */ /* * Mesa 3-D graphics library @@ -505,7 +505,8 @@ void _tnl_copy_immediate_vertices( GLcontext *ctx, struct immediate *next ) /* Revive a compiled immediate struct - propogate new 'Current' * values. Often this is redundant because the current values were - * known and fixed up at compile time. + * known and fixed up at compile time (or in the first execution of + * the cassette). */ void _tnl_fixup_compiled_cassette( GLcontext *ctx, struct immediate *IM ) { diff --git a/src/mesa/tnl/t_vb_normals.c b/src/mesa/tnl/t_vb_normals.c index ce3f0b7b268..1a71b13be32 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.8 2001/03/30 14:44:44 gareth Exp $ */ +/* $Id: t_vb_normals.c,v 1.9 2001/06/28 17:34:14 keithw Exp $ */ /* * Mesa 3-D graphics library @@ -65,10 +65,11 @@ static GLboolean run_normal_stage( GLcontext *ctx, store->NormalTransform( &ctx->ModelView, ctx->_ModelViewInvScale, VB->NormalPtr, - 0, + VB->NormalLengthPtr, &store->normal ); VB->NormalPtr = &store->normal; + VB->NormalLengthPtr = 0; /* no longer valid */ return GL_TRUE; } diff --git a/src/mesa/tnl/tnl.h b/src/mesa/tnl/tnl.h index 413864aba1f..16470295f48 100644 --- a/src/mesa/tnl/tnl.h +++ b/src/mesa/tnl/tnl.h @@ -1,4 +1,4 @@ -/* $Id: tnl.h,v 1.7 2001/06/04 16:09:28 keithw Exp $ */ +/* $Id: tnl.h,v 1.8 2001/06/28 17:34:14 keithw Exp $ */ /* * Mesa 3-D graphics library @@ -61,10 +61,15 @@ _tnl_wakeup_exec( GLcontext *ctx ); extern void _tnl_wakeup_save_exec( GLcontext *ctx ); +/* Driver configuration options: + */ extern void _tnl_need_projected_coords( GLcontext *ctx, GLboolean flag ); extern void _tnl_need_dlist_loopback( GLcontext *ctx, GLboolean flag ); +extern void +_tnl_need_dlist_norm_lengths( GLcontext *ctx, GLboolean flag ); + #endif |