summaryrefslogtreecommitdiff
path: root/src/mesa/tnl/t_imm_dlist.c
diff options
context:
space:
mode:
authorKeith Whitwell <keith@tungstengraphics.com>2001-06-28 17:34:14 +0000
committerKeith Whitwell <keith@tungstengraphics.com>2001-06-28 17:34:14 +0000
commit47a28c0b4d4ca27592e3cbb8e4b17d1cd8f7997d (patch)
tree0fdce5799b53ba8efcb3b30190fa746123cbee3e /src/mesa/tnl/t_imm_dlist.c
parent206eda8b69ab3c63e9597015189f49d1bda9356f (diff)
restore normal length optimization in dlists
Diffstat (limited to 'src/mesa/tnl/t_imm_dlist.c')
-rw-r--r--src/mesa/tnl/t_imm_dlist.c66
1 files changed, 62 insertions, 4 deletions
diff --git a/src/mesa/tnl/t_imm_dlist.c b/src/mesa/tnl/t_imm_dlist.c
index 722d67b143..9c22ed3e7b 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;
}