diff options
Diffstat (limited to 'src/mesa/tnl')
-rw-r--r-- | src/mesa/tnl/t_array_import.c | 44 | ||||
-rw-r--r-- | src/mesa/tnl/t_context.h | 157 | ||||
-rw-r--r-- | src/mesa/tnl/t_imm_alloc.c | 3 | ||||
-rw-r--r-- | src/mesa/tnl/t_imm_api.c | 81 | ||||
-rw-r--r-- | src/mesa/tnl/t_imm_api.h | 9 | ||||
-rw-r--r-- | src/mesa/tnl/t_imm_debug.c | 44 | ||||
-rw-r--r-- | src/mesa/tnl/t_imm_dlist.c | 18 | ||||
-rw-r--r-- | src/mesa/tnl/t_imm_elt.c | 30 | ||||
-rw-r--r-- | src/mesa/tnl/t_imm_eval.c | 38 | ||||
-rw-r--r-- | src/mesa/tnl/t_imm_exec.c | 83 | ||||
-rw-r--r-- | src/mesa/tnl/t_imm_fixup.c | 133 | ||||
-rw-r--r-- | src/mesa/tnl/t_pipeline.c | 5 | ||||
-rw-r--r-- | src/mesa/tnl/t_pipeline.h | 3 | ||||
-rw-r--r-- | src/mesa/tnl/t_vb_fog.c | 26 | ||||
-rw-r--r-- | src/mesa/tnl/t_vb_light.c | 29 | ||||
-rw-r--r-- | src/mesa/tnl/t_vb_lighttmp.h | 14 | ||||
-rw-r--r-- | src/mesa/tnl/t_vb_normals.c | 13 | ||||
-rw-r--r-- | src/mesa/tnl/t_vb_points.c | 6 | ||||
-rw-r--r-- | src/mesa/tnl/t_vb_program.c | 1028 | ||||
-rw-r--r-- | src/mesa/tnl/t_vb_render.c | 23 | ||||
-rw-r--r-- | src/mesa/tnl/t_vb_texgen.c | 19 | ||||
-rw-r--r-- | src/mesa/tnl/t_vb_texmat.c | 23 | ||||
-rw-r--r-- | src/mesa/tnl/t_vb_vertex.c | 16 |
23 files changed, 1483 insertions, 362 deletions
diff --git a/src/mesa/tnl/t_array_import.c b/src/mesa/tnl/t_array_import.c index 513e8931fc1..3393ea1a7a6 100644 --- a/src/mesa/tnl/t_array_import.c +++ b/src/mesa/tnl/t_array_import.c @@ -1,4 +1,4 @@ -/* $Id: t_array_import.c,v 1.18 2001/08/13 22:15:54 keithw Exp $ */ +/* $Id: t_array_import.c,v 1.19 2001/12/14 02:51:42 brianp Exp $ */ /* * Mesa 3-D graphics library @@ -247,45 +247,45 @@ static void _tnl_upgrade_client_data( GLcontext *ctx, if (writeable || stride) ca_flags |= CA_CLIENT_DATA; if ((required & VERT_CLIP) && VB->ClipPtr == VB->ObjPtr) - required |= VERT_OBJ; + required |= VERT_OBJ_BIT; /* _tnl_print_vert_flags("_tnl_upgrade_client_data", required); */ - if ((required & VERT_OBJ) && (VB->ObjPtr->flags & flags)) { + if ((required & VERT_OBJ_BIT) && (VB->ObjPtr->flags & flags)) { ASSERT(VB->ObjPtr == &inputs->Obj); _tnl_import_vertex( ctx, writeable, stride ); - VB->importable_data &= ~(VERT_OBJ|VERT_CLIP); + VB->importable_data &= ~(VERT_OBJ_BIT|VERT_CLIP); } - if ((required & VERT_NORM) && (VB->NormalPtr->flags & flags)) { + if ((required & VERT_NORMAL_BIT) && (VB->NormalPtr->flags & flags)) { ASSERT(VB->NormalPtr == &inputs->Normal); _tnl_import_normal( ctx, writeable, stride ); - VB->importable_data &= ~VERT_NORM; + VB->importable_data &= ~VERT_NORMAL_BIT; } - if ((required & VERT_RGBA) && (VB->ColorPtr[0]->Flags & ca_flags)) { + if ((required & VERT_COLOR0_BIT) && (VB->ColorPtr[0]->Flags & ca_flags)) { ASSERT(VB->ColorPtr[0] == &inputs->Color); _tnl_import_color( ctx, GL_FLOAT, writeable, stride ); - VB->importable_data &= ~VERT_RGBA; + VB->importable_data &= ~VERT_COLOR0_BIT; } - if ((required & VERT_SPEC_RGB) && + if ((required & VERT_COLOR1_BIT) && (VB->SecondaryColorPtr[0]->Flags & ca_flags)) { ASSERT(VB->SecondaryColorPtr[0] == &inputs->SecondaryColor); _tnl_import_secondarycolor( ctx, GL_FLOAT, writeable, stride ); - VB->importable_data &= ~VERT_SPEC_RGB; + VB->importable_data &= ~VERT_COLOR1_BIT; } - if ((required & VERT_FOG_COORD) && (VB->FogCoordPtr->flags & flags)) { + if ((required & VERT_FOG_BIT) && (VB->FogCoordPtr->flags & flags)) { ASSERT(VB->FogCoordPtr == &inputs->FogCoord); _tnl_import_fogcoord( ctx, writeable, stride ); - VB->importable_data &= ~VERT_FOG_COORD; + VB->importable_data &= ~VERT_FOG_BIT; } - if ((required & VERT_INDEX) && (VB->IndexPtr[0]->flags & flags)) { + if ((required & VERT_INDEX_BIT) && (VB->IndexPtr[0]->flags & flags)) { ASSERT(VB->IndexPtr[0] == &inputs->Index); _tnl_import_index( ctx, writeable, stride ); - VB->importable_data &= ~VERT_INDEX; + VB->importable_data &= ~VERT_INDEX_BIT; } if (required & VERT_TEX_ANY) @@ -332,19 +332,19 @@ void _tnl_vb_bind_arrays( GLcontext *ctx, GLint start, GLsizei count ) _ac_import_range( ctx, start, count ); - if (inputs & VERT_OBJ) { + if (inputs & VERT_OBJ_BIT) { _tnl_import_vertex( ctx, 0, 0 ); tmp->Obj.count = VB->Count; VB->ObjPtr = &tmp->Obj; } - if (inputs & VERT_NORM) { + if (inputs & VERT_NORMAL_BIT) { _tnl_import_normal( ctx, 0, 0 ); tmp->Normal.count = VB->Count; VB->NormalPtr = &tmp->Normal; } - if (inputs & VERT_RGBA) { + if (inputs & VERT_COLOR0_BIT) { _tnl_import_color( ctx, 0, 0, 0 ); VB->ColorPtr[0] = &tmp->Color; VB->ColorPtr[1] = 0; @@ -360,26 +360,26 @@ void _tnl_vb_bind_arrays( GLcontext *ctx, GLint start, GLsizei count ) } } - if (inputs & (VERT_INDEX|VERT_FOG_COORD|VERT_EDGE|VERT_SPEC_RGB)) { - if (inputs & VERT_INDEX) { + if (inputs & (VERT_INDEX_BIT|VERT_FOG_BIT|VERT_EDGEFLAG_BIT|VERT_COLOR1_BIT)) { + if (inputs & VERT_INDEX_BIT) { _tnl_import_index( ctx, 0, 0 ); tmp->Index.count = VB->Count; VB->IndexPtr[0] = &tmp->Index; VB->IndexPtr[1] = 0; } - if (inputs & VERT_FOG_COORD) { + if (inputs & VERT_FOG_BIT) { _tnl_import_fogcoord( ctx, 0, 0 ); tmp->FogCoord.count = VB->Count; VB->FogCoordPtr = &tmp->FogCoord; } - if (inputs & VERT_EDGE) { + if (inputs & VERT_EDGEFLAG_BIT) { _tnl_import_edgeflag( ctx, GL_TRUE, sizeof(GLboolean) ); VB->EdgeFlag = (GLboolean *) tmp->EdgeFlag.data; } - if (inputs & VERT_SPEC_RGB) { + if (inputs & VERT_COLOR1_BIT) { _tnl_import_secondarycolor( ctx, 0, 0, 0 ); VB->SecondaryColorPtr[0] = &tmp->SecondaryColor; VB->SecondaryColorPtr[1] = 0; diff --git a/src/mesa/tnl/t_context.h b/src/mesa/tnl/t_context.h index ed8eafe635d..dd0bfad5b61 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.32 2001/09/14 21:30:31 brianp Exp $ */ +/* $Id: t_context.h,v 1.33 2001/12/14 02:51:44 brianp Exp $ */ /* * Mesa 3-D graphics library @@ -71,43 +71,45 @@ * 5 spare flags, rearrangement of eval flags can secure at least 3 * more. */ -#define VERT_OBJ _NEW_ARRAY_VERTEX -#define VERT_RGBA _NEW_ARRAY_COLOR -#define VERT_NORM _NEW_ARRAY_NORMAL -#define VERT_INDEX _NEW_ARRAY_INDEX -#define VERT_EDGE _NEW_ARRAY_EDGEFLAG -#define VERT_SPEC_RGB _NEW_ARRAY_SECONDARYCOLOR -#define VERT_FOG_COORD _NEW_ARRAY_FOGCOORD -#define VERT_TEX0 _NEW_ARRAY_TEXCOORD_0 -#define VERT_TEX1 _NEW_ARRAY_TEXCOORD_1 -#define VERT_TEX2 _NEW_ARRAY_TEXCOORD_2 -#define VERT_TEX3 _NEW_ARRAY_TEXCOORD_3 -#define VERT_TEX4 _NEW_ARRAY_TEXCOORD_4 -#define VERT_TEX5 _NEW_ARRAY_TEXCOORD_5 -#define VERT_TEX6 _NEW_ARRAY_TEXCOORD_6 -#define VERT_TEX7 _NEW_ARRAY_TEXCOORD_7 -#define VERT_EVAL_C1 0x8000 /* imm only */ -#define VERT_EVAL_C2 0x10000 /* imm only */ -#define VERT_EVAL_P1 0x20000 /* imm only */ -#define VERT_EVAL_P2 0x40000 /* imm only */ -#define VERT_OBJ_3 0x80000 /* imm only */ -#define VERT_OBJ_4 0x100000 /* imm only */ -#define VERT_MATERIAL 0x200000 /* imm only, but tested in vb code */ -#define VERT_ELT 0x400000 /* imm only */ -#define VERT_BEGIN 0x800000 /* imm only, but tested in vb code */ -#define VERT_END 0x1000000 /* imm only, but tested in vb code */ -#define VERT_END_VB 0x2000000 /* imm only, but tested in vb code */ -#define VERT_POINT_SIZE 0x4000000 /* vb only, could reuse a bit */ +#define VERT_OBJ_BIT _NEW_ARRAY_VERTEX +#define VERT_WEIGHT_BIT _NEW_ARRAY_WEIGHT /* unused */ +#define VERT_NORMAL_BIT _NEW_ARRAY_NORMAL +#define VERT_COLOR0_BIT _NEW_ARRAY_COLOR0 +#define VERT_COLOR1_BIT _NEW_ARRAY_COLOR1 +#define VERT_FOG_BIT _NEW_ARRAY_FOGCOORD +#define VERT_INDEX_BIT _NEW_ARRAY_INDEX +#define VERT_EDGEFLAG_BIT _NEW_ARRAY_EDGEFLAG +#define VERT_TEX0_BIT _NEW_ARRAY_TEXCOORD_0 +#define VERT_TEX1_BIT _NEW_ARRAY_TEXCOORD_1 +#define VERT_TEX2_BIT _NEW_ARRAY_TEXCOORD_2 +#define VERT_TEX3_BIT _NEW_ARRAY_TEXCOORD_3 +#define VERT_TEX4_BIT _NEW_ARRAY_TEXCOORD_4 +#define VERT_TEX5_BIT _NEW_ARRAY_TEXCOORD_5 +#define VERT_TEX6_BIT _NEW_ARRAY_TEXCOORD_6 +#define VERT_TEX7_BIT _NEW_ARRAY_TEXCOORD_7 +#define VERT_EVAL_C1 0x10000 /* imm only */ +#define VERT_EVAL_C2 0x20000 /* imm only */ +#define VERT_EVAL_P1 0x40000 /* imm only */ +#define VERT_EVAL_P2 0x80000 /* imm only */ +#define VERT_OBJ_3 0x100000 /* imm only */ +#define VERT_OBJ_4 0x200000 /* imm only */ +#define VERT_MATERIAL 0x400000 /* imm only, but tested in vb code */ +#define VERT_ELT 0x800000 /* imm only */ +#define VERT_BEGIN 0x1000000 /* imm only, but tested in vb code */ +#define VERT_END 0x2000000 /* imm only, but tested in vb code */ +#define VERT_END_VB 0x4000000 /* imm only, but tested in vb code */ +#define VERT_POINT_SIZE 0x8000000 /* vb only, could reuse a bit */ #define VERT_EYE VERT_BEGIN /* vb only, reuse imm bit */ #define VERT_CLIP VERT_END /* vb only, reuse imm bit*/ + /* Flags for IM->TexCoordSize. Enough flags for 16 units. */ -#define TEX_0_SIZE_3 (GLuint) 0x1 -#define TEX_0_SIZE_4 (GLuint) 0x1001 -#define TEX_SIZE_3(unit) (TEX_0_SIZE_3<<unit) -#define TEX_SIZE_4(unit) (TEX_0_SIZE_4<<unit) +#define TEX_0_SIZE_3 0x1 +#define TEX_0_SIZE_4 0x10001 +#define TEX_SIZE_3(unit) (TEX_0_SIZE_3 << (unit)) +#define TEX_SIZE_4(unit) (TEX_0_SIZE_4 << (unit)) /* Shorthands. @@ -115,41 +117,41 @@ #define VERT_EVAL_ANY (VERT_EVAL_C1|VERT_EVAL_P1| \ VERT_EVAL_C2|VERT_EVAL_P2) -#define VERT_OBJ_23 (VERT_OBJ_3|VERT_OBJ) +#define VERT_OBJ_23 (VERT_OBJ_3|VERT_OBJ_BIT) #define VERT_OBJ_234 (VERT_OBJ_4|VERT_OBJ_23) -#define VERT_TEX0_SHIFT 11 +#define VERT_TEX0_BIT_SHIFT 11 -#define VERT_TEX(i) (VERT_TEX0 << i) +#define VERT_TEX(i) (VERT_TEX0_BIT << (i)) -#define VERT_TEX_ANY (VERT_TEX0 | \ - VERT_TEX1 | \ - VERT_TEX2 | \ - VERT_TEX3 | \ - VERT_TEX4 | \ - VERT_TEX5 | \ - VERT_TEX6 | \ - VERT_TEX7) +#define VERT_TEX_ANY (VERT_TEX0_BIT | \ + VERT_TEX1_BIT | \ + VERT_TEX2_BIT | \ + VERT_TEX3_BIT | \ + VERT_TEX4_BIT | \ + VERT_TEX5_BIT | \ + VERT_TEX6_BIT | \ + VERT_TEX7_BIT) #define VERT_FIXUP (VERT_TEX_ANY | \ - VERT_RGBA | \ - VERT_SPEC_RGB | \ - VERT_FOG_COORD | \ - VERT_INDEX | \ - VERT_EDGE | \ - VERT_NORM) + VERT_COLOR0_BIT | \ + VERT_COLOR1_BIT | \ + VERT_FOG_BIT | \ + VERT_INDEX_BIT | \ + VERT_EDGEFLAG_BIT | \ + VERT_NORMAL_BIT) #define VERT_CURRENT_DATA (VERT_FIXUP | \ VERT_MATERIAL) #define VERT_DATA (VERT_TEX_ANY | \ - VERT_RGBA | \ - VERT_SPEC_RGB | \ - VERT_FOG_COORD | \ - VERT_INDEX | \ - VERT_EDGE | \ - VERT_NORM | \ - VERT_OBJ | \ + VERT_COLOR0_BIT | \ + VERT_COLOR1_BIT | \ + VERT_FOG_BIT | \ + VERT_INDEX_BIT | \ + VERT_EDGEFLAG_BIT | \ + VERT_NORMAL_BIT | \ + VERT_OBJ_BIT | \ VERT_MATERIAL | \ VERT_ELT | \ VERT_EVAL_ANY) @@ -200,21 +202,24 @@ struct immediate GLuint MaterialOrMask; GLuint MaterialAndMask; - GLfloat (*TexCoord[MAX_TEXTURE_UNITS])[4]; - GLuint Primitive[IMM_SIZE]; /* BEGIN/END */ GLuint PrimitiveLength[IMM_SIZE]; /* BEGIN/END */ GLuint Flag[IMM_SIZE]; /* VERT_* flags */ - GLfloat Color[IMM_SIZE][4]; - GLfloat Obj[IMM_SIZE][4]; - GLfloat Normal[IMM_SIZE][3]; + + GLfloat Obj[IMM_SIZE][4]; /* attrib 0 */ + GLfloat Normal[IMM_SIZE][3]; /* attrib 2 */ GLfloat *NormalLengthPtr; - GLfloat TexCoord0[IMM_SIZE][4]; /* just VERT_TEX0 */ + GLfloat Color[IMM_SIZE][4]; /* attrib 3 */ + GLfloat SecondaryColor[IMM_SIZE][4]; /* attrib 4 */ + GLfloat FogCoord[IMM_SIZE]; /* attrib 5 */ + GLfloat TexCoord0[IMM_SIZE][4]; /* just VERT_TEX0_BIT */ + GLfloat (*TexCoord[MAX_TEXTURE_UNITS])[4]; /* attribs 8..15 */ + GLuint Elt[IMM_SIZE]; GLubyte EdgeFlag[IMM_SIZE]; GLuint Index[IMM_SIZE]; - GLfloat SecondaryColor[IMM_SIZE][4]; - GLfloat FogCoord[IMM_SIZE]; + + GLfloat Attrib[16][IMM_SIZE][4]; /* GL_NV_vertex_program */ }; @@ -229,6 +234,7 @@ struct vertex_arrays GLvector4f TexCoord[MAX_TEXTURE_UNITS]; GLvector1ui Elt; GLvector1f FogCoord; + GLvector4f Attribs[16]; }; @@ -244,27 +250,27 @@ typedef struct vertex_buffer /* Constant over the pipeline. */ - GLuint Count; /* for everything except Elts */ - GLuint FirstClipped; /* temp verts for clipping */ - GLuint FirstPrimitive; /* usually zero */ + GLuint Count; /* for everything except Elts */ + GLuint FirstClipped; /* temp verts for clipping */ + GLuint FirstPrimitive; /* usually zero */ /* Pointers to current data. */ GLuint *Elts; /* VERT_ELT */ - GLvector4f *ObjPtr; /* VERT_OBJ */ + GLvector4f *ObjPtr; /* VERT_OBJ_BIT */ GLvector4f *EyePtr; /* VERT_EYE */ GLvector4f *ClipPtr; /* VERT_CLIP */ GLvector4f *ProjectedClipPtr; /* VERT_CLIP (2) */ GLubyte ClipOrMask; /* VERT_CLIP (3) */ GLubyte *ClipMask; /* VERT_CLIP (4) */ - GLvector3f *NormalPtr; /* VERT_NORM */ - GLfloat *NormalLengthPtr; /* VERT_NORM */ - GLboolean *EdgeFlag; /* VERT_EDGE */ + GLvector3f *NormalPtr; /* VERT_NORMAL_BIT */ + GLfloat *NormalLengthPtr; /* VERT_NORMAL_BIT */ + GLboolean *EdgeFlag; /* VERT_EDGEFLAG_BIT */ GLvector4f *TexCoordPtr[MAX_TEXTURE_UNITS]; /* VERT_TEX_0..n */ - GLvector1ui *IndexPtr[2]; /* VERT_INDEX */ - struct gl_client_array *ColorPtr[2]; /* VERT_RGBA */ - struct gl_client_array *SecondaryColorPtr[2]; /* VERT_SPEC_RGB */ - GLvector1f *FogCoordPtr; /* VERT_FOG_COORD */ + GLvector1ui *IndexPtr[2]; /* VERT_INDEX_BIT */ + struct gl_client_array *ColorPtr[2]; /* VERT_COLOR0_BIT */ + struct gl_client_array *SecondaryColorPtr[2];/* VERT_COLOR1_BIT */ + GLvector1f *FogCoordPtr; /* VERT_FOG_BIT */ GLvector1f *PointSizePtr; /* VERT_POINT_SIZE */ GLmaterial (*Material)[2]; /* VERT_MATERIAL, optional */ GLuint *MaterialMask; /* VERT_MATERIAL, optional */ @@ -272,6 +278,7 @@ typedef struct vertex_buffer GLuint *Primitive; /* GL_(mode)|PRIM_* flags */ GLuint *PrimitiveLength; /* integers */ + GLvector4f *AttribPtr[16]; /* GL_NV_vertex_program */ GLuint importable_data; void *import_source; diff --git a/src/mesa/tnl/t_imm_alloc.c b/src/mesa/tnl/t_imm_alloc.c index 302d739c7f3..ff9c902171a 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.10 2001/09/07 06:55:59 joukj Exp $ */ +/* $Id: t_imm_alloc.c,v 1.11 2001/12/14 02:51:44 brianp Exp $ */ /* * Mesa 3-D graphics library @@ -62,7 +62,6 @@ static struct immediate *real_alloc_immediate( GLcontext *ctx ) IM->CopyTexSize = 0; IM->CopyStart = IM->Start; - /* TexCoord0 is special. */ IM->TexCoord[0] = IM->TexCoord0; diff --git a/src/mesa/tnl/t_imm_api.c b/src/mesa/tnl/t_imm_api.c index c4e7cfcb2e8..a4cb4845beb 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.19 2001/12/04 23:43:31 brianp Exp $ */ +/* $Id: t_imm_api.c,v 1.20 2001/12/14 02:51:44 brianp Exp $ */ /* * Mesa 3-D graphics library @@ -46,6 +46,9 @@ #include "t_imm_dlist.h" +extern void _tnl_vprog_vtxfmt_init( GLcontext *ctx ); + + /* A cassette is full or flushed on a statechange. */ void _tnl_flush_immediate( struct immediate *IM ) @@ -96,6 +99,13 @@ _tnl_begin( GLcontext *ctx, GLenum p ) if (ctx->NewState) _mesa_update_state(ctx); + /* Either install the normal vertex functions or the vertex program funcs */ + if (ctx->VertexProgram.Enabled) + _tnl_vprog_vtxfmt_init(ctx); + else + _tnl_imm_vtxfmt_init(ctx); + _mesa_init_exec_vtxfmt(ctx); + /* if only a very few slots left, might as well flush now */ if (IM->Count > IMM_MAXDATA-8) { @@ -161,7 +171,8 @@ _tnl_save_Begin( GLenum mode ) ctx->Driver.CurrentSavePrimitive = mode; } -static void + +void _tnl_Begin( GLenum mode ) { GET_CURRENT_CONTEXT(ctx); @@ -313,11 +324,11 @@ _tnl_end( GLcontext *ctx ) /* You can set this flag to get the old 'flush_vb on glEnd()' * behaviour. */ - if (1/*(MESA_DEBUG_FLAGS&DEBUG_ALWAYS_FLUSH)*/) + if (1 /*(MESA_DEBUG_FLAGS&DEBUG_ALWAYS_FLUSH)*/ ) _tnl_flush_immediate( IM ); } -static void +void _tnl_End(void) { GET_CURRENT_CONTEXT(ctx); @@ -335,7 +346,7 @@ _tnl_End(void) #define COLOR( IM, r, g, b, a ) \ { \ GLuint count = IM->Count; \ - IM->Flag[count] |= VERT_RGBA; \ + IM->Flag[count] |= VERT_COLOR0_BIT; \ IM->Color[count][0] = r; \ IM->Color[count][1] = g; \ IM->Color[count][2] = b; \ @@ -420,7 +431,7 @@ _tnl_Color4ubv( const GLubyte *v) #define SECONDARY_COLOR( IM, r, g, b ) \ { \ GLuint count = IM->Count; \ - IM->Flag[count] |= VERT_SPEC_RGB; \ + IM->Flag[count] |= VERT_COLOR1_BIT; \ IM->SecondaryColor[count][0] = r; \ IM->SecondaryColor[count][1] = g; \ IM->SecondaryColor[count][2] = b; \ @@ -470,7 +481,7 @@ _tnl_EdgeFlag( GLboolean flag ) GET_IMMEDIATE; count = IM->Count; IM->EdgeFlag[count] = flag; - IM->Flag[count] |= VERT_EDGE; + IM->Flag[count] |= VERT_EDGEFLAG_BIT; } @@ -481,7 +492,7 @@ _tnl_EdgeFlagv( const GLboolean *flag ) GET_IMMEDIATE; count = IM->Count; IM->EdgeFlag[count] = *flag; - IM->Flag[count] |= VERT_EDGE; + IM->Flag[count] |= VERT_EDGEFLAG_BIT; } @@ -492,7 +503,7 @@ _tnl_FogCoordfEXT( GLfloat f ) GET_IMMEDIATE; count = IM->Count; IM->FogCoord[count] = f; - IM->Flag[count] |= VERT_FOG_COORD; + IM->Flag[count] |= VERT_FOG_BIT; } static void @@ -502,7 +513,7 @@ _tnl_FogCoordfvEXT( const GLfloat *v ) GET_IMMEDIATE; count = IM->Count; IM->FogCoord[count] = v[0]; - IM->Flag[count] |= VERT_FOG_COORD; + IM->Flag[count] |= VERT_FOG_BIT; } @@ -513,7 +524,7 @@ _tnl_Indexi( GLint c ) GET_IMMEDIATE; count = IM->Count; IM->Index[count] = c; - IM->Flag[count] |= VERT_INDEX; + IM->Flag[count] |= VERT_INDEX_BIT; } @@ -524,7 +535,7 @@ _tnl_Indexiv( const GLint *c ) GET_IMMEDIATE; count = IM->Count; IM->Index[count] = *c; - IM->Flag[count] |= VERT_INDEX; + IM->Flag[count] |= VERT_INDEX_BIT; } @@ -534,7 +545,7 @@ _tnl_Indexiv( const GLint *c ) GLfloat *normal; \ GET_IMMEDIATE; \ count = IM->Count; \ - IM->Flag[count] |= VERT_NORM; \ + IM->Flag[count] |= VERT_NORMAL_BIT; \ normal = IM->Normal[count]; \ ASSIGN_3V(normal, x,y,z); \ } @@ -546,7 +557,7 @@ _tnl_Indexiv( const GLint *c ) fi_type *normal; \ GET_IMMEDIATE; \ count = IM->Count; \ - IM->Flag[count] |= VERT_NORM; \ + IM->Flag[count] |= VERT_NORMAL_BIT; \ normal = (fi_type *)IM->Normal[count]; \ normal[0].i = ((fi_type *)&(x))->i; \ normal[1].i = ((fi_type *)&(y))->i; \ @@ -577,7 +588,7 @@ _tnl_Normal3fv( const GLfloat *v ) GLfloat *tc; \ GET_IMMEDIATE; \ count = IM->Count; \ - IM->Flag[count] |= VERT_TEX0; \ + IM->Flag[count] |= VERT_TEX0_BIT; \ tc = IM->TexCoord0[count]; \ ASSIGN_4V(tc,s,0,0,1); \ } @@ -588,7 +599,7 @@ _tnl_Normal3fv( const GLfloat *v ) GLfloat *tc; \ GET_IMMEDIATE; \ count = IM->Count; \ - IM->Flag[count] |= VERT_TEX0; \ + IM->Flag[count] |= VERT_TEX0_BIT; \ tc = IM->TexCoord0[count]; \ ASSIGN_4V(tc, s,t,0,1); \ } @@ -599,7 +610,7 @@ _tnl_Normal3fv( const GLfloat *v ) GLfloat *tc; \ GET_IMMEDIATE; \ count = IM->Count; \ - IM->Flag[count] |= VERT_TEX0; \ + IM->Flag[count] |= VERT_TEX0_BIT; \ IM->TexSize |= TEX_0_SIZE_3; \ tc = IM->TexCoord0[count]; \ ASSIGN_4V(tc, s,t,u,1); \ @@ -611,7 +622,7 @@ _tnl_Normal3fv( const GLfloat *v ) GLfloat *tc; \ GET_IMMEDIATE; \ count = IM->Count; \ - IM->Flag[count] |= VERT_TEX0; \ + IM->Flag[count] |= VERT_TEX0_BIT; \ IM->TexSize |= TEX_0_SIZE_4; \ tc = IM->TexCoord0[count]; \ ASSIGN_4V(tc, s,t,u,v); \ @@ -624,7 +635,7 @@ _tnl_Normal3fv( const GLfloat *v ) fi_type *tc; \ GET_IMMEDIATE; \ count = IM->Count; \ - IM->Flag[count] |= VERT_TEX0; \ + IM->Flag[count] |= VERT_TEX0_BIT; \ tc = (fi_type *)IM->TexCoord0[count]; \ tc[0].i = ((fi_type *)&(s))->i; \ tc[1].i = ((fi_type *)&(t))->i; \ @@ -694,7 +705,7 @@ _tnl_TexCoord4fv( const GLfloat *v ) { \ GLuint count = IM->Count++; \ GLfloat *dest = IM->Obj[count]; \ - IM->Flag[count] |= VERT_OBJ; \ + IM->Flag[count] |= VERT_OBJ_BIT; \ ASSIGN_4V(dest, x, y, 0, 1); \ /* ASSERT(IM->Flag[IM->Count]==0); */\ if (count == IMM_MAXDATA - 1) \ @@ -727,7 +738,7 @@ _tnl_TexCoord4fv( const GLfloat *v ) { \ GLuint count = IM->Count++; \ fi_type *dest = (fi_type *)IM->Obj[count]; \ - IM->Flag[count] |= VERT_OBJ; \ + IM->Flag[count] |= VERT_OBJ_BIT; \ dest[0].i = ((fi_type *)&(x))->i; \ dest[1].i = ((fi_type *)&(y))->i; \ dest[2].i = 0; \ @@ -1100,6 +1111,30 @@ _tnl_vertex2f( GLcontext *ctx, GLfloat x, GLfloat y ) +/* + * NV_vertex_program + */ + +static void +_tnl_VertexAttrib4fNV(GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w) +{ + /* no-op? */ + printf("%s(%d, %f, %f, %f, %f)\n", __FUNCTION__, index, x, y, z, w); + (void) index; + (void) x; + (void) y; + (void) z; + (void) w; +} + +static void +_tnl_VertexAttrib4fvNV(GLuint index, const GLfloat *v) +{ + /* no-op? */ + (void) index; + (void) v; +} + /* Execute a glRectf() function. _tnl_hard_begin() ensures the check @@ -1206,6 +1241,8 @@ void _tnl_imm_vtxfmt_init( GLcontext *ctx ) { GLvertexformat *vfmt = &(TNL_CONTEXT(ctx)->vtxfmt); + printf("%s()\n", __FUNCTION__); + /* All begin/end operations are handled by this vertex format: */ vfmt->ArrayElement = _tnl_ArrayElement; @@ -1260,6 +1297,8 @@ void _tnl_imm_vtxfmt_init( GLcontext *ctx ) vfmt->Vertex3fv = _tnl_Vertex3fv; vfmt->Vertex4f = _tnl_Vertex4f; vfmt->Vertex4fv = _tnl_Vertex4fv; + vfmt->VertexAttrib4fNV = _tnl_VertexAttrib4fNV; + vfmt->VertexAttrib4fvNV = _tnl_VertexAttrib4fvNV; /* Outside begin/end functions (from t_varray.c, t_eval.c, ...): */ diff --git a/src/mesa/tnl/t_imm_api.h b/src/mesa/tnl/t_imm_api.h index ad1827f1f8a..c13dde77aa1 100644 --- a/src/mesa/tnl/t_imm_api.h +++ b/src/mesa/tnl/t_imm_api.h @@ -1,8 +1,8 @@ -/* $Id: t_imm_api.h,v 1.3 2001/03/12 00:48:43 gareth Exp $ */ +/* $Id: t_imm_api.h,v 1.4 2001/12/14 02:51:44 brianp Exp $ */ /* * Mesa 3-D graphics library - * Version: 3.5 + * Version: 4.1 * * Copyright (C) 1999-2001 Brian Paul All Rights Reserved. * @@ -34,6 +34,11 @@ extern void _tnl_save_Begin( GLenum mode ); +extern void _tnl_Begin( GLenum mode ); + +extern void _tnl_End(void); + + /* TNL-private internal functions for building higher-level operations: */ extern GLboolean _tnl_hard_begin( GLcontext *ctx, GLenum p ); diff --git a/src/mesa/tnl/t_imm_debug.c b/src/mesa/tnl/t_imm_debug.c index 78121f9e5a6..2bd36aa16e7 100644 --- a/src/mesa/tnl/t_imm_debug.c +++ b/src/mesa/tnl/t_imm_debug.c @@ -1,4 +1,4 @@ -/* $Id: t_imm_debug.c,v 1.4 2001/08/01 05:10:42 keithw Exp $ */ +/* $Id: t_imm_debug.c,v 1.5 2001/12/14 02:51:45 brianp Exp $ */ /* * Mesa 3-D graphics library @@ -35,29 +35,29 @@ void _tnl_print_vert_flags( const char *name, GLuint flags ) name, flags, (flags & VERT_CLIP) ? "clip/proj-clip/glend, " : "", - (flags & VERT_EDGE) ? "edgeflag, " : "", + (flags & VERT_EDGEFLAG_BIT) ? "edgeflag, " : "", (flags & VERT_ELT) ? "array-elt, " : "", (flags & VERT_END_VB) ? "end-vb, " : "", (flags & VERT_EVAL_ANY) ? "eval-coord, " : "", (flags & VERT_EYE) ? "eye/glbegin, " : "", - (flags & VERT_FOG_COORD) ? "fog-coord, " : "", - (flags & VERT_INDEX) ? "index, " : "", + (flags & VERT_FOG_BIT) ? "fog-coord, " : "", + (flags & VERT_INDEX_BIT) ? "index, " : "", (flags & VERT_MATERIAL) ? "material, " : "", - (flags & VERT_NORM) ? "normals, " : "", - (flags & VERT_OBJ) ? "obj, " : "", + (flags & VERT_NORMAL_BIT) ? "normals, " : "", + (flags & VERT_OBJ_BIT) ? "obj, " : "", (flags & VERT_OBJ_3) ? "obj-3, " : "", (flags & VERT_OBJ_4) ? "obj-4, " : "", (flags & VERT_POINT_SIZE) ? "point-size, " : "", - (flags & VERT_RGBA) ? "colors, " : "", - (flags & VERT_SPEC_RGB) ? "specular, " : "", - (flags & VERT_TEX0) ? "texcoord0, " : "", - (flags & VERT_TEX1) ? "texcoord1, " : "", - (flags & VERT_TEX2) ? "texcoord2, " : "", - (flags & VERT_TEX3) ? "texcoord3, " : "", - (flags & VERT_TEX4) ? "texcoord4, " : "", - (flags & VERT_TEX5) ? "texcoord5, " : "", - (flags & VERT_TEX6) ? "texcoord6, " : "", - (flags & VERT_TEX7) ? "texcoord7, " : "" + (flags & VERT_COLOR0_BIT) ? "colors, " : "", + (flags & VERT_COLOR1_BIT) ? "specular, " : "", + (flags & VERT_TEX0_BIT) ? "texcoord0, " : "", + (flags & VERT_TEX1_BIT) ? "texcoord1, " : "", + (flags & VERT_TEX2_BIT) ? "texcoord2, " : "", + (flags & VERT_TEX3_BIT) ? "texcoord3, " : "", + (flags & VERT_TEX4_BIT) ? "texcoord4, " : "", + (flags & VERT_TEX5_BIT) ? "texcoord5, " : "", + (flags & VERT_TEX6_BIT) ? "texcoord6, " : "", + (flags & VERT_TEX7_BIT) ? "texcoord7, " : "" ); } @@ -107,7 +107,7 @@ void _tnl_print_cassette( struct immediate *IM ) if (req & flags[i] & VERT_ELT) fprintf(stderr, " Elt %u\t", IM->Elt[i]); - if (req & flags[i] & VERT_NORM) + if (req & flags[i] & VERT_NORMAL_BIT) fprintf(stderr, " Norm %f %f %f ", IM->Normal[i][0], IM->Normal[i][1], IM->Normal[i][2]); @@ -124,23 +124,23 @@ void _tnl_print_cassette( struct immediate *IM ) } } - if (req & flags[i] & VERT_RGBA) + if (req & flags[i] & VERT_COLOR0_BIT) fprintf(stderr, " Rgba %f %f %f %f ", IM->Color[i][0], IM->Color[i][1], IM->Color[i][2], IM->Color[i][3]); - if (req & flags[i] & VERT_SPEC_RGB) + if (req & flags[i] & VERT_COLOR1_BIT) fprintf(stderr, " Spec %f %f %f ", IM->SecondaryColor[i][0], IM->SecondaryColor[i][1], IM->SecondaryColor[i][2]); - if (req & flags[i] & VERT_FOG_COORD) + if (req & flags[i] & VERT_FOG_BIT) fprintf(stderr, " Fog %f ", IM->FogCoord[i]); - if (req & flags[i] & VERT_INDEX) + if (req & flags[i] & VERT_INDEX_BIT) fprintf(stderr, " Index %u ", IM->Index[i]); - if (req & flags[i] & VERT_EDGE) + if (req & flags[i] & VERT_EDGEFLAG_BIT) fprintf(stderr, " Edgeflag %d ", IM->EdgeFlag[i]); if (req & flags[i] & VERT_MATERIAL) diff --git a/src/mesa/tnl/t_imm_dlist.c b/src/mesa/tnl/t_imm_dlist.c index d89d9292dff..04212a6480f 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.32 2001/12/13 10:49:04 keithw Exp $ */ +/* $Id: t_imm_dlist.c,v 1.33 2001/12/14 02:51:45 brianp Exp $ */ /* * Mesa 3-D graphics library @@ -86,7 +86,7 @@ static void build_normal_lengths( struct immediate *IM ) for (i = 0 ; i < count ; ) { dest[i] = len; - if (flags[++i] & VERT_NORM) { + if (flags[++i] & VERT_NORMAL_BIT) { len = (GLfloat) LEN_3FV( data[i] ); if (len > 0.0F) len = 1.0F / len; } @@ -108,7 +108,7 @@ static void fixup_normal_lengths( struct immediate *IM ) } if (i < IM->Count) { - while (!(flags[i] & (VERT_NORM|VERT_END_VB))) { + while (!(flags[i] & (VERT_NORMAL_BIT|VERT_END_VB))) { dest[i] = len; i++; } @@ -611,28 +611,28 @@ static void loopback_compiled_cassette( GLcontext *ctx, struct immediate *IM ) } } - if (flags[i] & VERT_NORM) { + if (flags[i] & VERT_NORMAL_BIT) { /* fprintf(stderr, "normal %d: %f %f %f\n", i, */ /* IM->Normal[i][0], IM->Normal[i][1], IM->Normal[i][2]); */ glNormal3fv(IM->Normal[i]); } - if (flags[i] & VERT_RGBA) { + if (flags[i] & VERT_COLOR0_BIT) { /* fprintf(stderr, "color %d: %f %f %f\n", i, */ /* IM->Color[i][0], IM->Color[i][1], IM->Color[i][2]); */ glColor4fv( IM->Color[i] ); } - if (flags[i] & VERT_SPEC_RGB) + if (flags[i] & VERT_COLOR1_BIT) glSecondaryColor3fvEXT( IM->SecondaryColor[i] ); - if (flags[i] & VERT_FOG_COORD) + if (flags[i] & VERT_FOG_BIT) glFogCoordfEXT( IM->FogCoord[i] ); - if (flags[i] & VERT_INDEX) + if (flags[i] & VERT_INDEX_BIT) glIndexi( IM->Index[i] ); - if (flags[i] & VERT_EDGE) + if (flags[i] & VERT_EDGEFLAG_BIT) glEdgeFlag( IM->EdgeFlag[i] ); if (flags[i] & VERT_MATERIAL) diff --git a/src/mesa/tnl/t_imm_elt.c b/src/mesa/tnl/t_imm_elt.c index 0a891733e9a..d585f63c47b 100644 --- a/src/mesa/tnl/t_imm_elt.c +++ b/src/mesa/tnl/t_imm_elt.c @@ -1,4 +1,4 @@ -/* $Id: t_imm_elt.c,v 1.12 2001/09/14 21:30:31 brianp Exp $ */ +/* $Id: t_imm_elt.c,v 1.13 2001/12/14 02:51:45 brianp Exp $ */ /* * Mesa 3-D graphics library @@ -757,10 +757,10 @@ void _tnl_translate_array_elts( GLcontext *ctx, struct immediate *IM, if (MESA_VERBOSE&VERBOSE_IMMEDIATE) fprintf(stderr, "exec_array_elements %d .. %d\n", start, count); - if (translate & VERT_OBJ) { + if (translate & VERT_OBJ_BIT) { _tnl_trans_elt_4f( IM->Obj, &ctx->Array.Vertex, - flags, elts, (VERT_ELT|VERT_OBJ), + flags, elts, (VERT_ELT|VERT_OBJ_BIT), start, count); if (ctx->Array.Vertex.Size == 4) @@ -770,42 +770,42 @@ void _tnl_translate_array_elts( GLcontext *ctx, struct immediate *IM, } - if (translate & VERT_NORM) + if (translate & VERT_NORMAL_BIT) _tnl_trans_elt_3f( IM->Normal, &ctx->Array.Normal, - flags, elts, (VERT_ELT|VERT_NORM), + flags, elts, (VERT_ELT|VERT_NORMAL_BIT), start, count); - if (translate & VERT_EDGE) + if (translate & VERT_EDGEFLAG_BIT) _tnl_trans_elt_1ub( IM->EdgeFlag, &ctx->Array.EdgeFlag, - flags, elts, (VERT_ELT|VERT_EDGE), + flags, elts, (VERT_ELT|VERT_EDGEFLAG_BIT), start, count); - if (translate & VERT_RGBA) { + if (translate & VERT_COLOR0_BIT) { _tnl_trans_elt_4f( IM->Color, &ctx->Array.Color, - flags, elts, (VERT_ELT|VERT_RGBA), + flags, elts, (VERT_ELT|VERT_COLOR0_BIT), start, count); } - if (translate & VERT_SPEC_RGB) { + if (translate & VERT_COLOR1_BIT) { _tnl_trans_elt_4f( IM->SecondaryColor, &ctx->Array.SecondaryColor, - flags, elts, (VERT_ELT|VERT_SPEC_RGB), + flags, elts, (VERT_ELT|VERT_COLOR1_BIT), start, count); } - if (translate & VERT_FOG_COORD) + if (translate & VERT_FOG_BIT) _tnl_trans_elt_1f( IM->FogCoord, &ctx->Array.FogCoord, - flags, elts, (VERT_ELT|VERT_FOG_COORD), + flags, elts, (VERT_ELT|VERT_FOG_BIT), start, count); - if (translate & VERT_INDEX) + if (translate & VERT_INDEX_BIT) _tnl_trans_elt_1ui( IM->Index, &ctx->Array.Index, - flags, elts, (VERT_ELT|VERT_INDEX), + flags, elts, (VERT_ELT|VERT_INDEX_BIT), start, count); if (translate & VERT_TEX_ANY) { diff --git a/src/mesa/tnl/t_imm_eval.c b/src/mesa/tnl/t_imm_eval.c index d90884d9426..662cfb936a8 100644 --- a/src/mesa/tnl/t_imm_eval.c +++ b/src/mesa/tnl/t_imm_eval.c @@ -1,4 +1,4 @@ -/* $Id: t_imm_eval.c,v 1.18 2001/09/14 21:30:31 brianp Exp $ */ +/* $Id: t_imm_eval.c,v 1.19 2001/12/14 02:51:45 brianp Exp $ */ /* * Mesa 3-D graphics library @@ -379,34 +379,34 @@ static void update_eval( GLcontext *ctx ) GLuint eval1 = 0, eval2 = 0; if (ctx->Eval.Map1Index) - eval1 |= VERT_INDEX; + eval1 |= VERT_INDEX_BIT; if (ctx->Eval.Map2Index) - eval2 |= VERT_INDEX; + eval2 |= VERT_INDEX_BIT; if (ctx->Eval.Map1Color4) - eval1 |= VERT_RGBA; + eval1 |= VERT_COLOR0_BIT; if (ctx->Eval.Map2Color4) - eval2 |= VERT_RGBA; + eval2 |= VERT_COLOR0_BIT; if (ctx->Eval.Map1Normal) - eval1 |= VERT_NORM; + eval1 |= VERT_NORMAL_BIT; if (ctx->Eval.Map2Normal) - eval2 |= VERT_NORM; + eval2 |= VERT_NORMAL_BIT; if (ctx->Eval.Map1TextureCoord4 || ctx->Eval.Map1TextureCoord3 || ctx->Eval.Map1TextureCoord2 || ctx->Eval.Map1TextureCoord1) - eval1 |= VERT_TEX0; + eval1 |= VERT_TEX0_BIT; if (ctx->Eval.Map2TextureCoord4 || ctx->Eval.Map2TextureCoord3 || ctx->Eval.Map2TextureCoord2 || ctx->Eval.Map2TextureCoord1) - eval2 |= VERT_TEX0; + eval2 |= VERT_TEX0_BIT; if (ctx->Eval.Map1Vertex4) eval1 |= VERT_OBJ_234; @@ -416,13 +416,13 @@ static void update_eval( GLcontext *ctx ) if (ctx->Eval.Map2Vertex4) { if (ctx->Eval.AutoNormal) - eval2 |= VERT_OBJ_234 | VERT_NORM; + eval2 |= VERT_OBJ_234 | VERT_NORMAL_BIT; else eval2 |= VERT_OBJ_234; } else if (ctx->Eval.Map2Vertex3) { if (ctx->Eval.AutoNormal) - eval2 |= VERT_OBJ_23 | VERT_NORM; + eval2 |= VERT_OBJ_23 | VERT_NORMAL_BIT; else eval2 |= VERT_OBJ_23; } @@ -507,7 +507,7 @@ void _tnl_eval_immediate( GLcontext *ctx, struct immediate *IM ) /* Perform the evaluations on active data elements. */ - if (req & VERT_INDEX) + if (req & VERT_INDEX_BIT) { GLuint generated = 0; @@ -528,7 +528,7 @@ void _tnl_eval_immediate( GLcontext *ctx, struct immediate *IM ) } } - if (req & VERT_RGBA) + if (req & VERT_COLOR0_BIT) { GLuint generated = 0; @@ -541,7 +541,7 @@ void _tnl_eval_immediate( GLcontext *ctx, struct immediate *IM ) tmp->Color.Ptr = store->Color + IM->CopyStart; tmp->Color.StrideB = 4 * sizeof(GLfloat); tmp->Color.Flags = 0; - tnl->vb.importable_data &= ~VERT_RGBA; + tnl->vb.importable_data &= ~VERT_COLOR0_BIT; if (ctx->Eval.Map1Color4 && any_eval1) { eval1_4f_ca( &tmp->Color, coord, flags, 4, &ctx->EvalMap.Map1Color4 ); @@ -616,7 +616,7 @@ void _tnl_eval_immediate( GLcontext *ctx, struct immediate *IM ) } - if (req & VERT_NORM) + if (req & VERT_NORMAL_BIT) { GLuint generated = 0; @@ -647,7 +647,7 @@ void _tnl_eval_immediate( GLcontext *ctx, struct immediate *IM ) /* In the AutoNormal case, the copy and assignment of tmp->NormalPtr * are done above. */ - if (req & VERT_OBJ) + if (req & VERT_OBJ_BIT) { if (copycount) { /* This copy may already have occurred when eliminating @@ -678,7 +678,7 @@ void _tnl_eval_immediate( GLcontext *ctx, struct immediate *IM ) if (any_eval2) { if (ctx->Eval.Map2Vertex4) { - if (ctx->Eval.AutoNormal && (req & VERT_NORM)) + if (ctx->Eval.AutoNormal && (req & VERT_NORMAL_BIT)) eval2_obj_norm( &tmp->Obj, &tmp->Normal, coord, flags, 4, &ctx->EvalMap.Map2Vertex4 ); else @@ -687,7 +687,7 @@ void _tnl_eval_immediate( GLcontext *ctx, struct immediate *IM ) } else if (ctx->Eval.Map2Vertex3) { - if (ctx->Eval.AutoNormal && (req & VERT_NORM)) + if (ctx->Eval.AutoNormal && (req & VERT_NORMAL_BIT)) eval2_obj_norm( &tmp->Obj, &tmp->Normal, coord, flags, 3, &ctx->EvalMap.Map2Vertex3 ); else @@ -704,7 +704,7 @@ void _tnl_eval_immediate( GLcontext *ctx, struct immediate *IM ) * must be ignored. */ if (purge_flags) { - GLuint vertex = VERT_OBJ|(VERT_EVAL_ANY & ~purge_flags); + GLuint vertex = VERT_OBJ_BIT|(VERT_EVAL_ANY & ~purge_flags); GLuint last_new_prim = 0; GLuint new_prim_length = 0; GLuint next_old_prim = 0; diff --git a/src/mesa/tnl/t_imm_exec.c b/src/mesa/tnl/t_imm_exec.c index 5b6d5d3d3c7..58c46c4777c 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.30 2001/11/30 15:43:53 alanh Exp $ */ +/* $Id: t_imm_exec.c,v 1.31 2001/12/14 02:51:45 brianp Exp $ */ /* * Mesa 3-D graphics library @@ -96,6 +96,7 @@ void _tnl_reset_exec_input( GLcontext *ctx, reset_input( ctx, start, beginstate, savedbeginstate ); IM->CopyStart = start - tnl->ExecCopyCount; + IM->Primitive[IM->CopyStart] = ctx->Driver.CurrentExecPrimitive; if (tnl->ExecParity) IM->Primitive[IM->CopyStart] |= PRIM_PARITY; @@ -117,40 +118,44 @@ void _tnl_reset_compile_input( GLcontext *ctx, } +/* + * Copy the last specified normal, color, texcoord, edge flag, etc + * from the immediate struct into the ctx->Current attribute group. + */ void _tnl_copy_to_current( GLcontext *ctx, struct immediate *IM, GLuint flag, GLuint count ) { if (MESA_VERBOSE&VERBOSE_IMMEDIATE) _tnl_print_vert_flags("copy to current", flag); - if (flag & VERT_NORM) - COPY_3FV( ctx->Current.Normal, IM->Normal[count]); + if (flag & VERT_NORMAL_BIT) + COPY_3FV( ctx->Current.Attrib[VERT_ATTRIB_NORMAL], IM->Normal[count]); - if (flag & VERT_INDEX) + if (flag & VERT_INDEX_BIT) ctx->Current.Index = IM->Index[count]; - if (flag & VERT_EDGE) + if (flag & VERT_EDGEFLAG_BIT) ctx->Current.EdgeFlag = IM->EdgeFlag[count]; - if (flag & VERT_RGBA) { - COPY_4FV(ctx->Current.Color, IM->Color[count]); + if (flag & VERT_COLOR0_BIT) { + COPY_4FV(ctx->Current.Attrib[VERT_ATTRIB_COLOR0], IM->Color[count]); if (ctx->Light.ColorMaterialEnabled) { - _mesa_update_color_material( ctx, ctx->Current.Color ); + _mesa_update_color_material( ctx, ctx->Current.Attrib[VERT_ATTRIB_COLOR0] ); _mesa_validate_all_lighting_tables( ctx ); } } - if (flag & VERT_SPEC_RGB) - COPY_4FV(ctx->Current.SecondaryColor, IM->SecondaryColor[count]); + if (flag & VERT_COLOR1_BIT) + COPY_4FV(ctx->Current.Attrib[VERT_ATTRIB_COLOR1], IM->SecondaryColor[count]); - if (flag & VERT_FOG_COORD) - ctx->Current.FogCoord = IM->FogCoord[count]; + if (flag & VERT_FOG_BIT) + ctx->Current.Attrib[VERT_ATTRIB_FOG][0] = IM->FogCoord[count]; if (flag & VERT_TEX_ANY) { GLuint i; for (i = 0 ; i < ctx->Const.MaxTextureUnits ; i++) { if (flag & VERT_TEX(i)) { - COPY_4FV( ctx->Current.Texcoord[0], IM->TexCoord[0][count]); + COPY_4FV( ctx->Current.Attrib[VERT_ATTRIB_TEX0 + i], IM->TexCoord[i][count]); } } } @@ -202,13 +207,11 @@ void _tnl_compute_orflag( struct immediate *IM, GLuint start ) } - - - - - - -/* Note: The 'start' member of the GLvector structs is now redundant +/* + * This is where the vertex data is transfered from the 'struct immediate + * into the 'struct vertex_buffer'. + * + * Note: The 'start' member of the GLvector structs is now redundant * because we always re-transform copied vertices, and the vectors * below are set up so that the first copied vertex (if any) appears * at position zero. @@ -263,7 +266,7 @@ static void _tnl_vb_bind_immediate( GLcontext *ctx, struct immediate *IM ) /* Setup the initial values of array pointers in the vb. */ - if (inputs & VERT_OBJ) { + if (inputs & VERT_OBJ_BIT) { tmp->Obj.data = IM->Obj + start; tmp->Obj.start = (GLfloat *)(IM->Obj + start); tmp->Obj.count = count; @@ -276,7 +279,7 @@ static void _tnl_vb_bind_immediate( GLcontext *ctx, struct immediate *IM ) tmp->Obj.size = 2; } - if (inputs & VERT_NORM) { + if (inputs & VERT_NORMAL_BIT) { tmp->Normal.data = IM->Normal + start; tmp->Normal.start = (GLfloat *)(IM->Normal + start); tmp->Normal.count = count; @@ -285,40 +288,41 @@ static void _tnl_vb_bind_immediate( GLcontext *ctx, struct immediate *IM ) VB->NormalLengthPtr = IM->NormalLengthPtr + start; } - if (inputs & VERT_INDEX) { + if (inputs & VERT_INDEX_BIT) { tmp->Index.count = count; tmp->Index.data = IM->Index + start; tmp->Index.start = IM->Index + start; VB->IndexPtr[0] = &tmp->Index; } - if (inputs & VERT_FOG_COORD) { + if (inputs & VERT_FOG_BIT) { tmp->FogCoord.data = IM->FogCoord + start; tmp->FogCoord.start = IM->FogCoord + start; tmp->FogCoord.count = count; VB->FogCoordPtr = &tmp->FogCoord; } - if (inputs & VERT_SPEC_RGB) { + if (inputs & VERT_COLOR1_BIT) { tmp->SecondaryColor.Ptr = IM->SecondaryColor + start; VB->SecondaryColorPtr[0] = &tmp->SecondaryColor; } - if (inputs & VERT_EDGE) { + if (inputs & VERT_EDGEFLAG_BIT) { VB->EdgeFlag = IM->EdgeFlag + start; } - if (inputs & VERT_RGBA) { - if (IM->CopyOrFlag & VERT_RGBA) { + if (inputs & VERT_COLOR0_BIT) { + if (IM->CopyOrFlag & VERT_COLOR0_BIT) { tmp->Color.Ptr = IM->Color + start; tmp->Color.StrideB = 4 * sizeof(GLfloat); tmp->Color.Flags = 0; - } else { - tmp->Color.Ptr = ctx->Current.Color; + } + else { + tmp->Color.Ptr = ctx->Current.Attrib[VERT_ATTRIB_COLOR0]; tmp->Color.StrideB = 0; tmp->Color.Flags = CA_CLIENT_DATA; /* hack */ VB->import_source = IM; - VB->importable_data |= VERT_RGBA; + VB->importable_data |= VERT_COLOR0_BIT; VB->import_data = _tnl_upgrade_current_data; } VB->ColorPtr[0] = &tmp->Color; @@ -347,6 +351,18 @@ static void _tnl_vb_bind_immediate( GLcontext *ctx, struct immediate *IM ) VB->MaterialMask = IM->MaterialMask + start; VB->Material = IM->Material + start; } + + /* GL_NV_vertex_program */ + if (ctx->VertexProgram.Enabled) { + GLuint attr; + for (attr = 0; attr < 16; attr++) { + tmp->Attribs[attr].count = count; + tmp->Attribs[attr].data = IM->Attrib[attr] + start; + tmp->Attribs[attr].start = (GLfloat *) (IM->Attrib[attr] + start); + tmp->Attribs[attr].size = 4; + VB->AttribPtr[attr] = &(tmp->Attribs[attr]); + } + } } @@ -359,8 +375,6 @@ void _tnl_run_cassette( GLcontext *ctx, struct immediate *IM ) { TNLcontext *tnl = TNL_CONTEXT(ctx); -/* fprintf(stderr, "%s\n", __FUNCTION__); */ - _tnl_vb_bind_immediate( ctx, IM ); if (IM->OrFlag & VERT_EVAL_ANY) @@ -449,6 +463,7 @@ void _tnl_execute_cassette( GLcontext *ctx, struct immediate *IM ) { TNLcontext *tnl = TNL_CONTEXT(ctx); + printf("enter %s()\n", __FUNCTION__); _tnl_compute_orflag( IM, IM->Start ); _tnl_copy_immediate_vertices( ctx, IM ); _tnl_get_exec_copy_verts( ctx, IM ); @@ -456,6 +471,7 @@ void _tnl_execute_cassette( GLcontext *ctx, struct immediate *IM ) if (tnl->pipeline.build_state_changes) _tnl_validate_pipeline( ctx ); + printf(" CopyStart %d == Count %d ?\n", IM->CopyStart, IM->Count); if (IM->CopyStart == IM->Count) { exec_empty_cassette( ctx, IM ); } @@ -488,6 +504,7 @@ void _tnl_execute_cassette( GLcontext *ctx, struct immediate *IM ) if (ctx->Driver.CurrentExecPrimitive == GL_POLYGON+1) ctx->Driver.NeedFlush &= ~FLUSH_STORED_VERTICES; + printf("leave %s()\n", __FUNCTION__); } diff --git a/src/mesa/tnl/t_imm_fixup.c b/src/mesa/tnl/t_imm_fixup.c index ce593343a90..8da694a9e3c 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.28 2001/12/03 17:47:04 keithw Exp $ */ +/* $Id: t_imm_fixup.c,v 1.29 2001/12/14 02:51:45 brianp Exp $ */ /* * Mesa 3-D graphics library @@ -194,37 +194,41 @@ fixup_first_1ub( GLubyte data[], GLuint flag[], GLuint match, data[i] = dflt; } +/* + * Copy vertex attributes from the ctx->Current group into the immediate + * struct at the given position according to copyMask. + */ static void copy_from_current( GLcontext *ctx, struct immediate *IM, - GLuint start, GLuint copy ) + GLuint pos, GLuint copyMask ) { if (MESA_VERBOSE&VERBOSE_IMMEDIATE) - _tnl_print_vert_flags("copy from current", copy); + _tnl_print_vert_flags("copy from current", copyMask); - if (copy & VERT_NORM) { - COPY_3V( IM->Normal[start], ctx->Current.Normal ); + if (copyMask & VERT_NORMAL_BIT) { + COPY_3V(IM->Normal[pos], ctx->Current.Attrib[VERT_ATTRIB_NORMAL]); } - if (copy & VERT_RGBA) { - COPY_4FV( IM->Color[start], ctx->Current.Color); + if (copyMask & VERT_COLOR0_BIT) { + COPY_4FV( IM->Color[pos], ctx->Current.Attrib[VERT_ATTRIB_COLOR0]); } - if (copy & VERT_SPEC_RGB) - COPY_4FV( IM->SecondaryColor[start], ctx->Current.SecondaryColor); + if (copyMask & VERT_COLOR1_BIT) + COPY_4FV( IM->SecondaryColor[pos], ctx->Current.Attrib[VERT_ATTRIB_COLOR1]); - if (copy & VERT_FOG_COORD) - IM->FogCoord[start] = ctx->Current.FogCoord; + if (copyMask & VERT_FOG_BIT) + IM->FogCoord[pos] = ctx->Current.Attrib[VERT_ATTRIB_FOG][0]; - if (copy & VERT_INDEX) - IM->Index[start] = ctx->Current.Index; + if (copyMask & VERT_INDEX_BIT) + IM->Index[pos] = ctx->Current.Index; - if (copy & VERT_EDGE) - IM->EdgeFlag[start] = ctx->Current.EdgeFlag; + if (copyMask & VERT_EDGEFLAG_BIT) + IM->EdgeFlag[pos] = ctx->Current.EdgeFlag; - if (copy & VERT_TEX_ANY) { + if (copyMask & VERT_TEX_ANY) { GLuint i; for (i = 0 ; i < ctx->Const.MaxTextureUnits ; i++) { - if (copy & VERT_TEX(i)) - COPY_4FV( IM->TexCoord[i][start], ctx->Current.Texcoord[i] ); + if (copyMask & VERT_TEX(i)) + COPY_4FV(IM->TexCoord[i][pos], ctx->Current.Attrib[VERT_ATTRIB_TEX0 + i]); } } } @@ -254,7 +258,7 @@ void _tnl_fixup_input( GLcontext *ctx, struct immediate *IM ) if (!ctx->ExecuteFlag) fixup &= orflag; - if ((orflag & (VERT_OBJ|VERT_EVAL_ANY)) == 0) + if ((orflag & (VERT_OBJ_BIT|VERT_EVAL_ANY)) == 0) fixup = 0; if (fixup) { @@ -285,50 +289,50 @@ void _tnl_fixup_input( GLcontext *ctx, struct immediate *IM ) } - if (fixup & VERT_EDGE) { - if (orflag & VERT_EDGE) - _tnl_fixup_1ub( IM->EdgeFlag, IM->Flag, start, VERT_EDGE ); + if (fixup & VERT_EDGEFLAG_BIT) { + if (orflag & VERT_EDGEFLAG_BIT) + _tnl_fixup_1ub( IM->EdgeFlag, IM->Flag, start, VERT_EDGEFLAG_BIT ); else fixup_first_1ub( IM->EdgeFlag, IM->Flag, VERT_END_VB, start, IM->EdgeFlag[start] ); } - if (fixup & VERT_INDEX) { - if (orflag & VERT_INDEX) - _tnl_fixup_1ui( IM->Index, IM->Flag, start, VERT_INDEX ); + if (fixup & VERT_INDEX_BIT) { + if (orflag & VERT_INDEX_BIT) + _tnl_fixup_1ui( IM->Index, IM->Flag, start, VERT_INDEX_BIT ); else fixup_first_1ui( IM->Index, IM->Flag, VERT_END_VB, start, IM->Index[start] ); } - if (fixup & VERT_RGBA) { - if (orflag & VERT_RGBA) - _tnl_fixup_4f( IM->Color, IM->Flag, start, VERT_RGBA ); + if (fixup & VERT_COLOR0_BIT) { + if (orflag & VERT_COLOR0_BIT) + _tnl_fixup_4f( IM->Color, IM->Flag, start, VERT_COLOR0_BIT ); /* No need for else case as the drivers understand stride * zero here. (TODO - propogate this) */ } - if (fixup & VERT_SPEC_RGB) { - if (orflag & VERT_SPEC_RGB) + if (fixup & VERT_COLOR1_BIT) { + if (orflag & VERT_COLOR1_BIT) _tnl_fixup_4f( IM->SecondaryColor, IM->Flag, start, - VERT_SPEC_RGB ); + VERT_COLOR1_BIT ); else fixup_first_4f( IM->SecondaryColor, IM->Flag, VERT_END_VB, start, IM->SecondaryColor[start] ); } - if (fixup & VERT_FOG_COORD) { - if (orflag & VERT_FOG_COORD) - _tnl_fixup_1f( IM->FogCoord, IM->Flag, start, VERT_FOG_COORD ); + if (fixup & VERT_FOG_BIT) { + if (orflag & VERT_FOG_BIT) + _tnl_fixup_1f( IM->FogCoord, IM->Flag, start, VERT_FOG_BIT ); else fixup_first_1f( IM->FogCoord, IM->Flag, VERT_END_VB, start, IM->FogCoord[start] ); } - if (fixup & VERT_NORM) { - if (orflag & VERT_NORM) - _tnl_fixup_3f( IM->Normal, IM->Flag, start, VERT_NORM ); + if (fixup & VERT_NORMAL_BIT) { + if (orflag & VERT_NORMAL_BIT) + _tnl_fixup_3f( IM->Normal, IM->Flag, start, VERT_NORMAL_BIT ); else fixup_first_3f( IM->Normal, IM->Flag, VERT_END_VB, start, IM->Normal[start] ); @@ -417,6 +421,7 @@ void _tnl_copy_immediate_vertices( GLcontext *ctx, struct immediate *next ) } next->CopyStart = next->Start - count; + printf("%s() CopyStart = %d\n", __FUNCTION__, next->CopyStart); if ((prev->CopyOrFlag & VERT_DATA) == VERT_ELT && ctx->Array.LockCount && @@ -472,7 +477,7 @@ void _tnl_copy_immediate_vertices( GLcontext *ctx, struct immediate *next ) */ COPY_4FV( next->Obj[dst], inputs->Obj.data[isrc] ); - if (copy & VERT_NORM) { + if (copy & VERT_NORMAL_BIT) { /* fprintf(stderr, "copy vert norm %d to %d (%p): %f %f %f\n", */ /* isrc, dst, */ /* next->Normal[dst], */ @@ -482,11 +487,11 @@ void _tnl_copy_immediate_vertices( GLcontext *ctx, struct immediate *next ) COPY_3FV( next->Normal[dst], inputs->Normal.data[isrc] ); } - if (copy & VERT_RGBA) + if (copy & VERT_COLOR0_BIT) COPY_4FV( next->Color[dst], ((GLfloat (*)[4])inputs->Color.Ptr)[isrc] ); - if (copy & VERT_INDEX) + if (copy & VERT_INDEX_BIT) next->Index[dst] = inputs->Index.data[isrc]; if (copy & VERT_TEX_ANY) { @@ -501,7 +506,7 @@ void _tnl_copy_immediate_vertices( GLcontext *ctx, struct immediate *next ) /* Remaining values should be the same in the 'input' struct and the * original immediate. */ - if (copy & (VERT_ELT|VERT_EDGE|VERT_SPEC_RGB|VERT_FOG_COORD| + if (copy & (VERT_ELT|VERT_EDGEFLAG_BIT|VERT_COLOR1_BIT|VERT_FOG_BIT| VERT_MATERIAL)) { if (prev->Flag[src] & VERT_MATERIAL) @@ -516,7 +521,7 @@ void _tnl_copy_immediate_vertices( GLcontext *ctx, struct immediate *next ) next->Flag[dst] = flag; next->CopyOrFlag |= prev->Flag[src] & (VERT_FIXUP| VERT_MATERIAL| - VERT_OBJ); + VERT_OBJ_BIT); } } @@ -580,37 +585,37 @@ void _tnl_fixup_compiled_cassette( GLcontext *ctx, struct immediate *IM ) for (i = 0 ; i < ctx->Const.MaxTextureUnits ; i++) { if (fixup & VERT_TEX(i)) fixup_first_4f( IM->TexCoord[i], IM->Flag, VERT_TEX(i), start, - ctx->Current.Texcoord[i] ); + ctx->Current.Attrib[VERT_ATTRIB_TEX0 + i] ); } } - if (fixup & VERT_EDGE) - fixup_first_1ub(IM->EdgeFlag, IM->Flag, VERT_EDGE, start, + if (fixup & VERT_EDGEFLAG_BIT) + fixup_first_1ub(IM->EdgeFlag, IM->Flag, VERT_EDGEFLAG_BIT, start, ctx->Current.EdgeFlag ); - if (fixup & VERT_INDEX) - fixup_first_1ui(IM->Index, IM->Flag, VERT_INDEX, start, + if (fixup & VERT_INDEX_BIT) + fixup_first_1ui(IM->Index, IM->Flag, VERT_INDEX_BIT, start, ctx->Current.Index ); - if (fixup & VERT_RGBA) { - if (IM->CopyOrFlag & VERT_RGBA) - fixup_first_4f(IM->Color, IM->Flag, VERT_RGBA, start, - ctx->Current.Color ); + if (fixup & VERT_COLOR0_BIT) { + if (IM->CopyOrFlag & VERT_COLOR0_BIT) + fixup_first_4f(IM->Color, IM->Flag, VERT_COLOR0_BIT, start, + ctx->Current.Attrib[VERT_ATTRIB_COLOR0] ); else - fixup &= ~VERT_RGBA; + fixup &= ~VERT_COLOR0_BIT; } - if (fixup & VERT_SPEC_RGB) - fixup_first_4f(IM->SecondaryColor, IM->Flag, VERT_SPEC_RGB, start, - ctx->Current.SecondaryColor ); + if (fixup & VERT_COLOR1_BIT) + fixup_first_4f(IM->SecondaryColor, IM->Flag, VERT_COLOR1_BIT, start, + ctx->Current.Attrib[VERT_ATTRIB_COLOR1] ); - if (fixup & VERT_FOG_COORD) - fixup_first_1f(IM->FogCoord, IM->Flag, VERT_FOG_COORD, start, - ctx->Current.FogCoord ); + if (fixup & VERT_FOG_BIT) + fixup_first_1f(IM->FogCoord, IM->Flag, VERT_FOG_BIT, start, + ctx->Current.Attrib[VERT_ATTRIB_FOG][0] ); - if (fixup & VERT_NORM) { - fixup_first_3f(IM->Normal, IM->Flag, VERT_NORM, start, - ctx->Current.Normal ); + if (fixup & VERT_NORMAL_BIT) { + fixup_first_3f(IM->Normal, IM->Flag, VERT_NORMAL_BIT, start, + ctx->Current.Attrib[VERT_ATTRIB_NORMAL] ); } IM->CopyOrFlag |= fixup; @@ -795,7 +800,7 @@ void _tnl_upgrade_current_data( GLcontext *ctx, /* _tnl_print_vert_flags("_tnl_upgrade_client_data", required); */ - if ((required & VERT_RGBA) && (VB->ColorPtr[0]->Flags & CA_CLIENT_DATA)) { + if ((required & VERT_COLOR0_BIT) && (VB->ColorPtr[0]->Flags & CA_CLIENT_DATA)) { struct gl_client_array *tmp = &tnl->imm_inputs.Color; GLuint start = IM->CopyStart; @@ -803,7 +808,7 @@ void _tnl_upgrade_current_data( GLcontext *ctx, tmp->StrideB = 4 * sizeof(GLfloat); tmp->Flags = 0; - COPY_4FV( IM->Color[start], ctx->Current.Color); + COPY_4FV( IM->Color[start], ctx->Current.Attrib[VERT_ATTRIB_COLOR0]); /* ASSERT(IM->Flag[IM->LastData+1] & VERT_END_VB); @@ -812,7 +817,7 @@ void _tnl_upgrade_current_data( GLcontext *ctx, fixup_first_4f( IM->Color, IM->Flag, VERT_END_VB, start, IM->Color[start] ); - VB->importable_data &= ~VERT_RGBA; + VB->importable_data &= ~VERT_COLOR0_BIT; } } diff --git a/src/mesa/tnl/t_pipeline.c b/src/mesa/tnl/t_pipeline.c index acca9d85b6a..6e39788f9d6 100644 --- a/src/mesa/tnl/t_pipeline.c +++ b/src/mesa/tnl/t_pipeline.c @@ -1,4 +1,4 @@ -/* $Id: t_pipeline.c,v 1.19 2001/05/21 16:33:41 gareth Exp $ */ +/* $Id: t_pipeline.c,v 1.20 2001/12/14 02:51:45 brianp Exp $ */ /* * Mesa 3-D graphics library @@ -131,6 +131,8 @@ void _tnl_run_pipeline( GLcontext *ctx ) pipe->run_state_changes = 0; pipe->run_input_changes = 0; + printf("%s()\n", __FUNCTION__); + /* Done elsewhere. */ ASSERT(pipe->build_state_changes == 0); @@ -203,6 +205,7 @@ const struct gl_pipeline_stage *_tnl_default_pipeline[] = { &_tnl_texgen_stage, &_tnl_texture_transform_stage, &_tnl_point_attenuation_stage, + &_tnl_vertex_program_stage, &_tnl_render_stage, 0 }; diff --git a/src/mesa/tnl/t_pipeline.h b/src/mesa/tnl/t_pipeline.h index cb057df8105..6138df32d5b 100644 --- a/src/mesa/tnl/t_pipeline.h +++ b/src/mesa/tnl/t_pipeline.h @@ -1,4 +1,4 @@ -/* $Id: t_pipeline.h,v 1.8 2001/07/12 22:09:22 keithw Exp $ */ +/* $Id: t_pipeline.h,v 1.9 2001/12/14 02:51:45 brianp Exp $ */ /* * Mesa 3-D graphics library @@ -54,6 +54,7 @@ extern const struct gl_pipeline_stage _tnl_fog_coordinate_stage; extern const struct gl_pipeline_stage _tnl_texgen_stage; extern const struct gl_pipeline_stage _tnl_texture_transform_stage; extern const struct gl_pipeline_stage _tnl_point_attenuation_stage; +extern const struct gl_pipeline_stage _tnl_vertex_program_stage; extern const struct gl_pipeline_stage _tnl_render_stage; /* Shorthand to plug in the default pipeline: diff --git a/src/mesa/tnl/t_vb_fog.c b/src/mesa/tnl/t_vb_fog.c index 6fad9528cda..9e3d440b6a0 100644 --- a/src/mesa/tnl/t_vb_fog.c +++ b/src/mesa/tnl/t_vb_fog.c @@ -1,4 +1,4 @@ -/* $Id: t_vb_fog.c,v 1.12 2001/09/14 21:30:31 brianp Exp $ */ +/* $Id: t_vb_fog.c,v 1.13 2001/12/14 02:51:45 brianp Exp $ */ /* * Mesa 3-D graphics library @@ -166,8 +166,7 @@ static GLboolean run_fog_stage( GLcontext *ctx, input->count = VB->ObjPtr->count; } - else - { + else { input = &store->input; if (VB->EyePtr->size < 2) @@ -178,7 +177,8 @@ static GLboolean run_fog_stage( GLcontext *ctx, input->stride = VB->EyePtr->stride; input->count = VB->EyePtr->count; } - } else { + } + else { /* use glFogCoord() coordinates */ /* source = VB->FogCoordPtr */ input = VB->FogCoordPtr; @@ -190,14 +190,15 @@ static GLboolean run_fog_stage( GLcontext *ctx, return GL_TRUE; } + static void check_fog_stage( GLcontext *ctx, struct gl_pipeline_stage *stage ) { - stage->active = ctx->Fog.Enabled; + stage->active = ctx->Fog.Enabled && !ctx->VertexProgram.Enabled; if (ctx->Fog.FogCoordinateSource == GL_FRAGMENT_DEPTH_EXT) stage->inputs = VERT_EYE; else - stage->inputs = VERT_FOG_COORD; + stage->inputs = VERT_FOG_BIT; } @@ -239,11 +240,14 @@ static void free_fog_data( struct gl_pipeline_stage *stage ) const struct gl_pipeline_stage _tnl_fog_coordinate_stage = { - "build fog coordinates", - _NEW_FOG, - _NEW_FOG, - 0, 0, VERT_FOG_COORD, /* active, inputs, outputs */ - 0, 0, /* changed_inputs, private_data */ + "build fog coordinates", /* name */ + _NEW_FOG, /* check_state */ + _NEW_FOG, /* run_state */ + GL_FALSE, /* active? */ + 0, /* inputs */ + VERT_FOG_BIT, /* outputs */ + 0, /* changed_inputs */ + NULL, /* private_data */ free_fog_data, /* dtr */ check_fog_stage, /* check */ alloc_fog_data /* run -- initially set to init. */ diff --git a/src/mesa/tnl/t_vb_light.c b/src/mesa/tnl/t_vb_light.c index d0f4981cbd8..bbf43468c03 100644 --- a/src/mesa/tnl/t_vb_light.c +++ b/src/mesa/tnl/t_vb_light.c @@ -1,4 +1,4 @@ -/* $Id: t_vb_light.c,v 1.15 2001/07/17 19:39:32 keithw Exp $ */ +/* $Id: t_vb_light.c,v 1.16 2001/12/14 02:51:45 brianp Exp $ */ /* * Mesa 3-D graphics library @@ -168,12 +168,12 @@ static GLboolean run_lighting( GLcontext *ctx, struct gl_pipeline_stage *stage ) /* Make sure we can talk about elements 0..2 in the vector we are * lighting. */ - if (stage->changed_inputs & (VERT_EYE|VERT_OBJ)) { + if (stage->changed_inputs & (VERT_EYE|VERT_OBJ_BIT)) { if (input->size <= 2) { if (input->flags & VEC_NOT_WRITEABLE) { - ASSERT(VB->importable_data & VERT_OBJ); + ASSERT(VB->importable_data & VERT_OBJ_BIT); - VB->import_data( ctx, VERT_OBJ, VEC_NOT_WRITEABLE ); + VB->import_data( ctx, VERT_OBJ_BIT, VEC_NOT_WRITEABLE ); input = ctx->_NeedEyeCoords ? VB->EyePtr : VB->ObjPtr; ASSERT((input->flags & VEC_NOT_WRITEABLE) == 0); @@ -295,19 +295,19 @@ static GLboolean run_init_lighting( GLcontext *ctx, */ static void check_lighting( GLcontext *ctx, struct gl_pipeline_stage *stage ) { - stage->active = ctx->Light.Enabled; + stage->active = ctx->Light.Enabled && !ctx->VertexProgram.Enabled; if (stage->active) { if (stage->privatePtr) stage->run = run_validate_lighting; - stage->inputs = VERT_NORM|VERT_MATERIAL; + stage->inputs = VERT_NORMAL_BIT|VERT_MATERIAL; if (ctx->Light._NeedVertices) stage->inputs |= VERT_EYE; /* effectively, even when lighting in obj */ if (ctx->Light.ColorMaterialEnabled) - stage->inputs |= VERT_RGBA; + stage->inputs |= VERT_COLOR0_BIT; - stage->outputs = VERT_RGBA; + stage->outputs = VERT_COLOR0_BIT; if (ctx->Light.Model.ColorControl == GL_SEPARATE_SPECULAR_COLOR) - stage->outputs |= VERT_SPEC_RGB; + stage->outputs |= VERT_COLOR1_BIT; } } @@ -334,13 +334,16 @@ static void dtr( struct gl_pipeline_stage *stage ) const struct gl_pipeline_stage _tnl_lighting_stage = { - "lighting", + "lighting", /* name */ _NEW_LIGHT, /* recheck */ _NEW_LIGHT|_NEW_MODELVIEW, /* recalc -- modelview dependency * otherwise not captured by inputs - * (which may be VERT_OBJ) */ - 0,0,0, /* active, inputs, outputs */ - 0,0, /* changed_inputs, private_data */ + * (which may be VERT_OBJ_BIT) */ + GL_FALSE, /* active? */ + 0, /* inputs */ + 0, /* outputs */ + 0, /* changed_inputs */ + NULL, /* private_data */ dtr, /* destroy */ check_lighting, /* check */ run_init_lighting /* run -- initially set to ctr */ diff --git a/src/mesa/tnl/t_vb_lighttmp.h b/src/mesa/tnl/t_vb_lighttmp.h index 25e29ce606f..691d9716aca 100644 --- a/src/mesa/tnl/t_vb_lighttmp.h +++ b/src/mesa/tnl/t_vb_lighttmp.h @@ -1,4 +1,4 @@ -/* $Id: t_vb_lighttmp.h,v 1.19 2001/10/20 00:13:45 keithw Exp $ */ +/* $Id: t_vb_lighttmp.h,v 1.20 2001/12/14 02:51:45 brianp Exp $ */ /* * Mesa 3-D graphics library @@ -37,20 +37,20 @@ # define CHECK_END_VB(x) (flags[x] & VERT_END_VB) # if (IDX & LIGHT_COLORMATERIAL) # define CMSTRIDE STRIDE_F(CMcolor, CMstride) -# define CHECK_COLOR_MATERIAL(x) (flags[x] & VERT_RGBA) -# define CHECK_VALIDATE(x) (flags[x] & (VERT_RGBA|VERT_MATERIAL)) +# define CHECK_COLOR_MATERIAL(x) (flags[x] & VERT_COLOR0_BIT) +# define CHECK_VALIDATE(x) (flags[x] & (VERT_COLOR0_BIT|VERT_MATERIAL)) # define DO_ANOTHER_NORMAL(x) \ - ((flags[x] & (VERT_RGBA|VERT_NORM|VERT_END_VB|VERT_MATERIAL)) == VERT_NORM) + ((flags[x] & (VERT_COLOR0_BIT|VERT_NORMAL_BIT|VERT_END_VB|VERT_MATERIAL)) == VERT_NORMAL_BIT) # define REUSE_LIGHT_RESULTS(x) \ - ((flags[x] & (VERT_RGBA|VERT_NORM|VERT_END_VB|VERT_MATERIAL)) == 0) + ((flags[x] & (VERT_COLOR0_BIT|VERT_NORMAL_BIT|VERT_END_VB|VERT_MATERIAL)) == 0) # else # define CMSTRIDE (void)0 # define CHECK_COLOR_MATERIAL(x) 0 # define CHECK_VALIDATE(x) (flags[x] & (VERT_MATERIAL)) # define DO_ANOTHER_NORMAL(x) \ - ((flags[x] & (VERT_NORM|VERT_END_VB|VERT_MATERIAL)) == VERT_NORM) + ((flags[x] & (VERT_NORMAL_BIT|VERT_END_VB|VERT_MATERIAL)) == VERT_NORMAL_BIT) # define REUSE_LIGHT_RESULTS(x) \ - ((flags[x] & (VERT_NORM|VERT_END_VB|VERT_MATERIAL)) == 0) + ((flags[x] & (VERT_NORMAL_BIT|VERT_END_VB|VERT_MATERIAL)) == 0) # endif #else # define VSTRIDE vstride diff --git a/src/mesa/tnl/t_vb_normals.c b/src/mesa/tnl/t_vb_normals.c index 1a71b13be32..aff84b08485 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.9 2001/06/28 17:34:14 keithw Exp $ */ +/* $Id: t_vb_normals.c,v 1.10 2001/12/14 02:51:45 brianp Exp $ */ /* * Mesa 3-D graphics library @@ -128,7 +128,7 @@ static GLboolean run_validate_normal_stage( GLcontext *ctx, static void check_normal_transform( GLcontext *ctx, struct gl_pipeline_stage *stage ) { - stage->active = ctx->_NeedNormals; + stage->active = ctx->_NeedNormals && !ctx->VertexProgram.Enabled; /* Don't clobber the initialize function: */ if (stage->privatePtr) @@ -175,11 +175,14 @@ static void free_normal_data( struct gl_pipeline_stage *stage ) const struct gl_pipeline_stage _tnl_normal_transform_stage = { - "normal transform", + "normal transform", /* name */ _TNL_NEW_NORMAL_TRANSFORM, /* re-check */ _TNL_NEW_NORMAL_TRANSFORM, /* re-run */ - 0,VERT_NORM,VERT_NORM, /* active, inputs, outputs */ - 0, 0, /* changed_inputs, private */ + GL_FALSE, /* active? */ + VERT_NORMAL_BIT, /* inputs */ + VERT_NORMAL_BIT, /* outputs */ + 0, /* changed_inputs */ + NULL, /* private data */ free_normal_data, /* destructor */ check_normal_transform, /* check */ alloc_normal_data /* run -- initially set to alloc */ diff --git a/src/mesa/tnl/t_vb_points.c b/src/mesa/tnl/t_vb_points.c index 2c35d436109..c60a0f56b12 100644 --- a/src/mesa/tnl/t_vb_points.c +++ b/src/mesa/tnl/t_vb_points.c @@ -1,4 +1,4 @@ -/* $Id: t_vb_points.c,v 1.4 2001/03/12 00:48:44 gareth Exp $ */ +/* $Id: t_vb_points.c,v 1.5 2001/12/14 02:51:45 brianp Exp $ */ /* * Mesa 3-D graphics library @@ -113,11 +113,11 @@ const struct gl_pipeline_stage _tnl_point_attenuation_stage = "point size attenuation", /* name */ _NEW_POINT, /* build_state_change */ _NEW_POINT, /* run_state_change */ - 0, /* active */ + GL_FALSE, /* active */ VERT_EYE, /* inputs */ VERT_POINT_SIZE, /* outputs */ 0, /* changed_inputs (temporary value) */ - 0, /* stage private data */ + NULL, /* stage private data */ free_point_data, /* destructor */ check_point_size, /* check */ alloc_point_data /* run -- initially set to alloc data */ diff --git a/src/mesa/tnl/t_vb_program.c b/src/mesa/tnl/t_vb_program.c new file mode 100644 index 00000000000..29a6ca5e65d --- /dev/null +++ b/src/mesa/tnl/t_vb_program.c @@ -0,0 +1,1028 @@ +/* $Id: t_vb_program.c,v 1.1 2001/12/14 02:51:45 brianp Exp $ */ + +/* + * Mesa 3-D graphics library + * Version: 4.1 + * + * Copyright (C) 1999-2001 Brian Paul All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN + * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + +/* + * -------- Regarding NV_vertex_program -------- + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * o Redistribution of the source code must contain a copyright notice + * and this list of conditions; + * + * o Redistribution in binary and source code form must contain the + * following Notice in the software and any documentation and/or other + * materials provided with the distribution; and + * + * o The name of Nvidia may not be used to promote or endorse software + * derived from the software. + * + * NOTICE: Nvidia hereby grants to each recipient a non-exclusive worldwide + * royalty free patent license under patent claims that are licensable by + * Nvidia and which are necessarily required and for which no commercially + * viable non infringing alternative exists to make, use, sell, offer to sell, + * import and otherwise transfer the vertex extension for the Mesa 3D Graphics + * Library as distributed in source code and object code form. No hardware or + * hardware implementation (including a semiconductor implementation and chips) + * are licensed hereunder. If a recipient makes a patent claim or institutes + * patent litigation against Nvidia or Nvidia's customers for use or sale of + * Nvidia products, then this license grant as to such recipient shall + * immediately terminate and recipient immediately agrees to cease use and + * distribution of the Mesa Program and derivatives thereof. + * + * THE MESA 3D GRAPHICS LIBRARY IS PROVIDED ON AN "AS IS BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED INCLUDING, + * WITHOUT LIMITATION, ANY WARRANTIES OR CONDITIONS OF TITLE, NON-NFRINGEMENT + * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. + * + * NVIDIA SHALL NOT HAVE ANY LIABILITY FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING WITHOUT LIMITATION + * LOST PROFITS), HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OR DISTRIBUTION OF THE MESA 3D GRAPHICS + * LIBRARY OR EVIDENCE OR THE EXERCISE OF ANY RIGHTS GRANTED HEREUNDR, EVEN + * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * If you do not comply with this agreement, then Nvidia may cancel the license + * and rights granted herein. + * --------------------------------------------- + */ + +/* + * Authors: + * Brian Paul + */ + + +#include "glheader.h" +#include "api_noop.h" +#include "colormac.h" +#include "context.h" +#include "dlist.h" +#include "hash.h" +#include "light.h" +#include "macros.h" +#include "mem.h" +#include "mmath.h" +#include "simple_list.h" +#include "mtypes.h" +#include "vpexec.h" + +#include "math/m_translate.h" + +#include "t_context.h" +#include "t_pipeline.h" +#include "t_imm_api.h" +#include "t_imm_exec.h" + + + +static void +_vp_ArrayElement( GLint i ) +{ + /* XXX to do */ +} + +static void +_vp_Color3f( GLfloat r, GLfloat g, GLfloat b ) +{ + GET_IMMEDIATE; + GLfloat *attrib = IM->Attrib[VERT_ATTRIB_COLOR0][IM->Count]; + ASSIGN_4V(attrib, r, g, b, 1.0F); + IM->Flag[IM->Count] |= VERT_COLOR0_BIT; +} + +static void +_vp_Color3fv( const GLfloat *color ) +{ + GET_IMMEDIATE; + GLfloat *attrib = IM->Attrib[VERT_ATTRIB_COLOR0][IM->Count]; + ASSIGN_4V(attrib, color[0], color[1], color[2], 1.0F); + IM->Flag[IM->Count] |= VERT_COLOR0_BIT; +} + +static void +_vp_Color3ub( GLubyte r, GLubyte g, GLubyte b ) +{ + GET_IMMEDIATE; + GLfloat *attrib = IM->Attrib[VERT_ATTRIB_COLOR0][IM->Count]; + attrib[0] = UBYTE_TO_FLOAT(r); + attrib[1] = UBYTE_TO_FLOAT(g); + attrib[2] = UBYTE_TO_FLOAT(b); + attrib[3] = 1.0F; + IM->Flag[IM->Count] |= VERT_COLOR0_BIT; +} + +static void +_vp_Color3ubv( const GLubyte *color ) +{ + GET_IMMEDIATE; + GLfloat *attrib = IM->Attrib[VERT_ATTRIB_COLOR0][IM->Count]; + attrib[0] = UBYTE_TO_FLOAT(color[0]); + attrib[1] = UBYTE_TO_FLOAT(color[1]); + attrib[2] = UBYTE_TO_FLOAT(color[2]); + attrib[3] = 1.0F; + IM->Flag[IM->Count] |= VERT_COLOR0_BIT; +} + +static void +_vp_Color4f( GLfloat r, GLfloat g, GLfloat b, GLfloat a ) +{ + GET_IMMEDIATE; + GLfloat *attrib = IM->Attrib[VERT_ATTRIB_COLOR0][IM->Count]; + ASSIGN_4V(attrib, r, g, b, a); + IM->Flag[IM->Count] |= VERT_COLOR0_BIT; +} + +static void +_vp_Color4fv( const GLfloat *color ) +{ + GET_IMMEDIATE; + GLfloat *attrib = IM->Attrib[VERT_ATTRIB_COLOR0][IM->Count]; + COPY_4V(attrib, color); + IM->Flag[IM->Count] |= VERT_COLOR0_BIT; +} + +static void +_vp_Color4ub( GLubyte r, GLubyte g, GLubyte b, GLubyte a ) +{ + GET_IMMEDIATE; + GLfloat *attrib = IM->Attrib[VERT_ATTRIB_COLOR0][IM->Count]; + attrib[0] = UBYTE_TO_FLOAT(r); + attrib[1] = UBYTE_TO_FLOAT(g); + attrib[2] = UBYTE_TO_FLOAT(b); + attrib[3] = UBYTE_TO_FLOAT(a); + IM->Flag[IM->Count] |= VERT_COLOR0_BIT; +} + +static void +_vp_Color4ubv( const GLubyte *color ) +{ + GET_IMMEDIATE; + GLfloat *attrib = IM->Attrib[VERT_ATTRIB_COLOR0][IM->Count]; + attrib[0] = UBYTE_TO_FLOAT(color[0]); + attrib[1] = UBYTE_TO_FLOAT(color[1]); + attrib[2] = UBYTE_TO_FLOAT(color[2]); + attrib[3] = UBYTE_TO_FLOAT(color[3]); + IM->Flag[IM->Count] |= VERT_COLOR0_BIT; +} + +static void +_vp_EdgeFlag( GLboolean flag ) +{ + GET_IMMEDIATE; + IM->EdgeFlag[IM->Count] = flag; + IM->Flag[IM->Count] |= VERT_EDGEFLAG_BIT; +} + +static void +_vp_EdgeFlagv( const GLboolean *flag ) +{ + GET_IMMEDIATE; + IM->EdgeFlag[IM->Count] = *flag; + IM->Flag[IM->Count] |= VERT_EDGEFLAG_BIT; +} + +static void +_vp_EvalCoord1f( GLfloat s ) +{ + (void) s; + /* XXX no-op? */ +} + +static void +_vp_EvalCoord1fv( const GLfloat *v ) +{ + (void) v; + /* XXX no-op? */ +} + +static void +_vp_EvalCoord2f( GLfloat s, GLfloat t ) +{ + (void) s; + (void )t; + /* XXX no-op? */ +} + +static void +_vp_EvalCoord2fv( const GLfloat *v ) +{ + (void) v; + /* XXX no-op? */ +} + +static void +_vp_EvalPoint1( GLint i ) +{ + (void) i; +} + +static void +_vp_EvalPoint2( GLint i, GLint j ) +{ + (void) i; + (void) j; +} + +static void +_vp_FogCoordf( GLfloat f ) +{ + GET_IMMEDIATE; + GLfloat *attrib = IM->Attrib[VERT_ATTRIB_FOG][IM->Count]; + ASSIGN_4V(attrib, f, 0.0F, 0.0F, 1.0F); + IM->Flag[IM->Count] |= VERT_FOG_BIT; +} + +static void +_vp_FogCoordfv( const GLfloat *f ) +{ + GET_IMMEDIATE; + GLfloat *attrib = IM->Attrib[VERT_ATTRIB_FOG][IM->Count]; + ASSIGN_4V(attrib, f[0], 0.0F, 0.0F, 1.0F); + IM->Flag[IM->Count] |= VERT_FOG_BIT; +} + +static void +_vp_Indexi( GLint i ) +{ + (void) i; +} + +static void +_vp_Indexiv( const GLint *i ) +{ + (void) i; +} + +static void +_vp_Materialfv( GLenum face, GLenum pname, const GLfloat *v) +{ + /* XXX no-op? */ +} + +static void +_vp_MultiTexCoord1f( GLenum unit, GLfloat s ) +{ + const GLint u = (GLint) unit - GL_TEXTURE0_ARB; + if (u >=0 && u < 8) { + GET_IMMEDIATE; + GLfloat *attrib = IM->Attrib[VERT_ATTRIB_TEX0 + u][IM->Count]; + ASSIGN_4V(attrib, s, 0.0F, 0.0F, 1.0F); + IM->Flag[IM->Count] |= (VERT_TEX0_BIT << u); + } +} + +static void +_vp_MultiTexCoord1fv( GLenum unit, const GLfloat *c ) +{ + const GLint u = unit - GL_TEXTURE0_ARB; + if (u >=0 && u < 8) { + GET_IMMEDIATE; + GLfloat *attrib = IM->Attrib[VERT_ATTRIB_TEX0 + u][IM->Count]; + ASSIGN_4V(attrib, c[0], 0.0F, 0.0F, 1.0F); + IM->Flag[IM->Count] |= (VERT_TEX0_BIT << u); + } +} + +static void +_vp_MultiTexCoord2f( GLenum unit, GLfloat s, GLfloat t ) +{ + const GLint u = unit - GL_TEXTURE0_ARB; + if (u >=0 && u < 8) { + GET_IMMEDIATE; + GLfloat *attrib = IM->Attrib[VERT_ATTRIB_TEX0 + u][IM->Count]; + ASSIGN_4V(attrib, s, t, 0.0F, 1.0F); + IM->Flag[IM->Count] |= (VERT_TEX0_BIT << u); + } +} + +static void +_vp_MultiTexCoord2fv( GLenum unit, const GLfloat *c ) +{ + const GLint u = unit - GL_TEXTURE0_ARB; + if (u >=0 && u < 8) { + GET_IMMEDIATE; + GLfloat *attrib = IM->Attrib[VERT_ATTRIB_TEX0 + u][IM->Count]; + ASSIGN_4V(attrib, c[0], c[1], 0.0F, 1.0F); + IM->Flag[IM->Count] |= (VERT_TEX0_BIT << u); + } +} + +static void +_vp_MultiTexCoord3f( GLenum unit, GLfloat s, GLfloat t, GLfloat r ) +{ + const GLint u = unit - GL_TEXTURE0_ARB; + if (u >=0 && u < 8) { + GET_IMMEDIATE; + GLfloat *attrib = IM->Attrib[VERT_ATTRIB_TEX0 + u][IM->Count]; + ASSIGN_4V(attrib, s, t, r, 1.0F); + IM->Flag[IM->Count] |= (VERT_TEX0_BIT << u); + } +} + +static void +_vp_MultiTexCoord3fv( GLenum unit, const GLfloat *c ) +{ + const GLint u = unit - GL_TEXTURE0_ARB; + if (u >=0 && u < 8) { + GET_IMMEDIATE; + GLfloat *attrib = IM->Attrib[VERT_ATTRIB_TEX0 + u][IM->Count]; + ASSIGN_4V(attrib, c[0], c[1], c[2], 1.0F); + IM->Flag[IM->Count] |= (VERT_TEX0_BIT << u); + } +} + +static void +_vp_MultiTexCoord4f( GLenum unit, GLfloat s, GLfloat t, GLfloat r, GLfloat q ) +{ + const GLint u = unit - GL_TEXTURE0_ARB; + if (u >=0 && u < 8) { + GET_IMMEDIATE; + GLfloat *attrib = IM->Attrib[VERT_ATTRIB_TEX0 + u][IM->Count]; + ASSIGN_4V(attrib, s, t, r, q); + IM->Flag[IM->Count] |= (VERT_TEX0_BIT << u); + } +} + +static void +_vp_MultiTexCoord4fv( GLenum unit, const GLfloat *c ) +{ + const GLint u = unit - GL_TEXTURE0_ARB; + if (u >=0 && u < 8) { + GET_IMMEDIATE; + GLfloat *attrib = IM->Attrib[VERT_ATTRIB_TEX0 + u][IM->Count]; + COPY_4V(attrib, c); + IM->Flag[IM->Count] |= (VERT_TEX0_BIT << u); + } +} + +static void +_vp_Normal3f( GLfloat x, GLfloat y, GLfloat z ) +{ + GET_IMMEDIATE; + GLfloat *attrib = IM->Attrib[VERT_ATTRIB_NORMAL][IM->Count]; + ASSIGN_4V(attrib, x, y, z, 1.0F); + IM->Flag[IM->Count] |= VERT_NORMAL_BIT; +} + +static void +_vp_Normal3fv( const GLfloat *n ) +{ + GET_IMMEDIATE; + GLfloat *attrib = IM->Attrib[VERT_ATTRIB_NORMAL][IM->Count]; + ASSIGN_4V(attrib, n[0], n[1], n[2], 1.0F); + IM->Flag[IM->Count] |= VERT_NORMAL_BIT; +} + +static void +_vp_SecondaryColor3f( GLfloat r, GLfloat g, GLfloat b ) +{ + GET_IMMEDIATE; + GLfloat *attrib = IM->Attrib[VERT_ATTRIB_COLOR1][IM->Count]; + ASSIGN_4V(attrib, r, g, b, 1.0F); + IM->Flag[IM->Count] |= VERT_COLOR1_BIT; +} + +static void +_vp_SecondaryColor3fv( const GLfloat *color ) +{ + GET_IMMEDIATE; + GLfloat *attrib = IM->Attrib[VERT_ATTRIB_COLOR1][IM->Count]; + ASSIGN_4V(attrib, color[0], color[1], color[2], 1.0F); + IM->Flag[IM->Count] |= VERT_COLOR1_BIT; +} + +static void +_vp_SecondaryColor3ub( GLubyte r, GLubyte g, GLubyte b ) +{ + GET_IMMEDIATE; + GLfloat *attrib = IM->Attrib[VERT_ATTRIB_COLOR1][IM->Count]; + attrib[0] = UBYTE_TO_FLOAT(r); + attrib[1] = UBYTE_TO_FLOAT(g); + attrib[2] = UBYTE_TO_FLOAT(b); + attrib[3] = 1.0F; + IM->Flag[IM->Count] |= VERT_COLOR1_BIT; +} + +static void +_vp_SecondaryColor3ubv( const GLubyte *color ) +{ + GET_IMMEDIATE; + GLfloat *attrib = IM->Attrib[VERT_ATTRIB_COLOR1][IM->Count]; + attrib[0] = UBYTE_TO_FLOAT(color[0]); + attrib[1] = UBYTE_TO_FLOAT(color[1]); + attrib[2] = UBYTE_TO_FLOAT(color[2]); + attrib[3] = 1.0F; + IM->Flag[IM->Count] |= VERT_COLOR1_BIT; +} + +static void +_vp_TexCoord1f( GLfloat s ) +{ + GET_IMMEDIATE; + GLfloat *attrib = IM->Attrib[VERT_ATTRIB_TEX0][IM->Count]; + ASSIGN_4V(attrib, s, 0.0F, 0.0F, 1.0F); + IM->Flag[IM->Count] |= VERT_TEX0_BIT; +} + +static void +_vp_TexCoord1fv( const GLfloat *c ) +{ + GET_IMMEDIATE; + GLfloat *attrib = IM->Attrib[VERT_ATTRIB_TEX0][IM->Count]; + ASSIGN_4V(attrib, c[0], 0.0F, 0.0F, 1.0F); + IM->Flag[IM->Count] |= VERT_TEX0_BIT; +} + +static void +_vp_TexCoord2f( GLfloat s, GLfloat t ) +{ + GET_IMMEDIATE; + GLfloat *attrib = IM->Attrib[VERT_ATTRIB_TEX0][IM->Count]; + ASSIGN_4V(attrib, s, t, 0.0F, 1.0F); + IM->Flag[IM->Count] |= VERT_TEX0_BIT; +} + +static void +_vp_TexCoord2fv( const GLfloat *c ) +{ + GET_IMMEDIATE; + GLfloat *attrib = IM->Attrib[VERT_ATTRIB_TEX0][IM->Count]; + ASSIGN_4V(attrib, c[0], c[1], 0.0F, 1.0F); + IM->Flag[IM->Count] |= VERT_TEX0_BIT; +} + +static void +_vp_TexCoord3f( GLfloat s, GLfloat t, GLfloat r ) +{ + GET_IMMEDIATE; + GLfloat *attrib = IM->Attrib[VERT_ATTRIB_TEX0][IM->Count]; + ASSIGN_4V(attrib, s, t, r, 1.0F); + IM->Flag[IM->Count] |= VERT_TEX0_BIT; +} + +static void +_vp_TexCoord3fv( const GLfloat *c ) +{ + GET_IMMEDIATE; + GLfloat *attrib = IM->Attrib[VERT_ATTRIB_TEX0][IM->Count]; + ASSIGN_4V(attrib, c[0], c[1], c[2], 1.0F); + IM->Flag[IM->Count] |= VERT_TEX0_BIT; +} + +static void +_vp_TexCoord4f( GLfloat s, GLfloat t, GLfloat r, GLfloat q ) +{ + GET_IMMEDIATE; + GLfloat *attrib = IM->Attrib[VERT_ATTRIB_TEX0][IM->Count]; + ASSIGN_4V(attrib, s, t, r, 1.0F); + IM->Flag[IM->Count] |= VERT_TEX0_BIT; +} + +static void +_vp_TexCoord4fv( const GLfloat *c ) +{ + GET_IMMEDIATE; + GLfloat *attrib = IM->Attrib[VERT_ATTRIB_TEX0][IM->Count]; + COPY_4V(attrib, c); + IM->Flag[IM->Count] |= VERT_TEX0_BIT; +} + +static void +_vp_Vertex2f( GLfloat x, GLfloat y ) +{ + GET_IMMEDIATE; + const GLuint count = IM->Count++; + GLfloat *attrib = IM->Attrib[VERT_ATTRIB_POS][count]; + ASSIGN_4V(attrib, x, y, 0.0F, 1.0F); + IM->Flag[count] |= VERT_OBJ_BIT; + if (count == IMM_MAXDATA - 1) + _tnl_flush_immediate( IM ); +} + +static void +_vp_Vertex2fv( const GLfloat *v ) +{ + GET_IMMEDIATE; + const GLuint count = IM->Count++; + GLfloat *attrib = IM->Attrib[VERT_ATTRIB_POS][count]; + ASSIGN_4V(attrib, v[0], v[1], 0.0F, 1.0F); + IM->Flag[count] |= VERT_OBJ_BIT; + if (count == IMM_MAXDATA - 1) + _tnl_flush_immediate( IM ); +} + +static void +_vp_Vertex3f( GLfloat x, GLfloat y, GLfloat z ) +{ + GET_IMMEDIATE; + const GLuint count = IM->Count++; + GLfloat *attrib = IM->Attrib[VERT_ATTRIB_POS][count]; + ASSIGN_4V(attrib, x, y, z, 1.0F); + IM->Flag[count] |= VERT_OBJ_BIT; + if (count == IMM_MAXDATA - 1) + _tnl_flush_immediate( IM ); +} + +static void +_vp_Vertex3fv( const GLfloat *v ) +{ + GET_IMMEDIATE; + const GLuint count = IM->Count++; + GLfloat *attrib = IM->Attrib[VERT_ATTRIB_POS][count]; + ASSIGN_4V(attrib, v[0], v[1], v[2], 1.0F); + IM->Flag[count] |= VERT_OBJ_BIT; + if (count == IMM_MAXDATA - 1) + _tnl_flush_immediate( IM ); +} + +static void +_vp_Vertex4f( GLfloat x, GLfloat y, GLfloat z, GLfloat w ) +{ + GET_IMMEDIATE; + const GLuint count = IM->Count++; + GLfloat *attrib = IM->Attrib[VERT_ATTRIB_POS][count]; + ASSIGN_4V(attrib, x, y, z, w); + IM->Flag[count] |= VERT_OBJ_BIT; + if (count == IMM_MAXDATA - 1) + _tnl_flush_immediate( IM ); +} + +static void +_vp_Vertex4fv( const GLfloat *v ) +{ + GET_IMMEDIATE; + const GLuint count = IM->Count++; + GLfloat *attrib = IM->Attrib[VERT_ATTRIB_POS][count]; + COPY_4V(attrib, v); + IM->Flag[count] |= VERT_OBJ_BIT; + if (count == IMM_MAXDATA - 1) + _tnl_flush_immediate( IM ); +} + +static void +_vp_VertexAttrib4f( GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w ) +{ + if (index < 16) { + GET_IMMEDIATE; + const GLuint count = IM->Count; + GLfloat *attrib = IM->Attrib[index][count]; + ASSIGN_4V(attrib, x, y, z, w); + IM->Flag[count] |= (1 << index); + if (index == 0) { + IM->Count++; + if (count == IMM_MAXDATA - 1) + _tnl_flush_immediate( IM ); + } + } +} + +static void +_vp_VertexAttrib4fv( GLuint index, const GLfloat *v ) +{ + if (index < 16) { + GET_IMMEDIATE; + const GLuint count = IM->Count; + GLfloat *attrib = IM->Attrib[index][count]; + COPY_4V(attrib, v); + IM->Flag[count] |= (1 << index); + if (index == 0) { + IM->Count++; + if (count == IMM_MAXDATA - 1) + _tnl_flush_immediate( IM ); + } + } +} + + +/* + * When vertex program mode is enabled we hook in different per-vertex + * functions. + */ +void _tnl_vprog_vtxfmt_init( GLcontext *ctx ) +{ + GLvertexformat *vfmt = &(TNL_CONTEXT(ctx)->vtxfmt); + + printf("%s()\n", __FUNCTION__); + + /* All begin/end operations are handled by this vertex format: + */ + vfmt->ArrayElement = _vp_ArrayElement; + vfmt->Begin = _tnl_Begin; + vfmt->Color3f = _vp_Color3f; + vfmt->Color3fv = _vp_Color3fv; + vfmt->Color3ub = _vp_Color3ub; + vfmt->Color3ubv = _vp_Color3ubv; + vfmt->Color4f = _vp_Color4f; + vfmt->Color4fv = _vp_Color4fv; + vfmt->Color4ub = _vp_Color4ub; + vfmt->Color4ubv = _vp_Color4ubv; + vfmt->EdgeFlag = _vp_EdgeFlag; + vfmt->EdgeFlagv = _vp_EdgeFlagv; + vfmt->End = _tnl_End; + vfmt->EvalCoord1f = _vp_EvalCoord1f; + vfmt->EvalCoord1fv = _vp_EvalCoord1fv; + vfmt->EvalCoord2f = _vp_EvalCoord2f; + vfmt->EvalCoord2fv = _vp_EvalCoord2fv; + vfmt->EvalPoint1 = _vp_EvalPoint1; + vfmt->EvalPoint2 = _vp_EvalPoint2; + vfmt->FogCoordfEXT = _vp_FogCoordf; + vfmt->FogCoordfvEXT = _vp_FogCoordfv; + vfmt->Indexi = _vp_Indexi; + vfmt->Indexiv = _vp_Indexiv; + vfmt->Materialfv = _vp_Materialfv; + vfmt->MultiTexCoord1fARB = _vp_MultiTexCoord1f; + vfmt->MultiTexCoord1fvARB = _vp_MultiTexCoord1fv; + vfmt->MultiTexCoord2fARB = _vp_MultiTexCoord2f; + vfmt->MultiTexCoord2fvARB = _vp_MultiTexCoord2fv; + vfmt->MultiTexCoord3fARB = _vp_MultiTexCoord3f; + vfmt->MultiTexCoord3fvARB = _vp_MultiTexCoord3fv; + vfmt->MultiTexCoord4fARB = _vp_MultiTexCoord4f; + vfmt->MultiTexCoord4fvARB = _vp_MultiTexCoord4fv; + vfmt->Normal3f = _vp_Normal3f; + vfmt->Normal3fv = _vp_Normal3fv; + vfmt->SecondaryColor3fEXT = _vp_SecondaryColor3f; + vfmt->SecondaryColor3fvEXT = _vp_SecondaryColor3fv; + vfmt->SecondaryColor3ubEXT = _vp_SecondaryColor3ub; + vfmt->SecondaryColor3ubvEXT = _vp_SecondaryColor3ubv; + vfmt->TexCoord1f = _vp_TexCoord1f; + vfmt->TexCoord1fv = _vp_TexCoord1fv; + vfmt->TexCoord2f = _vp_TexCoord2f; + vfmt->TexCoord2fv = _vp_TexCoord2fv; + vfmt->TexCoord3f = _vp_TexCoord3f; + vfmt->TexCoord3fv = _vp_TexCoord3fv; + vfmt->TexCoord4f = _vp_TexCoord4f; + vfmt->TexCoord4fv = _vp_TexCoord4fv; + vfmt->Vertex2f = _vp_Vertex2f; + vfmt->Vertex2fv = _vp_Vertex2fv; + vfmt->Vertex3f = _vp_Vertex3f; + vfmt->Vertex3fv = _vp_Vertex3fv; + vfmt->Vertex4f = _vp_Vertex4f; + vfmt->Vertex4fv = _vp_Vertex4fv; + vfmt->VertexAttrib4fNV = _vp_VertexAttrib4f; + vfmt->VertexAttrib4fvNV = _vp_VertexAttrib4fv; + + /* Outside begin/end functions (from t_varray.c, t_eval.c, ...): + */ + vfmt->Rectf = _mesa_noop_Rectf; + + /* Just use the core function: + */ + vfmt->CallList = _mesa_CallList; + + vfmt->prefer_float_colors = GL_TRUE; +} + + + +struct vp_stage_data { + GLvector4f clipCoords; /* resulting vertex positions */ + struct gl_client_array color0[2]; /* front and back */ + struct gl_client_array color1[2]; /* front and back */ + GLvector4f texCoord[MAX_TEXTURE_UNITS]; + GLvector1f fogCoord; + GLvector1f pointSize; +}; + + +#define VP_STAGE_DATA(stage) ((struct vp_stage_data *)(stage->privatePtr)) + + +static GLboolean run_vp( GLcontext *ctx, struct gl_pipeline_stage *stage ) +{ + TNLcontext *tnl = TNL_CONTEXT(ctx); + struct vp_stage_data *store = VP_STAGE_DATA(stage); + struct vertex_buffer *VB = &tnl->vb; + struct vp_machine *machine = &(ctx->VertexProgram.Machine); + struct vp_program *program; + GLfloat (*clip)[4]; + GLfloat (*color0)[4], (*color1)[4]; + GLfloat (*bfcolor0)[4], (*bfcolor1)[4]; + GLfloat *fog, *pointSize; + GLfloat (*texture0)[4]; + GLfloat (*texture1)[4]; + GLfloat (*texture2)[4]; + GLfloat (*texture3)[4]; + GLint i; + + /* convenience pointers */ + store->clipCoords.size = 4; + clip = (GLfloat (*)[4]) store->clipCoords.data; + color0 = (GLfloat (*)[4]) store->color0[0].Ptr; + color1 = (GLfloat (*)[4]) store->color1[0].Ptr; + bfcolor0 = (GLfloat (*)[4]) store->color0[1].Ptr; + bfcolor1 = (GLfloat (*)[4]) store->color1[1].Ptr; + fog = (GLfloat *) store->fogCoord.data; + pointSize = (GLfloat *) store->pointSize.data; + texture0 = (GLfloat (*)[4]) store->texCoord[0].data; + texture1 = (GLfloat (*)[4]) store->texCoord[1].data; + texture2 = (GLfloat (*)[4]) store->texCoord[2].data; + texture3 = (GLfloat (*)[4]) store->texCoord[3].data; + + + printf("In %s()\n", __FUNCTION__); + + program = (struct vp_program *) _mesa_HashLookup(ctx->VertexProgram.HashTable, ctx->VertexProgram.Binding); + assert(program); + + _mesa_init_tracked_matrices(ctx); + _mesa_init_vp_registers(ctx); /* sets temp regs to (0,0,0,1) */ + + for (i = 0; i < VB->Count; i++) { + GLuint attr; + + printf("Input %d: %f, %f, %f, %f\n", i, + VB->AttribPtr[0]->data[i][0], + VB->AttribPtr[0]->data[i][1], + VB->AttribPtr[0]->data[i][2], + VB->AttribPtr[0]->data[i][3]); + printf(" color: %f, %f, %f, %f\n", + VB->AttribPtr[3]->data[i][0], + VB->AttribPtr[3]->data[i][1], + VB->AttribPtr[3]->data[i][2], + VB->AttribPtr[3]->data[i][3]); + + /* load the input attribute registers */ + for (attr = 0; attr < 16; attr++) { + if (VB->Flag[i] & (1 << attr)) { + COPY_4V(machine->Registers[VP_INPUT_REG_START + attr], + VB->AttribPtr[attr]->data[i]); + } + } + + /* execute the program */ + _mesa_exec_program(ctx, program); + + printf("Output %d: %f, %f, %f, %f\n", i, + machine->Registers[VP_OUTPUT_REG_START + 0][0], + machine->Registers[VP_OUTPUT_REG_START + 0][1], + machine->Registers[VP_OUTPUT_REG_START + 0][2], + machine->Registers[VP_OUTPUT_REG_START + 0][3]); + printf(" color: %f, %f, %f, %f\n", + machine->Registers[VP_OUTPUT_REG_START + 1][0], + machine->Registers[VP_OUTPUT_REG_START + 1][1], + machine->Registers[VP_OUTPUT_REG_START + 1][2], + machine->Registers[VP_OUTPUT_REG_START + 1][3]); + + /* store the attribute output registers into the VB arrays */ + COPY_4V(clip[i], machine->Registers[VP_OUT_HPOS]); + COPY_4V(color0[i], machine->Registers[VP_OUT_COL0]); + COPY_4V(color1[i], machine->Registers[VP_OUT_COL1]); + COPY_4V(bfcolor0[i], machine->Registers[VP_OUT_BFC0]); + COPY_4V(bfcolor1[i], machine->Registers[VP_OUT_BFC1]); + fog[i] = machine->Registers[VP_OUT_FOGC][0]; + pointSize[i] = machine->Registers[VP_OUT_PSIZ][0]; + COPY_4V(texture0[i], machine->Registers[VP_OUT_TEX0]); + COPY_4V(texture1[i], machine->Registers[VP_OUT_TEX0]); + COPY_4V(texture2[i], machine->Registers[VP_OUT_TEX0]); + COPY_4V(texture3[i], machine->Registers[VP_OUT_TEX0]); + } + + VB->ColorPtr[0] = &store->color0[0]; + VB->ColorPtr[1] = &store->color0[1]; + VB->SecondaryColorPtr[0] = &store->color1[0]; + VB->SecondaryColorPtr[1] = &store->color1[1]; + VB->ProjectedClipPtr = &store->clipCoords; + VB->FogCoordPtr = &store->fogCoord; + VB->PointSizePtr = &store->pointSize; + VB->TexCoordPtr[0] = &store->texCoord[0]; + VB->TexCoordPtr[1] = &store->texCoord[1]; + VB->TexCoordPtr[2] = &store->texCoord[2]; + VB->TexCoordPtr[3] = &store->texCoord[3]; + +#if 000 + + GLvector4f *input = ctx->_NeedEyeCoords ? VB->EyePtr : VB->ObjPtr; + GLuint ind; + +/* _tnl_print_vert_flags( __FUNCTION__, stage->changed_inputs ); */ + + /* Make sure we can talk about elements 0..2 in the vector we are + * lighting. + */ + if (stage->changed_inputs & (VERT_EYE|VERT_OBJ_BIT)) { + if (input->size <= 2) { + if (input->flags & VEC_NOT_WRITEABLE) { + ASSERT(VB->importable_data & VERT_OBJ_BIT); + + VB->import_data( ctx, VERT_OBJ_BIT, VEC_NOT_WRITEABLE ); + input = ctx->_NeedEyeCoords ? VB->EyePtr : VB->ObjPtr; + + ASSERT((input->flags & VEC_NOT_WRITEABLE) == 0); + } + + _mesa_vector4f_clean_elem(input, VB->Count, 2); + } + } + + if (VB->Flag) + ind = LIGHT_FLAGS; + else + ind = 0; + + /* The individual functions know about replaying side-effects + * vs. full re-execution. + */ + store->light_func_tab[ind]( ctx, VB, stage, input ); +#endif + + return GL_TRUE; +} + + +/* Called in place of do_lighting when the light table may have changed. + */ +static GLboolean run_validate_program( GLcontext *ctx, + struct gl_pipeline_stage *stage ) +{ +#if 000 + GLuint ind = 0; + light_func *tab; + + if (ctx->Visual.rgbMode) { + if (ctx->Light._NeedVertices) { + if (ctx->Light.Model.ColorControl == GL_SEPARATE_SPECULAR_COLOR) + tab = _tnl_light_spec_tab; + else + tab = _tnl_light_tab; + } + else { + if (ctx->Light.EnabledList.next == ctx->Light.EnabledList.prev) + tab = _tnl_light_fast_single_tab; + else + tab = _tnl_light_fast_tab; + } + } + else + tab = _tnl_light_ci_tab; + + if (ctx->Light.ColorMaterialEnabled) + ind |= LIGHT_COLORMATERIAL; + + if (ctx->Light.Model.TwoSide) + ind |= LIGHT_TWOSIDE; + + VP_STAGE_DATA(stage)->light_func_tab = &tab[ind]; + + /* This and the above should only be done on _NEW_LIGHT: + */ + _mesa_validate_all_lighting_tables( ctx ); +#endif + + /* Now run the stage... + */ + stage->run = run_vp; + return stage->run( ctx, stage ); +} + + + +#if 0 +static void alloc_4chan( struct gl_client_array *a, GLuint sz ) +{ + a->Ptr = ALIGN_MALLOC( sz * sizeof(GLchan) * 4, 32 ); + a->Size = 4; + a->Type = CHAN_TYPE; + a->Stride = 0; + a->StrideB = sizeof(GLchan) * 4; + a->Enabled = 0; + a->Flags = 0; +} +#endif + +static void alloc_4float( struct gl_client_array *a, GLuint sz ) +{ + a->Ptr = ALIGN_MALLOC( sz * sizeof(GLfloat) * 4, 32 ); + a->Size = 4; + a->Type = GL_FLOAT; + a->Stride = 0; + a->StrideB = sizeof(GLfloat) * 4; + a->Enabled = 0; + a->Flags = 0; +} + + +/* Called the first time stage->run is called. In effect, don't + * allocate data until the first time the stage is run. + */ +static GLboolean run_init_vp( GLcontext *ctx, + struct gl_pipeline_stage *stage ) +{ + TNLcontext *tnl = TNL_CONTEXT(ctx); + struct vertex_buffer *VB = &(tnl->vb); + struct vp_stage_data *store; + const GLuint size = VB->Size; + GLuint i; + + stage->privatePtr = MALLOC(sizeof(*store)); + store = VP_STAGE_DATA(stage); + if (!store) + return GL_FALSE; + + /* The output of a vertex program is: */ + _mesa_vector4f_alloc( &store->clipCoords, 0, size, 32 ); + alloc_4float( &store->color0[0], size ); + alloc_4float( &store->color0[1], size ); + alloc_4float( &store->color1[0], size ); + alloc_4float( &store->color1[1], size ); + for (i = 0 ; i < ctx->Const.MaxTextureUnits ; i++) + _mesa_vector4f_alloc( &store->texCoord[i], 0, VB->Size, 32 ); + _mesa_vector1f_alloc( &store->fogCoord, 0, size, 32 ); + _mesa_vector1f_alloc( &store->pointSize, 0, size, 32 ); + + + /* Now validate the stage derived data... + */ + stage->run = run_validate_program; + return stage->run( ctx, stage ); +} + + + +/* + * Check if vertex program mode is enabled. + * If so, configure the pipeline stage's type, inputs, and outputs. + */ +static void check_vp( GLcontext *ctx, struct gl_pipeline_stage *stage ) +{ + stage->active = ctx->VertexProgram.Enabled; + printf("check_vp() active = %d\n", stage->active); + if (stage->active) { +#if 000 + if (stage->privatePtr) + stage->run = run_validate_program; + stage->inputs = VERT_NORMAL_BIT|VERT_MATERIAL; + if (ctx->Light._NeedVertices) + stage->inputs |= VERT_EYE; /* effectively, even when lighting in obj */ + if (ctx->Light.ColorMaterialEnabled) + stage->inputs |= VERT_COLOR0_BIT; + + stage->outputs = VERT_COLOR0_BIT; + if (ctx->Light.Model.ColorControl == GL_SEPARATE_SPECULAR_COLOR) + stage->outputs |= VERT_COLOR1_BIT; +#endif + } +} + + +static void dtr( struct gl_pipeline_stage *stage ) +{ + struct vp_stage_data *store = VP_STAGE_DATA(stage); + + if (store) { + GLuint i; + _mesa_vector4f_free( &store->clipCoords ); + ALIGN_FREE( store->color0[0].Ptr ); + ALIGN_FREE( store->color0[1].Ptr ); + ALIGN_FREE( store->color1[0].Ptr ); + ALIGN_FREE( store->color1[1].Ptr ); + for (i = 0 ; i < MAX_TEXTURE_UNITS ; i++) + if (store->texCoord[i].data) + _mesa_vector4f_free( &store->texCoord[i] ); + _mesa_vector1f_free( &store->fogCoord ); + _mesa_vector1f_free( &store->pointSize ); + + FREE( store ); + stage->privatePtr = 0; + } +} + +const struct gl_pipeline_stage _tnl_vertex_program_stage = +{ + "vertex-program", + _NEW_ALL, /*XXX FIX */ /* recheck */ + _NEW_ALL, /*XXX FIX */ /* recalc -- modelview dependency + * otherwise not captured by inputs + * (which may be VERT_OBJ_BIT) */ + GL_FALSE, /* active */ + 0, /* inputs */ + VERT_CLIP | VERT_COLOR0_BIT, /* outputs */ + 0, /* changed_inputs */ + NULL, /* private_data */ + dtr, /* destroy */ + check_vp, /* check */ + run_init_vp /* run -- initially set to ctr */ +}; diff --git a/src/mesa/tnl/t_vb_render.c b/src/mesa/tnl/t_vb_render.c index de57eaf2021..cc8deff464b 100644 --- a/src/mesa/tnl/t_vb_render.c +++ b/src/mesa/tnl/t_vb_render.c @@ -1,4 +1,4 @@ -/* $Id: t_vb_render.c,v 1.24 2001/12/03 17:48:58 keithw Exp $ */ +/* $Id: t_vb_render.c,v 1.25 2001/12/14 02:51:45 brianp Exp $ */ /* * Mesa 3-D graphics library @@ -282,7 +282,6 @@ static GLboolean run_render( GLcontext *ctx, render_func *tab; GLint pass = 0; - /* Allow the drivers to lock before projected verts are built so * that window coordinates are guarenteed not to change before * rendering. @@ -354,10 +353,10 @@ static void check_render( GLcontext *ctx, struct gl_pipeline_stage *stage ) GLuint i; if (ctx->Visual.rgbMode) { - inputs |= VERT_RGBA; + inputs |= VERT_COLOR0_BIT; if (ctx->_TriangleCaps & DD_SEPARATE_SPECULAR) - inputs |= VERT_SPEC_RGB; + inputs |= VERT_COLOR1_BIT; if (ctx->Texture._ReallyEnabled) { for (i = 0 ; i < ctx->Const.MaxTextureUnits ; i++) { @@ -367,7 +366,7 @@ static void check_render( GLcontext *ctx, struct gl_pipeline_stage *stage ) } } else { - inputs |= VERT_INDEX; + inputs |= VERT_INDEX_BIT; } if (ctx->Point._Attenuated) @@ -376,10 +375,10 @@ static void check_render( GLcontext *ctx, struct gl_pipeline_stage *stage ) /* How do drivers turn this off? */ if (ctx->Fog.Enabled) - inputs |= VERT_FOG_COORD; + inputs |= VERT_FOG_BIT; if (ctx->_TriangleCaps & DD_TRI_UNFILLED) - inputs |= VERT_EDGE; + inputs |= VERT_EDGEFLAG_BIT; if (ctx->RenderMode==GL_FEEDBACK) inputs |= VERT_TEX_ANY; @@ -397,7 +396,7 @@ static void dtr( struct gl_pipeline_stage *stage ) const struct gl_pipeline_stage _tnl_render_stage = { - "render", + "render", /* name */ (_NEW_BUFFERS | _DD_NEW_SEPARATE_SPECULAR | _DD_NEW_FLATSHADE | @@ -408,9 +407,11 @@ const struct gl_pipeline_stage _tnl_render_stage = _DD_NEW_TRI_UNFILLED | _NEW_RENDERMODE), /* re-check (new inputs, interp function) */ 0, /* re-run (always runs) */ - GL_TRUE, /* active */ - 0, 0, /* inputs (set in check_render), outputs */ - 0, 0, /* changed_inputs, private */ + GL_TRUE, /* active? */ + 0, /* inputs (set in check_render) */ + 0, /* outputs */ + 0, /* changed_inputs */ + NULL, /* private data */ dtr, /* destructor */ check_render, /* check */ run_render /* run */ diff --git a/src/mesa/tnl/t_vb_texgen.c b/src/mesa/tnl/t_vb_texgen.c index bdf5c63786d..90dff30752a 100644 --- a/src/mesa/tnl/t_vb_texgen.c +++ b/src/mesa/tnl/t_vb_texgen.c @@ -1,4 +1,4 @@ -/* $Id: t_vb_texgen.c,v 1.9 2001/04/26 14:53:48 keithw Exp $ */ +/* $Id: t_vb_texgen.c,v 1.10 2001/12/14 02:51:45 brianp Exp $ */ /* * Mesa 3-D graphics library @@ -529,7 +529,7 @@ static GLboolean run_texgen_stage( GLcontext *ctx, for (i = 0 ; i < ctx->Const.MaxTextureUnits ; i++) if (ctx->Texture._TexGenEnabled & ENABLE_TEXGEN(i)) { - if (stage->changed_inputs & (VERT_EYE | VERT_NORM | VERT_TEX(i))) + if (stage->changed_inputs & (VERT_EYE | VERT_NORMAL_BIT | VERT_TEX(i))) store->TexgenFunc[i]( ctx, store, i ); VB->TexCoordPtr[i] = &store->texcoord[i]; @@ -591,18 +591,18 @@ static void check_texgen( GLcontext *ctx, struct gl_pipeline_stage *stage ) GLuint i; stage->active = 0; - if (ctx->Texture._TexGenEnabled) { + if (ctx->Texture._TexGenEnabled && !ctx->VertexProgram.Enabled) { GLuint inputs = 0; GLuint outputs = 0; if (ctx->Texture._GenFlags & TEXGEN_OBJ_LINEAR) - inputs |= VERT_OBJ; + inputs |= VERT_OBJ_BIT; if (ctx->Texture._GenFlags & TEXGEN_NEED_EYE_COORD) inputs |= VERT_EYE; if (ctx->Texture._GenFlags & TEXGEN_NEED_NORMALS) - inputs |= VERT_NORM; + inputs |= VERT_NORMAL_BIT; for (i = 0 ; i < ctx->Const.MaxTextureUnits ; i++) if (ctx->Texture._TexGenEnabled & ENABLE_TEXGEN(i)) @@ -678,11 +678,14 @@ static void free_texgen_data( struct gl_pipeline_stage *stage ) const struct gl_pipeline_stage _tnl_texgen_stage = { - "texgen", + "texgen", /* name */ _NEW_TEXTURE, /* when to call check() */ _NEW_TEXTURE, /* when to invalidate stored data */ - 0,0,0, /* active, inputs, outputs */ - 0,0, /* changed_inputs, private */ + GL_FALSE, /* active? */ + 0, /* inputs */ + 0, /* outputs */ + 0, /* changed_inputs */ + NULL, /* private data */ free_texgen_data, /* destructor */ check_texgen, /* check */ alloc_texgen_data /* run -- initially set to alloc data */ diff --git a/src/mesa/tnl/t_vb_texmat.c b/src/mesa/tnl/t_vb_texmat.c index 2eb6c943d79..a0ed3e58990 100644 --- a/src/mesa/tnl/t_vb_texmat.c +++ b/src/mesa/tnl/t_vb_texmat.c @@ -1,4 +1,4 @@ -/* $Id: t_vb_texmat.c,v 1.5 2001/03/29 21:16:26 keithw Exp $ */ +/* $Id: t_vb_texmat.c,v 1.6 2001/12/14 02:51:45 brianp Exp $ */ /* * Mesa 3-D graphics library @@ -60,7 +60,7 @@ static void check_texmat( GLcontext *ctx, struct gl_pipeline_stage *stage ) GLuint i; stage->active = 0; - if (ctx->Texture._TexMatEnabled) { + if (ctx->Texture._TexMatEnabled && !ctx->VertexProgram.Enabled) { GLuint flags = 0; for (i = 0 ; i < ctx->Const.MaxTextureUnits ; i++) @@ -137,12 +137,15 @@ static void free_texmat_data( struct gl_pipeline_stage *stage ) const struct gl_pipeline_stage _tnl_texture_transform_stage = { - "texture transform", - _NEW_TEXTURE|_NEW_TEXTURE_MATRIX, - _NEW_TEXTURE|_NEW_TEXTURE_MATRIX, - 0,0,0, /* active, inputs, outputs */ - 0,0, /* changed_inputs, private */ - free_texmat_data, /* destructor */ - check_texmat, /* check */ - alloc_texmat_data, /* run -- initially set to init */ + "texture transform", /* name */ + _NEW_TEXTURE|_NEW_TEXTURE_MATRIX, /* check_state */ + _NEW_TEXTURE|_NEW_TEXTURE_MATRIX, /* run_state */ + GL_FALSE, /* active? */ + 0, /* inputs */ + 0, /* outputs */ + 0, /* changed_inputs */ + NULL, /* private data */ + free_texmat_data, /* destructor */ + check_texmat, /* check */ + alloc_texmat_data, /* run -- initially set to init */ }; diff --git a/src/mesa/tnl/t_vb_vertex.c b/src/mesa/tnl/t_vb_vertex.c index d9baed3b0ca..f54d73bd628 100644 --- a/src/mesa/tnl/t_vb_vertex.c +++ b/src/mesa/tnl/t_vb_vertex.c @@ -1,4 +1,4 @@ -/* $Id: t_vb_vertex.c,v 1.9 2001/05/30 10:01:41 keithw Exp $ */ +/* $Id: t_vb_vertex.c,v 1.10 2001/12/14 02:51:45 brianp Exp $ */ /* * Mesa 3-D graphics library @@ -170,7 +170,7 @@ static GLboolean run_vertex_stage( GLcontext *ctx, if (VB->ClipPtr->size < 4) { if (VB->ClipPtr->flags & VEC_NOT_WRITEABLE) { ASSERT(VB->ClipPtr == VB->ObjPtr); - VB->import_data( ctx, VERT_OBJ, VEC_NOT_WRITEABLE ); + VB->import_data( ctx, VERT_OBJ_BIT, VEC_NOT_WRITEABLE ); VB->ClipPtr = VB->ObjPtr; } if (VB->ClipPtr->size == 2) @@ -222,7 +222,7 @@ static GLboolean run_vertex_stage( GLcontext *ctx, VB->ClipOrMask = store->ormask; VB->ClipMask = store->clipmask; - if (VB->ClipPtr == VB->ObjPtr && (VB->importable_data & VERT_OBJ)) + if (VB->ClipPtr == VB->ObjPtr && (VB->importable_data & VERT_OBJ_BIT)) VB->importable_data |= VERT_CLIP; store->save_eyeptr = VB->EyePtr; @@ -237,7 +237,7 @@ static GLboolean run_vertex_stage( GLcontext *ctx, VB->ProjectedClipPtr = store->save_projptr; VB->ClipMask = store->clipmask; VB->ClipOrMask = store->ormask; - if (VB->ClipPtr == VB->ObjPtr && (VB->importable_data & VERT_OBJ)) + if (VB->ClipPtr == VB->ObjPtr && (VB->importable_data & VERT_OBJ_BIT)) VB->importable_data |= VERT_CLIP; if (store->andmask) return GL_FALSE; @@ -249,8 +249,7 @@ static GLboolean run_vertex_stage( GLcontext *ctx, static void check_vertex( GLcontext *ctx, struct gl_pipeline_stage *stage ) { - (void) ctx; - (void) stage; + stage->active = !ctx->VertexProgram.Enabled; } static GLboolean init_vertex_stage( GLcontext *ctx, @@ -308,9 +307,10 @@ const struct gl_pipeline_stage _tnl_vertex_transform_stage = _NEW_PROJECTION| _NEW_TRANSFORM, /* re-run */ GL_TRUE, /* active */ - VERT_OBJ, /* inputs */ + VERT_OBJ_BIT, /* inputs */ VERT_EYE|VERT_CLIP, /* outputs */ - 0, 0, /* changed_inputs, private */ + 0, /* changed_inputs */ + NULL, /* private data */ dtr, /* destructor */ check_vertex, /* check */ init_vertex_stage /* run -- initially set to init */ |