diff options
-rw-r--r-- | src/mesa/array_cache/ac_import.c | 6 | ||||
-rw-r--r-- | src/mesa/main/mtypes.h | 7 | ||||
-rw-r--r-- | src/mesa/main/varray.c | 9 | ||||
-rw-r--r-- | src/mesa/math/m_debug_norm.c | 52 | ||||
-rw-r--r-- | src/mesa/math/m_norm_tmp.h | 50 | ||||
-rw-r--r-- | src/mesa/math/m_xform.h | 6 | ||||
-rw-r--r-- | src/mesa/swrast_setup/ss_vbtmp.h | 6 | ||||
-rw-r--r-- | src/mesa/tnl/t_array_api.c | 6 | ||||
-rw-r--r-- | src/mesa/tnl/t_array_import.c | 13 | ||||
-rw-r--r-- | src/mesa/tnl/t_context.h | 67 | ||||
-rw-r--r-- | src/mesa/tnl/t_imm_alloc.c | 23 | ||||
-rw-r--r-- | src/mesa/tnl/t_imm_api.c | 342 | ||||
-rw-r--r-- | src/mesa/tnl/t_imm_debug.c | 48 | ||||
-rw-r--r-- | src/mesa/tnl/t_imm_dlist.c | 29 | ||||
-rw-r--r-- | src/mesa/tnl/t_imm_elt.c | 16 | ||||
-rw-r--r-- | src/mesa/tnl/t_imm_eval.c | 70 | ||||
-rw-r--r-- | src/mesa/tnl/t_imm_exec.c | 58 | ||||
-rw-r--r-- | src/mesa/tnl/t_imm_fixup.c | 158 | ||||
-rw-r--r-- | src/mesa/tnl/t_vb_fog.c | 40 | ||||
-rw-r--r-- | src/mesa/tnl/t_vb_lighttmp.h | 4 | ||||
-rw-r--r-- | src/mesa/tnl/t_vb_normals.c | 8 | ||||
-rw-r--r-- | src/mesa/tnl/t_vb_program.c | 616 | ||||
-rw-r--r-- | src/mesa/tnl/t_vb_texgen.c | 18 |
23 files changed, 551 insertions, 1101 deletions
diff --git a/src/mesa/array_cache/ac_import.c b/src/mesa/array_cache/ac_import.c index 35538e294c7..2fc13dc2d77 100644 --- a/src/mesa/array_cache/ac_import.c +++ b/src/mesa/array_cache/ac_import.c @@ -1,10 +1,10 @@ -/* $Id: ac_import.c,v 1.15 2001/12/14 02:50:57 brianp Exp $ */ +/* $Id: ac_import.c,v 1.16 2002/01/05 20:51:12 brianp Exp $ */ /* * Mesa 3-D graphics library - * Version: 3.5 + * Version: 4.1 * - * Copyright (C) 1999-2001 Brian Paul All Rights Reserved. + * Copyright (C) 1999-2002 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"), diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h index f597c1d02fe..e97ba8c8ce1 100644 --- a/src/mesa/main/mtypes.h +++ b/src/mesa/main/mtypes.h @@ -1,4 +1,4 @@ -/* $Id: mtypes.h,v 1.56 2001/12/18 04:06:45 brianp Exp $ */ +/* $Id: mtypes.h,v 1.57 2002/01/05 20:51:12 brianp Exp $ */ /* * Mesa 3-D graphics library @@ -314,11 +314,12 @@ struct gl_colorbuffer_attrib { #define VERT_ATTRIB_TEX5 13 #define VERT_ATTRIB_TEX6 14 #define VERT_ATTRIB_TEX7 15 +#define VERT_ATTRIB_MAX 16 struct gl_current_attrib { /* These values valid only when FLUSH_VERTICES has been called. */ - GLfloat Attrib[8 + MAX_TEXTURE_UNITS][4]; /* Current vertex attributes */ + GLfloat Attrib[VERT_ATTRIB_MAX][4]; /* Current vertex attributes */ /* indexed by VERT_ATTRIB_* */ GLuint Index; /* Current color index */ GLboolean EdgeFlag; /* Current edge flag */ @@ -1132,7 +1133,7 @@ struct gl_evaluators { #define VP_MAX_INSTRUCTIONS 128 -#define VP_NUM_INPUT_REGS 16 +#define VP_NUM_INPUT_REGS VERT_ATTRIB_MAX #define VP_NUM_OUTPUT_REGS 15 #define VP_NUM_TEMP_REGS 12 #define VP_NUM_PROG_REGS 96 diff --git a/src/mesa/main/varray.c b/src/mesa/main/varray.c index 54e471a5e88..31b0b9b223d 100644 --- a/src/mesa/main/varray.c +++ b/src/mesa/main/varray.c @@ -1,10 +1,10 @@ -/* $Id: varray.c,v 1.39 2001/03/12 00:48:39 gareth Exp $ */ +/* $Id: varray.c,v 1.40 2002/01/05 20:51:12 brianp Exp $ */ /* * Mesa 3-D graphics library - * Version: 3.5 + * Version: 4.1 * - * Copyright (C) 1999-2001 Brian Paul All Rights Reserved. + * Copyright (C) 1999-2002 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"), @@ -137,6 +137,7 @@ _mesa_NormalPointer(GLenum type, GLsizei stride, const GLvoid *ptr ) return; } } + ctx->Array.Normal.Size = 3; ctx->Array.Normal.Type = type; ctx->Array.Normal.Stride = stride; ctx->Array.Normal.Ptr = (void *) ptr; @@ -239,6 +240,7 @@ _mesa_FogCoordPointerEXT(GLenum type, GLsizei stride, const GLvoid *ptr) return; } } + ctx->Array.FogCoord.Size = 1; ctx->Array.FogCoord.Type = type; ctx->Array.FogCoord.Stride = stride; ctx->Array.FogCoord.Ptr = (void *) ptr; @@ -284,6 +286,7 @@ _mesa_IndexPointer(GLenum type, GLsizei stride, const GLvoid *ptr) return; } } + ctx->Array.Index.Size = 1; ctx->Array.Index.Type = type; ctx->Array.Index.Stride = stride; ctx->Array.Index.Ptr = (void *) ptr; diff --git a/src/mesa/math/m_debug_norm.c b/src/mesa/math/m_debug_norm.c index f1b702f02cd..392e7c6bfd4 100644 --- a/src/mesa/math/m_debug_norm.c +++ b/src/mesa/math/m_debug_norm.c @@ -1,10 +1,10 @@ -/* $Id: m_debug_norm.c,v 1.7 2001/03/30 14:44:43 gareth Exp $ */ +/* $Id: m_debug_norm.c,v 1.8 2002/01/05 20:51:12 brianp Exp $ */ /* * Mesa 3-D graphics library - * Version: 3.5 + * Version: 4.1 * - * Copyright (C) 1999-2001 Brian Paul All Rights Reserved. + * Copyright (C) 1999-2002 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"), @@ -119,14 +119,14 @@ static char *norm_strings[8] = { static void ref_norm_transform_rescale( const GLmatrix *mat, GLfloat scale, - const GLvector3f *in, + const GLvector4f *in, const GLfloat *lengths, - GLvector3f *dest ) + GLvector4f *dest ) { GLuint i; const GLfloat *s = in->start; const GLfloat *m = mat->inv; - GLfloat (*out)[3] = (GLfloat (*)[3])dest->start; + GLfloat (*out)[4] = (GLfloat (*)[4]) dest->start; (void) lengths; @@ -142,14 +142,14 @@ static void ref_norm_transform_rescale( const GLmatrix *mat, static void ref_norm_transform_normalize( const GLmatrix *mat, GLfloat scale, - const GLvector3f *in, + const GLvector4f *in, const GLfloat *lengths, - GLvector3f *dest ) + GLvector4f *dest ) { GLuint i; const GLfloat *s = in->start; const GLfloat *m = mat->inv; - GLfloat (*out)[3] = (GLfloat (*)[3])dest->start; + GLfloat (*out)[4] = (GLfloat (*)[4]) dest->start; for ( i = 0 ; i < in->count ; i++ ) { GLfloat t[3]; @@ -183,10 +183,10 @@ static void ref_norm_transform_normalize( const GLmatrix *mat, static int test_norm_function( normal_func func, int mtype, long *cycles ) { - GLvector3f source[1], dest[1], dest2[1], ref[1], ref2[1]; + GLvector4f source[1], dest[1], dest2[1], ref[1], ref2[1]; GLmatrix mat[1]; - GLfloat s[TEST_COUNT][5], d[TEST_COUNT][3], r[TEST_COUNT][3]; - GLfloat d2[TEST_COUNT][3], r2[TEST_COUNT][3], length[TEST_COUNT]; + GLfloat s[TEST_COUNT][5], d[TEST_COUNT][4], r[TEST_COUNT][4]; + GLfloat d2[TEST_COUNT][4], r2[TEST_COUNT][4], length[TEST_COUNT]; GLfloat scale; GLfloat *m; int i, j; @@ -232,34 +232,34 @@ static int test_norm_function( normal_func func, int mtype, long *cycles ) length[i] = 1 / sqrt( LEN_SQUARED_3FV( s[i] ) ); } - source->data = (GLfloat(*)[3])s; - source->start = (GLfloat *)s; + source->data = (GLfloat(*)[4]) s; + source->start = (GLfloat *) s; source->count = TEST_COUNT; source->stride = sizeof(s[0]); source->flags = 0; - dest->data = (GLfloat(*)[3])d; - dest->start = (GLfloat *)d; + dest->data = d; + dest->start = (GLfloat *) d; dest->count = TEST_COUNT; - dest->stride = sizeof(float[3]); + dest->stride = sizeof(float[4]); dest->flags = 0; - dest2->data = (GLfloat(*)[3])d2; - dest2->start = (GLfloat *)d2; + dest2->data = d2; + dest2->start = (GLfloat *) d2; dest2->count = TEST_COUNT; - dest2->stride = sizeof(float[3]); + dest2->stride = sizeof(float[4]); dest2->flags = 0; - ref->data = (GLfloat(*)[3])r; - ref->start = (GLfloat *)r; + ref->data = r; + ref->start = (GLfloat *) r; ref->count = TEST_COUNT; - ref->stride = sizeof(float[3]); + ref->stride = sizeof(float[4]); ref->flags = 0; - ref2->data = (GLfloat(*)[3])r2; - ref2->start = (GLfloat *)r2; + ref2->data = r2; + ref2->start = (GLfloat *) r2; ref2->count = TEST_COUNT; - ref2->stride = sizeof(float[3]); + ref2->stride = sizeof(float[4]); ref2->flags = 0; if ( norm_normalize_types[mtype] == 0 ) { diff --git a/src/mesa/math/m_norm_tmp.h b/src/mesa/math/m_norm_tmp.h index c0d6fac96b3..767d1feddf2 100644 --- a/src/mesa/math/m_norm_tmp.h +++ b/src/mesa/math/m_norm_tmp.h @@ -1,4 +1,4 @@ -/* $Id: m_norm_tmp.h,v 1.9 2002/01/05 14:12:24 brianp Exp $ */ +/* $Id: m_norm_tmp.h,v 1.10 2002/01/05 20:51:12 brianp Exp $ */ /* * Mesa 3-D graphics library @@ -47,11 +47,11 @@ static void _XFORMAPI TAG(transform_normalize_normals)( const GLmatrix *mat, GLfloat scale, - const GLvector3f *in, + const GLvector4f *in, const GLfloat *lengths, - GLvector3f *dest ) + GLvector4f *dest ) { - GLfloat (*out)[3] = (GLfloat (*)[3])dest->start; + GLfloat (*out)[4] = (GLfloat (*)[4])dest->start; const GLfloat *from = in->start; const GLuint stride = in->stride; const GLuint count = in->count; @@ -114,11 +114,11 @@ TAG(transform_normalize_normals)( const GLmatrix *mat, static void _XFORMAPI TAG(transform_normalize_normals_no_rot)( const GLmatrix *mat, GLfloat scale, - const GLvector3f *in, + const GLvector4f *in, const GLfloat *lengths, - GLvector3f *dest ) + GLvector4f *dest ) { - GLfloat (*out)[3] = (GLfloat (*)[3])dest->start; + GLfloat (*out)[4] = (GLfloat (*)[4])dest->start; const GLfloat *from = in->start; const GLuint stride = in->stride; const GLuint count = in->count; @@ -179,11 +179,11 @@ TAG(transform_normalize_normals_no_rot)( const GLmatrix *mat, static void _XFORMAPI TAG(transform_rescale_normals_no_rot)( const GLmatrix *mat, GLfloat scale, - const GLvector3f *in, + const GLvector4f *in, const GLfloat *lengths, - GLvector3f *dest ) + GLvector4f *dest ) { - GLfloat (*out)[3] = (GLfloat (*)[3])dest->start; + GLfloat (*out)[4] = (GLfloat (*)[4])dest->start; const GLfloat *from = in->start; const GLuint stride = in->stride; const GLuint count = in->count; @@ -208,11 +208,11 @@ TAG(transform_rescale_normals_no_rot)( const GLmatrix *mat, static void _XFORMAPI TAG(transform_rescale_normals)( const GLmatrix *mat, GLfloat scale, - const GLvector3f *in, + const GLvector4f *in, const GLfloat *lengths, - GLvector3f *dest ) + GLvector4f *dest ) { - GLfloat (*out)[3] = (GLfloat (*)[3])dest->start; + GLfloat (*out)[4] = (GLfloat (*)[4])dest->start; const GLfloat *from = in->start; const GLuint stride = in->stride; const GLuint count = in->count; @@ -240,11 +240,11 @@ TAG(transform_rescale_normals)( const GLmatrix *mat, static void _XFORMAPI TAG(transform_normals_no_rot)( const GLmatrix *mat, GLfloat scale, - const GLvector3f *in, + const GLvector4f *in, const GLfloat *lengths, - GLvector3f *dest ) + GLvector4f *dest ) { - GLfloat (*out)[3] = (GLfloat (*)[3])dest->start; + GLfloat (*out)[4] = (GLfloat (*)[4])dest->start; const GLfloat *from = in->start; const GLuint stride = in->stride; const GLuint count = in->count; @@ -270,11 +270,11 @@ TAG(transform_normals_no_rot)( const GLmatrix *mat, static void _XFORMAPI TAG(transform_normals)( const GLmatrix *mat, GLfloat scale, - const GLvector3f *in, + const GLvector4f *in, const GLfloat *lengths, - GLvector3f *dest ) + GLvector4f *dest ) { - GLfloat (*out)[3] = (GLfloat (*)[3])dest->start; + GLfloat (*out)[4] = (GLfloat (*)[4])dest->start; const GLfloat *from = in->start; const GLuint stride = in->stride; const GLuint count = in->count; @@ -300,11 +300,11 @@ TAG(transform_normals)( const GLmatrix *mat, static void _XFORMAPI TAG(normalize_normals)( const GLmatrix *mat, GLfloat scale, - const GLvector3f *in, + const GLvector4f *in, const GLfloat *lengths, - GLvector3f *dest ) + GLvector4f *dest ) { - GLfloat (*out)[3] = (GLfloat (*)[3])dest->start; + GLfloat (*out)[4] = (GLfloat (*)[4])dest->start; const GLfloat *from = in->start; const GLuint stride = in->stride; const GLuint count = in->count; @@ -346,11 +346,11 @@ TAG(normalize_normals)( const GLmatrix *mat, static void _XFORMAPI TAG(rescale_normals)( const GLmatrix *mat, GLfloat scale, - const GLvector3f *in, + const GLvector4f *in, const GLfloat *lengths, - GLvector3f *dest ) + GLvector4f *dest ) { - GLfloat (*out)[3] = (GLfloat (*)[3])dest->start; + GLfloat (*out)[4] = (GLfloat (*)[4])dest->start; const GLfloat *from = in->start; const GLuint stride = in->stride; const GLuint count = in->count; diff --git a/src/mesa/math/m_xform.h b/src/mesa/math/m_xform.h index f871783c162..5d94b5151b4 100644 --- a/src/mesa/math/m_xform.h +++ b/src/mesa/math/m_xform.h @@ -1,4 +1,4 @@ -/* $Id: m_xform.h,v 1.10 2001/03/30 14:44:43 gareth Exp $ */ +/* $Id: m_xform.h,v 1.11 2002/01/05 20:51:12 brianp Exp $ */ /* * Mesa 3-D graphics library @@ -155,9 +155,9 @@ typedef void (*vec_copy_func)( GLvector4f *to, */ typedef void (_NORMAPIP normal_func)( CONST GLmatrix *mat, GLfloat scale, - CONST GLvector3f *in, + CONST GLvector4f *in, CONST GLfloat lengths[], - GLvector3f *dest ); + GLvector4f *dest ); /* Flags for selecting a normal transformation function. diff --git a/src/mesa/swrast_setup/ss_vbtmp.h b/src/mesa/swrast_setup/ss_vbtmp.h index 759c4d594b7..8e6c41ab4db 100644 --- a/src/mesa/swrast_setup/ss_vbtmp.h +++ b/src/mesa/swrast_setup/ss_vbtmp.h @@ -1,4 +1,4 @@ -/* $Id: ss_vbtmp.h,v 1.18 2001/12/18 04:06:46 brianp Exp $ */ +/* $Id: ss_vbtmp.h,v 1.19 2002/01/05 20:51:12 brianp Exp $ */ /* * Mesa 3-D graphics library @@ -77,8 +77,8 @@ static void TAG(emit)(GLcontext *ctx, GLuint start, GLuint end, proj_stride = VB->NdcPtr->stride; if (IND & FOG) { - fog = VB->FogCoordPtr->data; - fog_stride = VB->FogCoordPtr->stride; + fog = (GLfloat *) VB->AttribPtr[VERT_ATTRIB_FOG]->data; + fog_stride = VB->AttribPtr[VERT_ATTRIB_FOG]->stride; } if (IND & COLOR) { if (VB->ColorPtr[0]->Type != CHAN_TYPE) diff --git a/src/mesa/tnl/t_array_api.c b/src/mesa/tnl/t_array_api.c index fff970ae742..010efbdc5d0 100644 --- a/src/mesa/tnl/t_array_api.c +++ b/src/mesa/tnl/t_array_api.c @@ -1,4 +1,4 @@ -/* $Id: t_array_api.c,v 1.22 2001/12/03 17:41:58 keithw Exp $ */ +/* $Id: t_array_api.c,v 1.23 2002/01/05 20:51:12 brianp Exp $ */ /* * Mesa 3-D graphics library @@ -365,8 +365,8 @@ void _tnl_array_init( GLcontext *ctx ) /* Setup vector pointers that will be used to bind arrays to VB's. */ _mesa_vector4f_init( &tmp->Obj, 0, 0 ); - _mesa_vector3f_init( &tmp->Normal, 0, 0 ); - _mesa_vector1f_init( &tmp->FogCoord, 0, 0 ); + _mesa_vector4f_init( &tmp->Normal, 0, 0 ); + _mesa_vector4f_init( &tmp->FogCoord, 0, 0 ); _mesa_vector1ui_init( &tmp->Index, 0, 0 ); _mesa_vector1ub_init( &tmp->EdgeFlag, 0, 0 ); diff --git a/src/mesa/tnl/t_array_import.c b/src/mesa/tnl/t_array_import.c index 3393ea1a7a6..c9bb9d502c5 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.19 2001/12/14 02:51:42 brianp Exp $ */ +/* $Id: t_array_import.c,v 1.20 2002/01/05 20:51:13 brianp Exp $ */ /* * Mesa 3-D graphics library @@ -81,7 +81,7 @@ static void _tnl_import_normal( GLcontext *ctx, stride ? 3*sizeof(GLfloat) : 0, writeable, &is_writeable); - inputs->Normal.data = (GLfloat (*)[3]) tmp->Ptr; + inputs->Normal.data = tmp->Ptr; inputs->Normal.start = (GLfloat *) tmp->Ptr; inputs->Normal.stride = tmp->StrideB; inputs->Normal.flags &= ~(VEC_BAD_STRIDE|VEC_NOT_WRITEABLE); @@ -143,7 +143,7 @@ static void _tnl_import_fogcoord( GLcontext *ctx, stride ? sizeof(GLfloat) : 0, writeable, &is_writeable); - inputs->FogCoord.data = (GLfloat *) tmp->Ptr; + inputs->FogCoord.data = (GLfloat (*)[4]) tmp->Ptr; inputs->FogCoord.start = (GLfloat *) tmp->Ptr; inputs->FogCoord.stride = tmp->StrideB; inputs->FogCoord.flags &= ~(VEC_BAD_STRIDE|VEC_NOT_WRITEABLE); @@ -276,8 +276,9 @@ static void _tnl_upgrade_client_data( GLcontext *ctx, VB->importable_data &= ~VERT_COLOR1_BIT; } - if ((required & VERT_FOG_BIT) && (VB->FogCoordPtr->flags & flags)) { - ASSERT(VB->FogCoordPtr == &inputs->FogCoord); + if ((required & VERT_FOG_BIT) + && (VB->AttribPtr[VERT_ATTRIB_FOG]->flags & flags)) { + ASSERT(VB->AttribPtr[VERT_ATTRIB_FOG] == &inputs->FogCoord); _tnl_import_fogcoord( ctx, writeable, stride ); VB->importable_data &= ~VERT_FOG_BIT; } @@ -371,7 +372,7 @@ void _tnl_vb_bind_arrays( GLcontext *ctx, GLint start, GLsizei count ) if (inputs & VERT_FOG_BIT) { _tnl_import_fogcoord( ctx, 0, 0 ); tmp->FogCoord.count = VB->Count; - VB->FogCoordPtr = &tmp->FogCoord; + VB->AttribPtr[VERT_ATTRIB_FOG] = &tmp->FogCoord; } if (inputs & VERT_EDGEFLAG_BIT) { diff --git a/src/mesa/tnl/t_context.h b/src/mesa/tnl/t_context.h index 7b1954a2057..cd435d89c4e 100644 --- a/src/mesa/tnl/t_context.h +++ b/src/mesa/tnl/t_context.h @@ -1,10 +1,10 @@ -/* $Id: t_context.h,v 1.34 2001/12/18 04:06:46 brianp Exp $ */ +/* $Id: t_context.h,v 1.35 2002/01/05 20:51:13 brianp Exp $ */ /* * Mesa 3-D graphics library - * Version: 3.5 + * Version: 4.1 * - * Copyright (C) 1999-2001 Brian Paul All Rights Reserved. + * Copyright (C) 1999-2002 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"), @@ -114,11 +114,11 @@ /* Shorthands. */ -#define VERT_EVAL_ANY (VERT_EVAL_C1|VERT_EVAL_P1| \ - VERT_EVAL_C2|VERT_EVAL_P2) +#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_BIT) -#define VERT_OBJ_234 (VERT_OBJ_4|VERT_OBJ_23) +#define VERT_OBJ_23 (VERT_OBJ_3 | VERT_OBJ_BIT) +#define VERT_OBJ_234 (VERT_OBJ_4 | VERT_OBJ_23) #define VERT_TEX0_BIT_SHIFT 11 @@ -133,27 +133,27 @@ VERT_TEX6_BIT | \ VERT_TEX7_BIT) -#define VERT_FIXUP (VERT_TEX_ANY | \ +#define VERT_FIXUP (VERT_TEX_ANY | \ VERT_COLOR0_BIT | \ - VERT_COLOR1_BIT | \ - VERT_FOG_BIT | \ + VERT_COLOR1_BIT | \ + VERT_FOG_BIT | \ VERT_INDEX_BIT | \ VERT_EDGEFLAG_BIT | \ VERT_NORMAL_BIT) -#define VERT_CURRENT_DATA (VERT_FIXUP | \ +#define VERT_CURRENT_DATA (VERT_FIXUP | \ VERT_MATERIAL) -#define VERT_DATA (VERT_TEX_ANY | \ +#define VERT_DATA (VERT_TEX_ANY | \ VERT_COLOR0_BIT | \ - VERT_COLOR1_BIT | \ - VERT_FOG_BIT | \ - VERT_INDEX_BIT | \ + VERT_COLOR1_BIT | \ + VERT_FOG_BIT | \ + VERT_INDEX_BIT | \ VERT_EDGEFLAG_BIT | \ VERT_NORMAL_BIT | \ - VERT_OBJ_BIT | \ - VERT_MATERIAL | \ - VERT_ELT | \ + VERT_OBJ_BIT | \ + VERT_MATERIAL | \ + VERT_ELT | \ VERT_EVAL_ANY) @@ -206,35 +206,34 @@ struct immediate GLuint PrimitiveLength[IMM_SIZE]; /* BEGIN/END */ GLuint Flag[IMM_SIZE]; /* VERT_* flags */ - GLfloat Obj[IMM_SIZE][4]; /* attrib 0 */ - GLfloat Normal[IMM_SIZE][3]; /* attrib 2 */ - GLfloat *NormalLengthPtr; - 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 */ + /* All vertex attributes (position, normal, color, secondary color, + * texcoords, fog coord) are stored in the Attrib[] arrays instead + * of individual arrays as we did prior to Mesa 4.1. + * + * XXX may need to use 32-byte aligned allocation for this!!! + */ + GLfloat Attrib[VERT_ATTRIB_MAX][IMM_SIZE][4]; /* GL_NV_vertex_program */ + + GLfloat *NormalLengthPtr; /* length of normal vectors (display list only) */ GLuint Elt[IMM_SIZE]; GLubyte EdgeFlag[IMM_SIZE]; GLuint Index[IMM_SIZE]; - - GLfloat Attrib[16][IMM_SIZE][4]; /* GL_NV_vertex_program */ }; struct vertex_arrays { GLvector4f Obj; - GLvector3f Normal; + GLvector4f Normal; struct gl_client_array Color; struct gl_client_array SecondaryColor; GLvector1ui Index; GLvector1ub EdgeFlag; GLvector4f TexCoord[MAX_TEXTURE_UNITS]; GLvector1ui Elt; - GLvector1f FogCoord; - GLvector4f Attribs[16]; + GLvector4f FogCoord; + GLvector4f Attribs[VERT_ATTRIB_MAX]; }; @@ -255,6 +254,7 @@ typedef struct vertex_buffer GLuint FirstPrimitive; /* usually zero */ /* Pointers to current data. + * XXX Replace ObjPtr, NormalPtr, TexCoordPtr, etc with AttribPtr[] arrays. */ GLuint *Elts; /* VERT_ELT */ GLvector4f *ObjPtr; /* VERT_OBJ_BIT */ @@ -263,14 +263,13 @@ typedef struct vertex_buffer GLvector4f *NdcPtr; /* VERT_CLIP (2) */ GLubyte ClipOrMask; /* VERT_CLIP (3) */ GLubyte *ClipMask; /* VERT_CLIP (4) */ - GLvector3f *NormalPtr; /* VERT_NORMAL_BIT */ + GLvector4f *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_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 */ @@ -278,7 +277,7 @@ typedef struct vertex_buffer GLuint *Primitive; /* GL_(mode)|PRIM_* flags */ GLuint *PrimitiveLength; /* integers */ - GLvector4f *AttribPtr[16]; /* GL_NV_vertex_program */ + GLvector4f *AttribPtr[VERT_ATTRIB_MAX]; /* 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 a0708d5f28f..38525375996 100644 --- a/src/mesa/tnl/t_imm_alloc.c +++ b/src/mesa/tnl/t_imm_alloc.c @@ -1,10 +1,10 @@ -/* $Id: t_imm_alloc.c,v 1.12 2001/12/15 00:49:00 brianp Exp $ */ +/* $Id: t_imm_alloc.c,v 1.13 2002/01/05 20:51:13 brianp Exp $ */ /* * Mesa 3-D graphics library - * Version: 4.0.1 + * Version: 4.1 * - * Copyright (C) 1999-2001 Brian Paul All Rights Reserved. + * Copyright (C) 1999-2002 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"), @@ -39,7 +39,6 @@ static int id = 0; /* give each struct immediate a unique ID number */ static struct immediate *real_alloc_immediate( GLcontext *ctx ) { struct immediate *IM = ALIGN_MALLOC_STRUCT( immediate, 32 ); - GLuint j; if (!IM) return 0; @@ -62,22 +61,14 @@ static struct immediate *real_alloc_immediate( GLcontext *ctx ) IM->CopyTexSize = 0; IM->CopyStart = IM->Start; - - /* TexCoord0 is special. - */ - IM->TexCoord[0] = IM->TexCoord0; - - for (j = 1; j < ctx->Const.MaxTextureUnits; j++) { - IM->TexCoord[j] = (GLfloat (*)[4]) - ALIGN_MALLOC( IMM_SIZE * sizeof(GLfloat) * 4, 32 ); - } - /* KW: Removed initialization of normals as these are now treated * identically to all other data types. */ MEMSET(IM->Flag, 0, sizeof(IM->Flag)); +#if 0 MEMSET(IM->Normal, 0.0 , sizeof(IM->Normal)); +#endif return IM; } @@ -86,7 +77,6 @@ static struct immediate *real_alloc_immediate( GLcontext *ctx ) static void real_free_immediate( struct immediate *IM ) { static int freed = 0; - GLuint j; if (IM->Material) { FREE( IM->Material ); @@ -95,9 +85,6 @@ static void real_free_immediate( struct immediate *IM ) IM->MaterialMask = 0; } - for (j = 1; j < IM->MaxTextureUnits; j++) - ALIGN_FREE( IM->TexCoord[j] ); - if (IM->NormalLengthPtr) ALIGN_FREE( IM->NormalLengthPtr ); diff --git a/src/mesa/tnl/t_imm_api.c b/src/mesa/tnl/t_imm_api.c index 94dab9acb13..48a8081c16a 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.22 2001/12/17 09:02:55 joukj Exp $ */ +/* $Id: t_imm_api.c,v 1.23 2002/01/05 20:51:13 brianp Exp $ */ /* * Mesa 3-D graphics library @@ -47,9 +47,6 @@ #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 ) @@ -100,14 +97,6 @@ _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); - /* XXX this should not be done here - inefficient */ - _mesa_install_exec_vtxfmt(ctx, &(TNL_CONTEXT(ctx)->vtxfmt)); - /* if only a very few slots left, might as well flush now */ if (IM->Count > IMM_MAXDATA-8) { @@ -345,29 +334,28 @@ _tnl_End(void) } -#define COLOR( IM, r, g, b, a ) \ -{ \ - GLuint count = IM->Count; \ - IM->Flag[count] |= VERT_COLOR0_BIT; \ - IM->Color[count][0] = r; \ - IM->Color[count][1] = g; \ - IM->Color[count][2] = b; \ - IM->Color[count][3] = a; \ +#define COLOR( r, g, b, a ) \ +{ \ + GET_IMMEDIATE; \ + GLuint count = IM->Count; \ + GLfloat *color = IM->Attrib[VERT_ATTRIB_COLOR0][count]; \ + IM->Flag[count] |= VERT_COLOR0_BIT; \ + color[0] = r; \ + color[1] = g; \ + color[2] = b; \ + color[3] = a; \ } static void _tnl_Color3f( GLfloat red, GLfloat green, GLfloat blue ) { - GET_IMMEDIATE; - COLOR( IM, red, green, blue, 1.0 ); + COLOR( red, green, blue, 1.0 ); } static void _tnl_Color3ub( GLubyte red, GLubyte green, GLubyte blue ) { - GET_IMMEDIATE; - COLOR(IM, - UBYTE_TO_FLOAT(red), + COLOR(UBYTE_TO_FLOAT(red), UBYTE_TO_FLOAT(green), UBYTE_TO_FLOAT(blue), 1.0); @@ -376,16 +364,13 @@ _tnl_Color3ub( GLubyte red, GLubyte green, GLubyte blue ) static void _tnl_Color4f( GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha ) { - GET_IMMEDIATE; - COLOR( IM, red, green, blue, alpha ); + COLOR( red, green, blue, alpha ); } static void _tnl_Color4ub( GLubyte red, GLubyte green, GLubyte blue, GLubyte alpha ) { - GET_IMMEDIATE; - COLOR(IM, - UBYTE_TO_FLOAT(red), + COLOR(UBYTE_TO_FLOAT(red), UBYTE_TO_FLOAT(green), UBYTE_TO_FLOAT(blue), UBYTE_TO_FLOAT(alpha)); @@ -394,16 +379,13 @@ _tnl_Color4ub( GLubyte red, GLubyte green, GLubyte blue, GLubyte alpha ) static void _tnl_Color3fv( const GLfloat *v ) { - GET_IMMEDIATE; - COLOR( IM, v[0], v[1], v[2], 1.0 ); + COLOR( v[0], v[1], v[2], 1.0 ); } static void _tnl_Color3ubv( const GLubyte *v ) { - GET_IMMEDIATE; - COLOR(IM, - UBYTE_TO_FLOAT(v[0]), + COLOR(UBYTE_TO_FLOAT(v[0]), UBYTE_TO_FLOAT(v[1]), UBYTE_TO_FLOAT(v[2]), 1.0 ); @@ -412,16 +394,13 @@ _tnl_Color3ubv( const GLubyte *v ) static void _tnl_Color4fv( const GLfloat *v ) { - GET_IMMEDIATE; - COLOR( IM, v[0], v[1], v[2], v[3] ); + COLOR( v[0], v[1], v[2], v[3] ); } static void _tnl_Color4ubv( const GLubyte *v) { - GET_IMMEDIATE; - COLOR(IM, - UBYTE_TO_FLOAT(v[0]), + COLOR(UBYTE_TO_FLOAT(v[0]), UBYTE_TO_FLOAT(v[1]), UBYTE_TO_FLOAT(v[2]), UBYTE_TO_FLOAT(v[3])); @@ -430,28 +409,27 @@ _tnl_Color4ubv( const GLubyte *v) -#define SECONDARY_COLOR( IM, r, g, b ) \ -{ \ - GLuint count = IM->Count; \ - IM->Flag[count] |= VERT_COLOR1_BIT; \ - IM->SecondaryColor[count][0] = r; \ - IM->SecondaryColor[count][1] = g; \ - IM->SecondaryColor[count][2] = b; \ +#define SECONDARY_COLOR( r, g, b ) \ +{ \ + GLuint count; \ + GET_IMMEDIATE; \ + count = IM->Count; \ + IM->Flag[count] |= VERT_COLOR1_BIT; \ + IM->Attrib[VERT_ATTRIB_COLOR1][count][0] = r; \ + IM->Attrib[VERT_ATTRIB_COLOR1][count][1] = g; \ + IM->Attrib[VERT_ATTRIB_COLOR1][count][2] = b; \ } static void _tnl_SecondaryColor3fEXT( GLfloat red, GLfloat green, GLfloat blue ) { - GET_IMMEDIATE; - SECONDARY_COLOR( IM, red, green, blue ); + SECONDARY_COLOR( red, green, blue ); } static void _tnl_SecondaryColor3ubEXT( GLubyte red, GLubyte green, GLubyte blue ) { - GET_IMMEDIATE; - SECONDARY_COLOR(IM, - UBYTE_TO_FLOAT(red), + SECONDARY_COLOR(UBYTE_TO_FLOAT(red), UBYTE_TO_FLOAT(green), UBYTE_TO_FLOAT(blue)); } @@ -459,23 +437,18 @@ _tnl_SecondaryColor3ubEXT( GLubyte red, GLubyte green, GLubyte blue ) static void _tnl_SecondaryColor3fvEXT( const GLfloat *v ) { - GET_IMMEDIATE; - SECONDARY_COLOR( IM, v[0], v[1], v[2] ); + SECONDARY_COLOR( v[0], v[1], v[2] ); } static void _tnl_SecondaryColor3ubvEXT( const GLubyte *v ) { - GET_IMMEDIATE; - SECONDARY_COLOR(IM, - UBYTE_TO_FLOAT(v[0]), + SECONDARY_COLOR(UBYTE_TO_FLOAT(v[0]), UBYTE_TO_FLOAT(v[1]), UBYTE_TO_FLOAT(v[2])); } - - static void _tnl_EdgeFlag( GLboolean flag ) { @@ -504,7 +477,7 @@ _tnl_FogCoordfEXT( GLfloat f ) GLuint count; GET_IMMEDIATE; count = IM->Count; - IM->FogCoord[count] = f; + IM->Attrib[VERT_ATTRIB_FOG][count][0] = f; /*FogCoord[count] = f;*/ IM->Flag[count] |= VERT_FOG_BIT; } @@ -514,7 +487,7 @@ _tnl_FogCoordfvEXT( const GLfloat *v ) GLuint count; GET_IMMEDIATE; count = IM->Count; - IM->FogCoord[count] = v[0]; + IM->Attrib[VERT_ATTRIB_FOG][count][0] = v[0]; /*FogCoord[count] = v[0];*/ IM->Flag[count] |= VERT_FOG_BIT; } @@ -541,15 +514,15 @@ _tnl_Indexiv( const GLint *c ) } -#define NORMAL( x, y, z ) \ -{ \ - GLuint count; \ - GLfloat *normal; \ - GET_IMMEDIATE; \ - count = IM->Count; \ - IM->Flag[count] |= VERT_NORMAL_BIT; \ - normal = IM->Normal[count]; \ - ASSIGN_3V(normal, x,y,z); \ +#define NORMAL( x, y, z ) \ +{ \ + GLuint count; \ + GLfloat *normal; \ + GET_IMMEDIATE; \ + count = IM->Count; \ + IM->Flag[count] |= VERT_NORMAL_BIT; \ + normal = IM->Attrib[VERT_ATTRIB_NORMAL][count]; \ + ASSIGN_3V(normal, x,y,z); \ } #if defined(USE_IEEE) @@ -560,7 +533,7 @@ _tnl_Indexiv( const GLint *c ) GET_IMMEDIATE; \ count = IM->Count; \ IM->Flag[count] |= VERT_NORMAL_BIT; \ - normal = (fi_type *)IM->Normal[count]; \ + normal = (fi_type *)IM->Attrib[VERT_ATTRIB_NORMAL][count]; \ normal[0].i = ((fi_type *)&(x))->i; \ normal[1].i = ((fi_type *)&(y))->i; \ normal[2].i = ((fi_type *)&(z))->i; \ @@ -591,54 +564,54 @@ _tnl_Normal3fv( const GLfloat *v ) GET_IMMEDIATE; \ count = IM->Count; \ IM->Flag[count] |= VERT_TEX0_BIT; \ - tc = IM->TexCoord0[count]; \ + tc = IM->Attrib[VERT_ATTRIB_TEX0][count]; \ ASSIGN_4V(tc,s,0,0,1); \ } -#define TEXCOORD2(s,t) \ +#define TEXCOORD2(s, t) \ { \ GLuint count; \ GLfloat *tc; \ GET_IMMEDIATE; \ count = IM->Count; \ IM->Flag[count] |= VERT_TEX0_BIT; \ - tc = IM->TexCoord0[count]; \ - ASSIGN_4V(tc, s,t,0,1); \ + tc = IM->Attrib[VERT_ATTRIB_TEX0][count]; \ + ASSIGN_4V(tc, s, t, 0, 1); \ } -#define TEXCOORD3(s,t,u) \ +#define TEXCOORD3(s, t, u) \ { \ GLuint count; \ GLfloat *tc; \ GET_IMMEDIATE; \ count = IM->Count; \ IM->Flag[count] |= VERT_TEX0_BIT; \ - IM->TexSize |= TEX_0_SIZE_3; \ - tc = IM->TexCoord0[count]; \ - ASSIGN_4V(tc, s,t,u,1); \ + IM->TexSize |= TEX_0_SIZE_3; \ + tc = IM->Attrib[VERT_ATTRIB_TEX0][count]; \ + ASSIGN_4V(tc, s, t, u, 1); \ } -#define TEXCOORD4(s,t,u,v) \ +#define TEXCOORD4(s, t, u, v) \ { \ GLuint count; \ GLfloat *tc; \ GET_IMMEDIATE; \ count = IM->Count; \ IM->Flag[count] |= VERT_TEX0_BIT; \ - IM->TexSize |= TEX_0_SIZE_4; \ - tc = IM->TexCoord0[count]; \ - ASSIGN_4V(tc, s,t,u,v); \ + IM->TexSize |= TEX_0_SIZE_4; \ + tc = IM->Attrib[VERT_ATTRIB_TEX0][count]; \ + ASSIGN_4V(tc, s, t, u, v); \ } #if defined(USE_IEEE) -#define TEXCOORD2F(s,t) \ +#define TEXCOORD2F(s, t) \ { \ GLuint count; \ fi_type *tc; \ GET_IMMEDIATE; \ count = IM->Count; \ IM->Flag[count] |= VERT_TEX0_BIT; \ - tc = (fi_type *)IM->TexCoord0[count]; \ + tc = (fi_type *)IM->Attrib[VERT_ATTRIB_TEX0][count]; \ tc[0].i = ((fi_type *)&(s))->i; \ tc[1].i = ((fi_type *)&(t))->i; \ tc[2].i = 0; \ @@ -658,20 +631,20 @@ _tnl_TexCoord1f( GLfloat s ) static void _tnl_TexCoord2f( GLfloat s, GLfloat t ) { - TEXCOORD2F(s,t); + TEXCOORD2F(s, t); } static void _tnl_TexCoord3f( GLfloat s, GLfloat t, GLfloat r ) { - TEXCOORD3(s,t,r); + TEXCOORD3(s, t, r); } static void _tnl_TexCoord4f( GLfloat s, GLfloat t, GLfloat r, GLfloat q ) { - TEXCOORD4(s,t,r,q) + TEXCOORD4(s, t, r, q) } static void @@ -683,19 +656,19 @@ _tnl_TexCoord1fv( const GLfloat *v ) static void _tnl_TexCoord2fv( const GLfloat *v ) { - TEXCOORD2F(v[0],v[1]); + TEXCOORD2F(v[0], v[1]); } static void _tnl_TexCoord3fv( const GLfloat *v ) { - TEXCOORD3(v[0],v[1],v[2]); + TEXCOORD3(v[0], v[1], v[2]); } static void _tnl_TexCoord4fv( const GLfloat *v ) { - TEXCOORD4(v[0],v[1],v[2],v[3]); + TEXCOORD4(v[0], v[1], v[2], v[3]); } @@ -703,86 +676,86 @@ _tnl_TexCoord4fv( const GLfloat *v ) /* KW: Run into bad problems in vertex copying if we don't fully pad * the incoming vertices. */ -#define VERTEX2(IM, x,y) \ -{ \ - GLuint count = IM->Count++; \ - GLfloat *dest = IM->Obj[count]; \ +#define VERTEX2(IM, x,y) \ +{ \ + GLuint count = IM->Count++; \ + GLfloat *dest = IM->Attrib[VERT_ATTRIB_POS][count]; \ IM->Flag[count] |= VERT_OBJ_BIT; \ - ASSIGN_4V(dest, x, y, 0, 1); \ -/* ASSERT(IM->Flag[IM->Count]==0); */\ - if (count == IMM_MAXDATA - 1) \ - _tnl_flush_immediate( IM ); \ + ASSIGN_4V(dest, x, y, 0, 1); \ +/* ASSERT(IM->Flag[IM->Count]==0); */ \ + if (count == IMM_MAXDATA - 1) \ + _tnl_flush_immediate( IM ); \ } -#define VERTEX3(IM,x,y,z) \ -{ \ - GLuint count = IM->Count++; \ - GLfloat *dest = IM->Obj[count]; \ - IM->Flag[count] |= VERT_OBJ_23; \ - ASSIGN_4V(dest, x, y, z, 1); \ +#define VERTEX3(IM,x,y,z) \ +{ \ + GLuint count = IM->Count++; \ + GLfloat *dest = IM->Attrib[VERT_ATTRIB_POS][count]; \ + IM->Flag[count] |= VERT_OBJ_23; \ + ASSIGN_4V(dest, x, y, z, 1); \ /* ASSERT(IM->Flag[IM->Count]==0); */ \ - if (count == IMM_MAXDATA - 1) \ - _tnl_flush_immediate( IM ); \ -} - -#define VERTEX4(IM, x,y,z,w) \ -{ \ - GLuint count = IM->Count++; \ - GLfloat *dest = IM->Obj[count]; \ - IM->Flag[count] |= VERT_OBJ_234; \ - ASSIGN_4V(dest, x, y, z, w); \ if (count == IMM_MAXDATA - 1) \ - _tnl_flush_immediate( IM ); \ + _tnl_flush_immediate( IM ); \ } -#if defined(USE_IEEE) -#define VERTEX2F(IM, x, y) \ +#define VERTEX4(IM, x,y,z,w) \ { \ GLuint count = IM->Count++; \ - fi_type *dest = (fi_type *)IM->Obj[count]; \ - IM->Flag[count] |= VERT_OBJ_BIT; \ - dest[0].i = ((fi_type *)&(x))->i; \ - dest[1].i = ((fi_type *)&(y))->i; \ - dest[2].i = 0; \ - dest[3].i = IEEE_ONE; \ -/* ASSERT(IM->Flag[IM->Count]==0); */ \ + GLfloat *dest = IM->Attrib[VERT_ATTRIB_POS][count]; \ + IM->Flag[count] |= VERT_OBJ_234; \ + ASSIGN_4V(dest, x, y, z, w); \ if (count == IMM_MAXDATA - 1) \ _tnl_flush_immediate( IM ); \ } + +#if defined(USE_IEEE) +#define VERTEX2F(IM, x, y) \ +{ \ + GLuint count = IM->Count++; \ + fi_type *dest = (fi_type *)IM->Attrib[VERT_ATTRIB_POS][count]; \ + IM->Flag[count] |= VERT_OBJ_BIT; \ + dest[0].i = ((fi_type *)&(x))->i; \ + dest[1].i = ((fi_type *)&(y))->i; \ + dest[2].i = 0; \ + dest[3].i = IEEE_ONE; \ +/* ASSERT(IM->Flag[IM->Count]==0); */ \ + if (count == IMM_MAXDATA - 1) \ + _tnl_flush_immediate( IM ); \ +} #else #define VERTEX2F VERTEX2 #endif #if defined(USE_IEEE) -#define VERTEX3F(IM, x, y, z) \ -{ \ - GLuint count = IM->Count++; \ - fi_type *dest = (fi_type *)IM->Obj[count]; \ - IM->Flag[count] |= VERT_OBJ_23; \ - dest[0].i = ((fi_type *)&(x))->i; \ - dest[1].i = ((fi_type *)&(y))->i; \ - dest[2].i = ((fi_type *)&(z))->i; \ - dest[3].i = IEEE_ONE; \ -/* ASSERT(IM->Flag[IM->Count]==0); */ \ - if (count == IMM_MAXDATA - 1) \ - _tnl_flush_immediate( IM ); \ +#define VERTEX3F(IM, x, y, z) \ +{ \ + GLuint count = IM->Count++; \ + fi_type *dest = (fi_type *)IM->Attrib[VERT_ATTRIB_POS][count]; \ + IM->Flag[count] |= VERT_OBJ_23; \ + dest[0].i = ((fi_type *)&(x))->i; \ + dest[1].i = ((fi_type *)&(y))->i; \ + dest[2].i = ((fi_type *)&(z))->i; \ + dest[3].i = IEEE_ONE; \ +/* ASSERT(IM->Flag[IM->Count]==0); */ \ + if (count == IMM_MAXDATA - 1) \ + _tnl_flush_immediate( IM ); \ } #else #define VERTEX3F VERTEX3 #endif #if defined(USE_IEEE) -#define VERTEX4F(IM, x, y, z, w) \ -{ \ - GLuint count = IM->Count++; \ - fi_type *dest = (fi_type *)IM->Obj[count]; \ - IM->Flag[count] |= VERT_OBJ_234; \ - dest[0].i = ((fi_type *)&(x))->i; \ - dest[1].i = ((fi_type *)&(y))->i; \ - dest[2].i = ((fi_type *)&(z))->i; \ - dest[3].i = ((fi_type *)&(w))->i; \ - if (count == IMM_MAXDATA - 1) \ - _tnl_flush_immediate( IM ); \ +#define VERTEX4F(IM, x, y, z, w) \ +{ \ + GLuint count = IM->Count++; \ + fi_type *dest = (fi_type *)IM->Attrib[VERT_ATTRIB_POS][count]; \ + IM->Flag[count] |= VERT_OBJ_234; \ + dest[0].i = ((fi_type *)&(x))->i; \ + dest[1].i = ((fi_type *)&(y))->i; \ + dest[2].i = ((fi_type *)&(z))->i; \ + dest[3].i = ((fi_type *)&(w))->i; \ + if (count == IMM_MAXDATA - 1) \ + _tnl_flush_immediate( IM ); \ } #else #define VERTEX4F VERTEX4 @@ -850,7 +823,7 @@ _tnl_Vertex4fv( const GLfloat *v ) GLuint texunit = target - GL_TEXTURE0_ARB; \ if (texunit < IM->MaxTextureUnits) { \ GLuint count = IM->Count; \ - GLfloat *tc = IM->TexCoord[texunit][count]; \ + GLfloat *tc = IM->Attrib[VERT_ATTRIB_TEX0 + texunit][count]; \ ASSIGN_4V(tc, s, 0.0F, 0.0F, 1.0F); \ IM->Flag[count] |= VERT_TEX(texunit); \ } \ @@ -862,7 +835,7 @@ _tnl_Vertex4fv( const GLfloat *v ) GLuint texunit = target - GL_TEXTURE0_ARB; \ if (texunit < IM->MaxTextureUnits) { \ GLuint count = IM->Count; \ - GLfloat *tc = IM->TexCoord[texunit][count]; \ + GLfloat *tc = IM->Attrib[VERT_ATTRIB_TEX0 + texunit][count]; \ ASSIGN_4V(tc, s, t, 0.0F, 1.0F); \ IM->Flag[count] |= VERT_TEX(texunit); \ } \ @@ -874,7 +847,7 @@ _tnl_Vertex4fv( const GLfloat *v ) GLuint texunit = target - GL_TEXTURE0_ARB; \ if (texunit < IM->MaxTextureUnits) { \ GLuint count = IM->Count; \ - GLfloat *tc = IM->TexCoord[texunit][count]; \ + GLfloat *tc = IM->Attrib[VERT_ATTRIB_TEX0 + texunit][count]; \ ASSIGN_4V(tc, s, t, u, 1.0F); \ IM->Flag[count] |= VERT_TEX(texunit); \ IM->TexSize |= TEX_SIZE_3(texunit); \ @@ -887,7 +860,7 @@ _tnl_Vertex4fv( const GLfloat *v ) GLuint texunit = target - GL_TEXTURE0_ARB; \ if (texunit < IM->MaxTextureUnits) { \ GLuint count = IM->Count; \ - GLfloat *tc = IM->TexCoord[texunit][count]; \ + GLfloat *tc = IM->Attrib[VERT_ATTRIB_TEX0 + texunit][count]; \ ASSIGN_4V(tc, s, t, u, v); \ IM->Flag[count] |= VERT_TEX(texunit); \ IM->TexSize |= TEX_SIZE_4(texunit); \ @@ -901,7 +874,7 @@ _tnl_Vertex4fv( const GLfloat *v ) GLuint texunit = target - GL_TEXTURE0_ARB; \ if (texunit < IM->MaxTextureUnits) { \ GLuint count = IM->Count; \ - fi_type *tc = (fi_type *)IM->TexCoord[texunit][count]; \ + fi_type *tc = (fi_type *)IM->Attrib[VERT_ATTRIB_TEX0 + texunit][count];\ IM->Flag[count] |= VERT_TEX(texunit); \ tc[0].i = ((fi_type *)&(s))->i; \ tc[1].i = ((fi_type *)&(t))->i; \ @@ -972,8 +945,9 @@ _tnl_MultiTexCoord4fvARB(GLenum target, const GLfloat *v) #define EVALCOORD1(IM, x) \ { \ GLuint count = IM->Count++; \ + GLfloat *dest = IM->Attrib[VERT_ATTRIB_POS][count]; \ IM->Flag[count] |= VERT_EVAL_C1; \ - ASSIGN_4V(IM->Obj[count], x, 0, 0, 1); \ + ASSIGN_4V(dest, x, 0, 0, 1); \ if (count == IMM_MAXDATA-1) \ _tnl_flush_immediate( IM ); \ } @@ -981,8 +955,9 @@ _tnl_MultiTexCoord4fvARB(GLenum target, const GLfloat *v) #define EVALCOORD2(IM, x, y) \ { \ GLuint count = IM->Count++; \ + GLfloat *dest = IM->Attrib[VERT_ATTRIB_POS][count]; \ IM->Flag[count] |= VERT_EVAL_C2; \ - ASSIGN_4V(IM->Obj[count], x, y, 0, 1); \ + ASSIGN_4V(dest, x, y, 0, 1); \ if (count == IMM_MAXDATA-1) \ _tnl_flush_immediate( IM ); \ } @@ -990,8 +965,9 @@ _tnl_MultiTexCoord4fvARB(GLenum target, const GLfloat *v) #define EVALPOINT1(IM, x) \ { \ GLuint count = IM->Count++; \ + GLfloat *dest = IM->Attrib[VERT_ATTRIB_POS][count]; \ IM->Flag[count] |= VERT_EVAL_P1; \ - ASSIGN_4V(IM->Obj[count], x, 0, 0, 1); \ + ASSIGN_4V(dest, x, 0, 0, 1); \ if (count == IMM_MAXDATA-1) \ _tnl_flush_immediate( IM ); \ } @@ -999,8 +975,9 @@ _tnl_MultiTexCoord4fvARB(GLenum target, const GLfloat *v) #define EVALPOINT2(IM, x, y) \ { \ GLuint count = IM->Count++; \ + GLfloat *dest = IM->Attrib[VERT_ATTRIB_POS][count]; \ IM->Flag[count] |= VERT_EVAL_P2; \ - ASSIGN_4V(IM->Obj[count], x, y, 0, 1); \ + ASSIGN_4V(dest, x, y, 0, 1); \ if (count == IMM_MAXDATA-1) \ _tnl_flush_immediate( IM ); \ } @@ -1061,7 +1038,7 @@ _tnl_EvalPoint2( GLint i, GLint j ) IM->Flag[count] |= VERT_ELT; \ IM->FlushElt = IM->ArrayEltFlush; \ IM->Count += IM->ArrayEltIncr; \ - if (IM->Count == IMM_MAXDATA) \ + if (IM->Count == IMM_MAXDATA) \ _tnl_flush_immediate( IM ); \ } @@ -1118,27 +1095,38 @@ _tnl_vertex2f( GLcontext *ctx, GLfloat x, GLfloat y ) */ static void -_tnl_VertexAttrib4fNV(GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w) -{ - /* no-op? */ -#ifndef __VMS - printf("%s(%d, %f, %f, %f, %f)\n", __FUNCTION__, index, x, y, z, w); -#endif - (void) index; - (void) x; - (void) y; - (void) z; - (void) w; -} +_tnl_VertexAttrib4fNV( 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 -_tnl_VertexAttrib4fvNV(GLuint index, const GLfloat *v) -{ - /* no-op? */ - (void) index; - (void) v; -} - +_tnl_VertexAttrib4fvNV( 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 ); + } + } +} /* Execute a glRectf() function. _tnl_hard_begin() ensures the check diff --git a/src/mesa/tnl/t_imm_debug.c b/src/mesa/tnl/t_imm_debug.c index 2bd36aa16e7..0572d4c93c8 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.5 2001/12/14 02:51:45 brianp Exp $ */ +/* $Id: t_imm_debug.c,v 1.6 2002/01/05 20:51:13 brianp Exp $ */ /* * Mesa 3-D graphics library @@ -91,16 +91,25 @@ void _tnl_print_cassette( struct immediate *IM ) fprintf(stderr, "%u: ", i); if (req & VERT_OBJ_234) { if (flags[i] & VERT_EVAL_C1) - fprintf(stderr, "EvalCoord %f ", IM->Obj[i][0]); + fprintf(stderr, "EvalCoord %f ", + IM->Attrib[VERT_ATTRIB_POS][i][0]); else if (flags[i] & VERT_EVAL_P1) - fprintf(stderr, "EvalPoint %.0f ", IM->Obj[i][0]); + fprintf(stderr, "EvalPoint %.0f ", + IM->Attrib[VERT_ATTRIB_POS][i][0]); else if (flags[i] & VERT_EVAL_C2) - fprintf(stderr, "EvalCoord %f %f ", IM->Obj[i][0], IM->Obj[i][1]); + fprintf(stderr, "EvalCoord %f %f ", + IM->Attrib[VERT_ATTRIB_POS][i][0], + IM->Attrib[VERT_ATTRIB_POS][i][1]); else if (flags[i] & VERT_EVAL_P2) - fprintf(stderr, "EvalPoint %.0f %.0f ", IM->Obj[i][0], IM->Obj[i][1]); + fprintf(stderr, "EvalPoint %.0f %.0f ", + IM->Attrib[VERT_ATTRIB_POS][i][0], + IM->Attrib[VERT_ATTRIB_POS][i][1]); else if (i < IM->Count && (flags[i]&VERT_OBJ_234)) { fprintf(stderr, "Obj %f %f %f %f", - IM->Obj[i][0], IM->Obj[i][1], IM->Obj[i][2], IM->Obj[i][3]); + IM->Attrib[VERT_ATTRIB_POS][i][0], + IM->Attrib[VERT_ATTRIB_POS][i][1], + IM->Attrib[VERT_ATTRIB_POS][i][2], + IM->Attrib[VERT_ATTRIB_POS][i][3]); } } @@ -109,33 +118,38 @@ void _tnl_print_cassette( struct immediate *IM ) 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]); + IM->Attrib[VERT_ATTRIB_NORMAL][i][0], + IM->Attrib[VERT_ATTRIB_NORMAL][i][1], + IM->Attrib[VERT_ATTRIB_NORMAL][i][2]); if (req & flags[i] & VERT_TEX_ANY) { GLuint j; for (j = 0 ; j < MAX_TEXTURE_UNITS ; j++) { if (req & flags[i] & VERT_TEX(j)) { - fprintf(stderr, - "TC%d %f %f %f %f", - j, - IM->TexCoord[j][i][0], IM->TexCoord[j][i][1], - IM->TexCoord[j][i][2], IM->TexCoord[j][i][2]); + fprintf(stderr, "TC%d %f %f %f %f", j, + IM->Attrib[VERT_ATTRIB_TEX0 + j][i][0], + IM->Attrib[VERT_ATTRIB_TEX0 + j][i][1], + IM->Attrib[VERT_ATTRIB_TEX0 + j][i][2], + IM->Attrib[VERT_ATTRIB_TEX0 + j][i][3]); } } } 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]); + IM->Attrib[VERT_ATTRIB_COLOR0][i][0], + IM->Attrib[VERT_ATTRIB_COLOR0][i][1], + IM->Attrib[VERT_ATTRIB_COLOR0][i][2], + IM->Attrib[VERT_ATTRIB_COLOR0][i][3]); 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]); + IM->Attrib[VERT_ATTRIB_COLOR1][i][0], + IM->Attrib[VERT_ATTRIB_COLOR1][i][1], + IM->Attrib[VERT_ATTRIB_COLOR1][i][2]); if (req & flags[i] & VERT_FOG_BIT) - fprintf(stderr, " Fog %f ", IM->FogCoord[i]); + fprintf(stderr, " Fog %f ", IM->Attrib[VERT_ATTRIB_FOG][i][0]); if (req & flags[i] & VERT_INDEX_BIT) fprintf(stderr, " Index %u ", IM->Index[i]); diff --git a/src/mesa/tnl/t_imm_dlist.c b/src/mesa/tnl/t_imm_dlist.c index 3cec4464601..e7668cb2927 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.34 2001/12/20 15:30:46 keithw Exp $ */ +/* $Id: t_imm_dlist.c,v 1.35 2002/01/05 20:51:13 brianp Exp $ */ /* * Mesa 3-D graphics library @@ -71,7 +71,7 @@ static void build_normal_lengths( struct immediate *IM ) { GLuint i; GLfloat len; - GLfloat (*data)[3] = IM->Normal + IM->Start; + GLfloat (*data)[4] = IM->Attrib[VERT_ATTRIB_NORMAL] + IM->Start; GLfloat *dest = IM->NormalLengthPtr; GLuint *flags = IM->Flag + IM->Start; GLuint count = IM->Count - IM->Start; @@ -98,7 +98,7 @@ static void fixup_normal_lengths( struct immediate *IM ) { GLuint i; GLfloat len = 1.0F; /* just to silence warnings */ - GLfloat (*data)[3] = IM->Normal; + GLfloat (*data)[4] = IM->Attrib[VERT_ATTRIB_NORMAL]; GLfloat *dest = IM->NormalLengthPtr; GLuint *flags = IM->Flag; @@ -606,22 +606,23 @@ static void loopback_compiled_cassette( GLcontext *ctx, struct immediate *IM ) GLuint k; for (k = 0 ; k < maxtex ; k++) { if (flags[i] & VERT_TEX(k)) { - texcoordfv[k]( GL_TEXTURE0_ARB + k, IM->TexCoord[k][i] ); + texcoordfv[k]( GL_TEXTURE0_ARB + k, + IM->Attrib[VERT_ATTRIB_TEX0 + k][i] ); } } } if (flags[i] & VERT_NORMAL_BIT) - glNormal3fv(IM->Normal[i]); + glNormal3fv(IM->Attrib[VERT_ATTRIB_NORMAL][i]); if (flags[i] & VERT_COLOR0_BIT) - glColor4fv( IM->Color[i] ); + glColor4fv( IM->Attrib[VERT_ATTRIB_COLOR0][i] ); if (flags[i] & VERT_COLOR1_BIT) - _compat_SecondaryColor3fvEXT( IM->SecondaryColor[i] ); + _compat_SecondaryColor3fvEXT( IM->Attrib[VERT_ATTRIB_COLOR1][i] ); if (flags[i] & VERT_FOG_BIT) - _compat_FogCoordfEXT( IM->FogCoord[i] ); + _compat_FogCoordfEXT( IM->Attrib[VERT_ATTRIB_FOG][i][0] ); if (flags[i] & VERT_INDEX_BIT) glIndexi( IM->Index[i] ); @@ -633,15 +634,17 @@ static void loopback_compiled_cassette( GLcontext *ctx, struct immediate *IM ) emit_material( IM->Material[i], IM->MaterialMask[i] ); if (flags[i]&VERT_OBJ_234) - vertex( IM->Obj[i] ); + vertex( IM->Attrib[VERT_ATTRIB_POS][i] ); else if (flags[i] & VERT_EVAL_C1) - glEvalCoord1f( IM->Obj[i][0] ); + glEvalCoord1f( IM->Attrib[VERT_ATTRIB_POS][i][0] ); else if (flags[i] & VERT_EVAL_P1) - glEvalPoint1( (GLint) IM->Obj[i][0] ); + glEvalPoint1( (GLint) IM->Attrib[VERT_ATTRIB_POS][i][0] ); else if (flags[i] & VERT_EVAL_C2) - glEvalCoord2f( IM->Obj[i][0], IM->Obj[i][1] ); + glEvalCoord2f( IM->Attrib[VERT_ATTRIB_POS][i][0], + IM->Attrib[VERT_ATTRIB_POS][i][1] ); else if (flags[i] & VERT_EVAL_P2) - glEvalPoint2( (GLint) IM->Obj[i][0], (GLint) IM->Obj[i][1] ); + glEvalPoint2( (GLint) IM->Attrib[VERT_ATTRIB_POS][i][0], + (GLint) IM->Attrib[VERT_ATTRIB_POS][i][1] ); } if (prim & PRIM_END) { diff --git a/src/mesa/tnl/t_imm_elt.c b/src/mesa/tnl/t_imm_elt.c index d585f63c47b..b127a9e4c3d 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.13 2001/12/14 02:51:45 brianp Exp $ */ +/* $Id: t_imm_elt.c,v 1.14 2002/01/05 20:51:13 brianp Exp $ */ /* * Mesa 3-D graphics library @@ -597,6 +597,7 @@ void _tnl_imm_elt_init( void ) } +#if 00 static void _tnl_trans_elt_1f(GLfloat *to, const struct gl_client_array *from, GLuint *flags, @@ -615,6 +616,7 @@ static void _tnl_trans_elt_1f(GLfloat *to, n ); } +#endif static void _tnl_trans_elt_1ui(GLuint *to, const struct gl_client_array *from, @@ -758,7 +760,7 @@ void _tnl_translate_array_elts( GLcontext *ctx, struct immediate *IM, fprintf(stderr, "exec_array_elements %d .. %d\n", start, count); if (translate & VERT_OBJ_BIT) { - _tnl_trans_elt_4f( IM->Obj, + _tnl_trans_elt_4f( IM->Attrib[VERT_ATTRIB_POS], &ctx->Array.Vertex, flags, elts, (VERT_ELT|VERT_OBJ_BIT), start, count); @@ -771,7 +773,7 @@ void _tnl_translate_array_elts( GLcontext *ctx, struct immediate *IM, if (translate & VERT_NORMAL_BIT) - _tnl_trans_elt_3f( IM->Normal, + _tnl_trans_elt_4f( IM->Attrib[VERT_ATTRIB_NORMAL], &ctx->Array.Normal, flags, elts, (VERT_ELT|VERT_NORMAL_BIT), start, count); @@ -783,21 +785,21 @@ void _tnl_translate_array_elts( GLcontext *ctx, struct immediate *IM, start, count); if (translate & VERT_COLOR0_BIT) { - _tnl_trans_elt_4f( IM->Color, + _tnl_trans_elt_4f( IM->Attrib[VERT_ATTRIB_COLOR0], &ctx->Array.Color, flags, elts, (VERT_ELT|VERT_COLOR0_BIT), start, count); } if (translate & VERT_COLOR1_BIT) { - _tnl_trans_elt_4f( IM->SecondaryColor, + _tnl_trans_elt_4f( IM->Attrib[VERT_ATTRIB_COLOR1], &ctx->Array.SecondaryColor, flags, elts, (VERT_ELT|VERT_COLOR1_BIT), start, count); } if (translate & VERT_FOG_BIT) - _tnl_trans_elt_1f( IM->FogCoord, + _tnl_trans_elt_4f( IM->Attrib[VERT_ATTRIB_FOG], &ctx->Array.FogCoord, flags, elts, (VERT_ELT|VERT_FOG_BIT), start, count); @@ -811,7 +813,7 @@ void _tnl_translate_array_elts( GLcontext *ctx, struct immediate *IM, if (translate & VERT_TEX_ANY) { for (i = 0 ; i < ctx->Const.MaxTextureUnits ; i++) if (translate & VERT_TEX(i)) { - _tnl_trans_elt_4f( IM->TexCoord[i], + _tnl_trans_elt_4f( IM->Attrib[VERT_ATTRIB_TEX0 + i], &ctx->Array.TexCoord[i], flags, elts, (VERT_ELT|VERT_TEX(i)), start, count); diff --git a/src/mesa/tnl/t_imm_eval.c b/src/mesa/tnl/t_imm_eval.c index 662cfb936a8..7eb3bee25d3 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.19 2001/12/14 02:51:45 brianp Exp $ */ +/* $Id: t_imm_eval.c,v 1.20 2002/01/05 20:51:13 brianp Exp $ */ /* * Mesa 3-D graphics library @@ -158,14 +158,14 @@ static void eval1_1ui( GLvector1ui *dest, } -static void eval1_norm( GLvector3f *dest, +static void eval1_norm( GLvector4f *dest, GLfloat coord[][4], const GLuint *flags, struct gl_1d_map *map ) { const GLfloat u1 = map->u1; const GLfloat du = map->du; - GLfloat (*to)[3] = dest->data; + GLfloat (*to)[4] = dest->data; GLuint i; for (i = 0 ; !(flags[i] & VERT_END_VB) ; i++) @@ -180,7 +180,7 @@ static void eval1_norm( GLvector3f *dest, static void eval2_obj_norm( GLvector4f *obj_ptr, - GLvector3f *norm_ptr, + GLvector4f *norm_ptr, GLfloat coord[][4], GLuint *flags, GLuint dimension, @@ -191,7 +191,7 @@ static void eval2_obj_norm( GLvector4f *obj_ptr, const GLfloat v1 = map->v1; const GLfloat dv = map->dv; GLfloat (*obj)[4] = obj_ptr->data; - GLfloat (*normal)[3] = norm_ptr->data; + GLfloat (*normal)[4] = norm_ptr->data; GLuint i; /* fprintf(stderr, "%s\n", __FUNCTION__); */ @@ -280,7 +280,7 @@ static void eval2_4f_ca( struct gl_client_array *dest, } -static void eval2_norm( GLvector3f *dest, +static void eval2_norm( GLvector4f *dest, GLfloat coord[][4], GLuint *flags, struct gl_2d_map *map ) @@ -289,17 +289,17 @@ static void eval2_norm( GLvector3f *dest, const GLfloat du = map->du; const GLfloat v1 = map->v1; const GLfloat dv = map->dv; - GLfloat (*to)[3] = dest->data; + GLfloat (*to)[4] = dest->data; GLuint i; - for (i = 0 ; !(flags[i] & VERT_END_VB) ; i++) + for (i = 0 ; !(flags[i] & VERT_END_VB) ; i++) { if (flags[i] & (VERT_EVAL_C2|VERT_EVAL_P2)) { GLfloat u = (coord[i][0] - u1) * du; GLfloat v = (coord[i][1] - v1) * dv; _math_horner_bezier_surf(map->Points, to[i], u, v, 3, map->Uorder, map->Vorder); - } - + } + } } @@ -351,7 +351,7 @@ static void copy_4f_stride( GLfloat to[][4], GLfloat *from, } } -static void copy_3f( GLfloat to[][3], GLfloat from[][3], GLuint count ) +static void copy_3f( GLfloat to[][4], GLfloat from[][4], GLuint count ) { GLuint i; /* MEMCPY( to, from, (count) * sizeof(to[0])); */ @@ -452,7 +452,7 @@ void _tnl_eval_immediate( GLcontext *ctx, struct immediate *IM ) GLuint any_eval2 = orflag & (VERT_EVAL_C2|VERT_EVAL_P2); GLuint req = 0; GLuint purge_flags = 0; - GLfloat (*coord)[4] = IM->Obj + IM->CopyStart; + GLfloat (*coord)[4] = IM->Attrib[VERT_ATTRIB_POS] + IM->CopyStart; if (IM->AndFlag & VERT_EVAL_ANY) copycount = IM->Start - IM->CopyStart; /* just copy copied vertices */ @@ -475,12 +475,12 @@ void _tnl_eval_immediate( GLcontext *ctx, struct immediate *IM ) purge_flags = (VERT_EVAL_P1|VERT_EVAL_C1); if (orflag & VERT_EVAL_P1) { - eval_points1( store->Obj + IM->CopyStart, + eval_points1( store->Attrib[VERT_ATTRIB_POS] + IM->CopyStart, coord, flags, ctx->Eval.MapGrid1du, ctx->Eval.MapGrid1u1); - coord = store->Obj + IM->CopyStart; + coord = store->Attrib[VERT_ATTRIB_POS] + IM->CopyStart; } } @@ -491,14 +491,14 @@ void _tnl_eval_immediate( GLcontext *ctx, struct immediate *IM ) purge_flags |= (VERT_EVAL_P2|VERT_EVAL_C2); if (orflag & VERT_EVAL_P2) { - eval_points2( store->Obj + IM->CopyStart, + eval_points2( store->Attrib[VERT_ATTRIB_POS] + IM->CopyStart, coord, flags, ctx->Eval.MapGrid2du, ctx->Eval.MapGrid2u1, ctx->Eval.MapGrid2dv, ctx->Eval.MapGrid2v1 ); - coord = store->Obj + IM->CopyStart; + coord = store->Attrib[VERT_ATTRIB_POS] + IM->CopyStart; } } @@ -533,12 +533,12 @@ void _tnl_eval_immediate( GLcontext *ctx, struct immediate *IM ) GLuint generated = 0; if (copycount) - copy_4f_stride( store->Color + IM->CopyStart, + copy_4f_stride( store->Attrib[VERT_ATTRIB_COLOR0] + IM->CopyStart, (GLfloat *)tmp->Color.Ptr, tmp->Color.StrideB, copycount ); - tmp->Color.Ptr = store->Color + IM->CopyStart; + tmp->Color.Ptr = store->Attrib[VERT_ATTRIB_COLOR0] + IM->CopyStart; tmp->Color.StrideB = 4 * sizeof(GLfloat); tmp->Color.Flags = 0; tnl->vb.importable_data &= ~VERT_COLOR0_BIT; @@ -560,12 +560,12 @@ void _tnl_eval_immediate( GLcontext *ctx, struct immediate *IM ) GLuint generated = 0; if (copycount) - copy_4f( store->TexCoord[0] + IM->CopyStart, + copy_4f( store->Attrib[VERT_ATTRIB_TEX0] + IM->CopyStart, tmp->TexCoord[0].data, copycount ); else tmp->TexCoord[0].size = 0; - tmp->TexCoord[0].data = store->TexCoord[0] + IM->CopyStart; + tmp->TexCoord[0].data = store->Attrib[VERT_ATTRIB_TEX0] + IM->CopyStart; tmp->TexCoord[0].start = (GLfloat *)tmp->TexCoord[0].data; if (any_eval1) { @@ -622,22 +622,20 @@ void _tnl_eval_immediate( GLcontext *ctx, struct immediate *IM ) if (copycount) { /* fprintf(stderr, "%s: Copy normals\n", __FUNCTION__); */ - copy_3f( store->Normal + IM->CopyStart, tmp->Normal.data, - copycount ); + copy_3f( store->Attrib[VERT_ATTRIB_NORMAL] + IM->CopyStart, + tmp->Normal.data, copycount ); } - tmp->Normal.data = store->Normal + IM->CopyStart; + tmp->Normal.data = store->Attrib[VERT_ATTRIB_NORMAL] + IM->CopyStart; tmp->Normal.start = (GLfloat *)tmp->Normal.data; if (ctx->Eval.Map1Normal && any_eval1) { - eval1_norm( &tmp->Normal, coord, flags, - &ctx->EvalMap.Map1Normal ); + eval1_norm( &tmp->Normal, coord, flags, &ctx->EvalMap.Map1Normal ); generated |= VERT_EVAL_C1|VERT_EVAL_P1; } if (ctx->Eval.Map2Normal && any_eval2) { - eval2_norm( &tmp->Normal, coord, flags, - &ctx->EvalMap.Map2Normal ); + eval2_norm( &tmp->Normal, coord, flags, &ctx->EvalMap.Map2Normal ); generated |= VERT_EVAL_C2|VERT_EVAL_P2; } } @@ -653,12 +651,16 @@ void _tnl_eval_immediate( GLcontext *ctx, struct immediate *IM ) /* This copy may already have occurred when eliminating * glEvalPoint calls: */ - if (coord != store->Obj + IM->CopyStart) - copy_4f( store->Obj + IM->CopyStart, tmp->Obj.data, copycount ); - } else + if (coord != store->Attrib[VERT_ATTRIB_POS] + IM->CopyStart) { + copy_4f( store->Attrib[VERT_ATTRIB_POS] + IM->CopyStart, + tmp->Obj.data, copycount ); + } + } + else { tmp->Obj.size = 0; + } - tmp->Obj.data = store->Obj + IM->CopyStart; + tmp->Obj.data = store->Attrib[VERT_ATTRIB_POS] + IM->CopyStart; tmp->Obj.start = (GLfloat *)tmp->Obj.data; /* Note: Normal data is already prepared above. @@ -676,8 +678,7 @@ void _tnl_eval_immediate( GLcontext *ctx, struct immediate *IM ) } if (any_eval2) { - if (ctx->Eval.Map2Vertex4) - { + if (ctx->Eval.Map2Vertex4) { if (ctx->Eval.AutoNormal && (req & VERT_NORMAL_BIT)) eval2_obj_norm( &tmp->Obj, &tmp->Normal, coord, flags, 4, &ctx->EvalMap.Map2Vertex4 ); @@ -685,8 +686,7 @@ void _tnl_eval_immediate( GLcontext *ctx, struct immediate *IM ) eval2_4f( &tmp->Obj, coord, flags, 4, &ctx->EvalMap.Map2Vertex4 ); } - else if (ctx->Eval.Map2Vertex3) - { + else if (ctx->Eval.Map2Vertex3) { if (ctx->Eval.AutoNormal && (req & VERT_NORMAL_BIT)) eval2_obj_norm( &tmp->Obj, &tmp->Normal, coord, flags, 3, &ctx->EvalMap.Map2Vertex3 ); diff --git a/src/mesa/tnl/t_imm_exec.c b/src/mesa/tnl/t_imm_exec.c index 4eceb7985a5..d02ec2ee212 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.32 2001/12/15 02:13:32 brianp Exp $ */ +/* $Id: t_imm_exec.c,v 1.33 2002/01/05 20:51:13 brianp Exp $ */ /* * Mesa 3-D graphics library @@ -128,8 +128,12 @@ void _tnl_copy_to_current( GLcontext *ctx, struct immediate *IM, if (MESA_VERBOSE&VERBOSE_IMMEDIATE) _tnl_print_vert_flags("copy to current", flag); + /* XXX should be able t replace these conditions with a loop over + * the 16 vertex attributes. + */ if (flag & VERT_NORMAL_BIT) - COPY_3FV( ctx->Current.Attrib[VERT_ATTRIB_NORMAL], IM->Normal[count]); + COPY_4FV( ctx->Current.Attrib[VERT_ATTRIB_NORMAL], + IM->Attrib[VERT_ATTRIB_NORMAL][count]); if (flag & VERT_INDEX_BIT) ctx->Current.Index = IM->Index[count]; @@ -138,24 +142,28 @@ void _tnl_copy_to_current( GLcontext *ctx, struct immediate *IM, ctx->Current.EdgeFlag = IM->EdgeFlag[count]; if (flag & VERT_COLOR0_BIT) { - COPY_4FV(ctx->Current.Attrib[VERT_ATTRIB_COLOR0], IM->Color[count]); + COPY_4FV(ctx->Current.Attrib[VERT_ATTRIB_COLOR0], + IM->Attrib[VERT_ATTRIB_COLOR0][count]); if (ctx->Light.ColorMaterialEnabled) { - _mesa_update_color_material( ctx, ctx->Current.Attrib[VERT_ATTRIB_COLOR0] ); + _mesa_update_color_material( ctx, + ctx->Current.Attrib[VERT_ATTRIB_COLOR0] ); _mesa_validate_all_lighting_tables( ctx ); } } if (flag & VERT_COLOR1_BIT) - COPY_4FV(ctx->Current.Attrib[VERT_ATTRIB_COLOR1], IM->SecondaryColor[count]); + COPY_4FV(ctx->Current.Attrib[VERT_ATTRIB_COLOR1], + IM->Attrib[VERT_ATTRIB_COLOR1][count]); if (flag & VERT_FOG_BIT) - ctx->Current.Attrib[VERT_ATTRIB_FOG][0] = IM->FogCoord[count]; + ctx->Current.Attrib[VERT_ATTRIB_FOG][0] = IM->Attrib[VERT_ATTRIB_FOG][count][0]; if (flag & VERT_TEX_ANY) { GLuint i; for (i = 0 ; i < ctx->Const.MaxTextureUnits ; i++) { if (flag & VERT_TEX(i)) { - COPY_4FV( ctx->Current.Attrib[VERT_ATTRIB_TEX0 + i], IM->TexCoord[i][count]); + COPY_4FV( ctx->Current.Attrib[VERT_ATTRIB_TEX0 + i], + IM->Attrib[VERT_ATTRIB_TEX0 + i][count]); } } } @@ -222,8 +230,9 @@ static void _tnl_vb_bind_immediate( GLcontext *ctx, struct immediate *IM ) struct vertex_buffer *VB = &tnl->vb; struct vertex_arrays *tmp = &tnl->imm_inputs; GLuint inputs = tnl->pipeline.inputs; /* for copy-to-current */ - GLuint start = IM->CopyStart; - GLuint count = IM->Count - start; + const GLuint start = IM->CopyStart; + const GLuint count = IM->Count - start; + GLuint i; /* TODO: optimize the case where nothing has changed. (Just bind * tmp to vb). @@ -248,7 +257,6 @@ static void _tnl_vb_bind_immediate( GLcontext *ctx, struct immediate *IM ) */ VB->NormalPtr = 0; VB->NormalLengthPtr = 0; - VB->FogCoordPtr = 0; VB->EdgeFlag = 0; VB->IndexPtr[0] = 0; VB->IndexPtr[1] = 0; @@ -259,6 +267,8 @@ static void _tnl_vb_bind_immediate( GLcontext *ctx, struct immediate *IM ) VB->Elts = 0; VB->MaterialMask = 0; VB->Material = 0; + for (i = 0; i < 16; i++) + VB->AttribPtr[i] = NULL; /* _tnl_print_vert_flags("copy-orflag", IM->CopyOrFlag); */ /* _tnl_print_vert_flags("orflag", IM->OrFlag); */ @@ -267,8 +277,8 @@ 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_BIT) { - tmp->Obj.data = IM->Obj + start; - tmp->Obj.start = (GLfloat *)(IM->Obj + start); + tmp->Obj.data = IM->Attrib[VERT_ATTRIB_POS] + start; + tmp->Obj.start = (GLfloat *)(IM->Attrib[VERT_ATTRIB_POS] + start); tmp->Obj.count = count; VB->ObjPtr = &tmp->Obj; if ((IM->CopyOrFlag & VERT_OBJ_234) == VERT_OBJ_234) @@ -280,8 +290,8 @@ static void _tnl_vb_bind_immediate( GLcontext *ctx, struct immediate *IM ) } if (inputs & VERT_NORMAL_BIT) { - tmp->Normal.data = IM->Normal + start; - tmp->Normal.start = (GLfloat *)(IM->Normal + start); + tmp->Normal.data = IM->Attrib[VERT_ATTRIB_NORMAL] + start; + tmp->Normal.start = (GLfloat *) (IM->Attrib[VERT_ATTRIB_NORMAL] + start); tmp->Normal.count = count; VB->NormalPtr = &tmp->Normal; if (IM->NormalLengthPtr) @@ -296,14 +306,14 @@ static void _tnl_vb_bind_immediate( GLcontext *ctx, struct immediate *IM ) } if (inputs & VERT_FOG_BIT) { - tmp->FogCoord.data = IM->FogCoord + start; - tmp->FogCoord.start = IM->FogCoord + start; + tmp->FogCoord.data = IM->Attrib[VERT_ATTRIB_FOG] + start; + tmp->FogCoord.start = (GLfloat *) (IM->Attrib[VERT_ATTRIB_FOG] + start); tmp->FogCoord.count = count; - VB->FogCoordPtr = &tmp->FogCoord; + VB->AttribPtr[VERT_ATTRIB_FOG] = &tmp->FogCoord; } if (inputs & VERT_COLOR1_BIT) { - tmp->SecondaryColor.Ptr = IM->SecondaryColor + start; + tmp->SecondaryColor.Ptr = IM->Attrib[VERT_ATTRIB_COLOR1] + start; VB->SecondaryColorPtr[0] = &tmp->SecondaryColor; } @@ -313,7 +323,7 @@ static void _tnl_vb_bind_immediate( GLcontext *ctx, struct immediate *IM ) if (inputs & VERT_COLOR0_BIT) { if (IM->CopyOrFlag & VERT_COLOR0_BIT) { - tmp->Color.Ptr = IM->Color + start; + tmp->Color.Ptr = IM->Attrib[VERT_ATTRIB_COLOR0] + start; tmp->Color.StrideB = 4 * sizeof(GLfloat); tmp->Color.Flags = 0; } @@ -334,8 +344,8 @@ static void _tnl_vb_bind_immediate( GLcontext *ctx, struct immediate *IM ) VB->TexCoordPtr[i] = 0; if (inputs & VERT_TEX(i)) { tmp->TexCoord[i].count = count; - tmp->TexCoord[i].data = IM->TexCoord[i] + start; - tmp->TexCoord[i].start = (GLfloat *)(IM->TexCoord[i] + start); + tmp->TexCoord[i].data = IM->Attrib[VERT_ATTRIB_TEX0 + i] + start; + tmp->TexCoord[i].start = (GLfloat *)(IM->Attrib[VERT_ATTRIB_TEX0 + i] + start); tmp->TexCoord[i].size = 2; if (IM->TexSize & TEX_SIZE_3(i)) { tmp->TexCoord[i].size = 3; @@ -355,7 +365,7 @@ static void _tnl_vb_bind_immediate( GLcontext *ctx, struct immediate *IM ) /* GL_NV_vertex_program */ if (ctx->VertexProgram.Enabled) { GLuint attr; - for (attr = 0; attr < 16; attr++) { + for (attr = 0; attr < VERT_ATTRIB_MAX; attr++) { tmp->Attribs[attr].count = count; tmp->Attribs[attr].data = IM->Attrib[attr] + start; tmp->Attribs[attr].start = (GLfloat *) (IM->Attrib[attr] + start); @@ -531,7 +541,7 @@ void _tnl_imm_init( GLcontext *ctx ) TNL_CURRENT_IM(ctx)->CopyStart = IMM_MAX_COPIED_VERTS; _mesa_vector4f_init( &tmp->Obj, 0, 0 ); - _mesa_vector3f_init( &tmp->Normal, 0, 0 ); + _mesa_vector4f_init( &tmp->Normal, 0, 0 ); tmp->Color.Ptr = 0; tmp->Color.Type = GL_FLOAT; @@ -547,7 +557,7 @@ void _tnl_imm_init( GLcontext *ctx ) tmp->SecondaryColor.StrideB = 4 * sizeof(GLfloat); tmp->SecondaryColor.Flags = 0; - _mesa_vector1f_init( &tmp->FogCoord, 0, 0 ); + _mesa_vector4f_init( &tmp->FogCoord, 0, 0 ); _mesa_vector1ui_init( &tmp->Index, 0, 0 ); _mesa_vector1ub_init( &tmp->EdgeFlag, 0, 0 ); diff --git a/src/mesa/tnl/t_imm_fixup.c b/src/mesa/tnl/t_imm_fixup.c index 83b31783e23..6d6bfad83fc 100644 --- a/src/mesa/tnl/t_imm_fixup.c +++ b/src/mesa/tnl/t_imm_fixup.c @@ -1,10 +1,10 @@ -/* $Id: t_imm_fixup.c,v 1.30 2001/12/15 02:13:32 brianp Exp $ */ +/* $Id: t_imm_fixup.c,v 1.31 2002/01/05 20:51:13 brianp Exp $ */ /* * Mesa 3-D graphics library - * Version: 3.5 + * Version: 4.1 * - * Copyright (C) 1999-2001 Brian Paul All Rights Reserved. + * Copyright (C) 1999-2002 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"), @@ -171,6 +171,7 @@ fixup_first_1ui( GLuint data[], GLuint flag[], GLuint match, data[i] = dflt; } +#if 00 static void fixup_first_1f( GLfloat data[], GLuint flag[], GLuint match, GLuint start, GLfloat dflt ) @@ -181,7 +182,7 @@ fixup_first_1f( GLfloat data[], GLuint flag[], GLuint match, while ((flag[++i]&match) == 0) data[i] = dflt; } - +#endif static void fixup_first_1ub( GLubyte data[], GLuint flag[], GLuint match, @@ -201,36 +202,50 @@ fixup_first_1ub( GLubyte data[], GLuint flag[], GLuint match, static void copy_from_current( GLcontext *ctx, struct immediate *IM, GLuint pos, GLuint copyMask ) { + GLuint attrib, attribBit; + if (MESA_VERBOSE&VERBOSE_IMMEDIATE) _tnl_print_vert_flags("copy from current", copyMask); +#if 0 if (copyMask & VERT_NORMAL_BIT) { - COPY_3V(IM->Normal[pos], ctx->Current.Attrib[VERT_ATTRIB_NORMAL]); + COPY_4V(IM->Attrib[VERT_ATTRIB_NORMAL][pos], + ctx->Current.Attrib[VERT_ATTRIB_NORMAL]); } if (copyMask & VERT_COLOR0_BIT) { - COPY_4FV( IM->Color[pos], ctx->Current.Attrib[VERT_ATTRIB_COLOR0]); + COPY_4FV( IM->Attrib[VERT_ATTRIB_COLOR0][pos], + ctx->Current.Attrib[VERT_ATTRIB_COLOR0]); } if (copyMask & VERT_COLOR1_BIT) - COPY_4FV( IM->SecondaryColor[pos], ctx->Current.Attrib[VERT_ATTRIB_COLOR1]); + COPY_4FV( IM->Attrib[VERT_ATTRIB_COLOR1][pos], + ctx->Current.Attrib[VERT_ATTRIB_COLOR1]); if (copyMask & VERT_FOG_BIT) - IM->FogCoord[pos] = ctx->Current.Attrib[VERT_ATTRIB_FOG][0]; - - if (copyMask & VERT_INDEX_BIT) - IM->Index[pos] = ctx->Current.Index; - - if (copyMask & VERT_EDGEFLAG_BIT) - IM->EdgeFlag[pos] = ctx->Current.EdgeFlag; + IM->Attrib[VERT_ATTRIB_FOG][pos][0] = ctx->Current.Attrib[VERT_ATTRIB_FOG][0]; if (copyMask & VERT_TEX_ANY) { GLuint i; for (i = 0 ; i < ctx->Const.MaxTextureUnits ; i++) { if (copyMask & VERT_TEX(i)) - COPY_4FV(IM->TexCoord[i][pos], ctx->Current.Attrib[VERT_ATTRIB_TEX0 + i]); + COPY_4FV(IM->Attrib[VERT_ATTRIB_TEX0 + i][pos], + ctx->Current.Attrib[VERT_ATTRIB_TEX0 + i]); + } + } +#else + for (attrib = 0, attribBit = 1; attrib < 16; attrib++, attribBit <<= 1) { + if (copyMask & attribBit) { + COPY_4FV( IM->Attrib[attrib][pos], ctx->Current.Attrib[attrib]); } } +#endif + + if (copyMask & VERT_INDEX_BIT) + IM->Index[pos] = ctx->Current.Index; + + if (copyMask & VERT_EDGEFLAG_BIT) + IM->EdgeFlag[pos] = ctx->Current.EdgeFlag; } @@ -274,16 +289,21 @@ void _tnl_fixup_input( GLcontext *ctx, struct immediate *IM ) if (MESA_VERBOSE&VERBOSE_IMMEDIATE) _tnl_print_vert_flags("fixup", fixup); + /* XXX replace these conditionals with a loop over the 16 + * vertex attributes. + */ + if (fixup & VERT_TEX_ANY) { GLuint i; for (i = 0 ; i < ctx->Const.MaxTextureUnits ; i++) { if (fixup & VERT_TEX(i)) { if (orflag & VERT_TEX(i)) - _tnl_fixup_4f( IM->TexCoord[i], IM->Flag, start, - VERT_TEX(i) ); + _tnl_fixup_4f( IM->Attrib[VERT_ATTRIB_TEX0 + i], IM->Flag, + start, VERT_TEX(i) ); else - fixup_first_4f( IM->TexCoord[i], IM->Flag, VERT_END_VB, start, - IM->TexCoord[i][start]); + fixup_first_4f( IM->Attrib[VERT_ATTRIB_TEX0 + i], IM->Flag, + VERT_END_VB, start, + IM->Attrib[VERT_ATTRIB_TEX0 + i][start]); } } } @@ -307,7 +327,8 @@ void _tnl_fixup_input( GLcontext *ctx, struct immediate *IM ) if (fixup & VERT_COLOR0_BIT) { if (orflag & VERT_COLOR0_BIT) - _tnl_fixup_4f( IM->Color, IM->Flag, start, VERT_COLOR0_BIT ); + _tnl_fixup_4f( IM->Attrib[VERT_ATTRIB_COLOR0], IM->Flag, start, + VERT_COLOR0_BIT ); /* No need for else case as the drivers understand stride * zero here. (TODO - propogate this) */ @@ -315,27 +336,30 @@ void _tnl_fixup_input( GLcontext *ctx, struct immediate *IM ) if (fixup & VERT_COLOR1_BIT) { if (orflag & VERT_COLOR1_BIT) - _tnl_fixup_4f( IM->SecondaryColor, IM->Flag, start, + _tnl_fixup_4f( IM->Attrib[VERT_ATTRIB_COLOR1], IM->Flag, start, VERT_COLOR1_BIT ); else - fixup_first_4f( IM->SecondaryColor, IM->Flag, VERT_END_VB, start, - IM->SecondaryColor[start] ); + fixup_first_4f( IM->Attrib[VERT_ATTRIB_COLOR1], IM->Flag, VERT_END_VB, start, + IM->Attrib[VERT_ATTRIB_COLOR1][start] ); } if (fixup & VERT_FOG_BIT) { if (orflag & VERT_FOG_BIT) - _tnl_fixup_1f( IM->FogCoord, IM->Flag, start, VERT_FOG_BIT ); + _tnl_fixup_4f( IM->Attrib[VERT_ATTRIB_FOG], IM->Flag, + start, VERT_FOG_BIT ); else - fixup_first_1f( IM->FogCoord, IM->Flag, VERT_END_VB, start, - IM->FogCoord[start] ); + fixup_first_4f( IM->Attrib[VERT_ATTRIB_FOG], IM->Flag, VERT_END_VB, + start, IM->Attrib[VERT_ATTRIB_FOG][start] ); } if (fixup & VERT_NORMAL_BIT) { if (orflag & VERT_NORMAL_BIT) - _tnl_fixup_3f( IM->Normal, IM->Flag, start, VERT_NORMAL_BIT ); + _tnl_fixup_4f( IM->Attrib[VERT_ATTRIB_NORMAL], IM->Flag, start, + VERT_NORMAL_BIT ); else - fixup_first_3f( IM->Normal, IM->Flag, VERT_END_VB, start, - IM->Normal[start] ); + fixup_first_4f( IM->Attrib[VERT_ATTRIB_NORMAL], IM->Flag, + VERT_END_VB, start, + IM->Attrib[VERT_ATTRIB_NORMAL][start] ); } } @@ -474,7 +498,8 @@ void _tnl_copy_immediate_vertices( GLcontext *ctx, struct immediate *next ) * * Note these pointers are null when inactive. */ - COPY_4FV( next->Obj[dst], inputs->Obj.data[isrc] ); + COPY_4FV( next->Attrib[VERT_ATTRIB_POS][dst], + inputs->Obj.data[isrc] ); if (copy & VERT_NORMAL_BIT) { /* fprintf(stderr, "copy vert norm %d to %d (%p): %f %f %f\n", */ @@ -483,11 +508,11 @@ void _tnl_copy_immediate_vertices( GLcontext *ctx, struct immediate *next ) /* inputs->Normal.data[isrc][0], */ /* inputs->Normal.data[isrc][1], */ /* inputs->Normal.data[isrc][2]); */ - COPY_3FV( next->Normal[dst], inputs->Normal.data[isrc] ); + COPY_3FV( next->Attrib[VERT_ATTRIB_NORMAL][dst], inputs->Normal.data[isrc] ); } if (copy & VERT_COLOR0_BIT) - COPY_4FV( next->Color[dst], + COPY_4FV( next->Attrib[VERT_ATTRIB_COLOR0][dst], ((GLfloat (*)[4])inputs->Color.Ptr)[isrc] ); if (copy & VERT_INDEX_BIT) @@ -497,7 +522,7 @@ void _tnl_copy_immediate_vertices( GLcontext *ctx, struct immediate *next ) GLuint i; for (i = 0 ; i < prev->MaxTextureUnits ; i++) { if (copy & VERT_TEX(i)) - COPY_4FV( next->TexCoord[i][dst], + COPY_4FV( next->Attrib[VERT_ATTRIB_TEX0 + i][dst], inputs->TexCoord[i].data[isrc] ); } } @@ -513,8 +538,10 @@ void _tnl_copy_immediate_vertices( GLcontext *ctx, struct immediate *next ) next->Elt[dst] = prev->Elt[src]; next->EdgeFlag[dst] = prev->EdgeFlag[src]; - COPY_4FV( next->SecondaryColor[dst], prev->SecondaryColor[src] ); - next->FogCoord[dst] = prev->FogCoord[src]; + COPY_4FV( next->Attrib[VERT_ATTRIB_COLOR1][dst], + prev->Attrib[VERT_ATTRIB_COLOR1][src] ); + COPY_4FV( next->Attrib[VERT_ATTRIB_FOG][dst], + prev->Attrib[VERT_ATTRIB_FOG][src] ); } next->Flag[dst] = flag; @@ -579,44 +606,54 @@ void _tnl_fixup_compiled_cassette( GLcontext *ctx, struct immediate *IM ) /* _tnl_print_vert_flags("fixup compiled", fixup); */ if (fixup) { - if (fixup & VERT_TEX_ANY) { - GLuint i; - 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.Attrib[VERT_ATTRIB_TEX0 + i] ); - } - } - if (fixup & VERT_EDGEFLAG_BIT) - fixup_first_1ub(IM->EdgeFlag, IM->Flag, VERT_EDGEFLAG_BIT, start, - ctx->Current.EdgeFlag ); + /* XXX try to replace this code with a loop over the 16 vertex + * attributes. + */ - if (fixup & VERT_INDEX_BIT) - fixup_first_1ui(IM->Index, IM->Flag, VERT_INDEX_BIT, start, - ctx->Current.Index ); + if (fixup & VERT_NORMAL_BIT) { + fixup_first_4f(IM->Attrib[VERT_ATTRIB_NORMAL], IM->Flag, + VERT_NORMAL_BIT, start, + ctx->Current.Attrib[VERT_ATTRIB_NORMAL] ); + } if (fixup & VERT_COLOR0_BIT) { if (IM->CopyOrFlag & VERT_COLOR0_BIT) - fixup_first_4f(IM->Color, IM->Flag, VERT_COLOR0_BIT, start, + fixup_first_4f(IM->Attrib[VERT_ATTRIB_COLOR0], IM->Flag, + VERT_COLOR0_BIT, start, ctx->Current.Attrib[VERT_ATTRIB_COLOR0] ); else fixup &= ~VERT_COLOR0_BIT; } if (fixup & VERT_COLOR1_BIT) - fixup_first_4f(IM->SecondaryColor, IM->Flag, VERT_COLOR1_BIT, start, + fixup_first_4f(IM->Attrib[VERT_ATTRIB_COLOR1], IM->Flag, + VERT_COLOR1_BIT, start, ctx->Current.Attrib[VERT_ATTRIB_COLOR1] ); if (fixup & VERT_FOG_BIT) - fixup_first_1f(IM->FogCoord, IM->Flag, VERT_FOG_BIT, start, - ctx->Current.Attrib[VERT_ATTRIB_FOG][0] ); + fixup_first_4f( IM->Attrib[VERT_ATTRIB_FOG], IM->Flag, + VERT_FOG_BIT, start, + ctx->Current.Attrib[VERT_ATTRIB_FOG] ); - if (fixup & VERT_NORMAL_BIT) { - fixup_first_3f(IM->Normal, IM->Flag, VERT_NORMAL_BIT, start, - ctx->Current.Attrib[VERT_ATTRIB_NORMAL] ); + if (fixup & VERT_TEX_ANY) { + GLuint i; + for (i = 0 ; i < ctx->Const.MaxTextureUnits ; i++) { + if (fixup & VERT_TEX(i)) + fixup_first_4f( IM->Attrib[VERT_ATTRIB_TEX0 + i], IM->Flag, + VERT_TEX(i), start, + ctx->Current.Attrib[VERT_ATTRIB_TEX0 + i] ); + } } + if (fixup & VERT_EDGEFLAG_BIT) + fixup_first_1ub(IM->EdgeFlag, IM->Flag, VERT_EDGEFLAG_BIT, start, + ctx->Current.EdgeFlag ); + + if (fixup & VERT_INDEX_BIT) + fixup_first_1ui(IM->Index, IM->Flag, VERT_INDEX_BIT, start, + ctx->Current.Index ); + IM->CopyOrFlag |= fixup; } @@ -803,18 +840,19 @@ void _tnl_upgrade_current_data( GLcontext *ctx, struct gl_client_array *tmp = &tnl->imm_inputs.Color; GLuint start = IM->CopyStart; - tmp->Ptr = IM->Color + start; + tmp->Ptr = IM->Attrib[VERT_ATTRIB_COLOR0] + start; tmp->StrideB = 4 * sizeof(GLfloat); tmp->Flags = 0; - COPY_4FV( IM->Color[start], ctx->Current.Attrib[VERT_ATTRIB_COLOR0]); + COPY_4FV( IM->Attrib[VERT_ATTRIB_COLOR0][start], + ctx->Current.Attrib[VERT_ATTRIB_COLOR0]); /* ASSERT(IM->Flag[IM->LastData+1] & VERT_END_VB); */ - fixup_first_4f( IM->Color, IM->Flag, VERT_END_VB, start, - IM->Color[start] ); + fixup_first_4f( IM->Attrib[VERT_ATTRIB_COLOR0], IM->Flag, VERT_END_VB, + start, IM->Attrib[VERT_ATTRIB_COLOR0][start] ); VB->importable_data &= ~VERT_COLOR0_BIT; } diff --git a/src/mesa/tnl/t_vb_fog.c b/src/mesa/tnl/t_vb_fog.c index eebeba265b3..b7876a4db9d 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.14 2001/12/18 04:06:46 brianp Exp $ */ +/* $Id: t_vb_fog.c,v 1.15 2002/01/05 20:51:13 brianp Exp $ */ /* * Mesa 3-D graphics library @@ -43,8 +43,8 @@ struct fog_stage_data { - GLvector1f fogcoord; /* has actual storage allocated */ - GLvector1f input; /* points into VB->EyePtr Z values */ + GLvector4f fogcoord; /* has actual storage allocated */ + GLvector4f input; /* points into VB->EyePtr Z values */ }; #define FOG_STAGE_DATA(stage) ((struct fog_stage_data *)stage->privatePtr) @@ -85,14 +85,14 @@ static void init_static_data( void ) } -static void make_win_fog_coords( GLcontext *ctx, GLvector1f *out, - const GLvector1f *in ) +static void make_win_fog_coords( GLcontext *ctx, GLvector4f *out, + const GLvector4f *in ) { GLfloat end = ctx->Fog.End; GLfloat *v = in->start; GLuint stride = in->stride; GLuint n = in->count; - GLfloat *data = out->data; + GLfloat (*data)[4] = out->data; GLfloat d; GLuint i; @@ -106,19 +106,19 @@ static void make_win_fog_coords( GLcontext *ctx, GLvector1f *out, d = 1.0F / (ctx->Fog.End - ctx->Fog.Start); for ( i = 0 ; i < n ; i++, STRIDE_F(v, stride)) { GLfloat f = (end - ABSF(*v)) * d; - data[i] = CLAMP(f, 0.0F, 1.0F); + data[i][0] = CLAMP(f, 0.0F, 1.0F); } break; case GL_EXP: d = ctx->Fog.Density; for ( i = 0 ; i < n ; i++, STRIDE_F(v,stride)) - NEG_EXP( data[i], d * ABSF(*v) ); + NEG_EXP( data[i][0], d * ABSF(*v) ); break; case GL_EXP2: d = ctx->Fog.Density*ctx->Fog.Density; for ( i = 0 ; i < n ; i++, STRIDE_F(v, stride)) { GLfloat z = *v; - NEG_EXP( data[i], d * z * z ); + NEG_EXP( data[i][0], d * z * z ); } break; default: @@ -133,7 +133,7 @@ static GLboolean run_fog_stage( GLcontext *ctx, { struct vertex_buffer *VB = &TNL_CONTEXT(ctx)->vb; struct fog_stage_data *store = FOG_STAGE_DATA(stage); - GLvector1f *input; + GLvector4f *input; if (stage->changed_inputs == 0) return GL_TRUE; @@ -142,7 +142,7 @@ static GLboolean run_fog_stage( GLcontext *ctx, /* fog computed from Z depth */ /* source = VB->ObjPtr or VB->EyePtr coords */ /* dest = VB->FogCoordPtr = fog stage private storage */ - VB->FogCoordPtr = &store->fogcoord; + VB->AttribPtr[VERT_ATTRIB_FOG] = &store->fogcoord; if (!ctx->_NeedEyeCoords) { const GLfloat *m = ctx->ModelviewMatrixStack.Top->m; @@ -160,8 +160,8 @@ static GLboolean run_fog_stage( GLcontext *ctx, /* Full eye coords weren't required, just calculate the * eye Z values. */ - _mesa_dotprod_tab[VB->ObjPtr->size]( input->data, - sizeof(GLfloat), + _mesa_dotprod_tab[VB->ObjPtr->size]( (GLfloat *) input->data, + 4 * sizeof(GLfloat), VB->ObjPtr, plane ); input->count = VB->ObjPtr->count; @@ -172,7 +172,7 @@ static GLboolean run_fog_stage( GLcontext *ctx, if (VB->EyePtr->size < 2) _mesa_vector4f_clean_elem( VB->EyePtr, VB->Count, 2 ); - input->data = &(VB->EyePtr->data[0][2]); + input->data = (GLfloat (*)[4]) &(VB->EyePtr->data[0][2]); input->start = VB->EyePtr->start+2; input->stride = VB->EyePtr->stride; input->count = VB->EyePtr->count; @@ -181,12 +181,12 @@ static GLboolean run_fog_stage( GLcontext *ctx, else { /* use glFogCoord() coordinates */ /* source = VB->FogCoordPtr */ - input = VB->FogCoordPtr; + input = VB->AttribPtr[VERT_ATTRIB_FOG]; /* dest = fog stage private storage */ - VB->FogCoordPtr = &store->fogcoord; + VB->AttribPtr[VERT_ATTRIB_FOG] = &store->fogcoord; } - make_win_fog_coords( ctx, VB->FogCoordPtr, input ); + make_win_fog_coords( ctx, VB->AttribPtr[VERT_ATTRIB_FOG], input ); return GL_TRUE; } @@ -214,8 +214,8 @@ static GLboolean alloc_fog_data( GLcontext *ctx, if (!store) return GL_FALSE; - _mesa_vector1f_alloc( &store->fogcoord, 0, tnl->vb.Size, 32 ); - _mesa_vector1f_init( &store->input, 0, 0 ); + _mesa_vector4f_alloc( &store->fogcoord, 0, tnl->vb.Size, 32 ); + _mesa_vector4f_init( &store->input, 0, 0 ); if (!inited) init_static_data(); @@ -231,7 +231,7 @@ static void free_fog_data( struct gl_pipeline_stage *stage ) { struct fog_stage_data *store = FOG_STAGE_DATA(stage); if (store) { - _mesa_vector1f_free( &store->fogcoord ); + _mesa_vector4f_free( &store->fogcoord ); FREE( store ); stage->privatePtr = NULL; } diff --git a/src/mesa/tnl/t_vb_lighttmp.h b/src/mesa/tnl/t_vb_lighttmp.h index d1f5bef0422..85321803094 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.22 2002/01/05 14:03:33 brianp Exp $ */ +/* $Id: t_vb_lighttmp.h,v 1.23 2002/01/05 20:51:13 brianp Exp $ */ /* * Mesa 3-D graphics library @@ -32,7 +32,7 @@ #if (IDX & LIGHT_FLAGS) # define VSTRIDE (4 * sizeof(GLfloat)) -# define NSTRIDE (3 * sizeof(GLfloat)) +# define NSTRIDE nstride /*(3 * sizeof(GLfloat))*/ # define CHECK_MATERIAL(x) (flags[x] & VERT_MATERIAL) # define CHECK_END_VB(x) (flags[x] & VERT_END_VB) # if (IDX & LIGHT_COLORMATERIAL) diff --git a/src/mesa/tnl/t_vb_normals.c b/src/mesa/tnl/t_vb_normals.c index 457acd2b522..da814a4e0ed 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.11 2001/12/18 04:06:46 brianp Exp $ */ +/* $Id: t_vb_normals.c,v 1.12 2002/01/05 20:51:13 brianp Exp $ */ /* * Mesa 3-D graphics library @@ -45,7 +45,7 @@ struct normal_stage_data { normal_func NormalTransform; - GLvector3f normal; + GLvector4f normal; }; #define NORMAL_STAGE_DATA(stage) ((struct normal_stage_data *)stage->privatePtr) @@ -146,7 +146,7 @@ static GLboolean alloc_normal_data( GLcontext *ctx, if (!store) return GL_FALSE; - _mesa_vector3f_alloc( &store->normal, 0, tnl->vb.Size, 32 ); + _mesa_vector4f_alloc( &store->normal, 0, tnl->vb.Size, 32 ); /* Now run the stage. */ @@ -160,7 +160,7 @@ static void free_normal_data( struct gl_pipeline_stage *stage ) { struct normal_stage_data *store = NORMAL_STAGE_DATA(stage); if (store) { - _mesa_vector3f_free( &store->normal ); + _mesa_vector4f_free( &store->normal ); FREE( store ); stage->privatePtr = NULL; } diff --git a/src/mesa/tnl/t_vb_program.c b/src/mesa/tnl/t_vb_program.c index aea3c868aca..a711c96c43e 100644 --- a/src/mesa/tnl/t_vb_program.c +++ b/src/mesa/tnl/t_vb_program.c @@ -1,10 +1,10 @@ -/* $Id: t_vb_program.c,v 1.5 2001/12/18 04:06:46 brianp Exp $ */ +/* $Id: t_vb_program.c,v 1.6 2002/01/05 20:51:13 brianp Exp $ */ /* * Mesa 3-D graphics library * Version: 4.1 * - * Copyright (C) 1999-2001 Brian Paul All Rights Reserved. + * Copyright (C) 1999-2002 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"), @@ -99,610 +99,13 @@ -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); - - /* 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; /* post-modelview/projection coords */ GLvector4f ndcCoords; /* normalized device coords */ 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; + GLvector4f fogCoord; GLvector1f pointSize; GLubyte *clipmask; GLubyte ormask, andmask; @@ -726,7 +129,7 @@ static GLboolean run_vp( GLcontext *ctx, struct gl_pipeline_stage *stage ) GLfloat (*color1)[4] = (GLfloat (*)[4]) store->color1[0].Ptr; GLfloat (*bfcolor0)[4] = (GLfloat (*)[4]) store->color0[1].Ptr; GLfloat (*bfcolor1)[4] = (GLfloat (*)[4]) store->color1[1].Ptr; - GLfloat *fog = (GLfloat *) store->fogCoord.data; + GLfloat (*fog)[4] = (GLfloat (*)[4]) store->fogCoord.data; GLfloat *pointSize = (GLfloat *) store->pointSize.data; GLfloat (*texture0)[4] = (GLfloat (*)[4]) store->texCoord[0].data; GLfloat (*texture1)[4] = (GLfloat (*)[4]) store->texCoord[1].data; @@ -758,7 +161,7 @@ static GLboolean run_vp( GLcontext *ctx, struct gl_pipeline_stage *stage ) #endif /* load the input attribute registers */ - for (attr = 0; attr < 16; attr++) { + for (attr = 0; attr < VERT_ATTRIB_MAX; attr++) { if (VB->Flag[i] & (1 << attr)) { COPY_4V(machine->Registers[VP_INPUT_REG_START + attr], VB->AttribPtr[attr]->data[i]); @@ -788,7 +191,7 @@ static GLboolean run_vp( GLcontext *ctx, struct gl_pipeline_stage *stage ) 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]; + fog[i][0] = 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]); @@ -803,7 +206,7 @@ static GLboolean run_vp( GLcontext *ctx, struct gl_pipeline_stage *stage ) VB->ColorPtr[1] = &store->color0[1]; VB->SecondaryColorPtr[0] = &store->color1[0]; VB->SecondaryColorPtr[1] = &store->color1[1]; - VB->FogCoordPtr = &store->fogCoord; + VB->AttribPtr[VERT_ATTRIB_FOG] = &store->fogCoord; VB->PointSizePtr = &store->pointSize; VB->TexCoordPtr[0] = &store->texCoord[0]; VB->TexCoordPtr[1] = &store->texCoord[1]; @@ -860,6 +263,7 @@ static GLboolean run_validate_program( GLcontext *ctx, struct gl_pipeline_stage *stage ) { #if 000 + /* XXX do we need any validation for vertex programs? */ GLuint ind = 0; light_func *tab; @@ -952,7 +356,7 @@ static GLboolean run_init_vp( GLcontext *ctx, 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_vector4f_alloc( &store->fogCoord, 0, size, 32 ); _mesa_vector1f_alloc( &store->pointSize, 0, size, 32 ); store->clipmask = (GLubyte *) ALIGN_MALLOC(sizeof(GLubyte)*size, 32 ); @@ -1006,7 +410,7 @@ static void dtr( struct gl_pipeline_stage *stage ) 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_vector4f_free( &store->fogCoord ); _mesa_vector1f_free( &store->pointSize ); ALIGN_FREE( store->clipmask ); diff --git a/src/mesa/tnl/t_vb_texgen.c b/src/mesa/tnl/t_vb_texgen.c index 90dff30752a..62898ab599e 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.10 2001/12/14 02:51:45 brianp Exp $ */ +/* $Id: t_vb_texgen.c,v 1.11 2002/01/05 20:51:13 brianp Exp $ */ /* * Mesa 3-D graphics library @@ -95,7 +95,7 @@ static GLuint all_bits[5] = { static void build_m3( GLfloat f[][3], GLfloat m[], - const GLvector3f *normal, + const GLvector4f *normal, const GLvector4f *eye ) { GLuint stride = eye->stride; @@ -122,7 +122,7 @@ static void build_m3( GLfloat f[][3], GLfloat m[], static void build_m2( GLfloat f[][3], GLfloat m[], - const GLvector3f *normal, + const GLvector4f *normal, const GLvector4f *eye ) { GLuint stride = eye->stride; @@ -152,7 +152,7 @@ static void build_m2( GLfloat f[][3], GLfloat m[], typedef void (*build_m_func)( GLfloat f[][3], GLfloat m[], - const GLvector3f *normal, + const GLvector4f *normal, const GLvector4f *eye ); @@ -171,7 +171,7 @@ static build_m_func build_m_tab[5] = { */ static void build_f3( GLfloat *f, GLuint fstride, - const GLvector3f *normal, + const GLvector4f *normal, const GLvector4f *eye ) { GLuint stride = eye->stride; @@ -198,7 +198,7 @@ static void build_f3( GLfloat *f, static void build_f2( GLfloat *f, GLuint fstride, - const GLvector3f *normal, + const GLvector4f *normal, const GLvector4f *eye ) { GLuint stride = eye->stride; @@ -226,7 +226,7 @@ static void build_f2( GLfloat *f, typedef void (*build_f_func)( GLfloat *f, GLuint fstride, - const GLvector3f *normal_vec, + const GLvector4f *normal_vec, const GLvector4f *eye ); @@ -281,7 +281,7 @@ static void texgen_normal_map_nv( GLcontext *ctx, struct vertex_buffer *VB = &TNL_CONTEXT(ctx)->vb; GLvector4f *in = VB->TexCoordPtr[unit]; GLvector4f *out = &store->texcoord[unit]; - GLvector3f *normal = VB->NormalPtr; + GLvector4f *normal = VB->NormalPtr; GLfloat (*texcoord)[4] = (GLfloat (*)[4])out->start; GLuint count = VB->Count; GLuint i; @@ -362,7 +362,7 @@ static void texgen( GLcontext *ctx, struct gl_texture_unit *texUnit = &ctx->Texture.Unit[unit]; const GLvector4f *obj = VB->ObjPtr; const GLvector4f *eye = VB->EyePtr; - const GLvector3f *normal = VB->NormalPtr; + const GLvector4f *normal = VB->NormalPtr; GLfloat (*texcoord)[4] = (GLfloat (*)[4])out->data; GLfloat *indata; GLuint count = VB->Count; |