-/* $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
}
}
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;
-/* $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
tnl->NeedProjCoords = GL_TRUE;
tnl->LoopbackDListCassettes = GL_FALSE;
+ tnl->CalcDListNormalLengths = GL_TRUE;
/* Hook our functions into exec and compile dispatch tables.
*/
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;
+ }
+}
-/* $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
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];
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 */
*/
GLboolean NeedProjCoords;
GLboolean LoopbackDListCassettes;
+ GLboolean CalcDListNormalLengths;
/* Derived state and storage for _tnl_eval_vb:
*/
-/* $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
IM->MaterialMask = 0;
IM->MaxTextureUnits = ctx->Const.MaxTextureUnits;
IM->TexSize = 0;
+ IM->NormalLengthPtr = 0;
IM->CopyTexSize = 0;
IM->CopyStart = IM->Start;
for (j = 1; j < IM->MaxTextureUnits; j++)
ALIGN_FREE( IM->TexCoord[j] );
+ if (IM->NormalLengthPtr)
+ ALIGN_FREE( IM->NormalLengthPtr );
ALIGN_FREE( IM );
freed++;
-/* $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
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.
*/
_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,
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 );
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 );
void
_tnl_EndCallList( GLcontext *ctx )
{
+ (void) ctx;
}
-/* $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
/* TexCoordPtr's are zeroed in loop below.
*/
VB->NormalPtr = 0;
+ VB->NormalLengthPtr = 0;
VB->FogCoordPtr = 0;
VB->EdgeFlag = 0;
VB->IndexPtr[0] = 0;
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) {
-/* $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
/* 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 )
{
-/* $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
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;
}
-/* $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
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