summaryrefslogtreecommitdiff
path: root/src/mesa/tnl
diff options
context:
space:
mode:
authorKeith Whitwell <keith@tungstengraphics.com>2001-04-09 14:47:34 +0000
committerKeith Whitwell <keith@tungstengraphics.com>2001-04-09 14:47:34 +0000
commit8a09c3a34bae4c262512d3a8ec3630732a686206 (patch)
tree8146d0d59584913bdb74c7caed92a043bc88ba6e /src/mesa/tnl
parentc818d6cce55098f48e953f1b7c96bdf188006bb6 (diff)
Perform fixup on material values
Diffstat (limited to 'src/mesa/tnl')
-rw-r--r--src/mesa/tnl/t_context.h3
-rw-r--r--src/mesa/tnl/t_imm_api.c34
-rw-r--r--src/mesa/tnl/t_imm_dlist.c6
-rw-r--r--src/mesa/tnl/t_imm_exec.c8
-rw-r--r--src/mesa/tnl/t_imm_fixup.c139
5 files changed, 112 insertions, 78 deletions
diff --git a/src/mesa/tnl/t_context.h b/src/mesa/tnl/t_context.h
index f7465d98a8..db315e69f7 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.18 2001/03/19 02:25:37 keithw Exp $ */
+/* $Id: t_context.h,v 1.19 2001/04/09 14:47:34 keithw Exp $ */
/*
* Mesa 3-D graphics library
@@ -194,6 +194,7 @@ struct immediate
GLuint *MaterialMask;
GLuint LastMaterial;
GLuint MaterialOrMask;
+ GLuint MaterialAndMask;
GLfloat (*TexCoord[MAX_TEXTURE_UNITS])[4];
diff --git a/src/mesa/tnl/t_imm_api.c b/src/mesa/tnl/t_imm_api.c
index 4a7ed8d94f..375e4b6309 100644
--- a/src/mesa/tnl/t_imm_api.c
+++ b/src/mesa/tnl/t_imm_api.c
@@ -1,4 +1,4 @@
-/* $Id: t_imm_api.c,v 1.9 2001/03/19 02:25:37 keithw Exp $ */
+/* $Id: t_imm_api.c,v 1.10 2001/04/09 14:47:34 keithw Exp $ */
/*
* Mesa 3-D graphics library
@@ -76,7 +76,8 @@ _tnl_begin( GLcontext *ctx, GLenum p )
GLuint inflags, state;
if (MESA_VERBOSE&VERBOSE_API)
- fprintf(stderr, "glBegin(IM %d) %s\n", IM->id, _mesa_lookup_enum_by_nr(p));
+ fprintf(stderr, "glBegin(IM %d) %s\n", IM->id,
+ _mesa_lookup_enum_by_nr(p));
if (ctx->NewState)
_mesa_update_state(ctx);
@@ -274,27 +275,6 @@ _tnl_save_Begin( GLenum mode )
-/* Note the continuation of a partially completed primitive. For
- * driver t&l fallbacks between begin/end primitives. Has basically
- * the same effects as a primitive wrapping onto a second immediate
- * struct.
- *
- * ==> Can actually call this from _tnl_wakeup_exec, taking mode from
- * ctx->Driver.CurrentExecPrimitive.
- */
-#if 0
-void _tnl_fallback_begin( GLcontext *ctx, GLenum mode )
-{
- struct immediate *IM = TNL_CURRENT_IM(ctx);
- ASSERT( IM->Count == IM->Start );
- ASSERT( IM->Flag[IM->Start] == 0 );
- ASSERT( mode < GL_POLYGON+1 );
- _tnl_begin( ctx, mode );
- IM->Primitive[IM->Start] &= ~PRIM_BEGIN;
-}
-#endif
-
-
/* Both streams now outside begin/end.
*
* Leave SavedBeginState untouched -- attempt to gather several
@@ -1231,16 +1211,18 @@ _tnl_Materialfv( GLenum face, GLenum pname, const GLfloat *params )
IM->Material = (GLmaterial (*)[2]) MALLOC( sizeof(GLmaterial) *
IMM_SIZE * 2 );
IM->MaterialMask = (GLuint *) MALLOC( sizeof(GLuint) * IMM_SIZE );
+ IM->MaterialMask[IM->LastMaterial] = 0;
}
else if (IM->MaterialOrMask & ~bitmask) {
_mesa_copy_material_pairs( IM->Material[count],
- IM->Material[IM->LastMaterial],
- IM->MaterialOrMask & ~bitmask );
+ IM->Material[IM->LastMaterial],
+ IM->MaterialOrMask & ~bitmask );
}
IM->Flag[count] |= VERT_MATERIAL;
- IM->LastMaterial = count;
IM->MaterialMask[count] = 0;
+ IM->MaterialAndMask &= IM->MaterialMask[IM->LastMaterial];
+ IM->LastMaterial = count;
}
IM->MaterialOrMask |= bitmask;
diff --git a/src/mesa/tnl/t_imm_dlist.c b/src/mesa/tnl/t_imm_dlist.c
index 0ce1909c9f..02ebbbbaf2 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.11 2001/03/12 00:48:43 gareth Exp $ */
+/* $Id: t_imm_dlist.c,v 1.12 2001/04/09 14:47:34 keithw Exp $ */
/*
* Mesa 3-D graphics library
@@ -59,6 +59,7 @@ typedef struct {
GLuint LastPrimitive;
GLuint LastMaterial;
GLuint MaterialOrMask;
+ GLuint MaterialAndMask;
} TNLvertexcassette;
static void execute_compiled_cassette( GLcontext *ctx, void *data );
@@ -124,6 +125,7 @@ _tnl_compile_cassette( GLcontext *ctx, struct immediate *IM )
node->LastPrimitive = im->LastPrimitive;
node->LastMaterial = im->LastMaterial;
node->MaterialOrMask = im->MaterialOrMask;
+ node->MaterialAndMask = im->MaterialAndMask;
if (ctx->ExecuteFlag) {
execute_compiled_cassette( ctx, (void *)node );
@@ -182,6 +184,7 @@ execute_compiled_cassette( GLcontext *ctx, void *data )
IM->LastPrimitive = node->LastPrimitive;
IM->LastMaterial = node->LastMaterial;
IM->MaterialOrMask = node->MaterialOrMask;
+ IM->MaterialAndMask = node->MaterialAndMask;
if ((MESA_VERBOSE & VERBOSE_DISPLAY_LIST) &&
(MESA_VERBOSE & VERBOSE_IMMEDIATE))
@@ -251,6 +254,7 @@ print_compiled_cassette( GLcontext *ctx, void *data )
IM->LastPrimitive = node->LastPrimitive;
IM->LastMaterial = node->LastMaterial;
IM->MaterialOrMask = node->MaterialOrMask;
+ IM->MaterialAndMask = node->MaterialAndMask;
_tnl_print_cassette( node->IM );
}
diff --git a/src/mesa/tnl/t_imm_exec.c b/src/mesa/tnl/t_imm_exec.c
index 888d8c34c3..a575253590 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.16 2001/03/12 00:48:43 gareth Exp $ */
+/* $Id: t_imm_exec.c,v 1.17 2001/04/09 14:47:34 keithw Exp $ */
/*
* Mesa 3-D graphics library
@@ -77,9 +77,13 @@ void _tnl_reset_input( GLcontext *ctx,
IM->BeginState = beginstate;
IM->SavedBeginState = savedbeginstate;
IM->TexSize = 0;
- IM->LastMaterial = 0;
+ IM->LastMaterial = IM->Start;
IM->MaterialOrMask = 0;
+ if (IM->MaterialMask)
+ IM->MaterialMask[IM->Start] = 0;
+
+
IM->ArrayEltFlags = ~ctx->Array._Enabled;
IM->ArrayEltIncr = ctx->Array.Vertex.Enabled ? 1 : 0;
IM->ArrayEltFlush = !ctx->Array.LockCount;
diff --git a/src/mesa/tnl/t_imm_fixup.c b/src/mesa/tnl/t_imm_fixup.c
index fd7f4b1231..9fde2a89c1 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.9 2001/03/12 00:48:43 gareth Exp $ */
+/* $Id: t_imm_fixup.c,v 1.10 2001/04/09 14:47:34 keithw Exp $ */
/*
* Mesa 3-D graphics library
@@ -35,6 +35,7 @@
#include "enums.h"
#include "dlist.h"
#include "colormac.h"
+#include "light.h"
#include "macros.h"
#include "mem.h"
#include "mmath.h"
@@ -243,7 +244,9 @@ void _tnl_fixup_input( GLcontext *ctx, struct immediate *IM )
* immediate.
*/
if (ctx->ExecuteFlag && copy) {
-/* _tnl_print_vert_flags("copy from current", copy); */
+
+ if (MESA_VERBOSE&VERBOSE_IMMEDIATE)
+ _tnl_print_vert_flags("copy from current", copy);
if (copy & VERT_NORM) {
COPY_3V( IM->Normal[start], ctx->Current.Normal );
@@ -275,7 +278,7 @@ void _tnl_fixup_input( GLcontext *ctx, struct immediate *IM )
}
if (MESA_VERBOSE&VERBOSE_IMMEDIATE)
-/* _tnl_print_vert_flags("fixup", fixup); */
+ _tnl_print_vert_flags("fixup", fixup);
if (fixup & VERT_TEX_ANY) {
GLuint i;
@@ -289,59 +292,81 @@ void _tnl_fixup_input( GLcontext *ctx, struct immediate *IM )
}
}
}
- }
-
- if (fixup & VERT_EDGE) {
- if (orflag & VERT_EDGE)
- fixup_1ub( IM->EdgeFlag, IM->Flag, start, VERT_EDGE );
- else
- fixup_first_1ub( IM->EdgeFlag, IM->Flag, VERT_END_VB, start,
- IM->EdgeFlag[start] );
- }
-
- if (fixup & VERT_INDEX) {
- if (orflag & VERT_INDEX)
- fixup_1ui( IM->Index, IM->Flag, start, VERT_INDEX );
- else
- fixup_first_1ui( IM->Index, IM->Flag, VERT_END_VB, start, IM->Index[start] );
- }
-
- if (fixup & VERT_RGBA) {
- if (orflag & VERT_RGBA)
- fixup_4chan( IM->Color, IM->Flag, start, VERT_RGBA );
- else
- fixup_first_4chan( IM->Color, IM->Flag, VERT_END_VB, start, IM->Color[start] );
- }
+
+
+ if (fixup & VERT_EDGE) {
+ if (orflag & VERT_EDGE)
+ fixup_1ub( IM->EdgeFlag, IM->Flag, start, VERT_EDGE );
+ else
+ fixup_first_1ub( IM->EdgeFlag, IM->Flag, VERT_END_VB, start,
+ IM->EdgeFlag[start] );
+ }
- if (fixup & VERT_SPEC_RGB) {
- if (orflag & VERT_SPEC_RGB)
- fixup_4chan( IM->SecondaryColor, IM->Flag, start, VERT_SPEC_RGB );
- else
- fixup_first_4chan( IM->SecondaryColor, IM->Flag, VERT_END_VB, start,
- IM->SecondaryColor[start] );
- }
+ if (fixup & VERT_INDEX) {
+ if (orflag & VERT_INDEX)
+ fixup_1ui( IM->Index, IM->Flag, start, VERT_INDEX );
+ else
+ fixup_first_1ui( IM->Index, IM->Flag, VERT_END_VB, start,
+ IM->Index[start] );
+ }
- if (fixup & VERT_FOG_COORD) {
- if (orflag & VERT_FOG_COORD)
- fixup_1f( IM->FogCoord, IM->Flag, start, VERT_FOG_COORD );
- else
- fixup_first_1f( IM->FogCoord, IM->Flag, VERT_END_VB, start,
- IM->FogCoord[start] );
- }
+ if (fixup & VERT_RGBA) {
+ if (orflag & VERT_RGBA)
+ fixup_4chan( IM->Color, IM->Flag, start, VERT_RGBA );
+ else
+ fixup_first_4chan( IM->Color, IM->Flag, VERT_END_VB, start,
+ IM->Color[start] );
+ }
+
+ if (fixup & VERT_SPEC_RGB) {
+ if (orflag & VERT_SPEC_RGB)
+ fixup_4chan( IM->SecondaryColor, IM->Flag, start, VERT_SPEC_RGB );
+ else
+ fixup_first_4chan( IM->SecondaryColor, IM->Flag, VERT_END_VB, start,
+ IM->SecondaryColor[start] );
+ }
+
+ if (fixup & VERT_FOG_COORD) {
+ if (orflag & VERT_FOG_COORD)
+ fixup_1f( IM->FogCoord, IM->Flag, start, VERT_FOG_COORD );
+ else
+ fixup_first_1f( IM->FogCoord, IM->Flag, VERT_END_VB, start,
+ IM->FogCoord[start] );
+ }
- if (fixup & VERT_NORM) {
- if (orflag & VERT_NORM)
- fixup_3f( IM->Normal, IM->Flag, start, VERT_NORM );
- else
- fixup_first_3f( IM->Normal, IM->Flag, VERT_END_VB, start,
- IM->Normal[start] );
+ if (fixup & VERT_NORM) {
+ if (orflag & VERT_NORM)
+ fixup_3f( IM->Normal, IM->Flag, start, VERT_NORM );
+ else
+ fixup_first_3f( IM->Normal, IM->Flag, VERT_END_VB, start,
+ IM->Normal[start] );
+ }
}
-
+
/* Prune possible half-filled slot.
*/
IM->Flag[IM->LastData+1] &= ~VERT_END_VB;
IM->Flag[IM->Count] |= VERT_END_VB;
+
+ /* Materials:
+ */
+ if (IM->MaterialOrMask & ~IM->MaterialAndMask) {
+ GLuint vulnerable = IM->MaterialOrMask;
+ GLuint i = IM->Start;
+
+ do {
+ while (!(IM->Flag[i] & VERT_MATERIAL))
+ i++;
+
+ vulnerable &= ~IM->MaterialMask[i];
+ _mesa_copy_material_pairs( IM->Material[i],
+ ctx->Light.Material,
+ vulnerable );
+
+
+ } while (vulnerable);
+ }
}
@@ -357,7 +382,7 @@ static void copy_material( struct immediate *next,
next->MaterialMask = (GLuint *) MALLOC( sizeof(GLuint) * IMM_SIZE );
}
- next->MaterialMask[dst] = prev->MaterialMask[src];
+ next->MaterialMask[dst] = prev->MaterialOrMask;
MEMCPY(next->Material[dst], prev->Material[src], 2*sizeof(GLmaterial));
}
@@ -538,6 +563,24 @@ void _tnl_fixup_compiled_cassette( GLcontext *ctx, struct immediate *IM )
}
}
+ /* Materials:
+ */
+ if (IM->MaterialOrMask & ~IM->MaterialAndMask) {
+ GLuint vulnerable = IM->MaterialOrMask;
+ GLuint i = IM->Start;
+
+ do {
+ while (!(IM->Flag[i] & VERT_MATERIAL))
+ i++;
+
+ vulnerable &= ~IM->MaterialMask[i];
+ _mesa_copy_material_pairs( IM->Material[i],
+ ctx->Light.Material,
+ vulnerable );
+
+
+ } while (vulnerable);
+ }
/* Can potentially overwrite primitive details - need to save the
* first slot: