Perform fixup on material values

This commit is contained in:
Keith Whitwell
2001-04-09 14:47:34 +00:00
parent c818d6cce5
commit 8a09c3a34b
5 changed files with 111 additions and 77 deletions

View File

@@ -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 * Mesa 3-D graphics library
@@ -194,6 +194,7 @@ struct immediate
GLuint *MaterialMask; GLuint *MaterialMask;
GLuint LastMaterial; GLuint LastMaterial;
GLuint MaterialOrMask; GLuint MaterialOrMask;
GLuint MaterialAndMask;
GLfloat (*TexCoord[MAX_TEXTURE_UNITS])[4]; GLfloat (*TexCoord[MAX_TEXTURE_UNITS])[4];

View File

@@ -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 * Mesa 3-D graphics library
@@ -76,7 +76,8 @@ _tnl_begin( GLcontext *ctx, GLenum p )
GLuint inflags, state; GLuint inflags, state;
if (MESA_VERBOSE&VERBOSE_API) 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) if (ctx->NewState)
_mesa_update_state(ctx); _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. /* Both streams now outside begin/end.
* *
* Leave SavedBeginState untouched -- attempt to gather several * Leave SavedBeginState untouched -- attempt to gather several
@@ -1231,6 +1211,7 @@ _tnl_Materialfv( GLenum face, GLenum pname, const GLfloat *params )
IM->Material = (GLmaterial (*)[2]) MALLOC( sizeof(GLmaterial) * IM->Material = (GLmaterial (*)[2]) MALLOC( sizeof(GLmaterial) *
IMM_SIZE * 2 ); IMM_SIZE * 2 );
IM->MaterialMask = (GLuint *) MALLOC( sizeof(GLuint) * IMM_SIZE ); IM->MaterialMask = (GLuint *) MALLOC( sizeof(GLuint) * IMM_SIZE );
IM->MaterialMask[IM->LastMaterial] = 0;
} }
else if (IM->MaterialOrMask & ~bitmask) { else if (IM->MaterialOrMask & ~bitmask) {
_mesa_copy_material_pairs( IM->Material[count], _mesa_copy_material_pairs( IM->Material[count],
@@ -1239,8 +1220,9 @@ _tnl_Materialfv( GLenum face, GLenum pname, const GLfloat *params )
} }
IM->Flag[count] |= VERT_MATERIAL; IM->Flag[count] |= VERT_MATERIAL;
IM->LastMaterial = count;
IM->MaterialMask[count] = 0; IM->MaterialMask[count] = 0;
IM->MaterialAndMask &= IM->MaterialMask[IM->LastMaterial];
IM->LastMaterial = count;
} }
IM->MaterialOrMask |= bitmask; IM->MaterialOrMask |= bitmask;

View File

@@ -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 * Mesa 3-D graphics library
@@ -59,6 +59,7 @@ typedef struct {
GLuint LastPrimitive; GLuint LastPrimitive;
GLuint LastMaterial; GLuint LastMaterial;
GLuint MaterialOrMask; GLuint MaterialOrMask;
GLuint MaterialAndMask;
} TNLvertexcassette; } TNLvertexcassette;
static void execute_compiled_cassette( GLcontext *ctx, void *data ); 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->LastPrimitive = im->LastPrimitive;
node->LastMaterial = im->LastMaterial; node->LastMaterial = im->LastMaterial;
node->MaterialOrMask = im->MaterialOrMask; node->MaterialOrMask = im->MaterialOrMask;
node->MaterialAndMask = im->MaterialAndMask;
if (ctx->ExecuteFlag) { if (ctx->ExecuteFlag) {
execute_compiled_cassette( ctx, (void *)node ); execute_compiled_cassette( ctx, (void *)node );
@@ -182,6 +184,7 @@ execute_compiled_cassette( GLcontext *ctx, void *data )
IM->LastPrimitive = node->LastPrimitive; IM->LastPrimitive = node->LastPrimitive;
IM->LastMaterial = node->LastMaterial; IM->LastMaterial = node->LastMaterial;
IM->MaterialOrMask = node->MaterialOrMask; IM->MaterialOrMask = node->MaterialOrMask;
IM->MaterialAndMask = node->MaterialAndMask;
if ((MESA_VERBOSE & VERBOSE_DISPLAY_LIST) && if ((MESA_VERBOSE & VERBOSE_DISPLAY_LIST) &&
(MESA_VERBOSE & VERBOSE_IMMEDIATE)) (MESA_VERBOSE & VERBOSE_IMMEDIATE))
@@ -251,6 +254,7 @@ print_compiled_cassette( GLcontext *ctx, void *data )
IM->LastPrimitive = node->LastPrimitive; IM->LastPrimitive = node->LastPrimitive;
IM->LastMaterial = node->LastMaterial; IM->LastMaterial = node->LastMaterial;
IM->MaterialOrMask = node->MaterialOrMask; IM->MaterialOrMask = node->MaterialOrMask;
IM->MaterialAndMask = node->MaterialAndMask;
_tnl_print_cassette( node->IM ); _tnl_print_cassette( node->IM );
} }

View File

@@ -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 * Mesa 3-D graphics library
@@ -77,9 +77,13 @@ void _tnl_reset_input( GLcontext *ctx,
IM->BeginState = beginstate; IM->BeginState = beginstate;
IM->SavedBeginState = savedbeginstate; IM->SavedBeginState = savedbeginstate;
IM->TexSize = 0; IM->TexSize = 0;
IM->LastMaterial = 0; IM->LastMaterial = IM->Start;
IM->MaterialOrMask = 0; IM->MaterialOrMask = 0;
if (IM->MaterialMask)
IM->MaterialMask[IM->Start] = 0;
IM->ArrayEltFlags = ~ctx->Array._Enabled; IM->ArrayEltFlags = ~ctx->Array._Enabled;
IM->ArrayEltIncr = ctx->Array.Vertex.Enabled ? 1 : 0; IM->ArrayEltIncr = ctx->Array.Vertex.Enabled ? 1 : 0;
IM->ArrayEltFlush = !ctx->Array.LockCount; IM->ArrayEltFlush = !ctx->Array.LockCount;

View File

@@ -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 * Mesa 3-D graphics library
@@ -35,6 +35,7 @@
#include "enums.h" #include "enums.h"
#include "dlist.h" #include "dlist.h"
#include "colormac.h" #include "colormac.h"
#include "light.h"
#include "macros.h" #include "macros.h"
#include "mem.h" #include "mem.h"
#include "mmath.h" #include "mmath.h"
@@ -243,7 +244,9 @@ void _tnl_fixup_input( GLcontext *ctx, struct immediate *IM )
* immediate. * immediate.
*/ */
if (ctx->ExecuteFlag && copy) { 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) { if (copy & VERT_NORM) {
COPY_3V( IM->Normal[start], ctx->Current.Normal ); 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) if (MESA_VERBOSE&VERBOSE_IMMEDIATE)
/* _tnl_print_vert_flags("fixup", fixup); */ _tnl_print_vert_flags("fixup", fixup);
if (fixup & VERT_TEX_ANY) { if (fixup & VERT_TEX_ANY) {
GLuint i; GLuint i;
@@ -289,7 +292,7 @@ void _tnl_fixup_input( GLcontext *ctx, struct immediate *IM )
} }
} }
} }
}
if (fixup & VERT_EDGE) { if (fixup & VERT_EDGE) {
if (orflag & VERT_EDGE) if (orflag & VERT_EDGE)
@@ -303,14 +306,16 @@ void _tnl_fixup_input( GLcontext *ctx, struct immediate *IM )
if (orflag & VERT_INDEX) if (orflag & VERT_INDEX)
fixup_1ui( IM->Index, IM->Flag, start, VERT_INDEX ); fixup_1ui( IM->Index, IM->Flag, start, VERT_INDEX );
else else
fixup_first_1ui( IM->Index, IM->Flag, VERT_END_VB, start, IM->Index[start] ); fixup_first_1ui( IM->Index, IM->Flag, VERT_END_VB, start,
IM->Index[start] );
} }
if (fixup & VERT_RGBA) { if (fixup & VERT_RGBA) {
if (orflag & VERT_RGBA) if (orflag & VERT_RGBA)
fixup_4chan( IM->Color, IM->Flag, start, VERT_RGBA ); fixup_4chan( IM->Color, IM->Flag, start, VERT_RGBA );
else else
fixup_first_4chan( IM->Color, IM->Flag, VERT_END_VB, start, IM->Color[start] ); fixup_first_4chan( IM->Color, IM->Flag, VERT_END_VB, start,
IM->Color[start] );
} }
if (fixup & VERT_SPEC_RGB) { if (fixup & VERT_SPEC_RGB) {
@@ -336,12 +341,32 @@ void _tnl_fixup_input( GLcontext *ctx, struct immediate *IM )
fixup_first_3f( IM->Normal, IM->Flag, VERT_END_VB, start, fixup_first_3f( IM->Normal, IM->Flag, VERT_END_VB, start,
IM->Normal[start] ); IM->Normal[start] );
} }
}
/* Prune possible half-filled slot. /* Prune possible half-filled slot.
*/ */
IM->Flag[IM->LastData+1] &= ~VERT_END_VB; IM->Flag[IM->LastData+1] &= ~VERT_END_VB;
IM->Flag[IM->Count] |= 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 = (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)); 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 /* Can potentially overwrite primitive details - need to save the
* first slot: * first slot: