diff options
author | Keith Whitwell <keith@tungstengraphics.com> | 2003-10-09 13:45:50 +0000 |
---|---|---|
committer | Keith Whitwell <keith@tungstengraphics.com> | 2003-10-09 13:45:50 +0000 |
commit | 8ae69294ad3baca78dcb1b306d5fd09505b08e91 (patch) | |
tree | 383229d8df3564194851729d13be4c07b2d07b75 | |
parent | 46330d3aa7f517789f44272020645bb900d08a7a (diff) |
Checkpoint commit -- module compiles
-rw-r--r-- | src/mesa/tnl/t_array_api.c | 3 | ||||
-rw-r--r-- | src/mesa/tnl/t_array_import.c | 10 | ||||
-rw-r--r-- | src/mesa/tnl/t_context.c | 6 | ||||
-rw-r--r-- | src/mesa/tnl/t_context.h | 50 | ||||
-rw-r--r-- | src/mesa/tnl/t_eval_api.c | 195 | ||||
-rw-r--r-- | src/mesa/tnl/t_eval_api.h | 43 | ||||
-rw-r--r-- | src/mesa/tnl/t_save_api.c | 4 | ||||
-rw-r--r-- | src/mesa/tnl/t_save_compile.c | 40 | ||||
-rw-r--r-- | src/mesa/tnl/t_save_playback.c | 18 | ||||
-rw-r--r-- | src/mesa/tnl/t_vb_light.c | 10 | ||||
-rw-r--r-- | src/mesa/tnl/t_vb_lighttmp.h | 4 | ||||
-rw-r--r-- | src/mesa/tnl/t_vtx_api.c | 348 | ||||
-rw-r--r-- | src/mesa/tnl/t_vtx_api.h | 8 | ||||
-rw-r--r-- | src/mesa/tnl/t_vtx_eval.c | 342 | ||||
-rw-r--r-- | src/mesa/tnl/t_vtx_exec.c | 153 |
15 files changed, 453 insertions, 781 deletions
diff --git a/src/mesa/tnl/t_array_api.c b/src/mesa/tnl/t_array_api.c index 2dae1610a9..45e3f25d9b 100644 --- a/src/mesa/tnl/t_array_api.c +++ b/src/mesa/tnl/t_array_api.c @@ -419,8 +419,7 @@ void _tnl_array_init( GLcontext *ctx ) _mesa_vector4f_init( &tmp->Obj, 0, 0 ); _mesa_vector4f_init( &tmp->Normal, 0, 0 ); _mesa_vector4f_init( &tmp->FogCoord, 0, 0 ); - _mesa_vector1f_init( &tmp->Index, 0, 0 ); - _mesa_vector1ub_init( &tmp->EdgeFlag, 0, 0 ); + _mesa_vector4f_init( &tmp->Index, 0, 0 ); for (i = 0; i < ctx->Const.MaxTextureUnits; i++) _mesa_vector4f_init( &tmp->TexCoord[i], 0, 0); diff --git a/src/mesa/tnl/t_array_import.c b/src/mesa/tnl/t_array_import.c index 2638b5571e..92e1e468a3 100644 --- a/src/mesa/tnl/t_array_import.c +++ b/src/mesa/tnl/t_array_import.c @@ -189,7 +189,7 @@ static void _tnl_import_index( GLcontext *ctx, #else data = tmp->Ptr; #endif - inputs->Index.data = (GLfloat *) data; + inputs->Index.data = (GLfloat (*)[4]) data; inputs->Index.start = (GLfloat *) data; inputs->Index.stride = tmp->StrideB; } @@ -233,7 +233,7 @@ static void _tnl_import_edgeflag( GLcontext *ctx, GLubyte *data; tmp = _ac_import_edgeflag(ctx, GL_UNSIGNED_BYTE, - stride ? sizeof(GLubyte) : 0, + sizeof(GLubyte), 0, &is_writeable); @@ -242,9 +242,7 @@ static void _tnl_import_edgeflag( GLcontext *ctx, #else data = tmp->Ptr; #endif - inputs->EdgeFlag.data = (GLubyte *) data; - inputs->EdgeFlag.start = (GLubyte *) data; - inputs->EdgeFlag.stride = tmp->StrideB; + inputs->EdgeFlag = (GLubyte *) data; } @@ -360,7 +358,7 @@ void _tnl_vb_bind_arrays( GLcontext *ctx, GLint start, GLsizei count ) if (inputs & _TNL_BIT_EDGEFLAG) { _tnl_import_edgeflag( ctx, GL_TRUE, sizeof(GLboolean) ); - VB->EdgeFlag = (GLboolean *) tmp->EdgeFlag.data; + VB->EdgeFlag = (GLboolean *) tmp->EdgeFlag; } if (inputs & _TNL_BIT_COLOR1) { diff --git a/src/mesa/tnl/t_context.c b/src/mesa/tnl/t_context.c index 0eff839d0a..6f9dfeb379 100644 --- a/src/mesa/tnl/t_context.c +++ b/src/mesa/tnl/t_context.c @@ -37,7 +37,6 @@ #include "t_context.h" #include "t_array_api.h" -#include "t_eval_api.h" #include "t_vtx_api.h" #include "t_save_api.h" #include "t_pipeline.h" @@ -58,7 +57,7 @@ install_driver_callbacks( GLcontext *ctx ) { ctx->Driver.NewList = _tnl_NewList; ctx->Driver.EndList = _tnl_EndList; - ctx->Driver.FlushVertices = _tnl_flush_vertices; + ctx->Driver.FlushVertices = _tnl_FlushVertices; ctx->Driver.MakeCurrent = _tnl_MakeCurrent; ctx->Driver.BeginCallList = _tnl_BeginCallList; ctx->Driver.EndCallList = _tnl_EndCallList; @@ -90,7 +89,6 @@ _tnl_CreateContext( GLcontext *ctx ) _tnl_save_init( ctx ); _tnl_array_init( ctx ); _tnl_vtx_init( ctx ); - _tnl_eval_init( ctx ); _tnl_install_pipeline( ctx, _tnl_default_pipeline ); @@ -148,7 +146,7 @@ _tnl_InvalidateState( GLcontext *ctx, GLuint new_state ) tnl->pipeline.build_state_changes |= (new_state & tnl->pipeline.build_state_trigger); - tnl->eval.EvalNewState |= new_state; + tnl->vtx.eval.new_state |= new_state; } diff --git a/src/mesa/tnl/t_context.h b/src/mesa/tnl/t_context.h index 0acfce9c16..e61fa6d58c 100644 --- a/src/mesa/tnl/t_context.h +++ b/src/mesa/tnl/t_context.h @@ -112,9 +112,8 @@ enum { _TNL_ATTRIB_MAT_BACK_SHININESS = 25, _TNL_ATTRIB_MAT_FRONT_INDEXES = 26, _TNL_ATTRIB_MAT_BACK_INDEXES = 27, - _TNL_ATTRIB_EVALFLAG = 28, + _TNL_ATTRIB_INDEX = 28, _TNL_ATTRIB_EDGEFLAG = 29, - _TNL_ATTRIB_INDEX = 30, _TNL_ATTRIB_MAX = 31 } ; @@ -150,9 +149,8 @@ enum { #define _TNL_BIT_MAT_BACK_SHININESS (1<<25) #define _TNL_BIT_MAT_FRONT_INDEXES (1<<26) #define _TNL_BIT_MAT_BACK_INDEXES (1<<27) -#define _TNL_BIT_EVALFLAG (1<<28) +#define _TNL_BIT_INDEX (1<<28) #define _TNL_BIT_EDGEFLAG (1<<29) -#define _TNL_BIT_INDEX (1<<30) #define _TNL_BIT_TEX(u) (1 << (_TNL_ATTRIB_TEX0 + (u))) @@ -193,7 +191,6 @@ enum { - #define PRIM_BEGIN 0x10 #define PRIM_END 0x20 #define PRIM_WEAK 0x40 @@ -208,6 +205,24 @@ struct tnl_prim { }; + +struct tnl_eval1_map { + struct gl_1d_map *map; + GLuint sz; +}; + +struct tnl_eval2_map { + struct gl_2d_map *map; + GLuint sz; +}; + +struct tnl_eval { + GLuint new_state; + struct tnl_eval1_map map1[_TNL_ATTRIB_INDEX + 1]; + struct tnl_eval2_map map2[_TNL_ATTRIB_INDEX + 1]; +}; + + #define TNL_MAX_PRIM 16 #define TNL_MAX_COPIED_VERTS 3 @@ -228,7 +243,6 @@ typedef void (*attrfv_func)( const GLfloat * ); struct tnl_vtx { GLfloat buffer[VERT_BUFFER_SIZE]; GLubyte attrsz[_TNL_ATTRIB_MAX]; - GLuint count; GLuint vertex_size; struct tnl_prim prim[TNL_MAX_PRIM]; GLuint prim_count; @@ -236,9 +250,10 @@ struct tnl_vtx { GLfloat vertex[_TNL_ATTRIB_MAX*4]; /* current vertex */ GLfloat *attrptr[_TNL_ATTRIB_MAX]; /* points into vertex */ GLfloat *current[_TNL_ATTRIB_MAX]; /* points into ctx->Current, etc */ - GLuint counter; + GLuint counter, initial_counter; struct tnl_copied_vtx copied; attrfv_func tabfv[_TNL_ATTRIB_MAX][4]; + struct tnl_eval eval; }; @@ -335,9 +350,10 @@ struct tnl_vertex_arrays GLvector4f SecondaryColor; GLvector4f FogCoord; GLvector4f TexCoord[MAX_TEXTURE_COORD_UNITS]; - GLvector1ub EdgeFlag; - GLvector1f Index; - GLvector1ui Elt; + GLvector4f Index; + + GLubyte *EdgeFlag; + GLuint *Elt; /* These attributes don't alias with the conventional attributes. * The GL_NV_vertex_program extension defines 16 extra sets of vertex @@ -373,7 +389,7 @@ struct vertex_buffer GLfloat *NormalLengthPtr; /* _TNL_BIT_NORMAL */ GLboolean *EdgeFlag; /* _TNL_BIT_EDGEFLAG */ GLvector4f *TexCoordPtr[MAX_TEXTURE_COORD_UNITS]; /* VERT_TEX_0..n */ - GLvector1f *IndexPtr[2]; /* _TNL_BIT_INDEX */ + GLvector4f *IndexPtr[2]; /* _TNL_BIT_INDEX */ GLvector4f *ColorPtr[2]; /* _TNL_BIT_COLOR0 */ GLvector4f *SecondaryColorPtr[2]; /* _TNL_BIT_COLOR1 */ GLvector4f *PointSizePtr; /* _TNL_BIT_POS */ @@ -460,13 +476,6 @@ struct tnl_pipeline { }; -struct tnl_eval_store { - GLuint EvalMap1Flags; - GLuint EvalMap2Flags; - GLuint EvalMap1AttribFlags; /* GL_NV_vertex_program */ - GLuint EvalMap2AttribFlags; /* GL_NV_vertex_program */ - GLuint EvalNewState; -}; typedef void (*points_func)( GLcontext *ctx, GLuint first, GLuint last ); @@ -616,11 +625,6 @@ typedef struct { struct tnl_vertex_arrays array_inputs; - /* Derived state and storage for _tnl_eval_vb: - */ - struct tnl_eval_store eval; - - /* Probably need a better configuration mechanism: */ GLboolean NeedNdcCoords; diff --git a/src/mesa/tnl/t_eval_api.c b/src/mesa/tnl/t_eval_api.c deleted file mode 100644 index 70930cdeae..0000000000 --- a/src/mesa/tnl/t_eval_api.c +++ /dev/null @@ -1,195 +0,0 @@ - -/* - * Mesa 3-D graphics library - * Version: 5.1 - * - * Copyright (C) 1999-2003 Brian Paul All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN - * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - * - * Authors: - * Keith Whitwell - original code - * Brian Paul - vertex program updates - */ - - -#include "glheader.h" -#include "colormac.h" -#include "context.h" -#include "macros.h" -#include "imports.h" -#include "mtypes.h" -#include "math/m_eval.h" - -#include "t_eval_api.h" -#include "t_vtx_api.h" - - -/* KW: If are compiling, we don't know whether eval will produce a - * vertex when it is run in the future. If this is pure immediate - * mode, eval is a noop if neither vertex map is enabled. - * - * Thus we need to have a check in the display list code or - * elsewhere for eval(1,2) vertices in the case where - * map(1,2)_vertex is disabled, and to purge those vertices from - * the vb. - */ -void -_tnl_exec_EvalMesh1( GLenum mode, GLint i1, GLint i2 ) -{ - GET_CURRENT_CONTEXT(ctx); - GLint i; - GLfloat u, du; - GLenum prim; - ASSERT_OUTSIDE_BEGIN_END(ctx); - - if (MESA_VERBOSE & VERBOSE_API) - _mesa_debug(ctx, "glEvalMesh1()"); - - switch (mode) { - case GL_POINT: - prim = GL_POINTS; - break; - case GL_LINE: - prim = GL_LINE_STRIP; - break; - default: - _mesa_error( ctx, GL_INVALID_ENUM, "glEvalMesh1(mode)" ); - return; - } - - /* No effect if vertex maps disabled. - */ - if (!ctx->Eval.Map1Vertex4 && !ctx->Eval.Map1Vertex3 && - (!ctx->VertexProgram.Enabled || !ctx->Eval.Map1Attrib[VERT_ATTRIB_POS])) - return; - - du = ctx->Eval.MapGrid1du; - u = ctx->Eval.MapGrid1u1 + i1 * du; - - /* Need to turn off compilation -- this is already saved, and the - * coordinates generated and the test above depend on state that - * may change before the list is executed. - * - * TODO: Anaylse display lists to determine if this state is - * constant. - * - * State to watch: - * - enabled maps - * - map state for each enabled map, including control points - * - grid state - * - * Could alternatively cache individual maps in arrays, rather than - * building immediates. - */ - { - ctx->Exec->Begin( prim ); - for (i=i1;i<=i2;i++,u+=du) { - ctx->Exec->EvalCoord1f( u ); - } - ctx->Exec->End(); - - /* Need this for replay *and* compile: - */ - FLUSH_VERTICES( ctx, 0 ); - } -} - - - -void -_tnl_exec_EvalMesh2( GLenum mode, GLint i1, GLint i2, GLint j1, GLint j2 ) -{ - GET_CURRENT_CONTEXT(ctx); - GLint i, j; - GLfloat u, du, v, dv, v1, u1; - ASSERT_OUTSIDE_BEGIN_END(ctx); - - if (MESA_VERBOSE & VERBOSE_API) - _mesa_debug(ctx, "glEvalMesh2()"); - - /* No effect if vertex maps disabled. - */ - if (!ctx->Eval.Map2Vertex4 && !ctx->Eval.Map2Vertex3 && - (!ctx->VertexProgram.Enabled || !ctx->Eval.Map2Attrib[VERT_ATTRIB_POS])) - return; - - du = ctx->Eval.MapGrid2du; - dv = ctx->Eval.MapGrid2dv; - v1 = ctx->Eval.MapGrid2v1 + j1 * dv; - u1 = ctx->Eval.MapGrid2u1 + i1 * du; - - /* Need to turn off compilation -- this is already saved, and the - * coordinates generated and the test above depend on state that - * may change before the list is executed. - */ - { - switch (mode) { - case GL_POINT: - ctx->Exec->Begin( GL_POINTS ); - for (v=v1,j=j1;j<=j2;j++,v+=dv) { - for (u=u1,i=i1;i<=i2;i++,u+=du) { - ctx->Exec->EvalCoord2f(u, v ); - } - } - ctx->Exec->End(); - break; - case GL_LINE: - for (v=v1,j=j1;j<=j2;j++,v+=dv) { - ctx->Exec->Begin( GL_LINE_STRIP ); - for (u=u1,i=i1;i<=i2;i++,u+=du) { - ctx->Exec->EvalCoord2f(u, v ); - } - ctx->Exec->End(); - } - for (u=u1,i=i1;i<=i2;i++,u+=du) { - ctx->Exec->Begin( GL_LINE_STRIP ); - for (v=v1,j=j1;j<=j2;j++,v+=dv) { - ctx->Exec->EvalCoord2f(u, v ); - } - ctx->Exec->End(); - } - break; - case GL_FILL: - for (v=v1,j=j1;j<j2;j++,v+=dv) { - ctx->Exec->Begin( GL_TRIANGLE_STRIP ); - for (u=u1,i=i1;i<=i2;i++,u+=du) { - ctx->Exec->EvalCoord2f(u, v ); - ctx->Exec->EvalCoord2f(u, v+dv ); - } - ctx->Exec->End(); - } - break; - default: - _mesa_error( ctx, GL_INVALID_ENUM, "glEvalMesh2(mode)" ); - return; - } - - /* Need this for replay *and* compile: - */ - FLUSH_VERTICES( ctx, 0 ); - } -} - - -void _tnl_eval_init( GLcontext *ctx ) -{ - GLvertexformat *vfmt = &(TNL_CONTEXT(ctx)->exec_vtxfmt); - vfmt->EvalMesh1 = _tnl_exec_EvalMesh1; - vfmt->EvalMesh2 = _tnl_exec_EvalMesh2; -} diff --git a/src/mesa/tnl/t_eval_api.h b/src/mesa/tnl/t_eval_api.h deleted file mode 100644 index 0ac6c0b147..0000000000 --- a/src/mesa/tnl/t_eval_api.h +++ /dev/null @@ -1,43 +0,0 @@ - -/* - * Mesa 3-D graphics library - * Version: 3.5 - * - * Copyright (C) 1999-2001 Brian Paul All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN - * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - - -#ifndef _T_EVAL_H -#define _T_EVAL_H - - -#include "mtypes.h" -#include "t_context.h" - -/* Use _mesa_save_EvalMesh{1,2} to save these to display lists. - */ -extern void _tnl_exec_EvalMesh1( GLenum mode, GLint i1, GLint i2 ); - -extern void _tnl_exec_EvalMesh2( GLenum mode, GLint i1, GLint i2, - GLint j1, GLint j2 ); - -void _tnl_eval_init( GLcontext *ctx ); - -#endif diff --git a/src/mesa/tnl/t_save_api.c b/src/mesa/tnl/t_save_api.c index 24e9c948d1..007984ddb8 100644 --- a/src/mesa/tnl/t_save_api.c +++ b/src/mesa/tnl/t_save_api.c @@ -1184,9 +1184,7 @@ void _tnl_save_init( GLcontext *ctx ) _save_vtxfmt_init( ctx ); - _mesa_vector1ub_init( &tmp->EdgeFlag, 0, 0 ); - - for (i = 0; i < _TNL_ATTRIB_EVALFLAG; i++) + for (i = 0; i < _TNL_ATTRIB_MAX; i++) _mesa_vector4f_init( &tmp->Attribs[i], 0, 0); } diff --git a/src/mesa/tnl/t_save_compile.c b/src/mesa/tnl/t_save_compile.c deleted file mode 100644 index 3ecb8a573e..0000000000 --- a/src/mesa/tnl/t_save_compile.c +++ /dev/null @@ -1,40 +0,0 @@ - -/* $XFree86$ */ -/************************************************************************** - -Copyright 2002 Tungsten Graphics Inc., Cedar Park, Texas. - -All Rights Reserved. - -Permission is hereby granted, free of charge, to any person obtaining a -copy of this software and associated documentation files (the "Software"), -to deal in the Software without restriction, including without limitation -on the rights to use, copy, modify, merge, publish, distribute, sub -license, and/or sell copies of the Software, and to permit persons to whom -the Software is furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice (including the next -paragraph) shall be included in all copies or substantial portions of the -Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL -TUNGSTEN GRAPHICS AND/OR THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM, -DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR -OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE -USE OR OTHER DEALINGS IN THE SOFTWARE. - -**************************************************************************/ - -/* - * Authors: - * Keith Whitwell <keith@tungstengraphics.com> - */ - -#include "dlist.h" -#include "context.h" -#include "macros.h" -#include "t_save_api.h" - - diff --git a/src/mesa/tnl/t_save_playback.c b/src/mesa/tnl/t_save_playback.c index 4e430f8c79..022b997641 100644 --- a/src/mesa/tnl/t_save_playback.c +++ b/src/mesa/tnl/t_save_playback.c @@ -56,7 +56,7 @@ static void _tnl_bind_vertex_list( GLcontext *ctx, VB->IndexPtr[1] = NULL; - for (attr = 0; attr < _TNL_ATTRIB_EVALFLAG; attr++) { + for (attr = 0; attr <= _TNL_ATTRIB_INDEX; attr++) { if (node->attrsz[attr]) { tmp->Attribs[attr].count = node->count; tmp->Attribs[attr].data = (GLfloat (*)[4]) data; @@ -71,21 +71,12 @@ static void _tnl_bind_vertex_list( GLcontext *ctx, } } - /* Index and edgeflag require special treatment, as usual: - */ - if (node->attrsz[_TNL_ATTRIB_INDEX]) { - tmp->Index.count = node->count; - tmp->Index.data = data; - tmp->Index.start = data; - tmp->Index.stride = node->vertex_size * sizeof(GLfloat); - VB->IndexPtr[0] = &tmp->Index; - data++; - } - /* Copy edgeflag to a contiguous array? + /* Copy edgeflag to a contiguous array */ if (node->attrsz[_TNL_ATTRIB_EDGEFLAG]) { - VB->EdgeFlag = _tnl_translate_edgeflag( ctx, data, node->vertex_size ); + VB->EdgeFlag = _tnl_translate_edgeflag( ctx, data, node->count, + node->vertex_size ); data++; } @@ -94,6 +85,7 @@ static void _tnl_bind_vertex_list( GLcontext *ctx, VB->ObjPtr = VB->AttribPtr[_TNL_ATTRIB_POS]; VB->NormalPtr = VB->AttribPtr[_TNL_ATTRIB_NORMAL]; VB->ColorPtr[0] = VB->AttribPtr[_TNL_ATTRIB_COLOR0]; + VB->IndexPtr[0] = VB->AttribPtr[_TNL_ATTRIB_INDEX]; VB->SecondaryColorPtr[0] = VB->AttribPtr[_TNL_ATTRIB_COLOR1]; for (i = 0; i < ctx->Const.MaxTextureCoordUnits; i++) { diff --git a/src/mesa/tnl/t_vb_light.c b/src/mesa/tnl/t_vb_light.c index b3f7c9e8d9..5bb88e333a 100644 --- a/src/mesa/tnl/t_vb_light.c +++ b/src/mesa/tnl/t_vb_light.c @@ -50,7 +50,7 @@ typedef void (*light_func)( GLcontext *ctx, struct light_stage_data { GLvector4f LitColor[2]; GLvector4f LitSecondary[2]; - GLvector1f LitIndex[2]; + GLvector4f LitIndex[2]; light_func *light_func_tab; }; @@ -210,8 +210,8 @@ static GLboolean run_init_lighting( GLcontext *ctx, _mesa_vector4f_alloc( &store->LitColor[1], 0, size, 32 ); _mesa_vector4f_alloc( &store->LitSecondary[0], 0, size, 32 ); _mesa_vector4f_alloc( &store->LitSecondary[1], 0, size, 32 ); - _mesa_vector1f_alloc( &store->LitIndex[0], 0, size, 32 ); - _mesa_vector1f_alloc( &store->LitIndex[1], 0, size, 32 ); + _mesa_vector4f_alloc( &store->LitIndex[0], 0, size, 32 ); + _mesa_vector4f_alloc( &store->LitIndex[1], 0, size, 32 ); /* Now validate the stage derived data... */ @@ -253,8 +253,8 @@ static void dtr( struct tnl_pipeline_stage *stage ) _mesa_vector4f_free( &store->LitColor[1] ); _mesa_vector4f_free( &store->LitSecondary[0] ); _mesa_vector4f_free( &store->LitSecondary[1] ); - _mesa_vector1f_free( &store->LitIndex[0] ); - _mesa_vector1f_free( &store->LitIndex[1] ); + _mesa_vector4f_free( &store->LitIndex[0] ); + _mesa_vector4f_free( &store->LitIndex[1] ); FREE( store ); stage->privatePtr = 0; } diff --git a/src/mesa/tnl/t_vb_lighttmp.h b/src/mesa/tnl/t_vb_lighttmp.h index 87071978bf..dd83733582 100644 --- a/src/mesa/tnl/t_vb_lighttmp.h +++ b/src/mesa/tnl/t_vb_lighttmp.h @@ -646,9 +646,9 @@ static void TAG(light_ci)( GLcontext *ctx, if (stage->changed_inputs == 0) return; - indexResult[0] = VB->IndexPtr[0]->data; + indexResult[0] = (GLfloat *)VB->IndexPtr[0]->data; if (IDX & LIGHT_TWOSIDE) - indexResult[1] = VB->IndexPtr[1]->data; + indexResult[1] = (GLfloat *)VB->IndexPtr[1]->data; /* loop over vertices */ for (j=0; j<nr; j++,STRIDE_F(vertex,vstride),STRIDE_F(normal, nstride)) { diff --git a/src/mesa/tnl/t_vtx_api.c b/src/mesa/tnl/t_vtx_api.c index a0f45791f6..8da76b844c 100644 --- a/src/mesa/tnl/t_vtx_api.c +++ b/src/mesa/tnl/t_vtx_api.c @@ -31,12 +31,21 @@ USE OR OTHER DEALINGS IN THE SOFTWARE. * Keith Whitwell <keith@tungstengraphics.com> */ +#include "context.h" +#include "macros.h" +#include "dlist.h" +#include "api_arrayelt.h" +#include "api_noop.h" +#include "t_vtx_api.h" + /* Close off the last primitive, execute the buffer, restart the * primitive. */ static void _tnl_wrap_buffers( GLcontext *ctx ) { + TNLcontext *tnl = TNL_CONTEXT(ctx); + if (ctx->Driver.CurrentExecPrimitive != GL_POLYGON+1) { GLint i = tnl->vtx.prim_count - 1; assert(i >= 0); @@ -46,7 +55,7 @@ static void _tnl_wrap_buffers( GLcontext *ctx ) /* Execute the buffer and save copied vertices. */ - _tnl_flush_immediate( ctx ); + _tnl_flush_vtx( ctx ); /* Emit a glBegin to start the new list. */ @@ -63,73 +72,78 @@ static void _tnl_wrap_buffers( GLcontext *ctx ) static void _tnl_wrap_filled_vertex( GLcontext *ctx ) { + TNLcontext *tnl = TNL_CONTEXT(ctx); + GLfloat *data = tnl->vtx.copied.buffer; int i; /* Run pipeline on current vertices, copy wrapped vertices - * to tnl->copied_verts. + * to tnl->copied. */ _tnl_wrap_buffers( ctx ); /* Copy stored stored vertices to start of new list. */ - assert(tnl->vtx.counter > tnl->copied_verts.nr); + assert(tnl->vtx.counter > tnl->vtx.copied.nr); - for (i = 0 ; i < tnl->copied_verts.nr ; i++) { + for (i = 0 ; i < tnl->vtx.copied.nr ; i++) { memcpy( tnl->vtx.vbptr, data, tnl->vtx.vertex_size * sizeof(GLfloat)); tnl->vtx.vbptr += tnl->vtx.vertex_size; data += tnl->vtx.vertex_size; tnl->vtx.counter--; } - tnl->copied_verts.nr = 0; + tnl->vtx.copied.nr = 0; } -static void tnl_copy_to_current( GLcontext *ctx ) +static void _tnl_copy_to_current( GLcontext *ctx ) { TNLcontext *tnl = TNL_CONTEXT(ctx); + GLuint i; - for (i = _TNL_ATTRIB_POS+1 ; i < _TNL_ATTRIB_EVALFLAG ; i++) - switch (tnl->vtx.attrib[i].sz) { - case 4: tnl->vtx.attrib[i].current[3] = tnl->vtx.vbptr[i].fi[3].f; - case 3: tnl->vtx.attrib[i].current[2] = tnl->vtx.vbptr[i].fi[2].f; - case 2: tnl->vtx.attrib[i].current[1] = tnl->vtx.vbptr[i].fi[1].f; - case 1: tnl->vtx.attrib[i].current[0] = tnl->vtx.vbptr[i].fi[0].f; + for (i = _TNL_ATTRIB_POS+1 ; i < _TNL_ATTRIB_INDEX ; i++) + switch (tnl->vtx.attrsz[i]) { + case 4: tnl->vtx.current[i][3] = tnl->vtx.attrptr[i][3]; + case 3: tnl->vtx.current[i][2] = tnl->vtx.attrptr[i][2]; + case 2: tnl->vtx.current[i][1] = tnl->vtx.attrptr[i][1]; + case 1: tnl->vtx.current[i][0] = tnl->vtx.attrptr[i][0]; break; } /* Edgeflag and Index require special treatment: */ - if (tnl->vtx.attrib[_TNL_ATTRIB_INDEX].sz) - ctx->Current.Index = tnl->vtx.vbptr[_TNL_ATTRIB_INDEX]; + if (tnl->vtx.attrsz[_TNL_ATTRIB_INDEX]) + ctx->Current.Index = tnl->vtx.attrptr[_TNL_ATTRIB_INDEX][0]; - if (tnl->vtx.attrib[_TNL_ATTRIB_EDGEFLAG].sz) - ctx->Current.Edgeflag = (tnl->vtx.vbptr[_TNL_ATTRIB_EDGEFLAG] == 1.0); + if (tnl->vtx.attrsz[_TNL_ATTRIB_EDGEFLAG]) + ctx->Current.EdgeFlag = (tnl->vtx.attrptr[_TNL_ATTRIB_EDGEFLAG][0] == 1.0); ctx->Driver.NeedFlush &= ~FLUSH_UPDATE_CURRENT; } -static void tnl_copy_from_current( GLcontext *ctx ) +static void _tnl_copy_from_current( GLcontext *ctx ) { TNLcontext *tnl = TNL_CONTEXT(ctx); - - for (i = _TNL_ATTRIB_POS+1 ; i < _TNL_ATTRIB_EVALFLAG ; i++) - switch (tnl->vtx.attrib[i].sz) { - case 4: tnl->vtx.vbptr[i].fi[3].f = tnl->vtx.attrib[i].current[3]; - case 3: tnl->vtx.vbptr[i].fi[2].f = tnl->vtx.attrib[i].current[2]; - case 2: tnl->vtx.vbptr[i].fi[1].f = tnl->vtx.attrib[i].current[1]; - case 1: tnl->vtx.vbptr[i].fi[0].f = tnl->vtx.attrib[i].current[0]; + GLint i; + + for (i = _TNL_ATTRIB_POS+1 ; i < _TNL_ATTRIB_INDEX ; i++) + switch (tnl->vtx.attrsz[i]) { + case 4: tnl->vtx.attrptr[i][3] = tnl->vtx.current[i][3]; + case 3: tnl->vtx.attrptr[i][2] = tnl->vtx.current[i][2]; + case 2: tnl->vtx.attrptr[i][1] = tnl->vtx.current[i][1]; + case 1: tnl->vtx.attrptr[i][0] = tnl->vtx.current[i][0]; break; } /* Edgeflag and Index require special treatment: */ - if (tnl->vtx.attrib[_TNL_ATTRIB_INDEX].sz) - tnl->vtx.vbptr[_TNL_ATTRIB_INDEX][0] = ctx->Current.Index; + if (tnl->vtx.attrsz[_TNL_ATTRIB_INDEX]) + tnl->vtx.attrptr[_TNL_ATTRIB_INDEX][0] = ctx->Current.Index; - if (tnl->vtx.attrib[_TNL_ATTRIB_EDGEFLAG].sz) - tnl->vtx.vbptr[_TNL_ATTRIB_EDGEFLAG][0] = (GLfloat)ctx->Current.Edgeflag; + if (tnl->vtx.attrsz[_TNL_ATTRIB_EDGEFLAG]) + tnl->vtx.attrptr[_TNL_ATTRIB_EDGEFLAG][0] = + (GLfloat)ctx->Current.EdgeFlag; ctx->Driver.NeedFlush |= FLUSH_UPDATE_CURRENT; @@ -147,10 +161,11 @@ static void _tnl_wrap_upgrade_vertex( GLcontext *ctx, { TNLcontext *tnl = TNL_CONTEXT(ctx); GLuint oldsz; - GLint diff; + GLint i; + GLfloat *tmp; /* Run pipeline on current vertices, copy wrapped vertices - * to tnl->copied_verts. + * to tnl->vtx.copied. */ _tnl_wrap_buffers( ctx ); @@ -162,21 +177,21 @@ static void _tnl_wrap_upgrade_vertex( GLcontext *ctx, /* Fix up sizes: */ - oldsz = tnl->vtx.attrib[attr].sz; - tnl->vtx.attrib[attr].sz = newsz; + oldsz = tnl->vtx.attrsz[attr]; + tnl->vtx.attrsz[attr] = newsz; tnl->vtx.vertex_size += newsz - oldsz; - tnl->vtx.counter = tnl->vtx.vbsize / tnl->vtx.vertex_size; + tnl->vtx.counter = VERT_BUFFER_SIZE / tnl->vtx.vertex_size; tnl->vtx.initial_counter = tnl->vtx.counter; tnl->vtx.vbptr = tnl->vtx.buffer; /* Recalculate all the attrptr[] values */ - for (i = 0, tmp = tnl->vtx.vertex ; i < TNL_MAX_ATTRIB ; i++) { - if (tnl->vtx.attrib[i].sz) { + for (i = 0, tmp = tnl->vtx.vertex ; i < _TNL_ATTRIB_MAX ; i++) { + if (tnl->vtx.attrsz[i]) { tnl->vtx.attrptr[i] = tmp; - tmp += tnl->vtx.attrib[i].sz; + tmp += tnl->vtx.attrsz[i]; } else tnl->vtx.attrptr[i] = 0; /* will not be dereferenced */ @@ -192,20 +207,21 @@ static void _tnl_wrap_upgrade_vertex( GLcontext *ctx, * -- No need to replay - just copy piecewise */ { - GLfloat *data = tnl->copied_verts.buffer; + GLfloat *data = tnl->vtx.copied.buffer; GLfloat *tmp = tnl->vtx.buffer; + GLuint j; - for (i = 0 ; i < tnl->copied_verts.nr ; i++) { - for (j = 1 ; j < TNL_MAX_ATTRIB ; j++) { - if (tnl->vtx.attrib[j].sz) { + for (i = 0 ; i < tnl->vtx.copied.nr ; i++) { + for (j = 1 ; j < _TNL_ATTRIB_MAX ; j++) { + if (tnl->vtx.attrsz[j]) { if (j == attr) { - COPY_SZ_4V( tmp, newsz, tnl->vtx.attrib[attr].current ); + COPY_SZ_4V( tmp, newsz, tnl->vtx.current[attr] ); COPY_SZ_4V( tmp, oldsz, data ); data += oldsz; tmp += newsz; } else { - GLuint sz = tnl->vtx.attrib[j].sz; + GLuint sz = tnl->vtx.attrsz[j]; COPY_SZ_4V( tmp, sz, data ); tmp += sz; data += sz; @@ -216,44 +232,51 @@ static void _tnl_wrap_upgrade_vertex( GLcontext *ctx, } tnl->vtx.vbptr = tmp; - tnl->vtx.counter -= tnl->copied_verts.nr; - tnl->copied_verts.nr = 0; + tnl->vtx.counter -= tnl->vtx.copied.nr; + tnl->vtx.copied.nr = 0; } -static void _tnl_fixup_vertex( ) +static void _tnl_fixup_vertex( GLcontext *ctx, GLuint attr, GLuint sz ) { + TNLcontext *tnl = TNL_CONTEXT(ctx); static float id[4] = { 0, 0, 0, 1 }; int i; - if (tnl->vtx.attrib_sz[attr] < sz) { + if (tnl->vtx.attrsz[attr] < sz) { /* New size is larger. Need to flush existing vertices and get * an enlarged vertex format. */ - _tnl_wrap_upgrade_vertex( tnl, attr, sz ); + _tnl_wrap_upgrade_vertex( ctx, attr, sz ); } - else if (tnl->vtx.attrib_sz[attr] > sz) { + else if (tnl->vtx.attrsz[attr] > sz) { /* New size is smaller - just need to fill in some * zeros. Don't need to flush or wrap. */ - for (i = sz ; i <= tnl->vtx.attrib_sz[attr] ; i++) - tnl->vtx.attrptr[attr].fi[i-1].f = id[i-1]; + for (i = sz ; i <= tnl->vtx.attrsz[attr] ; i++) + tnl->vtx.attrptr[attr][i-1] = id[i-1]; } } + + /* Helper function for 'CHOOSE' macro. Do what's necessary when an * entrypoint is called for the first time. */ -static void *do_choose( GLuint attr, GLuint sz, +static void do_choose( GLuint attr, GLuint sz, void (*fallback_attr_func)( const GLfloat *), + void (*choose1)( const GLfloat *), + void (*choose2)( const GLfloat *), + void (*choose3)( const GLfloat *), + void (*choose4)( const GLfloat *), const GLfloat *v ) { GET_CURRENT_CONTEXT( ctx ); TNLcontext *tnl = TNL_CONTEXT(ctx); - if (tnl->vtx.attrib_sz[attr] != sz) - _tnl_fixup_vertex( tnl, attr, sz ); + if (tnl->vtx.attrsz[attr] != sz) + _tnl_fixup_vertex( ctx, attr, sz ); /* Does this belong here? Necessitates resetting vtxfmt on each * flush (otherwise flags won't get reset afterwards). @@ -265,23 +288,18 @@ static void *do_choose( GLuint attr, GLuint sz, /* Reset any active pointers for this attribute */ - for (i = 1; i <= 4; i++) - tnl->vtx.tabfv[attr][i-1] = tnl->vtx.initial_tabfv[attr][i-1]; + tnl->vtx.tabfv[attr][0] = choose1; + tnl->vtx.tabfv[attr][1] = choose2; + tnl->vtx.tabfv[attr][2] = choose3; + tnl->vtx.tabfv[attr][3] = choose4; /* Update the secondary dispatch table with the new function */ tnl->vtx.tabfv[attr][sz-1] = fallback_attr_func; - (*fallback_attr_func)(v); } -static void do_flush( void ) -{ - GET_CURRENT_CONTEXT( ctx ); - _tnl_FlushVertices( ctx, FLUSH_STORED_VERTICES ); -} - /* Versions of all the entrypoints for situations where codegen isn't * available. @@ -293,7 +311,9 @@ static void do_flush( void ) * is the job of the chooser function when switching between Color4f * and Color3f. */ -#define ATTRFV( ATTR, N ) \ +#define ATTRFV( ATTR, N ) \ +static void choose_##ATTR##_##N( const GLfloat *v ); \ + \ static void attrib_##ATTR##_##N( const GLfloat *v ) \ { \ GET_CURRENT_CONTEXT( ctx ); \ @@ -302,10 +322,10 @@ static void attrib_##ATTR##_##N( const GLfloat *v ) \ if ((ATTR) == 0) { \ int i; \ \ - if (N>0) tnl->vtx.vbptr[0] = (V)[0]; \ - if (N>1) tnl->vtx.vbptr[1] = (V)[1]; \ - if (N>2) tnl->vtx.vbptr[2] = (V)[2]; \ - if (N>3) tnl->vtx.vbptr[3] = (V)[3]; \ + if (N>0) tnl->vtx.vbptr[0] = v[0]; \ + if (N>1) tnl->vtx.vbptr[1] = v[1]; \ + if (N>2) tnl->vtx.vbptr[2] = v[2]; \ + if (N>3) tnl->vtx.vbptr[3] = v[3]; \ \ for (i = N; i < tnl->vtx.vertex_size; i++) \ tnl->vtx.vbptr[i] = tnl->vtx.vertex[i]; \ @@ -313,21 +333,27 @@ static void attrib_##ATTR##_##N( const GLfloat *v ) \ tnl->vtx.vbptr += tnl->vtx.vertex_size; \ \ if (--tnl->vtx.counter == 0) \ - do_flush(); \ + _tnl_wrap_filled_vertex( ctx ); \ } \ else { \ - TNLfi *dest = tnl->vtx.attrptr[ATTR]; \ - if (N>0) dest[0] = (V)[0]; \ - if (N>1) dest[1] = (V)[1]; \ - if (N>2) dest[2] = (V)[2]; \ - if (N>3) dest[3] = (V)[3]; \ + GLfloat *dest = tnl->vtx.attrptr[ATTR]; \ + if (N>0) dest[0] = v[0]; \ + if (N>1) dest[1] = v[1]; \ + if (N>2) dest[2] = v[2]; \ + if (N>3) dest[3] = v[3]; \ } \ } #define CHOOSE( ATTR, N ) \ static void choose_##ATTR##_##N( const GLfloat *v ) \ { \ - do_choose(ATTR, N, attrib_##ATTR##_##N, v); \ + do_choose(ATTR, N, \ + attrib_##ATTR##_##N, \ + choose_##ATTR##_1, \ + choose_##ATTR##_2, \ + choose_##ATTR##_3, \ + choose_##ATTR##_4, \ + v ); \ } #define ATTRS( ATTRIB ) \ @@ -407,13 +433,6 @@ static void enum_error( void ) _mesa_error( ctx, GL_INVALID_ENUM, __FUNCTION__ ); } -static void op_error( void ) -{ - GET_CURRENT_CONTEXT( ctx ); - _mesa_error( ctx, GL_INVALID_OPERATION, __FUNCTION__ ); -} - - static void _tnl_Vertex2f( GLfloat x, GLfloat y ) { DISPATCH_ATTR2F( _TNL_ATTRIB_POS, x, y ); @@ -666,16 +685,16 @@ static void _tnl_VertexAttrib4fvNV( GLuint index, const GLfloat *v ) */ #define MAT_ATTR( A, N, params ) \ do { \ - if (tnl->vtx.attrib_sz[A] != N) { \ - tnl_fixup_vertex( ctx, A, N ); \ + if (tnl->vtx.attrsz[A] != N) { \ + _tnl_fixup_vertex( ctx, A, N ); \ } \ \ { \ - TNLfi *dest = tnl->vtx.attrptr[A]; \ - if (N>0) dest[0].f = params[0]; \ - if (N>1) dest[1].f = params[1]; \ - if (N>2) dest[2].f = params[2]; \ - if (N>3) dest[3].f = params[3]; \ + GLfloat *dest = tnl->vtx.attrptr[A]; \ + if (N>0) dest[0] = params[0]; \ + if (N>1) dest[1] = params[1]; \ + if (N>2) dest[2] = params[2]; \ + if (N>3) dest[3] = params[3]; \ ctx->Driver.NeedFlush |= FLUSH_UPDATE_CURRENT; \ } \ } while (0) @@ -745,13 +764,13 @@ do { \ GET_CURRENT_CONTEXT( ctx ); \ TNLcontext *tnl = TNL_CONTEXT(ctx); \ \ - if (tnl->vtx.attrib_sz[A] != 1) { \ - tnl_fixup_vertex( ctx, A, 1 ); \ + if (tnl->vtx.attrsz[A] != 1) { \ + _tnl_fixup_vertex( ctx, A, 1 ); \ } \ \ { \ - TNLfi *dest = tnl->vtx.attrptr[A]; \ - dest[0].ui = IDX; \ + GLfloat *dest = tnl->vtx.attrptr[A]; \ + dest[0] = IDX; \ ctx->Driver.NeedFlush |= FLUSH_UPDATE_CURRENT; \ } \ } while (0) @@ -777,71 +796,99 @@ static void _tnl_Indexfv( const GLfloat *v ) IDX_ATTR( _TNL_ATTRIB_INDEX, v[0] ); } - -/* EvalCoord - * - * Set a flag to indicate that this vertex is an eval point/coordinate. - * Emit the vertex with the eval point/coord in attrib 0 (POS). - * Set the flag back to zero. +/* Eval */ -static void evalcoord( GLfloat a, GLfloat b, GLuint type ) +static void _tnl_EvalCoord1f( GLfloat u ) { - /* Do this with a 'CHOOSE()' function */ - { - GET_CURRENT_CONTEXT( ctx ); - TNLcontext *tnl = TNL_CONTEXT(ctx); + GET_CURRENT_CONTEXT( ctx ); + TNLcontext *tnl = TNL_CONTEXT(ctx); - if (tnl->eval.EvalNewState & _NEW_EVAL) + /* TODO: use a CHOOSE() function for this: */ + { + GLint i; + if (tnl->vtx.eval.new_state) _tnl_update_eval( ctx ); - if (type == TNL_EVAL_COORD1 && !tnl->Eval._ActiveMap1Attrib[0].map) - return; - if (type == TNL_EVAL_COORD2 && !tnl->Eval._ActiveMap2Attrib[0].map) - return; + for (i = 0 ; i <= _TNL_ATTRIB_INDEX ; i++) { + if (tnl->vtx.eval.map1[i].map) + if (tnl->vtx.attrsz[i] < tnl->vtx.eval.map1[i].sz) + _tnl_fixup_vertex( ctx, i, tnl->vtx.eval.map1[i].sz ); + } } - - IDX_ATTR( _TNL_ATTRIB_EVALFLAG, type ); - ATTR2F( _TNL_ATTRIB_POS, a, b ); - IDX_ATTR( _TNL_ATTRIB_EVALFLAG, TNL_EVAL_NONE ); -} -static void _tnl_EvalCoord1f( GLfloat u ) -{ - evalcoord( u, 0, TNL_EVAL_COORD1 ); + memcpy( tnl->vtx.copied.buffer, tnl->vtx.vertex, + tnl->vtx.vertex_size * sizeof(GLfloat)); + + _tnl_do_EvalCoord1f( ctx, u ); + + memcpy( tnl->vtx.vertex, tnl->vtx.copied.buffer, + tnl->vtx.vertex_size * sizeof(GLfloat)); } -static void _tnl_EvalCoord1fv( const GLfloat *v ) +static void _tnl_EvalCoord2f( GLfloat u, GLfloat v ) { - evalcoord( v[0], 0, TNL_EVAL_COORD1 ); + GET_CURRENT_CONTEXT( ctx ); + TNLcontext *tnl = TNL_CONTEXT(ctx); + + /* TODO: use a CHOOSE() function for this: */ + { + GLint i; + if (tnl->vtx.eval.new_state) + _tnl_update_eval( ctx ); + + for (i = 0 ; i <= _TNL_ATTRIB_INDEX ; i++) { + if (tnl->vtx.eval.map2[i].map) + if (tnl->vtx.attrsz[i] < tnl->vtx.eval.map2[i].sz) + _tnl_fixup_vertex( ctx, i, tnl->vtx.eval.map2[i].sz ); + } + + if (ctx->Eval.AutoNormal) + if (tnl->vtx.attrsz[_TNL_ATTRIB_NORMAL] < 3) + _tnl_fixup_vertex( ctx, _TNL_ATTRIB_NORMAL, 3 ); + } + + memcpy( tnl->vtx.copied.buffer, tnl->vtx.vertex, + tnl->vtx.vertex_size * sizeof(GLfloat)); + + _tnl_do_EvalCoord2f( ctx, u, v ); + + memcpy( tnl->vtx.vertex, tnl->vtx.copied.buffer, + tnl->vtx.vertex_size * sizeof(GLfloat)); } -static void _tnl_EvalCoord2f( GLfloat u, GLfloat v ) +static void _tnl_EvalCoord1fv( const GLfloat *u ) { - evalcoord( u, v, TNL_EVAL_COORD2 ); + _tnl_EvalCoord1f( u[0] ); } -static void _tnl_EvalCoord2fv( const GLfloat *v ) +static void _tnl_EvalCoord2fv( const GLfloat *u ) { - evalcoord( v[0], v[1], TNL_EVAL_COORD2 ); + _tnl_EvalCoord2f( u[0], u[1] ); } static void _tnl_EvalPoint1( GLint i ) { - GET_CURRENT_CONTEXT(ctx); - GLfloat du = ctx->Eval.MapGrid1du; - GLfloat u1 = ctx->Eval.MapGrid1u1; - glEvalCoord1f( i * du + u1 ); + GET_CURRENT_CONTEXT( ctx ); + GLfloat du = ((ctx->Eval.MapGrid1u2 - ctx->Eval.MapGrid1u1) / + (GLfloat) ctx->Eval.MapGrid1un); + GLfloat u = i * du + ctx->Eval.MapGrid1u1; + + _tnl_EvalCoord1f( u ); } + static void _tnl_EvalPoint2( GLint i, GLint j ) { - GET_CURRENT_CONTEXT(ctx); - GLfloat du = ctx->Eval.MapGrid1du; - GLfloat u1 = ctx->Eval.MapGrid1u1; - GLfloat dv = ctx->Eval.MapGrid1dv; - GLfloat v1 = ctx->Eval.MapGrid1v1; - glEvalCoord2f( i * du + u1, j * dv + v1 ); + GET_CURRENT_CONTEXT( ctx ); + GLfloat du = ((ctx->Eval.MapGrid2u2 - ctx->Eval.MapGrid2u1) / + (GLfloat) ctx->Eval.MapGrid2un); + GLfloat dv = ((ctx->Eval.MapGrid2v2 - ctx->Eval.MapGrid2v1) / + (GLfloat) ctx->Eval.MapGrid2vn); + GLfloat u = i * du + ctx->Eval.MapGrid2u1; + GLfloat v = j * dv + ctx->Eval.MapGrid2v1; + + _tnl_EvalCoord2f( u, v ); } @@ -858,7 +905,7 @@ static void _tnl_Begin( GLenum mode ) tnl->vtx.prim[i].mode = mode | PRIM_BEGIN; tnl->vtx.prim[i].start = tnl->vtx.initial_counter - tnl->vtx.counter; - tnl->vtx.prim[i].nr = 0; + tnl->vtx.prim[i].count = 0; ctx->Driver.CurrentExecPrimitive = mode; } @@ -877,21 +924,21 @@ static void _tnl_End( void ) int i = tnl->vtx.prim_count - 1; tnl->vtx.prim[i].mode |= PRIM_END; - tnl->vtx.prim[i].nr = idx - tnl->vtx.prim[i].start; + tnl->vtx.prim[i].count = idx - tnl->vtx.prim[i].start; ctx->Driver.CurrentExecPrimitive = GL_POLYGON+1; - if (tnl->vtx.prim_count == _TNL_MAX_PRIM) - _tnl_flush_immediate( ctx ); + if (tnl->vtx.prim_count == TNL_MAX_PRIM) + _tnl_flush_vtx( ctx ); } else _mesa_error( ctx, GL_INVALID_OPERATION, __FUNCTION__ ); } -void _tnl_imm_vtxfmt_init( GLcontext *ctx ) +static void _tnl_imm_vtxfmt_init( GLcontext *ctx ) { - GLvertexformat *vfmt = &(TNL_CONTEXT(ctx)->vtxfmt); + GLvertexformat *vfmt = &(TNL_CONTEXT(ctx)->exec_vtxfmt); vfmt->ArrayElement = _ae_loopback_array_elt; /* generic helper */ vfmt->Begin = _tnl_Begin; vfmt->CallList = _mesa_CallList; @@ -914,16 +961,15 @@ void _tnl_imm_vtxfmt_init( GLcontext *ctx ) vfmt->Indexfv = _tnl_Indexfv; vfmt->Materialfv = _tnl_Materialfv; vfmt->MultiTexCoord1fARB = _tnl_MultiTexCoord1f; - vfmt->MultiTexCoord1fvARB = _tnl_MultiTexCoord1fvARB; + vfmt->MultiTexCoord1fvARB = _tnl_MultiTexCoord1fv; vfmt->MultiTexCoord2fARB = _tnl_MultiTexCoord2f; - vfmt->MultiTexCoord2fvARB = _tnl_MultiTexCoord2fvARB; + vfmt->MultiTexCoord2fvARB = _tnl_MultiTexCoord2fv; vfmt->MultiTexCoord3fARB = _tnl_MultiTexCoord3f; - vfmt->MultiTexCoord3fvARB = _tnl_MultiTexCoord3fvARB; + vfmt->MultiTexCoord3fvARB = _tnl_MultiTexCoord3fv; vfmt->MultiTexCoord4fARB = _tnl_MultiTexCoord4f; - vfmt->MultiTexCoord4fvARB = _tnl_MultiTexCoord4fvARB; + vfmt->MultiTexCoord4fvARB = _tnl_MultiTexCoord4fv; vfmt->Normal3f = _tnl_Normal3f; vfmt->Normal3fv = _tnl_Normal3fv; - vfmt->Rectf = _tnl_Rectf; vfmt->SecondaryColor3fEXT = _tnl_SecondaryColor3fEXT; vfmt->SecondaryColor3fvEXT = _tnl_SecondaryColor3fvEXT; vfmt->TexCoord1f = _tnl_TexCoord1f; @@ -948,6 +994,10 @@ void _tnl_imm_vtxfmt_init( GLcontext *ctx ) vfmt->VertexAttrib3fvNV = _tnl_VertexAttrib3fvNV; vfmt->VertexAttrib4fNV = _tnl_VertexAttrib4fNV; vfmt->VertexAttrib4fvNV = _tnl_VertexAttrib4fvNV; + + vfmt->Rectf = _mesa_noop_Rectf; + vfmt->EvalMesh1 = _mesa_noop_EvalMesh1; + vfmt->EvalMesh2 = _mesa_noop_EvalMesh2; } @@ -957,17 +1007,11 @@ void _tnl_imm_vtxfmt_init( GLcontext *ctx ) void _tnl_vtx_init( GLcontext *ctx ) { TNLcontext *tnl = TNL_CONTEXT(ctx); - _tnl_InitDispatch( tnl->Exec ); - - TNLcontext *tnl = TNL_CONTEXT(ctx); - struct tnl_vertex_arrays *tmp = &tnl->imm_inputs; + struct tnl_vertex_arrays *tmp = &tnl->vtx_inputs; GLuint i; - _mesa_vector1f_init( &tmp->Index, 0, 0 ); - _mesa_vector1ub_init( &tmp->EdgeFlag, 0, 0 ); - - for (i = 0; i < _TNL_ATTRIB_EVALFLAG; i++) - _mesa_vector4f_init( &tmp->Attrib[i], 0, 0); + for (i = 0; i < _TNL_ATTRIB_INDEX; i++) + _mesa_vector4f_init( &tmp->Attribs[i], 0, 0); _tnl_imm_vtxfmt_init( ctx ); } diff --git a/src/mesa/tnl/t_vtx_api.h b/src/mesa/tnl/t_vtx_api.h index d1e2d96e33..12edd9077d 100644 --- a/src/mesa/tnl/t_vtx_api.h +++ b/src/mesa/tnl/t_vtx_api.h @@ -40,7 +40,11 @@ USE OR OTHER DEALINGS IN THE SOFTWARE. extern void _tnl_vtx_init( GLcontext *ctx ); extern void _tnl_vtx_destroy( GLcontext *ctx ); -extern void _tnl_vtx_invalidate( GLcontext *ctx ); -extern void _tnl_flush_vertices( GLcontext *ctx, GLuint flags ); +extern void _tnl_FlushVertices( GLcontext *ctx, GLuint flags ); +extern void _tnl_flush_vtx( GLcontext *ctx ); + +extern void _tnl_do_EvalCoord2f( GLcontext* ctx, GLfloat u, GLfloat v ); +extern void _tnl_do_EvalCoord1f(GLcontext* ctx, GLfloat u); +extern void _tnl_update_eval( GLcontext *ctx ); #endif diff --git a/src/mesa/tnl/t_vtx_eval.c b/src/mesa/tnl/t_vtx_eval.c index 3ba7b42c78..a9ad6b20e2 100644 --- a/src/mesa/tnl/t_vtx_eval.c +++ b/src/mesa/tnl/t_vtx_eval.c @@ -1,4 +1,3 @@ - /* * Mesa 3-D graphics library * Version: 5.1 @@ -26,185 +25,42 @@ * Keith Whitwell <keith@tungstengraphics.com> */ - #include "glheader.h" -#include "colormac.h" +#include "api_eval.h" #include "context.h" #include "macros.h" -#include "imports.h" -#include "mtypes.h" #include "math/m_eval.h" - -#include "t_context.h" -#include "t_imm_debug.h" -#include "t_imm_eval.h" -#include "t_imm_exec.h" -#include "t_imm_fixup.h" -#include "t_imm_alloc.h" - - - -static const GLubyte dirty_flags[5] = { - 0, /* not possible */ - VEC_DIRTY_0, - VEC_DIRTY_1, - VEC_DIRTY_2, - VEC_DIRTY_3 -}; - - -static void eval1_4f( GLvector4f *dest, - GLfloat coord[][4], - const GLuint *flags, - GLuint dimension, - const struct gl_1d_map *map ) -{ - const GLfloat u1 = map->u1; - const GLfloat du = map->du; - GLfloat (*to)[4] = dest->data; - GLuint i; - - for (i = 0 ; i < count ; i++) - if (flags[i] == TNL_EVAL_COORD1) { - 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); - dest->flags |= dirty_flags[dimension]; -} +#include "t_vtx_api.h" - -static void eval2_auto_normal( GLvector4f *pos_ptr, - GLvector4f *norm_ptr, - GLfloat coord[][4], - GLuint *flags, - GLuint dimension, - const struct gl_2d_map *map ) +static void clear_active_eval1( TNLcontext *tnl, GLuint attr ) { - const GLfloat u1 = map->u1; - const GLfloat du = map->du; - const GLfloat v1 = map->v1; - const GLfloat dv = map->dv; - GLfloat (*pos)[4] = pos_ptr->data; - GLfloat (*normal)[4] = norm_ptr->data; - GLuint i; - - for (i = 0 ; i < count ; i++) - if (flags[i] == TNL_EVAL_COORD2) { - GLfloat u = (coord[i][0] - u1) * du; - GLfloat v = (coord[i][1] - v1) * dv; - GLfloat du[4], dv[4]; - - ASSIGN_4V(pos[i], 0,0,0,1); - _math_de_casteljau_surf(map->Points, pos[i], du, dv, u, v, dimension, - map->Uorder, map->Vorder); - - if (dimension == 4) { - du[0] = du[0]*pos[i][3] - du[3]*pos[i][0]; - du[1] = du[1]*pos[i][3] - du[3]*pos[i][1]; - du[2] = du[2]*pos[i][3] - du[3]*pos[i][2]; - - dv[0] = dv[0]*pos[i][3] - dv[3]*pos[i][0]; - dv[1] = dv[1]*pos[i][3] - dv[3]*pos[i][1]; - dv[2] = dv[2]*pos[i][3] - dv[3]*pos[i][2]; - } - - CROSS3(normal[i], du, dv); - NORMALIZE_3FV(normal[i]); - normal[i][3] = 1; /* fill in final value */ - } - - pos_ptr->size = MAX2(pos_ptr->size, dimension); - pos_ptr->flags |= dirty_flags[dimension]; + tnl->vtx.eval.map1[attr].map = 0; } - -static void eval2_4f( GLvector4f *dest, - GLfloat coord[][4], - const GLuint *flags, - GLuint dimension, - const struct gl_2d_map *map ) +static void clear_active_eval2( TNLcontext *tnl, GLuint attr ) { - const GLfloat u1 = map->u1; - const GLfloat du = map->du; - const GLfloat v1 = map->v1; - const GLfloat dv = map->dv; - GLfloat (*to)[4] = dest->data; - GLuint i; - - for (i = 0 ; i < count ; i++) - if (flags[i] == TNL_EVAL_COORD2) { - 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); - dest->flags |= dirty_flags[dimension]; + tnl->vtx.eval.map2[attr].map = 0; } - - - -static void copy_4f( GLfloat to[][4], const GLfloat *from, - GLuint sz, GLuint stride, GLuint count ) +static void set_active_eval1( TNLcontext *tnl, GLuint attr, GLuint dim, + struct gl_1d_map *map ) { - GLuint i; - - switch (sz) { - case 1: - for (i = 0 ; i < count ; i++, STRIDE_F(from, stride)) - ASSIGN_4FV( to[i], from[0], 0, 0, 1 ); - return; - case 2: - for (i = 0 ; i < count ; i++, STRIDE_F(from, stride)) - ASSIGN_4FV( to[i], from[0], from[1], 0, 1 ); - return; - case 3: - for (i = 0 ; i < count ; i++, STRIDE_F(from, stride)) - ASSIGN_4FV( to[i], from[0], from[1], from[2], 1 ); - return; - case 4: - for (i = 0 ; i < count ; i++, STRIDE_F(from, stride)) - COPY_4FV( to[i], from ); - return; - default: - return; + if (!tnl->vtx.eval.map1[attr].map) { + tnl->vtx.eval.map1[attr].map = map; + tnl->vtx.eval.map1[attr].sz = dim; } -} - - - -static void clear_active_eval1( TNLcontext *tnl, GLuint attr ) -{ - tnl->eval._ActiveMap1Attrib[attr].map = 0; -} - +} -static void set_active_eval1( TNLcontext *tnl, GLuint attr, GLuint dim, - struct _mesa_eval_map *map ) +static void set_active_eval2( TNLcontext *tnl, GLuint attr, GLuint dim, + struct gl_2d_map *map ) { - if (!tnl->eval._ActiveMap1Attrib[attr].map) { - tnl->eval._ActiveMap1Attrib[attr].map = map; - tnl->eval._ActiveMap1Attrib[attr].dimension = dim; + if (!tnl->vtx.eval.map2[attr].map) { + tnl->vtx.eval.map2[attr].map = map; + tnl->vtx.eval.map2[attr].sz = dim; } } - - -/* This looks a lot like a pipeline stage, but for various reasons is - * better handled outside the pipeline, and considered the final stage - * of fixing up an immediate struct for execution. - * - * Really want to cache the results of this function in display lists, - * at least for EvalMesh commands. - */ void _tnl_update_eval( GLcontext *ctx ) { TNLcontext *tnl = TNL_CONTEXT(ctx); @@ -266,94 +122,132 @@ void _tnl_update_eval( GLcontext *ctx ) set_active_eval2( tnl, VERT_ATTRIB_POS, 4, &ctx->EvalMap.Map2Vertex4 ); else if (ctx->Eval.Map2Vertex3) set_active_eval2( tnl, VERT_ATTRIB_POS, 3, &ctx->EvalMap.Map2Vertex3 ); + + tnl->vtx.eval.new_state = 0; } -void _tnl_eval_immediate( GLcontext *ctx ) +void _tnl_do_EvalCoord1f(GLcontext* ctx, GLfloat u) { TNLcontext *tnl = TNL_CONTEXT(ctx); - struct tnl_vertex_arrays *tmp = &tnl->imm_inputs; - GLuint *flags = IM->Flag + IM->CopyStart; - GLuint orflag = IM->OrFlag; - GLuint any_eval1 = orflag & _TNL_BIT_EVAL_C1; - GLuint any_eval2 = orflag & _TNL_BIT_EVAL_C2; - GLuint all_eval = andflag & (_TNL_BIT_EVAL_C1|_TNL_BIT_EVAL_C2); - GLuint all_eval1 = andflag & _TNL_BIT_EVAL_C1; - GLuint all_eval2 = andflag & _TNL_BIT_EVAL_C1; - GLuint req = 0; - GLfloat (*coord)[4] = IM->Attrib[VERT_ATTRIB_POS] + IM->CopyStart; GLuint attr; - if (!store) - store = tnl->eval.im = _tnl_alloc_immediate( ctx ); + for (attr = 1; attr <= _TNL_ATTRIB_INDEX; attr++) { + struct gl_1d_map *map = tnl->vtx.eval.map1[attr].map; + if (map) { + GLfloat uu = (u - map->u1) * map->du; + GLfloat data[4]; - assert (tnl->eval.EvalNewState == 0); + ASSIGN_4V(data, 0, 0, 0, 1); - /* All non-position attributes */ - for (attr = 1; attr < VERT_ATTRIB_MAX; attr++) { - if (any_eval1 && ctx->Eval._ActiveMap1Attrib[attr].map) { - eval1_4f( &tmp->Attribs[attr], coord, flags, - ctx->Eval._ActiveMap1Attrib[attr].dimension, - ctx->Eval._ActiveMap1Attrib[attr].map ); - } + _math_horner_bezier_curve(map->Points, data, uu, + tnl->vtx.eval.map1[attr].sz, + map->Order); - if (any_eval2 && ctx->Eval._ActiveMap2Attrib[attr].map) { - eval2_4f( &tmp->Attribs[attr], coord, flags, - ctx->Eval._ActiveMap2Attrib[attr].dimension, - ctx->Eval._ActiveMap2Attrib[attr].map ); + COPY_SZ_4V( tnl->vtx.attrptr[attr], + tnl->vtx.attrsz[attr], + data ); } } - /* Index */ - if (req & _TNL_BIT_INDEX) { + /** Vertex -- EvalCoord1f is a noop if this map not enabled: + **/ + if (tnl->vtx.eval.map1[0].map) { + struct gl_1d_map *map = tnl->vtx.eval.map1[0].map; + GLfloat uu = (u - map->u1) * map->du; + GLfloat vertex[4]; - if (copycount) - copy_1f( store->Index + IM->CopyStart, tmp->Index.data, copycount ); + ASSIGN_4V(vertex, 0, 0, 0, 1); - tmp->Index.data = store->Index + IM->CopyStart; - tmp->Index.start = store->Index + IM->CopyStart; + _math_horner_bezier_curve(map->Points, vertex, uu, + tnl->vtx.eval.map1[attr].sz, + map->Order); - if (ctx->Eval.Map1Index && any_eval1) { - eval1_1f( &tmp->Index, coord, flags, &ctx->EvalMap.Map1Index ); - } + if (tnl->vtx.attrsz[0] == 4) + glVertex4fv( vertex ); + else + glVertex3fv( vertex ); + } +} + + + +void _tnl_do_EvalCoord2f( GLcontext* ctx, GLfloat u, GLfloat v ) +{ + TNLcontext *tnl = TNL_CONTEXT(ctx); + GLuint attr; + + for (attr = 1; attr <= _TNL_ATTRIB_INDEX; attr++) { + struct gl_2d_map *map = tnl->vtx.eval.map2[attr].map; + if (map) { + GLfloat uu = (u - map->u1) * map->du; + GLfloat vv = (v - map->v1) * map->dv; + GLfloat data[4]; - if (ctx->Eval.Map2Index && any_eval2) { - eval2_1f( &tmp->Index, coord, flags, &ctx->EvalMap.Map2Index ); + ASSIGN_4V(data, 0, 0, 0, 1); + + _math_horner_bezier_surf(map->Points, + data, + uu, vv, + tnl->vtx.eval.map2[attr].sz, + map->Uorder, map->Vorder); + + COPY_SZ_4V( tnl->vtx.attrptr[attr], + tnl->vtx.attrsz[attr], + data ); } } + /** Vertex -- EvalCoord2f is a noop if this map not enabled: + **/ + if (tnl->vtx.eval.map2[0].map) { + struct gl_2d_map *map = tnl->vtx.eval.map2[0].map; + GLfloat uu = (u - map->u1) * map->du; + GLfloat vv = (v - map->v1) * map->dv; + GLfloat vertex[4]; - /* Position */ - if (1) { - /* Copy required for mixed eval/vert usage? - */ - if (copycount) { - copy_4f( store->Attrib[VERT_ATTRIB_POS], - im->Attrib[VERT_ATTRIB_POS], - copycount ); - } + ASSIGN_4V(vertex, 0, 0, 0, 1); - tmp->Attribs[0].data = store->Attrib[0] + IM->CopyStart; - tmp->Attribs[0].start = (GLfloat *) tmp->Attribs[0].data; - tmp->Attribs[0].size = 0; + if (ctx->Eval.AutoNormal) { + GLfloat normal[3]; + GLfloat du[4], dv[4]; - if (any_eval1 && ctx->Eval._ActiveMap1Attrib[0].map) { - eval1_4f( &tmp->Attribs[0], coord, flags, - ctx->Eval._ActiveMap1Attrib[0].dimension, - ctx->Eval._ActiveMap1Attrib[0].map ); - } + _math_de_casteljau_surf(map->Points, vertex, du, dv, uu, vv, + tnl->vtx.eval.map2[0].sz, + map->Uorder, map->Vorder); + + if (tnl->vtx.eval.map2[0].sz == 4) { + du[0] = du[0]*vertex[3] - du[3]*vertex[0]; + du[1] = du[1]*vertex[3] - du[3]*vertex[1]; + du[2] = du[2]*vertex[3] - du[3]*vertex[2]; + + dv[0] = dv[0]*vertex[3] - dv[3]*vertex[0]; + dv[1] = dv[1]*vertex[3] - dv[3]*vertex[1]; + dv[2] = dv[2]*vertex[3] - dv[3]*vertex[2]; + } - if (any_eval2 && ctx->Eval._ActiveMap2Attrib[0].map) { - if (ctx->Eval.AutoNormal) - eval2_auto_normal( &tmp->Attribs[0], - &tmp->Attribs[VERT_ATTRIB_NORMAL], coord, flags, - ctx->Eval._ActiveMap1Attrib[0].dimension, - ctx->Eval._ActiveMap1Attrib[0].map ); - else - eval2_4f( &tmp->Attribs[0], coord, flags, - ctx->Eval._ActiveMap1Attrib[0].dimension, - ctx->Eval._ActiveMap1Attrib[0].map ); + + CROSS3(normal, du, dv); + NORMALIZE_3FV(normal); + normal[3] = 1.0; + + COPY_SZ_4V( tnl->vtx.attrptr[_TNL_ATTRIB_NORMAL], + tnl->vtx.attrsz[_TNL_ATTRIB_NORMAL], + normal ); + + } + else { + _math_horner_bezier_surf(map->Points, vertex, uu, vv, + tnl->vtx.eval.map2[0].sz, + map->Uorder, map->Vorder); } + + if (tnl->vtx.attrsz[0] == 4) + glVertex4fv( vertex ); + else + glVertex3fv( vertex ); } } + + diff --git a/src/mesa/tnl/t_vtx_exec.c b/src/mesa/tnl/t_vtx_exec.c index 195a080752..31f9e7f958 100644 --- a/src/mesa/tnl/t_vtx_exec.c +++ b/src/mesa/tnl/t_vtx_exec.c @@ -1,82 +1,99 @@ +/* + * Mesa 3-D graphics library + * Version: 5.1 + * + * Copyright (C) 1999-2003 Brian Paul All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN + * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + * + * Authors: + * Keith Whitwell <keith@tungstengraphics.com> + */ + +#include "glheader.h" +#include "api_eval.h" +#include "context.h" +#include "macros.h" +#include "math/m_eval.h" +#include "t_vtx_api.h" +#include "t_pipeline.h" /* Some nasty stuff still hanging on here. * * TODO - remove VB->ColorPtr, etc and just use the AttrPtr's. */ -static void _tnl_vb_bind_immediate( GLcontext *ctx ) +static void _tnl_vb_bind_vtx( GLcontext *ctx ) { TNLcontext *tnl = TNL_CONTEXT(ctx); struct vertex_buffer *VB = &tnl->vb; - struct tnl_vertex_arrays *tmp = &tnl->imm_inputs; - const GLuint count = IM->Count - start; + struct tnl_vertex_arrays *tmp = &tnl->vtx_inputs; + GLfloat *data = tnl->vtx.buffer; + GLuint count = tnl->vtx.initial_counter - tnl->vtx.counter; + GLuint attr, i; /* Setup constant data in the VB. */ VB->Count = count; VB->Primitive = tnl->vtx.prim; - VB->PrimitiveNr = tnl->vtx.prim_nr; + VB->PrimitiveCount = tnl->vtx.prim_count; VB->Elts = NULL; VB->NormalLengthPtr = NULL; - GLuint attr; - for (attr = 0; attr < VERT_ATTRIB_EVALFLAG; attr++) { - tmp->Attribs[attr].count = count; - tmp->Attribs[attr].data = IM->Attrib[attr] + start; - tmp->Attribs[attr].start = (GLfloat *) (IM->Attrib[attr] + start); - tmp->Attribs[attr].size = 4; - tmp->Attribs[attr].stride = sz * sizeof(GLfloat); - VB->AttribPtr[attr] = &(tmp->Attribs[attr]); + for (attr = 0; attr <= _TNL_ATTRIB_INDEX ; attr++) { + if (tnl->vtx.attrsz[attr]) { + tmp->Attribs[attr].count = count; + tmp->Attribs[attr].data = (GLfloat (*)[4]) data; + tmp->Attribs[attr].start = data; + tmp->Attribs[attr].size = tnl->vtx.attrsz[attr]; + tmp->Attribs[attr].stride = tnl->vtx.vertex_size * sizeof(GLfloat); + VB->AttribPtr[attr] = &tmp->Attribs[attr]; + data += tnl->vtx.attrsz[attr]; + } + else { + VB->AttribPtr[attr] = &tnl->current.Attribs[attr]; + } } - /* Index and edgeflag require special treatment, as usual: - */ - { - tmp->Index.count = count; - tmp->Index.data = IM->Index; - tmp->Index.start = IM->Index; - tmp->Index.stride = sz * sizeof(GLfloat); - VB->IndexPtr[0] = &tmp->Index; - VB->IndexPtr[1] = NULL; - } /* Copy and translate EdgeFlag to a contiguous array of GLbooleans */ - { - VB->EdgeFlag = IM->EdgeFlag + start; + if (tnl->vtx.attrsz[_TNL_ATTRIB_EDGEFLAG]) { + VB->EdgeFlag = _tnl_translate_edgeflag( ctx, data, count, + tnl->vtx.vertex_size ); + data++; } /* Legacy pointers -- remove one day. */ - VB->ObjPtr = &tmp->Attribs[VERT_ATTRIB_POS]; - VB->NormalPtr = &tmp->Attribs[VERT_ATTRIB_NORMAL]; - VB->ColorPtr[0] = &tmp->Attribs[VERT_ATTRIB_COLOR0]; - VB->ColorPtr[1] = NULL; - VB->SecondaryColorPtr[0] = &tmp->Attribs[VERT_ATTRIB_COLOR1]; - VB->SecondaryColorPtr[1] = NULL; + VB->ObjPtr = VB->AttribPtr[_TNL_ATTRIB_POS]; + VB->NormalPtr = VB->AttribPtr[_TNL_ATTRIB_NORMAL]; + VB->ColorPtr[0] = VB->AttribPtr[_TNL_ATTRIB_COLOR0]; + VB->IndexPtr[0] = VB->AttribPtr[_TNL_ATTRIB_INDEX]; + VB->SecondaryColorPtr[0] = VB->AttribPtr[_TNL_ATTRIB_COLOR1]; for (i = 0; i < ctx->Const.MaxTextureCoordUnits; i++) { - VB->TexCoordPtr[i] = &tmp->Attribs[VERT_ATTRIB_TEX0 + i]; + VB->TexCoordPtr[i] = VB->AttribPtr[_TNL_ATTRIB_TEX0 + i]; } } -static void copy_vertex( r200ContextPtr rmesa, GLuint n, GLfloat *dst ) -{ - GLuint i; - GLfloat *src = (GLfloat *)(rmesa->dma.current.address + - rmesa->dma.current.ptr + - (rmesa->vb.primlist[rmesa->vb.nrprims].start + n) * - rmesa->vb.vertex_size * 4); - - if (R200_DEBUG & DEBUG_VFMT) - fprintf(stderr, "copy_vertex %d\n", rmesa->vb.primlist[rmesa->vb.nrprims].start + n); - - for (i = 0 ; i < rmesa->vb.vertex_size; i++) { - dst[i] = src[i]; - } -} /* * NOTE: Need to have calculated primitives by this point -- do it on the fly. @@ -85,10 +102,12 @@ static void copy_vertex( r200ContextPtr rmesa, GLuint n, GLfloat *dst ) static GLuint _tnl_copy_vertices( GLcontext *ctx ) { TNLcontext *tnl = TNL_CONTEXT( ctx ); - GLuint nr = tnl->vtx.primlist[tnl->vtx.nrprims-1].nr; + GLuint nr = tnl->vtx.prim[tnl->vtx.prim_count-1].count; GLuint ovf, i; + GLuint sz = tnl->vtx.vertex_size; + GLfloat *dst = tnl->vtx.copied.buffer; GLfloat *src = (tnl->vtx.buffer + - tnl->vtx.primlist[tnl->vtx.nrprims].start * + tnl->vtx.prim[tnl->vtx.prim_count-1].start * tnl->vtx.vertex_size); @@ -99,23 +118,23 @@ static GLuint _tnl_copy_vertices( GLcontext *ctx ) case GL_LINES: ovf = nr&1; for (i = 0 ; i < ovf ; i++) - memcpy( dst+i*sz, src+(nr-ovf+i)*sz, sz*4 ); + memcpy( dst+i*sz, src+(nr-ovf+i)*sz, sz * sizeof(GLfloat) ); return i; case GL_TRIANGLES: ovf = nr%3; for (i = 0 ; i < ovf ; i++) - memcpy( dst+i*sz, src+(nr-ovf+i)*sz, sz*4 ); + memcpy( dst+i*sz, src+(nr-ovf+i)*sz, sz * sizeof(GLfloat) ); return i; case GL_QUADS: ovf = nr&3; for (i = 0 ; i < ovf ; i++) - memcpy( dst+i*sz, src+(nr-ovf+i)*sz, sz*4 ); + memcpy( dst+i*sz, src+(nr-ovf+i)*sz, sz * sizeof(GLfloat) ); return i; case GL_LINE_STRIP: if (nr == 0) return 0; else { - memcpy( dst, src+(nr-1)*sz, sz*4 ); + memcpy( dst, src+(nr-1)*sz, sz * sizeof(GLfloat) ); return 1; } case GL_LINE_LOOP: @@ -124,11 +143,11 @@ static GLuint _tnl_copy_vertices( GLcontext *ctx ) if (nr == 0) return 0; else if (nr == 1) { - memcpy( dst, src+0, sz*4 ); + memcpy( dst, src+0, sz * sizeof(GLfloat) ); return 1; } else { - memcpy( dst, src+0, sz*4 ); - memcpy( dst+sz, src+(nr-1)*sz, sz*4 ); + memcpy( dst, src+0, sz * sizeof(GLfloat) ); + memcpy( dst+sz, src+(nr-1)*sz, sz * sizeof(GLfloat) ); return 2; } case GL_TRIANGLE_STRIP: @@ -139,7 +158,7 @@ static GLuint _tnl_copy_vertices( GLcontext *ctx ) default: ovf = 2 + (nr&1); break; } for (i = 0 ; i < ovf ; i++) - memcpy( dst+i*sz, src+(nr-ovf+i)*sz, sz*4 ); + memcpy( dst+i*sz, src+(nr-ovf+i)*sz, sz * sizeof(GLfloat) ); return i; case GL_POLYGON+1: return 0; @@ -157,22 +176,19 @@ static GLuint _tnl_copy_vertices( GLcontext *ctx ) /** * Execute the buffer and save copied verts. */ -void _tnl_flush_immediate( GLcontext *ctx ) +void _tnl_flush_vtx( GLcontext *ctx ) { TNLcontext *tnl = TNL_CONTEXT(ctx); - if (!tnl->vtx.prim_nr) + if (!tnl->vtx.prim_count) return; - tnl->copied_verts.nr = _tnl_copy_vertices( ctx ); + tnl->vtx.copied.nr = _tnl_copy_vertices( ctx ); if (tnl->pipeline.build_state_changes) _tnl_validate_pipeline( ctx ); - _tnl_vb_bind_immediate( ctx ); - - if (tnl->vtx.attrsz[VERT_ATTRIB_EVALFLAG]) - _tnl_eval_immediate( ctx ); + _tnl_vb_bind_vtx( ctx ); /* Invalidate all stored data before and after run: */ @@ -185,13 +201,16 @@ void _tnl_flush_immediate( GLcontext *ctx ) -void _tnl_flush_vertices( GLcontext *ctx, GLuint flags ) +void _tnl_FlushVertices( GLcontext *ctx, GLuint flags ) { + TNLcontext *tnl = TNL_CONTEXT(ctx); + GLuint i; + if (ctx->Driver.CurrentExecPrimitive != PRIM_OUTSIDE_BEGIN_END) return; if (tnl->vtx.counter != tnl->vtx.initial_counter) - _tnl_flush_immediate( ctx ); + _tnl_flush_vtx( ctx ); if (flags & FLUSH_UPDATE_CURRENT) { _tnl_copy_to_current( ctx ); @@ -200,7 +219,7 @@ void _tnl_flush_vertices( GLcontext *ctx, GLuint flags ) /* DO THIS IN _tnl_reset_vtxfmt: */ tnl->vtx.vertex_size = 0; - for (i = 0 ; i < TNL_MAX_ATTRIB ; i++) - tnl->vtx.attrib[i].sz = 0; + for (i = 0 ; i < _TNL_ATTRIB_MAX ; i++) + tnl->vtx.attrsz[i] = 0; } } |