diff options
author | Keith Whitwell <[email protected]> | 2001-04-28 08:39:17 +0000 |
---|---|---|
committer | Keith Whitwell <[email protected]> | 2001-04-28 08:39:17 +0000 |
commit | 51c0c71811508b6658e0d5dcff8426b618322a73 (patch) | |
tree | 05ccb4905625b200ed1a5de00acb2295e1babec9 /src/mesa/tnl | |
parent | 27b0758a940f19ce344f21b8db708d91933ce06d (diff) |
Support for floating point color representation in tnl module.
Diffstat (limited to 'src/mesa/tnl')
-rw-r--r-- | src/mesa/tnl/t_array_api.c | 8 | ||||
-rw-r--r-- | src/mesa/tnl/t_array_import.c | 114 | ||||
-rw-r--r-- | src/mesa/tnl/t_array_import.h | 3 | ||||
-rw-r--r-- | src/mesa/tnl/t_context.h | 14 | ||||
-rw-r--r-- | src/mesa/tnl/t_imm_api.c | 127 | ||||
-rw-r--r-- | src/mesa/tnl/t_imm_debug.c | 6 | ||||
-rw-r--r-- | src/mesa/tnl/t_imm_elt.c | 41 | ||||
-rw-r--r-- | src/mesa/tnl/t_imm_eval.c | 127 | ||||
-rw-r--r-- | src/mesa/tnl/t_imm_exec.c | 48 | ||||
-rw-r--r-- | src/mesa/tnl/t_imm_fixup.c | 91 | ||||
-rw-r--r-- | src/mesa/tnl/t_imm_fixup.h | 12 | ||||
-rw-r--r-- | src/mesa/tnl/t_vb_cliptmp.h | 58 | ||||
-rw-r--r-- | src/mesa/tnl/t_vb_light.c | 43 | ||||
-rw-r--r-- | src/mesa/tnl/t_vb_lighttmp.h | 274 | ||||
-rw-r--r-- | src/mesa/tnl/t_vb_render.c | 23 |
15 files changed, 462 insertions, 527 deletions
diff --git a/src/mesa/tnl/t_array_api.c b/src/mesa/tnl/t_array_api.c index e2697730426..95d1f455485 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.11 2001/04/26 14:51:06 keithw Exp $ */ +/* $Id: t_array_api.c,v 1.12 2001/04/28 08:39:18 keithw Exp $ */ /* * Mesa 3-D graphics library @@ -417,9 +417,9 @@ 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_vector4chan_init( &tmp->Color, 0, 0 ); - _mesa_vector4chan_init( &tmp->SecondaryColor, 0, 0 ); + _mesa_vector3f_init( &tmp->Normal, 0, 0 ); +/* _mesa_vector4chan_init( &tmp->Color, 0, 0 ); */ +/* _mesa_vector4chan_init( &tmp->SecondaryColor, 0, 0 ); */ _mesa_vector1f_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 7bb208cf725..78ba9175705 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.13 2001/04/26 14:53:48 keithw Exp $ */ +/* $Id: t_array_import.c,v 1.14 2001/04/28 08:39:18 keithw Exp $ */ /* * Mesa 3-D graphics library @@ -43,8 +43,8 @@ static void _tnl_import_vertex( GLcontext *ctx, - GLboolean writeable, - GLboolean stride ) + GLboolean writeable, + GLboolean stride ) { struct gl_client_array *tmp; GLboolean is_writeable = 0; @@ -69,8 +69,8 @@ static void _tnl_import_vertex( GLcontext *ctx, } static void _tnl_import_normal( GLcontext *ctx, - GLboolean writeable, - GLboolean stride ) + GLboolean writeable, + GLboolean stride ) { struct gl_client_array *tmp; GLboolean is_writeable = 0; @@ -92,6 +92,7 @@ static void _tnl_import_normal( GLcontext *ctx, static void _tnl_import_color( GLcontext *ctx, + GLenum type, GLboolean writeable, GLboolean stride ) { @@ -102,50 +103,38 @@ static void _tnl_import_color( GLcontext *ctx, /* fprintf(stderr, "%s\n", __FUNCTION__); */ tmp = _ac_import_color(ctx, - GL_UNSIGNED_BYTE, - stride ? 4*sizeof(GLubyte) : 0, + type, + stride ? 4*sizeof(GLfloat) : 0, 4, writeable, &is_writeable); - inputs->Color.data = (GLchan (*)[4]) tmp->Ptr; - inputs->Color.start = (GLchan *) tmp->Ptr; - inputs->Color.stride = tmp->StrideB; - inputs->Color.flags &= ~(VEC_BAD_STRIDE|VEC_NOT_WRITEABLE); - if (inputs->Color.stride != 4*sizeof(GLchan)) - inputs->Color.flags |= VEC_BAD_STRIDE; - if (!is_writeable) - inputs->Color.flags |= VEC_NOT_WRITEABLE; + inputs->Color = *tmp; } static void _tnl_import_secondarycolor( GLcontext *ctx, - GLboolean writeable, - GLboolean stride ) + GLenum type, + GLboolean writeable, + GLboolean stride ) { struct gl_client_array *tmp; GLboolean is_writeable = 0; struct vertex_arrays *inputs = &TNL_CONTEXT(ctx)->array_inputs; - tmp = _ac_import_secondarycolor(ctx, GL_UNSIGNED_BYTE, - stride ? 4*sizeof(GLubyte) : 0, + tmp = _ac_import_secondarycolor(ctx, + type, + stride ? 4*sizeof(GLfloat) : 0, 4, writeable, &is_writeable); - inputs->SecondaryColor.data = (GLchan (*)[4]) tmp->Ptr; - inputs->SecondaryColor.start = (GLchan *) tmp->Ptr; - inputs->SecondaryColor.stride = tmp->StrideB; - inputs->SecondaryColor.flags &= ~(VEC_BAD_STRIDE|VEC_NOT_WRITEABLE); - if (inputs->SecondaryColor.stride != 4*sizeof(GLubyte)) - inputs->SecondaryColor.flags |= VEC_BAD_STRIDE; - if (!is_writeable) - inputs->SecondaryColor.flags |= VEC_NOT_WRITEABLE; + inputs->SecondaryColor = *tmp; } static void _tnl_import_fogcoord( GLcontext *ctx, - GLboolean writeable, - GLboolean stride ) + GLboolean writeable, + GLboolean stride ) { struct vertex_arrays *inputs = &TNL_CONTEXT(ctx)->array_inputs; struct gl_client_array *tmp; @@ -166,8 +155,8 @@ static void _tnl_import_fogcoord( GLcontext *ctx, } static void _tnl_import_index( GLcontext *ctx, - GLboolean writeable, - GLboolean stride ) + GLboolean writeable, + GLboolean stride ) { struct vertex_arrays *inputs = &TNL_CONTEXT(ctx)->array_inputs; struct gl_client_array *tmp; @@ -189,9 +178,9 @@ static void _tnl_import_index( GLcontext *ctx, static void _tnl_import_texcoord( GLcontext *ctx, - GLuint i, - GLboolean writeable, - GLboolean stride ) + GLuint i, + GLboolean writeable, + GLboolean stride ) { struct vertex_arrays *inputs = &TNL_CONTEXT(ctx)->array_inputs; struct gl_client_array *tmp; @@ -216,8 +205,8 @@ static void _tnl_import_texcoord( GLcontext *ctx, static void _tnl_import_edgeflag( GLcontext *ctx, - GLboolean writeable, - GLboolean stride ) + GLboolean writeable, + GLboolean stride ) { struct vertex_arrays *inputs = &TNL_CONTEXT(ctx)->array_inputs; struct gl_client_array *tmp; @@ -253,8 +242,11 @@ static void _tnl_upgrade_client_data( GLcontext *ctx, GLboolean writeable = (flags & VEC_NOT_WRITEABLE) != 0; GLboolean stride = (flags & VEC_BAD_STRIDE) != 0; struct vertex_arrays *inputs = &TNL_CONTEXT(ctx)->array_inputs; + GLuint ca_flags = 0; (void) inputs; + if (writeable || stride) ca_flags |= CA_CLIENT_DATA; + if ((required & VERT_CLIP) && VB->ClipPtr == VB->ObjPtr) required |= VERT_OBJ; @@ -272,15 +264,16 @@ static void _tnl_upgrade_client_data( GLcontext *ctx, VB->importable_data &= ~VERT_NORM; } - if ((required & VERT_RGBA) && (VB->ColorPtr[0]->flags & flags)) { + if ((required & VERT_RGBA) && (VB->ColorPtr[0]->Flags & ca_flags)) { ASSERT(VB->ColorPtr[0] == &inputs->Color); - _tnl_import_color( ctx, writeable, stride ); + _tnl_import_color( ctx, GL_FLOAT, writeable, stride ); VB->importable_data &= ~VERT_RGBA; } - if ((required & VERT_SPEC_RGB) && (VB->SecondaryColorPtr[0]->flags&flags)) { + if ((required & VERT_SPEC_RGB) && + (VB->SecondaryColorPtr[0]->Flags & ca_flags)) { ASSERT(VB->SecondaryColorPtr[0] == &inputs->SecondaryColor); - _tnl_import_secondarycolor( ctx, writeable, stride ); + _tnl_import_secondarycolor( ctx, GL_FLOAT, writeable, stride ); VB->importable_data &= ~VERT_SPEC_RGB; } @@ -308,8 +301,6 @@ static void _tnl_upgrade_client_data( GLcontext *ctx, - - void _tnl_vb_bind_arrays( GLcontext *ctx, GLint start, GLsizei count ) { TNLcontext *tnl = TNL_CONTEXT(ctx); @@ -360,11 +351,13 @@ void _tnl_vb_bind_arrays( GLcontext *ctx, GLint start, GLsizei count ) if (inputs & VERT_RGBA) { if (imports & VERT_RGBA) { - _tnl_import_color( ctx, 0, 0 ); - tmp->Color.count = VB->Count; + _tnl_import_color( ctx, 0, 0, 0 ); } VB->ColorPtr[0] = &tmp->Color; VB->ColorPtr[1] = 0; +/* fprintf(stderr, "VB->ColorPtr[0]->StrideB %d Type %s\n", */ +/* VB->ColorPtr[0]->StrideB, */ +/* _mesa_lookup_enum_by_nr(VB->ColorPtr[0]->Type)); */ } if (inputs & VERT_INDEX) { @@ -392,9 +385,9 @@ void _tnl_vb_bind_arrays( GLcontext *ctx, GLint start, GLsizei count ) if (inputs & VERT_SPEC_RGB) { if (imports & VERT_SPEC_RGB) { - _tnl_import_secondarycolor( ctx, 0, 0 ); - tmp->SecondaryColor.count = VB->Count; + _tnl_import_secondarycolor( ctx, 0, 0, 0 ); } + VB->SecondaryColorPtr[0] = &tmp->SecondaryColor; VB->SecondaryColorPtr[1] = 0; } @@ -414,9 +407,10 @@ void _tnl_vb_bind_arrays( GLcontext *ctx, GLint start, GLsizei count ) VB->Primitive = tnl->tmp_primitive; VB->PrimitiveLength = tnl->tmp_primitive_length; VB->import_data = _tnl_upgrade_client_data; - VB->importable_data = imports & VERT_FIXUP; -/* _tnl_print_vert_flags("_tnl_vb_bind_arrays: importable", VB->importable_data); */ + VB->importable_data = inputs & VERT_FIXUP; +/* _tnl_print_vert_flags("_tnl_vb_bind_arrays: importable", */ +/* VB->importable_data); */ } @@ -469,21 +463,21 @@ void _tnl_fill_immediate_drawarrays( GLcontext *ctx, struct immediate *IM, } if (required & VERT_RGBA) { - _math_trans_4chan( IM->Color + IM->Start, - ctx->Array.Color.Ptr, - ctx->Array.Color.StrideB, - ctx->Array.Color.Type, - ctx->Array.Color.Size, - start, n ); + _math_trans_4f( IM->Color + IM->Start, + ctx->Array.Color.Ptr, + ctx->Array.Color.StrideB, + ctx->Array.Color.Type, + ctx->Array.Color.Size, + start, n ); } if (required & VERT_SPEC_RGB) { - _math_trans_4chan( IM->SecondaryColor + IM->Start, - ctx->Array.SecondaryColor.Ptr, - ctx->Array.SecondaryColor.StrideB, - ctx->Array.SecondaryColor.Type, - ctx->Array.SecondaryColor.Size, - start, n ); + _math_trans_4f( IM->SecondaryColor + IM->Start, + ctx->Array.SecondaryColor.Ptr, + ctx->Array.SecondaryColor.StrideB, + ctx->Array.SecondaryColor.Type, + ctx->Array.SecondaryColor.Size, + start, n ); } if (required & VERT_FOG_COORD) { diff --git a/src/mesa/tnl/t_array_import.h b/src/mesa/tnl/t_array_import.h index 1236850b91d..fbcb795d3b7 100644 --- a/src/mesa/tnl/t_array_import.h +++ b/src/mesa/tnl/t_array_import.h @@ -1,4 +1,4 @@ -/* $Id: t_array_import.h,v 1.2 2001/03/12 00:48:43 gareth Exp $ */ +/* $Id: t_array_import.h,v 1.3 2001/04/28 08:39:18 keithw Exp $ */ /* * Mesa 3-D graphics library @@ -38,5 +38,4 @@ extern void _tnl_fill_immediate_drawarrays( GLcontext *ctx, extern void _tnl_array_import_init( GLcontext *ctx ); - #endif diff --git a/src/mesa/tnl/t_context.h b/src/mesa/tnl/t_context.h index 7e5c0de3635..5b57fe86354 100644 --- a/src/mesa/tnl/t_context.h +++ b/src/mesa/tnl/t_context.h @@ -1,4 +1,4 @@ -/* $Id: t_context.h,v 1.20 2001/04/26 14:53:48 keithw Exp $ */ +/* $Id: t_context.h,v 1.21 2001/04/28 08:39:18 keithw Exp $ */ /* * Mesa 3-D graphics library @@ -201,14 +201,14 @@ struct immediate GLuint Primitive[IMM_SIZE]; /* BEGIN/END */ GLuint PrimitiveLength[IMM_SIZE]; /* BEGIN/END */ GLuint Flag[IMM_SIZE]; /* VERT_* flags */ - GLchan Color[IMM_SIZE][4]; + GLfloat Color[IMM_SIZE][4]; GLfloat Obj[IMM_SIZE][4]; GLfloat Normal[IMM_SIZE][3]; GLfloat TexCoord0[IMM_SIZE][4]; /* just VERT_TEX0 */ GLuint Elt[IMM_SIZE]; GLubyte EdgeFlag[IMM_SIZE]; GLuint Index[IMM_SIZE]; - GLchan SecondaryColor[IMM_SIZE][4]; + GLfloat SecondaryColor[IMM_SIZE][4]; GLfloat FogCoord[IMM_SIZE]; }; @@ -217,8 +217,8 @@ struct vertex_arrays { GLvector4f Obj; GLvector3f Normal; - GLvector4chan Color; - GLvector4chan SecondaryColor; + struct gl_client_array Color; + struct gl_client_array SecondaryColor; GLvector1ui Index; GLvector1ub EdgeFlag; GLvector4f TexCoord[MAX_TEXTURE_UNITS]; @@ -256,8 +256,8 @@ typedef struct vertex_buffer GLboolean *EdgeFlag; /* VERT_EDGE */ GLvector4f *TexCoordPtr[MAX_TEXTURE_UNITS]; /* VERT_TEX_0..n */ GLvector1ui *IndexPtr[2]; /* VERT_INDEX */ - GLvector4chan *ColorPtr[2]; /* VERT_RGBA */ - GLvector4chan *SecondaryColorPtr[2]; /* VERT_SPEC_RGB */ + struct gl_client_array *ColorPtr[2]; /* VERT_RGBA */ + struct gl_client_array *SecondaryColorPtr[2]; /* VERT_SPEC_RGB */ GLvector1f *FogCoordPtr; /* VERT_FOG_COORD */ GLvector1f *PointSizePtr; /* VERT_POINT_SIZE */ GLmaterial (*Material)[2]; /* VERT_MATERIAL, optional */ diff --git a/src/mesa/tnl/t_imm_api.c b/src/mesa/tnl/t_imm_api.c index 375e4b63090..5b4630881bb 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.10 2001/04/09 14:47:34 keithw Exp $ */ +/* $Id: t_imm_api.c,v 1.11 2001/04/28 08:39:18 keithw Exp $ */ /* * Mesa 3-D graphics library @@ -348,56 +348,29 @@ _tnl_End(void) IM->Color[count][3] = a; \ } -#define COLORV( IM, v ) \ -{ \ - GLuint count = IM->Count; \ - IM->Flag[count] |= VERT_RGBA; \ - COPY_CHAN4(IM->Color[count], v); \ -} - - static void _tnl_Color3f( GLfloat red, GLfloat green, GLfloat blue ) { - GLchan col[4]; GET_IMMEDIATE; - UNCLAMPED_FLOAT_TO_CHAN(col[0], red); - UNCLAMPED_FLOAT_TO_CHAN(col[1], green); - UNCLAMPED_FLOAT_TO_CHAN(col[2], blue); - col[3] = CHAN_MAX; - COLORV( IM, col ); + COLOR( IM, red, green, blue, 1.0 ); } - static void _tnl_Color3ub( GLubyte red, GLubyte green, GLubyte blue ) { -#if CHAN_BITS == 8 - GET_IMMEDIATE; - COLOR( IM, red, green, blue, CHAN_MAX ); -#else GET_IMMEDIATE; COLOR(IM, - UBYTE_TO_CHAN(red), - UBYTE_TO_CHAN(green), - UBYTE_TO_CHAN(blue), - CHAN_MAX); -#endif + UBYTE_TO_FLOAT(red), + UBYTE_TO_FLOAT(green), + UBYTE_TO_FLOAT(blue), + 1.0); } - - - static void _tnl_Color4f( GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha ) { - GLchan col[4]; GET_IMMEDIATE; - UNCLAMPED_FLOAT_TO_CHAN(col[0], red); - UNCLAMPED_FLOAT_TO_CHAN(col[1], green); - UNCLAMPED_FLOAT_TO_CHAN(col[2], blue); - UNCLAMPED_FLOAT_TO_CHAN(col[3], alpha); - COLORV( IM, col ); + COLOR( IM, red, green, blue, alpha ); } static void @@ -405,61 +378,46 @@ _tnl_Color4ub( GLubyte red, GLubyte green, GLubyte blue, GLubyte alpha ) { GET_IMMEDIATE; COLOR(IM, - UBYTE_TO_CHAN(red), - UBYTE_TO_CHAN(green), - UBYTE_TO_CHAN(blue), - UBYTE_TO_CHAN(alpha)); + UBYTE_TO_FLOAT(red), + UBYTE_TO_FLOAT(green), + UBYTE_TO_FLOAT(blue), + UBYTE_TO_FLOAT(alpha)); } - static void _tnl_Color3fv( const GLfloat *v ) { - GLchan col[4]; GET_IMMEDIATE; - UNCLAMPED_FLOAT_TO_CHAN(col[0], v[0]); - UNCLAMPED_FLOAT_TO_CHAN(col[1], v[1]); - UNCLAMPED_FLOAT_TO_CHAN(col[2], v[2]); - col[3] = CHAN_MAX; - COLORV( IM, col ); + COLOR( IM, v[0], v[1], v[2], 1.0 ); } - - static void _tnl_Color3ubv( const GLubyte *v ) { GET_IMMEDIATE; COLOR(IM, - UBYTE_TO_CHAN(v[0]), - UBYTE_TO_CHAN(v[1]), - UBYTE_TO_CHAN(v[2]), - CHAN_MAX ); + UBYTE_TO_FLOAT(v[0]), + UBYTE_TO_FLOAT(v[1]), + UBYTE_TO_FLOAT(v[2]), + 1.0 ); } static void _tnl_Color4fv( const GLfloat *v ) { - GLchan col[4]; GET_IMMEDIATE; - UNCLAMPED_FLOAT_TO_CHAN(col[0], v[0]); - UNCLAMPED_FLOAT_TO_CHAN(col[1], v[1]); - UNCLAMPED_FLOAT_TO_CHAN(col[2], v[2]); - UNCLAMPED_FLOAT_TO_CHAN(col[3], v[3]); - COLORV( IM, col ); + COLOR( IM, v[0], v[1], v[2], v[3] ); } - - static void _tnl_Color4ubv( const GLubyte *v) { GET_IMMEDIATE; COLOR(IM, - UBYTE_TO_CHAN(v[0]), - UBYTE_TO_CHAN(v[1]), - UBYTE_TO_CHAN(v[2]), - UBYTE_TO_CHAN(v[3])); + UBYTE_TO_FLOAT(v[0]), + UBYTE_TO_FLOAT(v[1]), + UBYTE_TO_FLOAT(v[2]), + UBYTE_TO_FLOAT(v[3])); } @@ -474,65 +432,38 @@ _tnl_Color4ubv( const GLubyte *v) IM->SecondaryColor[count][2] = b; \ } -#define SECONDARY_COLORV( IM, v ) \ -{ \ - GLuint count = IM->Count; \ - IM->Flag[count] |= VERT_SPEC_RGB; \ - IM->SecondaryColor[count][0] = v[0]; \ - IM->SecondaryColor[count][1] = v[1]; \ - IM->SecondaryColor[count][2] = v[2]; \ -} - - - - static void _tnl_SecondaryColor3fEXT( GLfloat red, GLfloat green, GLfloat blue ) { - GLchan col[3]; GET_IMMEDIATE; - UNCLAMPED_FLOAT_TO_CHAN(col[0], red); - UNCLAMPED_FLOAT_TO_CHAN(col[1], green); - UNCLAMPED_FLOAT_TO_CHAN(col[2], blue); - SECONDARY_COLORV( IM, col ); + SECONDARY_COLOR( IM, red, green, blue ); } - - static void _tnl_SecondaryColor3ubEXT( GLubyte red, GLubyte green, GLubyte blue ) { GET_IMMEDIATE; SECONDARY_COLOR(IM, - UBYTE_TO_CHAN(red), - UBYTE_TO_CHAN(green), - UBYTE_TO_CHAN(blue)); + UBYTE_TO_FLOAT(red), + UBYTE_TO_FLOAT(green), + UBYTE_TO_FLOAT(blue)); } - - - static void _tnl_SecondaryColor3fvEXT( const GLfloat *v ) { - GLchan col[3]; GET_IMMEDIATE; - UNCLAMPED_FLOAT_TO_CHAN(col[0], v[0]); - UNCLAMPED_FLOAT_TO_CHAN(col[1], v[1]); - UNCLAMPED_FLOAT_TO_CHAN(col[2], v[2]); - SECONDARY_COLORV( IM, col ); + SECONDARY_COLOR( IM, v[0], v[1], v[2] ); } - - static void _tnl_SecondaryColor3ubvEXT( const GLubyte *v ) { GET_IMMEDIATE; SECONDARY_COLOR(IM, - UBYTE_TO_CHAN(v[0]), - UBYTE_TO_CHAN(v[1]), - UBYTE_TO_CHAN(v[2])); + UBYTE_TO_FLOAT(v[0]), + UBYTE_TO_FLOAT(v[1]), + UBYTE_TO_FLOAT(v[2])); } diff --git a/src/mesa/tnl/t_imm_debug.c b/src/mesa/tnl/t_imm_debug.c index ded4ee4d0c1..d641ee10493 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.2 2001/03/12 00:48:43 gareth Exp $ */ +/* $Id: t_imm_debug.c,v 1.3 2001/04/28 08:39:18 keithw Exp $ */ /* * Mesa 3-D graphics library @@ -125,12 +125,12 @@ void _tnl_print_cassette( struct immediate *IM ) } if (req & flags[i] & VERT_RGBA) - fprintf(stderr, " Rgba %d %d %d %d ", + fprintf(stderr, " Rgba %f %f %f %f ", IM->Color[i][0], IM->Color[i][1], IM->Color[i][2], IM->Color[i][3]); if (req & flags[i] & VERT_SPEC_RGB) - fprintf(stderr, " Spec %d %d %d ", + fprintf(stderr, " Spec %f %f %f ", IM->SecondaryColor[i][0], IM->SecondaryColor[i][1], IM->SecondaryColor[i][2]); diff --git a/src/mesa/tnl/t_imm_elt.c b/src/mesa/tnl/t_imm_elt.c index 1386ef16f7c..c339897bc95 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.7 2001/04/26 14:53:48 keithw Exp $ */ +/* $Id: t_imm_elt.c,v 1.8 2001/04/28 08:39:18 keithw Exp $ */ /* * Mesa 3-D graphics library @@ -647,6 +647,7 @@ static void _tnl_trans_elt_1ub(GLubyte *to, } +#if 0 static void _tnl_trans_elt_4ub(GLubyte (*to)[4], const struct gl_client_array *from, GLuint *flags, @@ -665,7 +666,9 @@ static void _tnl_trans_elt_4ub(GLubyte (*to)[4], n ); } +#endif +#if 0 static void _tnl_trans_elt_4us(GLushort (*to)[4], const struct gl_client_array *from, GLuint *flags, @@ -684,6 +687,7 @@ static void _tnl_trans_elt_4us(GLushort (*to)[4], n ); } +#endif static void _tnl_trans_elt_4f(GLfloat (*to)[4], const struct gl_client_array *from, @@ -704,25 +708,6 @@ static void _tnl_trans_elt_4f(GLfloat (*to)[4], } -static void _tnl_trans_elt_4chan(GLchan (*to)[4], - const struct gl_client_array *from, - GLuint *flags, - GLuint *elts, - GLuint match, - GLuint start, - GLuint n ) -{ -#if CHAN_TYPE == GL_UNSIGNED_BYTE - _tnl_trans_elt_4ub( to, from, flags, elts, match, start, n ); - (void)_tnl_trans_elt_4us; -#elif CHAN_TYPE == GL_UNSIGNED_SHORT - _tnl_trans_elt_4us( to, from, flags, elts, match, start, n ); -#elif CHAN_TYPE == GL_FLOAT - _tnl_trans_elt_4f( to, from, flags, elts, match, start, n ); - (void)_tnl_trans_elt_4us; -#endif -} - static void _tnl_trans_elt_3f(GLfloat (*to)[3], @@ -789,17 +774,17 @@ void _tnl_translate_array_elts( GLcontext *ctx, struct immediate *IM, start, count); if (translate & VERT_RGBA) { - _tnl_trans_elt_4chan( IM->Color, - &ctx->Array.Color, - flags, elts, (VERT_ELT|VERT_RGBA), - start, count); + _tnl_trans_elt_4f( IM->Color, + &ctx->Array.Color, + flags, elts, (VERT_ELT|VERT_RGBA), + start, count); } if (translate & VERT_SPEC_RGB) { - _tnl_trans_elt_4chan( IM->SecondaryColor, - &ctx->Array.SecondaryColor, - flags, elts, (VERT_ELT|VERT_SPEC_RGB), - start, count); + _tnl_trans_elt_4f( IM->SecondaryColor, + &ctx->Array.SecondaryColor, + flags, elts, (VERT_ELT|VERT_SPEC_RGB), + start, count); } if (translate & VERT_FOG_COORD) diff --git a/src/mesa/tnl/t_imm_eval.c b/src/mesa/tnl/t_imm_eval.c index 21529a42b5a..d06f702e5bc 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.7 2001/04/26 14:53:48 keithw Exp $ */ +/* $Id: t_imm_eval.c,v 1.8 2001/04/28 08:39:18 keithw Exp $ */ /* * Mesa 3-D graphics library @@ -85,10 +85,10 @@ static const GLubyte dirty_flags[5] = { static void eval1_4f( GLvector4f *dest, - GLfloat coord[][4], - const GLuint *flags, - GLuint dimension, - struct gl_1d_map *map ) + GLfloat coord[][4], + const GLuint *flags, + GLuint dimension, + struct gl_1d_map *map ) { const GLfloat u1 = map->u1; const GLfloat du = map->du; @@ -107,6 +107,31 @@ static void eval1_4f( GLvector4f *dest, dest->flags |= dirty_flags[dimension]; } +static void eval1_4f_ca( struct gl_client_array *dest, + GLfloat coord[][4], + const GLuint *flags, + GLuint dimension, + struct gl_1d_map *map ) +{ + const GLfloat u1 = map->u1; + const GLfloat du = map->du; + GLfloat (*to)[4] = (GLfloat (*)[4])dest->Ptr; + GLuint i; + + ASSERT(dest->Type == GL_FLOAT); + ASSERT(dest->StrideB == 4 * sizeof(GLfloat)); + + for (i = 0 ; !(flags[i] & VERT_END_VB) ; i++) + if (flags[i] & (VERT_EVAL_C1|VERT_EVAL_P1)) { + GLfloat u = (coord[i][0] - u1) * du; + ASSIGN_4V(to[i], 0,0,0,1); + _math_horner_bezier_curve(map->Points, to[i], u, + dimension, map->Order); + } + + dest->Size = MAX2(dest->Size, dimension); +} + static void eval1_1ui( GLvector1ui *dest, GLfloat coord[][4], @@ -145,25 +170,6 @@ static void eval1_norm( GLvector3f *dest, } } -static void eval1_color( GLvector4chan *dest, - GLfloat coord[][4], - const GLuint *flags, - struct gl_1d_map *map ) -{ - const GLfloat u1 = map->u1; - const GLfloat du = map->du; - GLchan (*to)[4] = dest->data; - GLuint i; - - for (i = 0 ; !(flags[i] & VERT_END_VB) ; i++) { - if (flags[i] & (VERT_EVAL_C1|VERT_EVAL_P1)) { - GLfloat u = (coord[i][0] - u1) * du; - GLfloat fcolor[4]; - _math_horner_bezier_curve(map->Points, fcolor, u, 4, map->Order); - UNCLAMPED_FLOAT_TO_RGBA_CHAN(to[i], fcolor); - } - } -} @@ -227,6 +233,33 @@ static void eval2_4f( GLvector4f *dest, dest->flags |= dirty_flags[dimension]; } +static void eval2_4f_ca( struct gl_client_array *dest, + GLfloat coord[][4], + const GLuint *flags, + GLuint dimension, + struct gl_2d_map *map ) +{ + const GLfloat u1 = map->u1; + const GLfloat du = map->du; + const GLfloat v1 = map->v1; + const GLfloat dv = map->dv; + GLfloat (*to)[4] = (GLfloat (*)[4])dest->Ptr; + GLuint i; + + ASSERT(dest->Type == GL_FLOAT); + ASSERT(dest->StrideB == 4 * sizeof(GLfloat)); + + 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, dimension, + map->Uorder, map->Vorder); + } + + dest->Size = MAX2(dest->Size, dimension); +} + static void eval2_norm( GLvector3f *dest, GLfloat coord[][4], @@ -277,29 +310,6 @@ static void eval2_1ui( GLvector1ui *dest, -static void eval2_color( GLvector4chan *dest, - GLfloat coord[][4], - GLuint *flags, - struct gl_2d_map *map ) -{ - const GLfloat u1 = map->u1; - const GLfloat du = map->du; - const GLfloat v1 = map->v1; - const GLfloat dv = map->dv; - GLchan (*to)[4] = dest->data; - GLuint 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; - GLfloat fcolor[4]; - _math_horner_bezier_surf(map->Points, fcolor, u, v, 4, - map->Uorder, map->Vorder); - UNCLAMPED_FLOAT_TO_RGBA_CHAN(to[i], fcolor); - } - } -} @@ -313,10 +323,6 @@ static void copy_3f( GLfloat to[][3], GLfloat from[][3], GLuint count ) MEMCPY( to, from, (count) * sizeof(to[0])); } -static void copy_4chan( GLchan to[][4], GLchan from[][4], GLuint count ) -{ - MEMCPY( to, from, (count) * sizeof(to[0])); -} static void copy_1ui( GLuint to[], GLuint from[], GLuint count ) { @@ -496,18 +502,17 @@ void _tnl_eval_vb( GLcontext *ctx, GLuint generated = 0; if (!all_eval) - copy_4chan( store->Color, tmp->Color.data, count ); + copy_4f( store->Color, (GLfloat (*)[4])tmp->Color.Ptr, count ); - tmp->Color.data = store->Color; - tmp->Color.start = (GLchan *) store->Color; + tmp->Color.Ptr = store->Color; if (ctx->Eval.Map1Color4 && any_eval1) { - eval1_color( &tmp->Color, coord, flags, &ctx->EvalMap.Map1Color4 ); + eval1_4f_ca( &tmp->Color, coord, flags, 4, &ctx->EvalMap.Map1Color4 ); generated |= VERT_EVAL_C1|VERT_EVAL_P1; } if (ctx->Eval.Map2Color4 && any_eval2) { - eval2_color( &tmp->Color, coord, flags, &ctx->EvalMap.Map2Color4 ); + eval2_4f_ca( &tmp->Color, coord, flags, 4, &ctx->EvalMap.Map2Color4 ); generated |= VERT_EVAL_C2|VERT_EVAL_P2; } @@ -515,11 +520,11 @@ void _tnl_eval_vb( GLcontext *ctx, * maps are disabled. */ if (purge_flags & generated) - _tnl_fixup_4chan( store->Color, flags, 0, - VERT_RGBA| - VERT_OBJ| - generated| - (VERT_EVAL_ANY&~purge_flags) ); + _tnl_fixup_4f( store->Color, flags, 0, + VERT_RGBA| + VERT_OBJ| + generated| + (VERT_EVAL_ANY&~purge_flags) ); } diff --git a/src/mesa/tnl/t_imm_exec.c b/src/mesa/tnl/t_imm_exec.c index a5752535908..18eaa488a35 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.17 2001/04/09 14:47:34 keithw Exp $ */ +/* $Id: t_imm_exec.c,v 1.18 2001/04/28 08:39:18 keithw Exp $ */ /* * Mesa 3-D graphics library @@ -109,7 +109,7 @@ void _tnl_copy_to_current( GLcontext *ctx, struct immediate *IM, ctx->Current.EdgeFlag = IM->EdgeFlag[count]; if (flag & VERT_RGBA) { - COPY_CHAN4(ctx->Current.Color, IM->Color[count]); + COPY_4FV(ctx->Current.Color, IM->Color[count]); if (ctx->Light.ColorMaterialEnabled) { _mesa_update_color_material( ctx, ctx->Current.Color ); _mesa_validate_all_lighting_tables( ctx ); @@ -117,7 +117,7 @@ void _tnl_copy_to_current( GLcontext *ctx, struct immediate *IM, } if (flag & VERT_SPEC_RGB) - COPY_CHAN4(ctx->Current.SecondaryColor, IM->SecondaryColor[count]); + COPY_4FV(ctx->Current.SecondaryColor, IM->SecondaryColor[count]); if (flag & VERT_FOG_COORD) ctx->Current.FogCoord = IM->FogCoord[count]; @@ -179,6 +179,9 @@ void _tnl_compute_orflag( struct immediate *IM ) + + + /* Note: The 'start' member of the GLvector structs is now redundant * because we always re-transform copied vertices, and the vectors * below are set up so that the first copied vertex (if any) appears @@ -268,9 +271,7 @@ static void _tnl_vb_bind_immediate( GLcontext *ctx, struct immediate *IM ) } if (inputs & VERT_SPEC_RGB) { - tmp->SecondaryColor.data = IM->SecondaryColor + start; - tmp->SecondaryColor.start = (GLchan *)(IM->SecondaryColor + start); - tmp->SecondaryColor.count = count; + tmp->SecondaryColor.Ptr = IM->SecondaryColor + start; VB->SecondaryColorPtr[0] = &tmp->SecondaryColor; } @@ -279,9 +280,17 @@ static void _tnl_vb_bind_immediate( GLcontext *ctx, struct immediate *IM ) } if (inputs & VERT_RGBA) { - tmp->Color.data = IM->Color + start; - tmp->Color.start = (GLchan *)(IM->Color + start); - tmp->Color.count = count; + if (IM->CopyOrFlag & VERT_RGBA) { + tmp->Color.Ptr = IM->Color + start; + tmp->Color.StrideB = 4 * sizeof(GLfloat); + tmp->Color.Flags = 0; + } else { + tmp->Color.Ptr = ctx->Current.Color; + tmp->Color.StrideB = 0; + tmp->Color.Flags = CA_CLIENT_DATA; /* hack */ + VB->importable_data |= VERT_RGBA; + VB->import_data = _tnl_upgrade_current_data; + } VB->ColorPtr[0] = &tmp->Color; } @@ -308,6 +317,10 @@ static void _tnl_vb_bind_immediate( GLcontext *ctx, struct immediate *IM ) VB->MaterialMask = IM->MaterialMask + start; VB->Material = IM->Material + start; } + +/* _tnl_print_vert_flags("_tnl_vb_bind_immediate: importable", */ +/* VB->importable_data); */ + } @@ -477,8 +490,21 @@ void _tnl_imm_init( GLcontext *ctx ) _mesa_vector4f_init( &tmp->Obj, 0, 0 ); _mesa_vector3f_init( &tmp->Normal, 0, 0 ); - _mesa_vector4chan_init( &tmp->Color, 0, 0 ); - _mesa_vector4chan_init( &tmp->SecondaryColor, 0, 0 ); + + tmp->Color.Ptr = 0; + tmp->Color.Type = GL_FLOAT; + tmp->Color.Size = 4; + tmp->Color.Stride = 0; + tmp->Color.StrideB = 4 * sizeof(GLfloat); + tmp->Color.Flags = 0; + + tmp->SecondaryColor.Ptr = 0; + tmp->SecondaryColor.Type = GL_FLOAT; + tmp->SecondaryColor.Size = 4; + tmp->SecondaryColor.Stride = 0; + tmp->SecondaryColor.StrideB = 4 * sizeof(GLfloat); + tmp->SecondaryColor.Flags = 0; + _mesa_vector1f_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 bfb1d306427..53e5dcbdc55 100644 --- a/src/mesa/tnl/t_imm_fixup.c +++ b/src/mesa/tnl/t_imm_fixup.c @@ -1,4 +1,4 @@ -/* $Id: t_imm_fixup.c,v 1.11 2001/04/26 14:53:48 keithw Exp $ */ +/* $Id: t_imm_fixup.c,v 1.12 2001/04/28 08:39:18 keithw Exp $ */ /* * Mesa 3-D graphics library @@ -126,21 +126,6 @@ _tnl_fixup_1ub( GLubyte *data, GLuint flag[], GLuint start, GLuint match ) } -void -_tnl_fixup_4chan( GLchan data[][4], GLuint flag[], GLuint start, GLuint match ) -{ - GLuint i = start; - - for (;;) { - if ((flag[++i] & match) == 0) { - COPY_CHAN4(data[i], data[i-1]); - if (flag[i] & VERT_END_VB) break; - } - } - flag[i] |= match; -} - - static void fixup_first_4f( GLfloat data[][4], GLuint flag[], GLuint match, GLuint start, GLfloat *dflt ) @@ -199,18 +184,6 @@ fixup_first_1ub( GLubyte data[], GLuint flag[], GLuint match, } -static void -fixup_first_4chan( GLchan data[][4], GLuint flag[], GLuint match, - GLuint start, GLchan dflt[4] ) -{ - GLuint i = start-1; - match |= VERT_END_VB; - - while ((flag[++i]&match) == 0) - COPY_CHAN4(data[i], dflt); -} - - void _tnl_fixup_input( GLcontext *ctx, struct immediate *IM ) { TNLcontext *tnl = TNL_CONTEXT(ctx); @@ -255,11 +228,11 @@ void _tnl_fixup_input( GLcontext *ctx, struct immediate *IM ) } if (copy & VERT_RGBA) { - COPY_CHAN4( IM->Color[start], ctx->Current.Color); + COPY_4FV( IM->Color[start], ctx->Current.Color); } if (copy & VERT_SPEC_RGB) - COPY_CHAN4( IM->SecondaryColor[start], ctx->Current.SecondaryColor); + COPY_4FV( IM->SecondaryColor[start], ctx->Current.SecondaryColor); if (copy & VERT_FOG_COORD) IM->FogCoord[start] = ctx->Current.FogCoord; @@ -315,19 +288,19 @@ void _tnl_fixup_input( GLcontext *ctx, struct immediate *IM ) if (fixup & VERT_RGBA) { if (orflag & VERT_RGBA) - _tnl_fixup_4chan( IM->Color, IM->Flag, start, VERT_RGBA ); - else - fixup_first_4chan( IM->Color, IM->Flag, VERT_END_VB, start, - IM->Color[start] ); + _tnl_fixup_4f( IM->Color, IM->Flag, start, VERT_RGBA ); +/* else */ +/* fixup_first_4f( IM->Color, IM->Flag, VERT_END_VB, start, */ +/* IM->Color[start] ); */ } if (fixup & VERT_SPEC_RGB) { if (orflag & VERT_SPEC_RGB) - _tnl_fixup_4chan( IM->SecondaryColor, IM->Flag, start, - VERT_SPEC_RGB ); + _tnl_fixup_4f( IM->SecondaryColor, IM->Flag, start, + VERT_SPEC_RGB ); else - fixup_first_4chan( IM->SecondaryColor, IM->Flag, VERT_END_VB, start, - IM->SecondaryColor[start] ); + fixup_first_4f( IM->SecondaryColor, IM->Flag, VERT_END_VB, start, + IM->SecondaryColor[start] ); } if (fixup & VERT_FOG_COORD) { @@ -422,7 +395,7 @@ static void copy_vertices( GLcontext *ctx, COPY_4FV( next->Obj[dst], prev->Obj[src] ); COPY_3FV( next->Normal[dst], prev->Normal[src] ); - COPY_CHAN4( next->Color[dst], prev->Color[src] ); + COPY_4FV( next->Color[dst], prev->Color[src] ); if (prev->OrFlag & VERT_TEX_ANY) { GLuint i; @@ -438,7 +411,7 @@ static void copy_vertices( GLcontext *ctx, next->Elt[dst] = prev->Elt[src]; next->EdgeFlag[dst] = prev->EdgeFlag[src]; next->Index[dst] = prev->Index[src]; - COPY_CHAN4( next->SecondaryColor[dst], prev->SecondaryColor[src] ); + COPY_4FV( next->SecondaryColor[dst], prev->SecondaryColor[src] ); next->FogCoord[dst] = prev->FogCoord[src]; next->Flag[dst] = (prev->CopyOrFlag & VERT_FIXUP); next->CopyOrFlag |= prev->Flag[src]; /* redundant for current_im */ @@ -550,12 +523,13 @@ void _tnl_fixup_compiled_cassette( GLcontext *ctx, struct immediate *IM ) ctx->Current.Index ); if (fixup & VERT_RGBA) - fixup_first_4chan(IM->Color, IM->Flag, VERT_RGBA, start, - ctx->Current.Color ); + if (IM->CopyOrFlag & VERT_RGBA) + fixup_first_4f(IM->Color, IM->Flag, VERT_RGBA, start, + ctx->Current.Color ); if (fixup & VERT_SPEC_RGB) - fixup_first_4chan(IM->SecondaryColor, IM->Flag, VERT_SPEC_RGB, start, - ctx->Current.SecondaryColor ); + fixup_first_4f(IM->SecondaryColor, IM->Flag, VERT_SPEC_RGB, start, + ctx->Current.SecondaryColor ); if (fixup & VERT_FOG_COORD) fixup_first_1f(IM->FogCoord, IM->Flag, VERT_FOG_COORD, start, @@ -795,7 +769,7 @@ void _tnl_fixup_purged_eval( GLcontext *ctx, struct immediate *IM ) GLenum prim = IM->Primitive[last]; GLuint pincr = increment[prim]; GLuint pintro = intro[prim]; - GLuint ovf, i; + GLuint ovf = 0, i; tnl->ExecCopyCount = 0; tnl->ExecParity = IM->PrimitiveLength[last] & 1; @@ -810,3 +784,30 @@ void _tnl_fixup_purged_eval( GLcontext *ctx, struct immediate *IM ) tnl->ExecCopyElts[i] = IM->Elt[tnl->ExecCopyElts[i]]; } } + + +void _tnl_upgrade_current_data( GLcontext *ctx, + GLuint required, + GLuint flags ) +{ + TNLcontext *tnl = TNL_CONTEXT(ctx); + struct immediate *IM = tnl->ExecCopySource; + struct vertex_buffer *VB = &tnl->vb; + +/* _tnl_print_vert_flags("_tnl_upgrade_client_data", required); */ + + if ((required & VERT_RGBA) && (VB->ColorPtr[0]->Flags & CA_CLIENT_DATA)) { + struct gl_client_array *tmp = &tnl->imm_inputs.Color; + GLuint start = IM->CopyStart; + + tmp->Ptr = IM->Color + start; + tmp->StrideB = 4 * sizeof(GLfloat); + tmp->Flags = 0; + + COPY_4FV( IM->Color[start], ctx->Current.Color); + fixup_first_4f( IM->Color, IM->Flag, VERT_END_VB, start, + IM->Color[start] ); + + VB->importable_data &= ~VERT_RGBA; + } +} diff --git a/src/mesa/tnl/t_imm_fixup.h b/src/mesa/tnl/t_imm_fixup.h index 939bba408b2..584712167f0 100644 --- a/src/mesa/tnl/t_imm_fixup.h +++ b/src/mesa/tnl/t_imm_fixup.h @@ -1,4 +1,4 @@ -/* $Id: t_imm_fixup.h,v 1.3 2001/04/26 14:53:48 keithw Exp $ */ +/* $Id: t_imm_fixup.h,v 1.4 2001/04/28 08:39:18 keithw Exp $ */ /* * Mesa 3-D graphics library @@ -31,9 +31,6 @@ #include "mtypes.h" #include "t_context.h" -extern void _tnl_fixup_4chan( GLchan data[][4], GLuint flag[], - GLuint start, GLuint match ); - extern void _tnl_fixup_1ub( GLubyte *data, GLuint flag[], GLuint start, GLuint match ); @@ -60,7 +57,12 @@ extern void _tnl_restore_compiled_cassette( GLcontext *ctx, extern void _tnl_fixup_purged_eval( GLcontext *ctx, struct immediate *IM ); -extern void _tnl_copy_immediate_vertices( GLcontext *ctx, struct immediate *IM ); +extern void _tnl_copy_immediate_vertices( GLcontext *ctx, + struct immediate *IM ); + extern void _tnl_get_exec_copy_verts( GLcontext *ctx, struct immediate *IM ); +extern void _tnl_upgrade_current_data( GLcontext *ctx, GLuint required, + GLuint flags ); + #endif diff --git a/src/mesa/tnl/t_vb_cliptmp.h b/src/mesa/tnl/t_vb_cliptmp.h index 6ecd1c3c605..5c64d964896 100644 --- a/src/mesa/tnl/t_vb_cliptmp.h +++ b/src/mesa/tnl/t_vb_cliptmp.h @@ -1,4 +1,4 @@ -/* $Id: t_vb_cliptmp.h,v 1.10 2001/03/19 02:25:37 keithw Exp $ */ +/* $Id: t_vb_cliptmp.h,v 1.11 2001/04/28 08:39:18 keithw Exp $ */ /* * Mesa 3-D graphics library @@ -58,13 +58,13 @@ do { \ * know dp != dpPrev from DIFFERENT_SIGNS, above. \ */ \ GLfloat t = dp / (dp - dpPrev); \ - LINTERP_4F( t, coord, newvert, idx, idxPrev, SIZE ); \ + INTERP_4F( t, coord[newvert], coord[idx], coord[idxPrev]); \ interp( ctx, t, newvert, idx, idxPrev, GL_TRUE ); \ } else { \ /* Coming back in. \ */ \ GLfloat t = dpPrev / (dpPrev - dp); \ - LINTERP_4F( t, coord, newvert, idxPrev, idx, SIZE ); \ + INTERP_4F( t, coord[newvert], coord[idxPrev], coord[idx]); \ interp( ctx, t, newvert, idxPrev, idx, GL_FALSE ); \ } \ } \ @@ -86,32 +86,32 @@ do { \ } while (0) -#define LINE_CLIP(PLANE, A, B, C, D ) \ -do { \ - if (mask & PLANE) { \ - GLfloat dpI = CLIP_DOTPROD( ii, A, B, C, D ); \ - GLfloat dpJ = CLIP_DOTPROD( jj, A, B, C, D ); \ - \ - if (DIFFERENT_SIGNS(dpI, dpJ)) { \ - GLuint newvert = VB->LastClipped++; \ - VB->ClipMask[newvert] = 0; \ - if (NEGATIVE(dpJ)) { \ - GLfloat t = dpI / (dpI - dpJ); \ - VB->ClipMask[jj] |= PLANE; \ - LINTERP_4F( t, coord, newvert, ii, jj, SIZE ); \ - interp( ctx, t, newvert, ii, jj, GL_FALSE ); \ - jj = newvert; \ - } else { \ - GLfloat t = dpJ / (dpJ - dpI); \ - VB->ClipMask[ii] |= PLANE; \ - LINTERP_4F( t, coord, newvert, jj, ii, SIZE ); \ - interp( ctx, t, newvert, jj, ii, GL_FALSE ); \ - ii = newvert; \ - } \ - } \ - else if (NEGATIVE(dpI)) \ - return; \ - } \ +#define LINE_CLIP(PLANE, A, B, C, D ) \ +do { \ + if (mask & PLANE) { \ + GLfloat dpI = CLIP_DOTPROD( ii, A, B, C, D ); \ + GLfloat dpJ = CLIP_DOTPROD( jj, A, B, C, D ); \ + \ + if (DIFFERENT_SIGNS(dpI, dpJ)) { \ + GLuint newvert = VB->LastClipped++; \ + VB->ClipMask[newvert] = 0; \ + if (NEGATIVE(dpJ)) { \ + GLfloat t = dpI / (dpI - dpJ); \ + VB->ClipMask[jj] |= PLANE; \ + INTERP_4F( t, coord[newvert], coord[ii], coord[jj] ); \ + interp( ctx, t, newvert, ii, jj, GL_FALSE ); \ + jj = newvert; \ + } else { \ + GLfloat t = dpJ / (dpJ - dpI); \ + VB->ClipMask[ii] |= PLANE; \ + INTERP_4F( t, coord[newvert], coord[jj], coord[ii] ); \ + interp( ctx, t, newvert, jj, ii, GL_FALSE ); \ + ii = newvert; \ + } \ + } \ + else if (NEGATIVE(dpI)) \ + return; \ + } \ } while (0) diff --git a/src/mesa/tnl/t_vb_light.c b/src/mesa/tnl/t_vb_light.c index 209c32f8aba..7b24cbfaa3a 100644 --- a/src/mesa/tnl/t_vb_light.c +++ b/src/mesa/tnl/t_vb_light.c @@ -1,4 +1,4 @@ -/* $Id: t_vb_light.c,v 1.13 2001/04/26 14:53:48 keithw Exp $ */ +/* $Id: t_vb_light.c,v 1.14 2001/04/28 08:39:18 keithw Exp $ */ /* * Mesa 3-D graphics library @@ -49,8 +49,8 @@ typedef void (*light_func)( GLcontext *ctx, GLvector4f *input ); struct light_stage_data { - GLvector4chan LitColor[2]; - GLvector4chan LitSecondary[2]; + struct gl_client_array LitColor[2]; + struct gl_client_array LitSecondary[2]; GLvector1ui LitIndex[2]; light_func *light_func_tab; }; @@ -149,8 +149,8 @@ static GLboolean run_lighting( GLcontext *ctx, struct gl_pipeline_stage *stage ) else ind = 0; - /* The individual tabs know about replaying side-effects vs. full - * re-execution. + /* The individual functions know about replaying side-effects + * vs. full re-execution. */ store->light_func_tab[ind]( ctx, VB, stage, input ); @@ -201,6 +201,22 @@ static GLboolean run_validate_lighting( GLcontext *ctx, return stage->run( ctx, stage ); } +static void alloc_4f( struct gl_client_array *a, GLuint sz ) +{ + a->Ptr = ALIGN_MALLOC( sz * sizeof(GLfloat) * 4, 32 ); + a->Size = 4; + a->Type = GL_FLOAT; + a->Stride = 0; + a->StrideB = sizeof(GLfloat) * 4; + a->Enabled = 0; + a->Flags = 0; +} + +static void free_4f( struct gl_client_array *a ) +{ + ALIGN_FREE( a->Ptr ); +} + /* Called the first time stage->run is called. In effect, don't * allocate data until the first time the stage is run. */ @@ -220,10 +236,11 @@ static GLboolean run_init_lighting( GLcontext *ctx, */ init_lighting(); - _mesa_vector4chan_alloc( &store->LitColor[0], 0, size, 32 ); - _mesa_vector4chan_alloc( &store->LitColor[1], 0, size, 32 ); - _mesa_vector4chan_alloc( &store->LitSecondary[0], 0, size, 32 ); - _mesa_vector4chan_alloc( &store->LitSecondary[1], 0, size, 32 ); + alloc_4f( &store->LitColor[0], size ); + alloc_4f( &store->LitColor[1], size ); + alloc_4f( &store->LitSecondary[0], size ); + alloc_4f( &store->LitSecondary[1], size ); + _mesa_vector1ui_alloc( &store->LitIndex[0], 0, size, 32 ); _mesa_vector1ui_alloc( &store->LitIndex[1], 0, size, 32 ); @@ -263,10 +280,10 @@ static void dtr( struct gl_pipeline_stage *stage ) struct light_stage_data *store = LIGHT_STAGE_DATA(stage); if (store) { - _mesa_vector4chan_free( &store->LitColor[0] ); - _mesa_vector4chan_free( &store->LitColor[1] ); - _mesa_vector4chan_free( &store->LitSecondary[0] ); - _mesa_vector4chan_free( &store->LitSecondary[1] ); + free_4f( &store->LitColor[0] ); + free_4f( &store->LitColor[1] ); + free_4f( &store->LitSecondary[0] ); + free_4f( &store->LitSecondary[1] ); _mesa_vector1ui_free( &store->LitIndex[0] ); _mesa_vector1ui_free( &store->LitIndex[1] ); FREE( store ); diff --git a/src/mesa/tnl/t_vb_lighttmp.h b/src/mesa/tnl/t_vb_lighttmp.h index a9df6de1d51..76d2a8c047b 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.11 2001/04/19 12:22:09 keithw Exp $ */ +/* $Id: t_vb_lighttmp.h,v 1.12 2001/04/28 08:39:18 keithw Exp $ */ /* * Mesa 3-D graphics library @@ -36,7 +36,7 @@ # define CHECK_MATERIAL(x) (flags[x] & VERT_MATERIAL) # define CHECK_END_VB(x) (flags[x] & VERT_END_VB) # if (IDX & LIGHT_COLORMATERIAL) -# define CMSTRIDE STRIDE_CHAN(CMcolor, (4 * sizeof(GLchan))) +# define CMSTRIDE STRIDE_F(CMcolor, (4 * sizeof(GLfloat))) # define CHECK_COLOR_MATERIAL(x) (flags[x] & VERT_RGBA) # define CHECK_VALIDATE(x) (flags[x] & (VERT_RGBA|VERT_MATERIAL)) # define DO_ANOTHER_NORMAL(x) \ @@ -58,7 +58,7 @@ # define CHECK_MATERIAL(x) 0 /* no materials on array paths */ # define CHECK_END_VB(XX) (XX >= nr) # if (IDX & LIGHT_COLORMATERIAL) -# define CMSTRIDE STRIDE_CHAN(CMcolor, CMstride) +# define CMSTRIDE STRIDE_F(CMcolor, CMstride) # define CHECK_COLOR_MATERIAL(x) (x < nr) /* always have colormaterial */ # define CHECK_VALIDATE(x) (x < nr) # define DO_ANOTHER_NORMAL(x) 0 /* always stop to recalc colormat */ @@ -88,7 +88,7 @@ static void TAG(light_rgba_spec)( GLcontext *ctx, { struct light_stage_data *store = LIGHT_STAGE_DATA(stage); GLfloat (*base)[3] = ctx->Light._BaseColor; - const GLchan *sumA = ctx->Light._BaseAlpha; + const GLfloat *sumA = ctx->Light._BaseAlpha; GLuint j; @@ -97,15 +97,16 @@ static void TAG(light_rgba_spec)( GLcontext *ctx, GLuint nstride = VB->NormalPtr->stride; const GLfloat *normal = (GLfloat *)VB->NormalPtr->data; - GLchan *CMcolor; + GLfloat *CMcolor; GLuint CMstride; - GLchan (*Fcolor)[4] = (GLchan (*)[4]) store->LitColor[0].data; - GLchan (*Bcolor)[4] = (GLchan (*)[4]) store->LitColor[1].data; - GLchan (*Fspec)[4] = (GLchan (*)[4]) store->LitSecondary[0].data; - GLchan (*Bspec)[4] = (GLchan (*)[4]) store->LitSecondary[1].data; - GLuint nr = VB->Count; + GLfloat (*Fcolor)[4] = (GLfloat (*)[4]) store->LitColor[0].Ptr; + GLfloat (*Bcolor)[4] = (GLfloat (*)[4]) store->LitColor[1].Ptr; + GLfloat (*Fspec)[4] = (GLfloat (*)[4]) store->LitSecondary[0].Ptr; + GLfloat (*Bspec)[4] = (GLfloat (*)[4]) store->LitSecondary[1].Ptr; + GLfloat (*spec[2])[4]; + GLuint nr = VB->Count; GLuint *flags = VB->Flag; struct gl_material (*new_material)[2] = VB->Material; GLuint *new_material_mask = VB->MaterialMask; @@ -114,11 +115,18 @@ static void TAG(light_rgba_spec)( GLcontext *ctx, (void) nstride; (void) vstride; + /* fprintf(stderr, "%s\n", __FUNCTION__ ); */ + spec[0] = Fspec; + spec[1] = Bspec; + if (IDX & LIGHT_COLORMATERIAL) { - CMcolor = (GLchan *) VB->ColorPtr[0]->data; - CMstride = VB->ColorPtr[0]->stride; + if (VB->ColorPtr[0]->Type != GL_FLOAT) + VB->import_data( ctx, VERT_RGBA, ~0 ); + + CMcolor = (GLfloat *) VB->ColorPtr[0]->Ptr; + CMstride = VB->ColorPtr[0]->StrideB; } VB->ColorPtr[0] = &store->LitColor[0]; @@ -138,7 +146,6 @@ static void TAG(light_rgba_spec)( GLcontext *ctx, j<nr ; j++,STRIDE_F(vertex,VSTRIDE),STRIDE_F(normal,NSTRIDE),CMSTRIDE) { - GLfloat sum[2][3], spec[2][3]; struct gl_light *light; if ( CHECK_COLOR_MATERIAL(j) ) @@ -150,12 +157,14 @@ static void TAG(light_rgba_spec)( GLcontext *ctx, if ( CHECK_VALIDATE(j) ) _mesa_validate_all_lighting_tables( ctx ); - COPY_3V(sum[0], base[0]); - ZERO_3V(spec[0]); + COPY_3V(Fcolor[j], base[0]); + Fcolor[j][3] = sumA[0]; + ZERO_3V(Fspec[j]); if (IDX & LIGHT_TWOSIDE) { - COPY_3V(sum[1], base[1]); - ZERO_3V(spec[1]); + COPY_3V(Bcolor[j], base[1]); + Bcolor[j][3] = sumA[1]; + ZERO_3V(Bspec[j]); } /* Add contribution from each enabled light source */ @@ -217,27 +226,30 @@ static void TAG(light_rgba_spec)( GLcontext *ctx, /* Which side gets the diffuse & specular terms? */ if (n_dot_VP < 0.0F) { - ACC_SCALE_SCALAR_3V(sum[0], attenuation, light->_MatAmbient[0]); + ACC_SCALE_SCALAR_3V(Fcolor[j], attenuation, light->_MatAmbient[0]); if (!(IDX & LIGHT_TWOSIDE)) { continue; } - side = 1; + /* diffuse term */ + COPY_3V(contrib, light->_MatAmbient[1]); + ACC_SCALE_SCALAR_3V(contrib, -n_dot_VP, light->_MatDiffuse[1]); + ACC_SCALE_SCALAR_3V(Bcolor[j], attenuation, contrib ); correction = -1; - n_dot_VP = -n_dot_VP; + side = 1; } else { if (IDX & LIGHT_TWOSIDE) { - ACC_SCALE_SCALAR_3V( sum[1], attenuation, light->_MatAmbient[1]); + ACC_SCALE_SCALAR_3V( Bcolor[j], attenuation, + light->_MatAmbient[1]); } - side = 0; + /* diffuse term */ + COPY_3V(contrib, light->_MatAmbient[0]); + ACC_SCALE_SCALAR_3V(contrib, n_dot_VP, light->_MatDiffuse[0]); + ACC_SCALE_SCALAR_3V(Fcolor[j], attenuation, contrib ); correction = 1; + side = 0; } - /* diffuse term */ - COPY_3V(contrib, light->_MatAmbient[side]); - ACC_SCALE_SCALAR_3V(contrib, n_dot_VP, light->_MatDiffuse[side]); - ACC_SCALE_SCALAR_3V(sum[side], attenuation, contrib ); - /* specular term - cannibalize VP... */ if (ctx->Light.Model.LocalViewer) { GLfloat v[3]; @@ -265,21 +277,11 @@ static void TAG(light_rgba_spec)( GLcontext *ctx, if (spec_coef > 1.0e-10) { spec_coef *= attenuation; - ACC_SCALE_SCALAR_3V( spec[side], spec_coef, + ACC_SCALE_SCALAR_3V( spec[side][j], spec_coef, light->_MatSpecular[side]); } } } /*loop over lights*/ - - UNCLAMPED_FLOAT_TO_RGB_CHAN( Fcolor[j], sum[0] ); - UNCLAMPED_FLOAT_TO_RGB_CHAN( Fspec[j], spec[0] ); - Fcolor[j][3] = sumA[0]; - - if (IDX & LIGHT_TWOSIDE) { - UNCLAMPED_FLOAT_TO_RGB_CHAN( Bcolor[j], sum[1] ); - UNCLAMPED_FLOAT_TO_RGB_CHAN( Bspec[j], spec[1] ); - Bcolor[j][3] = sumA[1]; - } } } @@ -293,18 +295,19 @@ static void TAG(light_rgba)( GLcontext *ctx, GLuint j; GLfloat (*base)[3] = ctx->Light._BaseColor; - const GLchan *sumA = ctx->Light._BaseAlpha; + const GLfloat *sumA = ctx->Light._BaseAlpha; GLuint vstride = input->stride; const GLfloat *vertex = (GLfloat *) input->data; GLuint nstride = VB->NormalPtr->stride; const GLfloat *normal = (GLfloat *)VB->NormalPtr->data; - GLchan *CMcolor; + GLfloat *CMcolor; GLuint CMstride; - GLchan (*Fcolor)[4] = (GLchan (*)[4]) store->LitColor[0].data; - GLchan (*Bcolor)[4] = (GLchan (*)[4]) store->LitColor[1].data; + GLfloat (*Fcolor)[4] = (GLfloat (*)[4]) store->LitColor[0].Ptr; + GLfloat (*Bcolor)[4] = (GLfloat (*)[4]) store->LitColor[1].Ptr; + GLfloat (*color[2])[4]; GLuint *flags = VB->Flag; struct gl_material (*new_material)[2] = VB->Material; @@ -316,9 +319,15 @@ static void TAG(light_rgba)( GLcontext *ctx, (void) nstride; (void) vstride; + color[0] = Fcolor; + color[1] = Bcolor; + if (IDX & LIGHT_COLORMATERIAL) { - CMcolor = (GLchan *)VB->ColorPtr[0]->data; - CMstride = VB->ColorPtr[0]->stride; + if (VB->ColorPtr[0]->Type != GL_FLOAT) + VB->import_data( ctx, VERT_RGBA, ~0 ); + + CMcolor = (GLfloat *)VB->ColorPtr[0]->Ptr; + CMstride = VB->ColorPtr[0]->StrideB; } VB->ColorPtr[0] = &store->LitColor[0]; @@ -332,7 +341,6 @@ static void TAG(light_rgba)( GLcontext *ctx, j<nr ; j++,STRIDE_F(vertex,VSTRIDE), STRIDE_F(normal,NSTRIDE),CMSTRIDE) { - GLfloat sum[2][3]; struct gl_light *light; if ( CHECK_COLOR_MATERIAL(j) ) @@ -344,10 +352,14 @@ static void TAG(light_rgba)( GLcontext *ctx, if ( CHECK_VALIDATE(j) ) _mesa_validate_all_lighting_tables( ctx ); - COPY_3V(sum[0], base[0]); + COPY_3V(Fcolor[j], base[0]); + Fcolor[j][3] = sumA[0]; + + if (IDX & LIGHT_TWOSIDE) { + COPY_3V(Bcolor[j], base[1]); + Bcolor[j][3] = sumA[1]; + } - if ( IDX & LIGHT_TWOSIDE ) - COPY_3V(sum[1], base[1]); /* Add contribution from each enabled light source */ foreach (light, &ctx->Light.EnabledList) { @@ -411,7 +423,7 @@ static void TAG(light_rgba)( GLcontext *ctx, /* which side are we lighting? */ if (n_dot_VP < 0.0F) { - ACC_SCALE_SCALAR_3V(sum[0], attenuation, light->_MatAmbient[0]); + ACC_SCALE_SCALAR_3V(Fcolor[j], attenuation, light->_MatAmbient[0]); if (!(IDX & LIGHT_TWOSIDE)) continue; @@ -422,7 +434,8 @@ static void TAG(light_rgba)( GLcontext *ctx, } else { if (IDX & LIGHT_TWOSIDE) { - ACC_SCALE_SCALAR_3V( sum[1], attenuation, light->_MatAmbient[1]); + ACC_SCALE_SCALAR_3V(Bcolor[j], attenuation, + light->_MatAmbient[1]); } side = 0; correction = 1; @@ -465,16 +478,9 @@ static void TAG(light_rgba)( GLcontext *ctx, light->_MatSpecular[side]); } } - - ACC_SCALE_SCALAR_3V( sum[side], attenuation, contrib ); - } - - UNCLAMPED_FLOAT_TO_RGB_CHAN( Fcolor[j], sum[0] ); - Fcolor[j][3] = sumA[0]; - - if (IDX & LIGHT_TWOSIDE) { - UNCLAMPED_FLOAT_TO_RGB_CHAN( Bcolor[j], sum[1] ); - Bcolor[j][3] = sumA[1]; + + + ACC_SCALE_SCALAR_3V( color[side][j], attenuation, contrib ); } } } @@ -493,17 +499,16 @@ static void TAG(light_fast_rgba_single)( GLcontext *ctx, struct light_stage_data *store = LIGHT_STAGE_DATA(stage); GLuint nstride = VB->NormalPtr->stride; const GLfloat *normal = (GLfloat *)VB->NormalPtr->data; - GLchan *CMcolor; + GLfloat *CMcolor; GLuint CMstride; - GLchan (*Fcolor)[4] = (GLchan (*)[4]) store->LitColor[0].data; - GLchan (*Bcolor)[4] = (GLchan (*)[4]) store->LitColor[1].data; + GLfloat (*Fcolor)[4] = (GLfloat (*)[4]) store->LitColor[0].Ptr; + GLfloat (*Bcolor)[4] = (GLfloat (*)[4]) store->LitColor[1].Ptr; struct gl_light *light = ctx->Light.EnabledList.next; GLuint *flags = VB->Flag; - GLchan baseubyte[2][4]; GLuint j = 0; struct gl_material (*new_material)[2] = VB->Material; GLuint *new_material_mask = VB->MaterialMask; - GLfloat base[2][3]; + GLfloat base[2][4]; GLuint nr = VB->Count; /* fprintf(stderr, "%s\n", __FUNCTION__ ); */ @@ -513,8 +518,11 @@ static void TAG(light_fast_rgba_single)( GLcontext *ctx, (void) nstride; if (IDX & LIGHT_COLORMATERIAL) { - CMcolor = (GLchan *)VB->ColorPtr[0]->data; - CMstride = VB->ColorPtr[0]->stride; + if (VB->ColorPtr[0]->Type != GL_FLOAT) + VB->import_data( ctx, VERT_RGBA, ~0 ); + + CMcolor = (GLfloat *)VB->ColorPtr[0]->Ptr; + CMstride = VB->ColorPtr[0]->StrideB; } VB->ColorPtr[0] = &store->LitColor[0]; @@ -535,54 +543,42 @@ static void TAG(light_fast_rgba_single)( GLcontext *ctx, if ( CHECK_VALIDATE(j) ) _mesa_validate_all_lighting_tables( ctx ); - baseubyte[0][3] = ctx->Light._BaseAlpha[0]; - baseubyte[1][3] = ctx->Light._BaseAlpha[1]; - /* No attenuation, so incoporate _MatAmbient into base color. - */ - { - COPY_3V(base[0], light->_MatAmbient[0]); - ACC_3V(base[0], ctx->Light._BaseColor[0] ); - UNCLAMPED_FLOAT_TO_RGB_CHAN( baseubyte[0], base[0] ); + COPY_3V(base[0], light->_MatAmbient[0]); + ACC_3V(base[0], ctx->Light._BaseColor[0] ); + base[0][3] = ctx->Light._BaseAlpha[0]; - if (IDX & LIGHT_TWOSIDE) { - COPY_3V(base[1], light->_MatAmbient[1]); - ACC_3V(base[1], ctx->Light._BaseColor[1]); - UNCLAMPED_FLOAT_TO_RGB_CHAN( baseubyte[1], base[1]); - } + if (IDX & LIGHT_TWOSIDE) { + COPY_3V(base[1], light->_MatAmbient[1]); + ACC_3V(base[1], ctx->Light._BaseColor[1]); + base[1][3] = ctx->Light._BaseAlpha[1]; } do { - GLfloat n_dot_VP = DOT3(normal, light->_VP_inf_norm); + GLfloat n_dot_VP; - COPY_CHAN4(Fcolor[j], baseubyte[0]); - if (IDX & LIGHT_TWOSIDE) COPY_CHAN4(Bcolor[j], baseubyte[1]); + COPY_4FV(Fcolor[j], base[0]); + if (IDX & LIGHT_TWOSIDE) COPY_4FV(Bcolor[j], base[1]); - if (n_dot_VP < 0.0F) { - if (IDX & LIGHT_TWOSIDE) { - GLfloat n_dot_h = -DOT3(normal, light->_h_inf_norm); - GLfloat sum[3]; - COPY_3V(sum, base[1]); - ACC_SCALE_SCALAR_3V(sum, -n_dot_VP, light->_MatDiffuse[1]); - if (n_dot_h > 0.0F) { - GLfloat spec; - GET_SHINE_TAB_ENTRY( ctx->_ShineTable[1], n_dot_h, spec ); - ACC_SCALE_SCALAR_3V(sum, spec, light->_MatSpecular[1]); - } - UNCLAMPED_FLOAT_TO_RGB_CHAN(Bcolor[j], sum ); - } - } else { + n_dot_VP = DOT3(normal, light->_VP_inf_norm); + + if (n_dot_VP > 0.0F) { GLfloat n_dot_h = DOT3(normal, light->_h_inf_norm); - GLfloat sum[3]; - COPY_3V(sum, base[0]); - ACC_SCALE_SCALAR_3V(sum, n_dot_VP, light->_MatDiffuse[0]); + ACC_SCALE_SCALAR_3V(Fcolor[j], n_dot_VP, light->_MatDiffuse[0]); if (n_dot_h > 0.0F) { GLfloat spec; GET_SHINE_TAB_ENTRY( ctx->_ShineTable[0], n_dot_h, spec ); - ACC_SCALE_SCALAR_3V(sum, spec, light->_MatSpecular[0]); - + ACC_SCALE_SCALAR_3V( Fcolor[j], spec, light->_MatSpecular[0]); + } + } + else if (IDX & LIGHT_TWOSIDE) { + GLfloat n_dot_h = -DOT3(normal, light->_h_inf_norm); + ACC_SCALE_SCALAR_3V(Bcolor[j], -n_dot_VP, light->_MatDiffuse[1]); + if (n_dot_h > 0.0F) { + GLfloat spec; + GET_SHINE_TAB_ENTRY( ctx->_ShineTable[1], n_dot_h, spec ); + ACC_SCALE_SCALAR_3V( Bcolor[j], spec, light->_MatSpecular[1]); } - UNCLAMPED_FLOAT_TO_RGB_CHAN(Fcolor[j], sum ); } j++; @@ -591,11 +587,11 @@ static void TAG(light_fast_rgba_single)( GLcontext *ctx, } while (DO_ANOTHER_NORMAL(j)); - for ( ; REUSE_LIGHT_RESULTS(j) ; j++, CMSTRIDE ) { - COPY_CHAN4(Fcolor[j], Fcolor[j-1]); + for ( ; REUSE_LIGHT_RESULTS(j) ; j++, CMSTRIDE, STRIDE_F(normal,NSTRIDE)) + { + COPY_4FV(Fcolor[j], Fcolor[j-1]); if (IDX & LIGHT_TWOSIDE) - COPY_CHAN4(Bcolor[j], Bcolor[j-1]); - STRIDE_F(normal, NSTRIDE); + COPY_4FV(Bcolor[j], Bcolor[j-1]); } } while (!CHECK_END_VB(j)); @@ -610,13 +606,13 @@ static void TAG(light_fast_rgba)( GLcontext *ctx, GLvector4f *input ) { struct light_stage_data *store = LIGHT_STAGE_DATA(stage); - const GLchan *sumA = ctx->Light._BaseAlpha; + const GLfloat *sumA = ctx->Light._BaseAlpha; GLuint nstride = VB->NormalPtr->stride; const GLfloat *normal = (GLfloat *)VB->NormalPtr->data; - GLchan *CMcolor; + GLfloat *CMcolor; GLuint CMstride; - GLchan (*Fcolor)[4] = (GLchan (*)[4]) store->LitColor[0].data; - GLchan (*Bcolor)[4] = (GLchan (*)[4]) store->LitColor[1].data; + GLfloat (*Fcolor)[4] = (GLfloat (*)[4]) store->LitColor[0].Ptr; + GLfloat (*Bcolor)[4] = (GLfloat (*)[4]) store->LitColor[1].Ptr; GLuint *flags = VB->Flag; GLuint j = 0; struct gl_material (*new_material)[2] = VB->Material; @@ -631,8 +627,11 @@ static void TAG(light_fast_rgba)( GLcontext *ctx, (void) nstride; if (IDX & LIGHT_COLORMATERIAL) { - CMcolor = (GLchan *)VB->ColorPtr[0]->data; - CMstride = VB->ColorPtr[0]->stride; + if (VB->ColorPtr[0]->Type != GL_FLOAT) + VB->import_data( ctx, VERT_RGBA, ~0 ); + + CMcolor = (GLfloat *)VB->ColorPtr[0]->Ptr; + CMstride = VB->ColorPtr[0]->StrideB; } VB->ColorPtr[0] = &store->LitColor[0]; @@ -644,8 +643,6 @@ static void TAG(light_fast_rgba)( GLcontext *ctx, do { do { - GLfloat sum[2][3]; - if ( CHECK_COLOR_MATERIAL(j) ) _mesa_update_color_material( ctx, CMcolor ); @@ -656,49 +653,45 @@ static void TAG(light_fast_rgba)( GLcontext *ctx, _mesa_validate_all_lighting_tables( ctx ); - COPY_3V(sum[0], ctx->Light._BaseColor[0]); - if (IDX & LIGHT_TWOSIDE) - COPY_3V(sum[1], ctx->Light._BaseColor[1]); + COPY_3V(Fcolor[j], ctx->Light._BaseColor[0]); + Fcolor[j][3] = sumA[0]; + + if (IDX & LIGHT_TWOSIDE) { + COPY_3V(Bcolor[j], ctx->Light._BaseColor[1]); + Bcolor[j][3] = sumA[1]; + } foreach (light, &ctx->Light.EnabledList) { GLfloat n_dot_h, n_dot_VP, spec; - ACC_3V(sum[0], light->_MatAmbient[0]); + ACC_3V(Fcolor[j], light->_MatAmbient[0]); if (IDX & LIGHT_TWOSIDE) - ACC_3V(sum[1], light->_MatAmbient[1]); + ACC_3V(Bcolor[j], light->_MatAmbient[1]); n_dot_VP = DOT3(normal, light->_VP_inf_norm); if (n_dot_VP > 0.0F) { - ACC_SCALE_SCALAR_3V(sum[0], n_dot_VP, light->_MatDiffuse[0]); + ACC_SCALE_SCALAR_3V(Fcolor[j], n_dot_VP, light->_MatDiffuse[0]); n_dot_h = DOT3(normal, light->_h_inf_norm); if (n_dot_h > 0.0F) { struct gl_shine_tab *tab = ctx->_ShineTable[0]; GET_SHINE_TAB_ENTRY( tab, n_dot_h, spec ); - ACC_SCALE_SCALAR_3V( sum[0], spec, + ACC_SCALE_SCALAR_3V( Fcolor[j], spec, light->_MatSpecular[0]); } } else if (IDX & LIGHT_TWOSIDE) { - ACC_SCALE_SCALAR_3V(sum[1], -n_dot_VP, light->_MatDiffuse[1]); + ACC_SCALE_SCALAR_3V(Bcolor[j], -n_dot_VP, light->_MatDiffuse[1]); n_dot_h = -DOT3(normal, light->_h_inf_norm); if (n_dot_h > 0.0F) { struct gl_shine_tab *tab = ctx->_ShineTable[1]; GET_SHINE_TAB_ENTRY( tab, n_dot_h, spec ); - ACC_SCALE_SCALAR_3V( sum[1], spec, + ACC_SCALE_SCALAR_3V( Bcolor[j], spec, light->_MatSpecular[1]); } } } - UNCLAMPED_FLOAT_TO_RGB_CHAN( Fcolor[j], sum[0] ); - Fcolor[j][3] = sumA[0]; - - if (IDX & LIGHT_TWOSIDE) { - UNCLAMPED_FLOAT_TO_RGB_CHAN( Bcolor[j], sum[1] ); - Bcolor[j][3] = sumA[1]; - } - j++; CMSTRIDE; STRIDE_F(normal, NSTRIDE); @@ -707,11 +700,11 @@ static void TAG(light_fast_rgba)( GLcontext *ctx, /* Reuse the shading results while there is no change to * normal or material values. */ - for ( ; REUSE_LIGHT_RESULTS(j) ; j++, CMSTRIDE ) { - COPY_CHAN4(Fcolor[j], Fcolor[j-1]); + for ( ; REUSE_LIGHT_RESULTS(j) ; j++, CMSTRIDE, STRIDE_F(normal, NSTRIDE)) + { + COPY_4FV(Fcolor[j], Fcolor[j-1]); if (IDX & LIGHT_TWOSIDE) - COPY_CHAN4(Bcolor[j], Bcolor[j-1]); - STRIDE_F(normal, NSTRIDE); + COPY_4FV(Bcolor[j], Bcolor[j-1]); } } while (!CHECK_END_VB(j)); @@ -741,7 +734,7 @@ static void TAG(light_ci)( GLcontext *ctx, const GLfloat *vertex = (GLfloat *) input->data; GLuint nstride = VB->NormalPtr->stride; const GLfloat *normal = (GLfloat *)VB->NormalPtr->data; - GLchan *CMcolor; + GLfloat *CMcolor; GLuint CMstride; GLuint *flags = VB->Flag; GLuint *indexResult[2]; @@ -766,8 +759,11 @@ static void TAG(light_ci)( GLcontext *ctx, indexResult[1] = VB->IndexPtr[1]->data; if (IDX & LIGHT_COLORMATERIAL) { - CMcolor = (GLchan *)VB->ColorPtr[0]->data; - CMstride = VB->ColorPtr[0]->stride; + if (VB->ColorPtr[0]->Type != GL_FLOAT) + VB->import_data( ctx, VERT_RGBA, ~0 ); + + CMcolor = (GLfloat *)VB->ColorPtr[0]->Ptr; + CMstride = VB->ColorPtr[0]->StrideB; } /* loop over vertices */ diff --git a/src/mesa/tnl/t_vb_render.c b/src/mesa/tnl/t_vb_render.c index a71ed8d4493..fc4fb958528 100644 --- a/src/mesa/tnl/t_vb_render.c +++ b/src/mesa/tnl/t_vb_render.c @@ -1,4 +1,4 @@ -/* $Id: t_vb_render.c,v 1.18 2001/04/26 14:53:48 keithw Exp $ */ +/* $Id: t_vb_render.c,v 1.19 2001/04/28 08:39:18 keithw Exp $ */ /* * Mesa 3-D graphics library @@ -79,27 +79,6 @@ */ #endif -#define LINTERP_SZ( t, vec, to, a, b, sz ) \ -do { \ - switch (sz) { \ - case 2: vec[to][2] = 0.0; \ - case 3: vec[to][3] = 1.0; \ - } \ - switch (sz) { \ - case 4: vec[to][3] = LINTERP( t, vec[a][3], vec[b][3] ); \ - case 3: vec[to][2] = LINTERP( t, vec[a][2], vec[b][2] ); \ - case 2: vec[to][1] = LINTERP( t, vec[a][1], vec[b][1] ); \ - vec[to][0] = LINTERP( t, vec[a][0], vec[b][0] ); \ - } \ -} while(0) - -#define LINTERP_4F( t, vec, to, a, b, sz ) \ -do { \ - vec[to][3] = LINTERP( t, vec[a][3], vec[b][3] ); \ - vec[to][2] = LINTERP( t, vec[a][2], vec[b][2] ); \ - vec[to][1] = LINTERP( t, vec[a][1], vec[b][1] ); \ - vec[to][0] = LINTERP( t, vec[a][0], vec[b][0] ); \ -} while (0) #define W(i) coord[i][3] #define Z(i) coord[i][2] |