summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKeith Whitwell <keith@tungstengraphics.com>2003-01-16 00:38:44 +0000
committerKeith Whitwell <keith@tungstengraphics.com>2003-01-16 00:38:44 +0000
commit65fdafaefbc24b786156e668836fa04d26a4b9dc (patch)
treebcb9b0776118db28ab7c397168f7782992ba3a1a
parent878e544c6b9e5b856adba30ccd027dc18f6ec88c (diff)
downloadmesa-vtx-0-1-branch.tar.gz
checkpoint, changes from end of last yearvtx-0-1-branch
-rw-r--r--src/mesa/tnl/t_context.h133
-rw-r--r--src/mesa/tnl/t_pipeline.c10
-rw-r--r--src/mesa/tnl/t_vb_fog.c14
-rw-r--r--src/mesa/tnl/t_vb_light.c18
-rw-r--r--src/mesa/tnl/t_vb_lighttmp.h12
-rw-r--r--src/mesa/tnl/t_vb_normals.c16
-rw-r--r--src/mesa/tnl/t_vb_points.c14
-rw-r--r--src/mesa/tnl/t_vb_program.c16
-rw-r--r--src/mesa/tnl/t_vb_render.c12
-rw-r--r--src/mesa/tnl/t_vb_texgen.c16
-rw-r--r--src/mesa/tnl/t_vb_texmat.c14
-rw-r--r--src/mesa/tnl/t_vb_vertex.c14
-rw-r--r--src/mesa/tnl/t_vtx_api.c42
-rw-r--r--src/mesa/tnl/t_vtx_exec.c345
14 files changed, 470 insertions, 206 deletions
diff --git a/src/mesa/tnl/t_context.h b/src/mesa/tnl/t_context.h
index 0ee194a085a..3d9da7d6c25 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.43.2.3 2002/11/19 12:01:29 keithw Exp $ */
+/* $Id: t_context.h,v 1.43.2.4 2003/01/16 00:38:44 keithw Exp $ */
/*
* Mesa 3-D graphics library
@@ -77,21 +77,7 @@
#define TNL_EVAL_POINT2 0x8
-/* Numbers for sizing immediate structs.
- */
-#define IMM_MAX_COPIED_VERTS 3
-
-
-/* Storage for vertices generated by.
- */
-struct vertex_block
-{
- GLuint refcount;
- GLuint vertex_format[2];
- GLuint vertex_size;
- GLuint block_size;
- GLubyte verts[1];
-};
+#define TNL_MAX_WRAPPED_VERTS 3
#define PRIM_MODE_MASK 0xff /* Extract the actual primitive */
@@ -129,7 +115,7 @@ struct vertex_buffer
struct gl_client_array *NdcPtr;
GLubyte *ClipMask;
GLfloat *NormalLengthPtr;
- struct gl_client_array *PointSizePtr; /* why not just a float *? */
+ struct gl_client_array *PointSizePtr;
struct tnl_prim *Primitive; /* primitive descriptors */
GLuint NrPrimitives; /* nr */
@@ -139,10 +125,6 @@ struct vertex_buffer
* float arrays. This may have to change later.
*/
- GLuint AttribActive;
- /* Bitmap: Which arrays are non-zero?
- */
-
GLuint LastClipped;
/* Private data from _tnl_render_stage that has no business being
* in this struct.
@@ -355,18 +337,62 @@ struct dynfn {
#define TNL_END 0x1
#define TNL_BE_MAX 3 /* XXX */
+struct tnl_be {
+ GLint type;
+ GLint idx;
+ GLenum mode;
+};
+
+#define TNL_VTX_STORE_MAX ((4096-sizeof(GLint))/sizeof(union uif))
+#define TNL_ATTRIB_STORE_MAX ((4096-sizeof(GLint))/sizeof(GLubyte))
+#define TNL_BE_STORE_MAX ((4096-sizeof(GLint))/sizeof(struct tnl_be))
+
+struct tnl_vtx_store {
+ union uif vertices[TNL_VTX_STORE_MAX];
+ GLint ref_count;
+};
+
+struct tnl_be_store {
+ struct tnl_be be[TNL_BE_STORE_MAX];
+ GLint ref_count;
+};
+
+struct tnl_attrib_store {
+ GLubyte attrib_sz[TNL_ATTRIB_STORE_MAX]; /* ??? */
+ GLint ref_count;
+};
+
+/* Will be saved into dlists, also used below.
+ */
+struct tnl_vtx_node {
+ struct tnl_vtx_store *vert_store;
+ struct tnl_be_store *be_store;
+ struct tnl_attrib_store *attrib_store;
+ union uif *verts;
+ struct tnl_be *be;
+ GLubyte *attrib_sz;
+ GLint vert_count, vert_size;
+ GLint be_count;
+};
+
+/* Mechanism for building tnl_vtx_nodes from GL api commands.
+ */
struct tnl_vtx {
+ struct tnl_vtx_node node; /* May be copied into dlists. */
+
int initial_counter;
- int counter; /* nr of vertices */
+ int counter; /* nr of vertices */
int vertex_size;
- union uif *vbstart; /* built vertices */
- union uif *vbptr; /* built vertices */
+
+ union uif *vbptr; /* derived from node, above */
+ struct tnl_be *beptr; /* derived from node, above */
+ GLubyte *attrib_sz; /* derived from node, above */
+
union uif *attrptr[TNL_ATTRIB_MAX]; /* pointers into vertex below */
union uif vertex[TNL_ATTRIB_MAX*4]; /* current vertex */
- GLubyte attrib_sz[TNL_ATTRIB_MAX];
-
- struct dynfn *generated[4][2][2]; /* chains of generated functions
+
+ struct dynfn *generated[4][2][2]; /* chains of generated functions
* could use a hash also.
*/
@@ -391,13 +417,32 @@ struct tnl_vtx {
*/
void (*tabfv[4][TNL_ATTRIB_MAX])( const GLfloat * );
- /* Build a list of begins and ends.
- */
- struct { GLint type; GLint idx; GLenum mode; } be[TNL_BE_MAX];
- GLint be_count;
};
+/* State for executing tnl_vtx_nodes
+ */
+struct tnl_vtx_exec {
+ struct tnl_vtx_node *bound;
+ struct tnl_vtx_node *tmp; /* ??? */
+
+
+ /* Always bound to current:
+ */
+ struct gl_client_array Current[TNL_ATTRIB_MAX];
+
+ /* Bound to
+ */
+ struct gl_client_array Attrib[TNL_ATTRIB_MAX];
+
+ /* Which and how many vertices must be copied?
+ */
+ GLint wrap_nr;
+ GLint wrap_elts[TNL_MAX_WRAPPED_VERTS];
+};
+
+
+
typedef struct {
/* Driver interface.
@@ -408,6 +453,10 @@ typedef struct {
*/
struct tnl_vtx vtx;
+ /* Support for executing vertices:
+ */
+ struct tnl_vtx_exec exec;
+
/* Track whether the module is active.
*/
GLboolean bound_exec;
@@ -441,32 +490,10 @@ typedef struct {
#define TNL_CONTEXT(ctx) ((TNLcontext *)(ctx->swtnl_context))
-#define TNL_CURRENT_IM(ctx) ((struct immediate *)(ctx->swtnl_im))
-
-#define TYPE_IDX(t) ((t) & 0xf)
-#define MAX_TYPES TYPE_IDX(GL_DOUBLE)+1 /* 0xa + 1 */
extern void _tnl_MakeCurrent( GLcontext *ctx,
GLframebuffer *drawBuffer,
GLframebuffer *readBuffer );
-
-/*
- * Macros for fetching current input buffer.
- */
-#ifdef THREADS
-#define GET_IMMEDIATE struct immediate *IM = TNL_CURRENT_IM(((GLcontext *) (_glapi_Context ? _glapi_Context : _glapi_get_context())))
-#define SET_IMMEDIATE(ctx, im) ctx->swtnl_im = (void *)im
-#else
-extern struct immediate *_tnl_CurrentInput;
-#define GET_IMMEDIATE struct immediate *IM = _tnl_CurrentInput
-#define SET_IMMEDIATE(ctx, im) \
-do { \
- ctx->swtnl_im = (void *)im; \
- _tnl_CurrentInput = im; \
-} while (0)
-#endif
-
-
#endif
diff --git a/src/mesa/tnl/t_pipeline.c b/src/mesa/tnl/t_pipeline.c
index 065a0766bac..47f35ab5014 100644
--- a/src/mesa/tnl/t_pipeline.c
+++ b/src/mesa/tnl/t_pipeline.c
@@ -1,4 +1,4 @@
-/* $Id: t_pipeline.c,v 1.22.2.2 2002/10/17 14:26:37 keithw Exp $ */
+/* $Id: t_pipeline.c,v 1.22.2.3 2003/01/16 00:38:44 keithw Exp $ */
/*
* Mesa 3-D graphics library
@@ -42,7 +42,7 @@
void _tnl_install_pipeline( GLcontext *ctx,
- const struct gl_pipeline_stage **stages )
+ const struct tnl_pipeline_stage **stages )
{
TNLcontext *tnl = TNL_CONTEXT(ctx);
struct gl_pipeline *pipe = &tnl->pipeline;
@@ -87,7 +87,7 @@ void _tnl_validate_pipeline( GLcontext *ctx )
{
TNLcontext *tnl = TNL_CONTEXT(ctx);
struct gl_pipeline *pipe = &tnl->pipeline;
- struct gl_pipeline_stage *s = pipe->stages;
+ struct tnl_pipeline_stage *s = pipe->stages;
GLuint newstate = pipe->build_state_changes;
GLuint generated[2];
GLuint changed_inputs[2];
@@ -138,7 +138,7 @@ void _tnl_run_pipeline( GLcontext *ctx )
TNLcontext *tnl = TNL_CONTEXT(ctx);
struct vertex_buffer *VB = &tnl->vb;
struct gl_pipeline *pipe = &tnl->pipeline;
- struct gl_pipeline_stage *s = pipe->stages;
+ struct tnl_pipeline_stage *s = pipe->stages;
GLuint changed_state = pipe->run_state_changes;
GLuint changed_inputs[2];
GLboolean running = GL_TRUE;
@@ -219,7 +219,7 @@ void _tnl_run_pipeline( GLcontext *ctx )
* Some work can be done to lift some of the restrictions in the final
* case, if it becomes necessary to do so.
*/
-const struct gl_pipeline_stage *_tnl_default_pipeline[] = {
+const struct tnl_pipeline_stage *_tnl_default_pipeline[] = {
&_tnl_vertex_transform_stage,
&_tnl_normal_transform_stage,
&_tnl_lighting_stage,
diff --git a/src/mesa/tnl/t_vb_fog.c b/src/mesa/tnl/t_vb_fog.c
index a4709075ad2..215ef8b2a43 100644
--- a/src/mesa/tnl/t_vb_fog.c
+++ b/src/mesa/tnl/t_vb_fog.c
@@ -1,4 +1,4 @@
-/* $Id: t_vb_fog.c,v 1.17.2.3 2002/10/31 15:32:41 keithw Exp $ */
+/* $Id: t_vb_fog.c,v 1.17.2.4 2003/01/16 00:38:44 keithw Exp $ */
/*
* Mesa 3-D graphics library
@@ -129,7 +129,7 @@ static void make_win_fog_coords( GLcontext *ctx, GLvector4f *out,
static GLboolean run_fog_stage( GLcontext *ctx,
- struct gl_pipeline_stage *stage )
+ struct tnl_pipeline_stage *stage )
{
struct vertex_buffer *VB = &TNL_CONTEXT(ctx)->vb;
struct fog_stage_data *store = FOG_STAGE_DATA(stage);
@@ -189,7 +189,7 @@ static GLboolean run_fog_stage( GLcontext *ctx,
}
-static void check_fog_stage( GLcontext *ctx, struct gl_pipeline_stage *stage )
+static void check_fog_stage( GLcontext *ctx, struct tnl_pipeline_stage *stage )
{
stage->active = ctx->Fog.Enabled && !ctx->VertexProgram.Enabled;
@@ -207,7 +207,7 @@ static void check_fog_stage( GLcontext *ctx, struct gl_pipeline_stage *stage )
/* Called the first time stage->run() is invoked.
*/
static GLboolean alloc_fog_data( GLcontext *ctx,
- struct gl_pipeline_stage *stage )
+ struct tnl_pipeline_stage *stage )
{
TNLcontext *tnl = TNL_CONTEXT(ctx);
struct fog_stage_data *store;
@@ -229,7 +229,7 @@ static GLboolean alloc_fog_data( GLcontext *ctx,
}
-static void free_fog_data( struct gl_pipeline_stage *stage )
+static void free_fog_data( struct tnl_pipeline_stage *stage )
{
struct fog_stage_data *store = FOG_STAGE_DATA(stage);
if (store) {
@@ -240,9 +240,9 @@ static void free_fog_data( struct gl_pipeline_stage *stage )
}
-struct gl_pipeline_stage *_tnl_fog_stage( GLcontext *ctx )
+struct tnl_pipeline_stage *_tnl_fog_stage( GLcontext *ctx )
{
- struct gl_pipeline_stage *stage = CALLOC_STRUCT( gl_pipeline_stage );
+ struct tnl_pipeline_stage *stage = CALLOC_STRUCT( tnl_pipeline_stage );
stage->name = "fog";
stage->recheck = _NEW_FOG;
diff --git a/src/mesa/tnl/t_vb_light.c b/src/mesa/tnl/t_vb_light.c
index 3e57d7f1493..84042c5791b 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.18.2.2 2002/10/17 14:26:37 keithw Exp $ */
+/* $Id: t_vb_light.c,v 1.18.2.3 2003/01/16 00:38:44 keithw Exp $ */
/*
* Mesa 3-D graphics library
@@ -46,7 +46,7 @@
typedef void (*light_func)( GLcontext *ctx,
struct vertex_buffer *VB,
- struct gl_pipeline_stage *stage,
+ struct tnl_pipeline_stage *stage,
GLvector4f *input );
struct light_stage_data {
@@ -100,7 +100,7 @@ static void init_lighting( void )
}
-static GLboolean run_lighting( GLcontext *ctx, struct gl_pipeline_stage *stage )
+static GLboolean run_lighting( GLcontext *ctx, struct tnl_pipeline_stage *stage )
{
struct light_stage_data *store = LIGHT_STAGE_DATA(stage);
TNLcontext *tnl = TNL_CONTEXT(ctx);
@@ -127,7 +127,7 @@ static GLboolean run_lighting( GLcontext *ctx, struct gl_pipeline_stage *stage )
/* Called in place of do_lighting when the light table may have changed.
*/
static GLboolean run_validate_lighting( GLcontext *ctx,
- struct gl_pipeline_stage *stage )
+ struct tnl_pipeline_stage *stage )
{
GLuint ind = 0;
light_func *tab;
@@ -177,7 +177,7 @@ static void alloc_4f( struct gl_client_array *a, GLuint sz )
* allocate data until the first time the stage is run.
*/
static GLboolean run_init_lighting( GLcontext *ctx,
- struct gl_pipeline_stage *stage )
+ struct tnl_pipeline_stage *stage )
{
TNLcontext *tnl = TNL_CONTEXT(ctx);
struct light_stage_data *store;
@@ -212,7 +212,7 @@ static GLboolean run_init_lighting( GLcontext *ctx,
* Check if lighting is enabled. If so, configure the pipeline stage's
* type, inputs, and outputs.
*/
-static void check_lighting( GLcontext *ctx, struct gl_pipeline_stage *stage )
+static void check_lighting( GLcontext *ctx, struct tnl_pipeline_stage *stage )
{
stage->active = ctx->Light.Enabled && !ctx->VertexProgram.Enabled;
if (stage->active) {
@@ -235,7 +235,7 @@ static void check_lighting( GLcontext *ctx, struct gl_pipeline_stage *stage )
}
}
-static void dtr( struct gl_pipeline_stage *stage )
+static void dtr( struct tnl_pipeline_stage *stage )
{
struct light_stage_data *store = LIGHT_STAGE_DATA(stage);
@@ -252,9 +252,9 @@ static void dtr( struct gl_pipeline_stage *stage )
}
}
-struct gl_pipeline_stage *_tnl_lighting_stage( GLcontext *ctx )
+struct tnl_pipeline_stage *_tnl_lighting_stage( GLcontext *ctx )
{
- stage = CALLOC_STRUCT( gl_pipeline_stage );
+ stage = CALLOC_STRUCT( tnl_pipeline_stage );
stage->name = "lighting";
stage->recheck = _NEW_LIGHT;
diff --git a/src/mesa/tnl/t_vb_lighttmp.h b/src/mesa/tnl/t_vb_lighttmp.h
index 34d9047be40..7cee9b75d65 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.25.2.1 2002/10/15 16:56:52 keithw Exp $ */
+/* $Id: t_vb_lighttmp.h,v 1.25.2.2 2003/01/16 00:38:44 keithw Exp $ */
/*
* Mesa 3-D graphics library
@@ -60,7 +60,7 @@
*/
static void TAG(light_rgba_spec)( GLcontext *ctx,
struct vertex_buffer *VB,
- struct gl_pipeline_stage *stage,
+ struct tnl_pipeline_stage *stage,
GLvector4f *input )
{
struct light_stage_data *store = LIGHT_STAGE_DATA(stage);
@@ -251,7 +251,7 @@ static void TAG(light_rgba_spec)( GLcontext *ctx,
static void TAG(light_rgba)( GLcontext *ctx,
struct vertex_buffer *VB,
- struct gl_pipeline_stage *stage,
+ struct tnl_pipeline_stage *stage,
GLvector4f *input )
{
struct light_stage_data *store = LIGHT_STAGE_DATA(stage);
@@ -442,7 +442,7 @@ static void TAG(light_rgba)( GLcontext *ctx,
*/
static void TAG(light_fast_rgba_single)( GLcontext *ctx,
struct vertex_buffer *VB,
- struct gl_pipeline_stage *stage,
+ struct tnl_pipeline_stage *stage,
GLvector4f *input )
{
@@ -548,7 +548,7 @@ static void TAG(light_fast_rgba_single)( GLcontext *ctx,
*/
static void TAG(light_fast_rgba)( GLcontext *ctx,
struct vertex_buffer *VB,
- struct gl_pipeline_stage *stage,
+ struct tnl_pipeline_stage *stage,
GLvector4f *input )
{
struct light_stage_data *store = LIGHT_STAGE_DATA(stage);
@@ -668,7 +668,7 @@ static void TAG(light_fast_rgba)( GLcontext *ctx,
*/
static void TAG(light_ci)( GLcontext *ctx,
struct vertex_buffer *VB,
- struct gl_pipeline_stage *stage,
+ struct tnl_pipeline_stage *stage,
GLvector4f *input )
{
struct light_stage_data *store = LIGHT_STAGE_DATA(stage);
diff --git a/src/mesa/tnl/t_vb_normals.c b/src/mesa/tnl/t_vb_normals.c
index 4aa5cba389f..202c09b0e3e 100644
--- a/src/mesa/tnl/t_vb_normals.c
+++ b/src/mesa/tnl/t_vb_normals.c
@@ -1,4 +1,4 @@
-/* $Id: t_vb_normals.c,v 1.15.2.2 2002/10/17 14:26:37 keithw Exp $ */
+/* $Id: t_vb_normals.c,v 1.15.2.3 2003/01/16 00:38:44 keithw Exp $ */
/*
* Mesa 3-D graphics library
@@ -54,7 +54,7 @@ struct normal_stage_data {
static GLboolean run_normal_stage( GLcontext *ctx,
- struct gl_pipeline_stage *stage )
+ struct tnl_pipeline_stage *stage )
{
struct normal_stage_data *store = NORMAL_STAGE_DATA(stage);
struct vertex_buffer *VB = &TNL_CONTEXT(ctx)->vb;
@@ -85,7 +85,7 @@ static GLboolean run_normal_stage( GLcontext *ctx,
static GLboolean run_validate_normal_stage( GLcontext *ctx,
- struct gl_pipeline_stage *stage )
+ struct tnl_pipeline_stage *stage )
{
struct normal_stage_data *store = NORMAL_STAGE_DATA(stage);
@@ -136,7 +136,7 @@ static GLboolean run_validate_normal_stage( GLcontext *ctx,
static void check_normal_transform( GLcontext *ctx,
- struct gl_pipeline_stage *stage )
+ struct tnl_pipeline_stage *stage )
{
stage->active = ctx->_NeedNormals && !ctx->VertexProgram.Enabled;
/* Don't clobber the initialize function:
@@ -147,7 +147,7 @@ static void check_normal_transform( GLcontext *ctx,
static GLboolean alloc_normal_data( GLcontext *ctx,
- struct gl_pipeline_stage *stage )
+ struct tnl_pipeline_stage *stage )
{
TNLcontext *tnl = TNL_CONTEXT(ctx);
struct normal_stage_data *store;
@@ -166,7 +166,7 @@ static GLboolean alloc_normal_data( GLcontext *ctx,
-static void free_normal_data( struct gl_pipeline_stage *stage )
+static void free_normal_data( struct tnl_pipeline_stage *stage )
{
struct normal_stage_data *store = NORMAL_STAGE_DATA(stage);
if (store) {
@@ -183,9 +183,9 @@ static void free_normal_data( struct gl_pipeline_stage *stage )
-struct gl_pipeline_stage *_tnl_normal_transform_stage( GLcontext *ctx )
+struct tnl_pipeline_stage *_tnl_normal_transform_stage( GLcontext *ctx )
{
- struct gl_pipeline_stage *stage = CALLOC_STRUCT( gl_pipeline_stage );
+ struct tnl_pipeline_stage *stage = CALLOC_STRUCT( tnl_pipeline_stage );
stage->name = "normal transform";
stage->recheck = _TNL_NEW_NORMAL_TRANSFORM;
diff --git a/src/mesa/tnl/t_vb_points.c b/src/mesa/tnl/t_vb_points.c
index 92eb7965246..69a5c157d2c 100644
--- a/src/mesa/tnl/t_vb_points.c
+++ b/src/mesa/tnl/t_vb_points.c
@@ -1,4 +1,4 @@
-/* $Id: t_vb_points.c,v 1.8.2.1 2002/10/17 14:26:37 keithw Exp $ */
+/* $Id: t_vb_points.c,v 1.8.2.2 2003/01/16 00:38:44 keithw Exp $ */
/*
* Mesa 3-D graphics library
@@ -44,7 +44,7 @@ struct point_stage_data {
* Compute attenuated point sizes
*/
static GLboolean run_point_stage( GLcontext *ctx,
- struct gl_pipeline_stage *stage )
+ struct tnl_pipeline_stage *stage )
{
struct point_stage_data *store = POINT_STAGE_DATA(stage);
struct vertex_buffer *VB = &TNL_CONTEXT(ctx)->vb;
@@ -74,13 +74,13 @@ static GLboolean run_point_stage( GLcontext *ctx,
/* If point size attenuation is on we'll compute the point size for
* each vertex in a special pipeline stage.
*/
-static void check_point_size( GLcontext *ctx, struct gl_pipeline_stage *d )
+static void check_point_size( GLcontext *ctx, struct tnl_pipeline_stage *d )
{
d->active = ctx->Point._Attenuated && !ctx->VertexProgram.Enabled;
}
static GLboolean alloc_point_data( GLcontext *ctx,
- struct gl_pipeline_stage *stage )
+ struct tnl_pipeline_stage *stage )
{
struct vertex_buffer *VB = &TNL_CONTEXT(ctx)->vb;
struct point_stage_data *store;
@@ -98,7 +98,7 @@ static GLboolean alloc_point_data( GLcontext *ctx,
}
-static void free_point_data( struct gl_pipeline_stage *stage )
+static void free_point_data( struct tnl_pipeline_stage *stage )
{
struct point_stage_data *store = POINT_STAGE_DATA(stage);
if (store) {
@@ -109,9 +109,9 @@ static void free_point_data( struct gl_pipeline_stage *stage )
}
-struct gl_pipeline_stage *_tnl_normal_transform_stage( GLcontext *ctx )
+struct tnl_pipeline_stage *_tnl_normal_transform_stage( GLcontext *ctx )
{
- struct gl_pipeline_stage *stage = CALLOC_STRUCT( gl_pipeline_stage );
+ struct tnl_pipeline_stage *stage = CALLOC_STRUCT( tnl_pipeline_stage );
stage->name = "normal transform";
stage->recheck = _NEW_POINT;
diff --git a/src/mesa/tnl/t_vb_program.c b/src/mesa/tnl/t_vb_program.c
index 91290239fff..2f5d0ebceb1 100644
--- a/src/mesa/tnl/t_vb_program.c
+++ b/src/mesa/tnl/t_vb_program.c
@@ -1,4 +1,4 @@
-/* $Id: t_vb_program.c,v 1.14.2.3 2002/11/19 12:01:29 keithw Exp $ */
+/* $Id: t_vb_program.c,v 1.14.2.4 2003/01/16 00:38:44 keithw Exp $ */
/*
* Mesa 3-D graphics library
@@ -143,7 +143,7 @@ struct vp_stage_data {
/**
* This function executes vertex programs
*/
-static GLboolean run_vp( GLcontext *ctx, struct gl_pipeline_stage *stage )
+static GLboolean run_vp( GLcontext *ctx, struct tnl_pipeline_stage *stage )
{
TNLcontext *tnl = TNL_CONTEXT(ctx);
struct vp_stage_data *store = VP_STAGE_DATA(stage);
@@ -289,7 +289,7 @@ static GLboolean run_vp( GLcontext *ctx, struct gl_pipeline_stage *stage )
* This function validates stuff.
*/
static GLboolean run_validate_program( GLcontext *ctx,
- struct gl_pipeline_stage *stage )
+ struct tnl_pipeline_stage *stage )
{
#if 000
/* XXX do we need any validation for vertex programs? */
@@ -353,7 +353,7 @@ static void init_color_array( struct gl_client_array *a, GLvector4f *vec )
* allocate data until the first time the stage is run.
*/
static GLboolean run_init_vp( GLcontext *ctx,
- struct gl_pipeline_stage *stage )
+ struct tnl_pipeline_stage *stage )
{
TNLcontext *tnl = TNL_CONTEXT(ctx);
struct vertex_buffer *VB = &(tnl->vb);
@@ -392,7 +392,7 @@ static GLboolean run_init_vp( GLcontext *ctx,
* Check if vertex program mode is enabled.
* If so, configure the pipeline stage's type, inputs, and outputs.
*/
-static void check_vp( GLcontext *ctx, struct gl_pipeline_stage *stage )
+static void check_vp( GLcontext *ctx, struct tnl_pipeline_stage *stage )
{
stage->active = ctx->VertexProgram.Enabled;
@@ -416,7 +416,7 @@ static void check_vp( GLcontext *ctx, struct gl_pipeline_stage *stage )
/**
* Destructor for this pipeline stage.
*/
-static void dtr( struct gl_pipeline_stage *stage )
+static void dtr( struct tnl_pipeline_stage *stage )
{
struct vp_stage_data *store = VP_STAGE_DATA(stage);
@@ -436,9 +436,9 @@ static void dtr( struct gl_pipeline_stage *stage )
}
}
-struct gl_pipeline_stage *_tnl_vertex_program_stage( GLcontext *ctx )
+struct tnl_pipeline_stage *_tnl_vertex_program_stage( GLcontext *ctx )
{
- struct gl_pipeline_stage *stage = CALLOC_STRUCT( gl_pipeline_stage );
+ struct tnl_pipeline_stage *stage = CALLOC_STRUCT( tnl_pipeline_stage );
stage->name = "vertex-program";
stage->recheck = _NEW_ALL;
diff --git a/src/mesa/tnl/t_vb_render.c b/src/mesa/tnl/t_vb_render.c
index 6b09002d25c..de78998cb5f 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.31.2.2 2002/10/17 14:26:37 keithw Exp $ */
+/* $Id: t_vb_render.c,v 1.31.2.3 2003/01/16 00:38:44 keithw Exp $ */
/*
* Mesa 3-D graphics library
@@ -277,7 +277,7 @@ void _tnl_RenderClippedLine( GLcontext *ctx, GLuint ii, GLuint jj )
static GLboolean run_render( GLcontext *ctx,
- struct gl_pipeline_stage *stage )
+ struct tnl_pipeline_stage *stage )
{
TNLcontext *tnl = TNL_CONTEXT(ctx);
struct vertex_buffer *VB = &tnl->vb;
@@ -358,7 +358,7 @@ static GLboolean run_render( GLcontext *ctx,
/* Quite a bit of work involved in finding out the inputs for the
* render stage.
*/
-static void check_render( GLcontext *ctx, struct gl_pipeline_stage *stage )
+static void check_render( GLcontext *ctx, struct tnl_pipeline_stage *stage )
{
GLuint i;
@@ -404,15 +404,15 @@ static void check_render( GLcontext *ctx, struct gl_pipeline_stage *stage )
-static void dtr( struct gl_pipeline_stage *stage )
+static void dtr( struct tnl_pipeline_stage *stage )
{
}
-struct gl_pipeline_stage *_tnl_render_stage( GLcontext *ctx )
+struct tnl_pipeline_stage *_tnl_render_stage( GLcontext *ctx )
{
- struct gl_pipeline_stage *stage = CALLOC_STRUCT( gl_pipeline_stage );
+ struct tnl_pipeline_stage *stage = CALLOC_STRUCT( tnl_pipeline_stage );
stage->name = "render";
stage->recheck = (_NEW_BUFFERS |
diff --git a/src/mesa/tnl/t_vb_texgen.c b/src/mesa/tnl/t_vb_texgen.c
index eacb5a735d5..9c0a4a2c1e9 100644
--- a/src/mesa/tnl/t_vb_texgen.c
+++ b/src/mesa/tnl/t_vb_texgen.c
@@ -1,4 +1,4 @@
-/* $Id: t_vb_texgen.c,v 1.13.2.2 2002/10/17 14:26:37 keithw Exp $ */
+/* $Id: t_vb_texgen.c,v 1.13.2.3 2003/01/16 00:38:44 keithw Exp $ */
/*
* Mesa 3-D graphics library
@@ -517,7 +517,7 @@ static void texgen( GLcontext *ctx,
static GLboolean run_texgen_stage( GLcontext *ctx,
- struct gl_pipeline_stage *stage )
+ struct tnl_pipeline_stage *stage )
{
struct vertex_buffer *VB = &TNL_CONTEXT(ctx)->vb;
struct texgen_stage_data *store = TEXGEN_STAGE_DATA( stage );
@@ -538,7 +538,7 @@ static GLboolean run_texgen_stage( GLcontext *ctx,
static GLboolean run_validate_texgen_stage( GLcontext *ctx,
- struct gl_pipeline_stage *stage )
+ struct tnl_pipeline_stage *stage )
{
struct texgen_stage_data *store = TEXGEN_STAGE_DATA(stage);
GLuint i;
@@ -582,7 +582,7 @@ static GLboolean run_validate_texgen_stage( GLcontext *ctx,
}
-static void check_texgen( GLcontext *ctx, struct gl_pipeline_stage *stage )
+static void check_texgen( GLcontext *ctx, struct tnl_pipeline_stage *stage )
{
GLuint i;
stage->active = 0;
@@ -618,7 +618,7 @@ static void check_texgen( GLcontext *ctx, struct gl_pipeline_stage *stage )
/* Called the first time stage->run() is invoked.
*/
static GLboolean alloc_texgen_data( GLcontext *ctx,
- struct gl_pipeline_stage *stage )
+ struct tnl_pipeline_stage *stage )
{
struct vertex_buffer *VB = &TNL_CONTEXT(ctx)->vb;
struct texgen_stage_data *store;
@@ -642,7 +642,7 @@ static GLboolean alloc_texgen_data( GLcontext *ctx,
}
-static void free_texgen_data( struct gl_pipeline_stage *stage )
+static void free_texgen_data( struct tnl_pipeline_stage *stage )
{
struct texgen_stage_data *store = TEXGEN_STAGE_DATA(stage);
@@ -663,9 +663,9 @@ static void free_texgen_data( struct gl_pipeline_stage *stage )
-struct gl_pipeline_stage *_tnl_texgen_stage( GLcontext *ctx )
+struct tnl_pipeline_stage *_tnl_texgen_stage( GLcontext *ctx )
{
- struct gl_pipeline_stage *stage = CALLOC_STRUCT( gl_pipeline_stage );
+ struct tnl_pipeline_stage *stage = CALLOC_STRUCT( tnl_pipeline_stage );
stage->name = "texgen";
stage->recheck = _NEW_TEXTURE;
diff --git a/src/mesa/tnl/t_vb_texmat.c b/src/mesa/tnl/t_vb_texmat.c
index 0b26737056e..a9b1473cda0 100644
--- a/src/mesa/tnl/t_vb_texmat.c
+++ b/src/mesa/tnl/t_vb_texmat.c
@@ -1,4 +1,4 @@
-/* $Id: t_vb_texmat.c,v 1.8.2.2 2002/10/17 14:26:37 keithw Exp $ */
+/* $Id: t_vb_texmat.c,v 1.8.2.3 2003/01/16 00:38:44 keithw Exp $ */
/*
* Mesa 3-D graphics library
@@ -55,7 +55,7 @@ struct texmat_stage_data {
#define TEXMAT_STAGE_DATA(stage) ((struct texmat_stage_data *)stage->privatePtr)
-static void check_texmat( GLcontext *ctx, struct gl_pipeline_stage *stage )
+static void check_texmat( GLcontext *ctx, struct tnl_pipeline_stage *stage )
{
GLuint i;
stage->active = 0;
@@ -77,7 +77,7 @@ static void check_texmat( GLcontext *ctx, struct gl_pipeline_stage *stage )
}
static GLboolean run_texmat_stage( GLcontext *ctx,
- struct gl_pipeline_stage *stage )
+ struct tnl_pipeline_stage *stage )
{
struct texmat_stage_data *store = TEXMAT_STAGE_DATA(stage);
struct vertex_buffer *VB = &TNL_CONTEXT(ctx)->vb;
@@ -102,7 +102,7 @@ static GLboolean run_texmat_stage( GLcontext *ctx,
/* Called the first time stage->run() is invoked.
*/
static GLboolean alloc_texmat_data( GLcontext *ctx,
- struct gl_pipeline_stage *stage )
+ struct tnl_pipeline_stage *stage )
{
struct vertex_buffer *VB = &TNL_CONTEXT(ctx)->vb;
struct texmat_stage_data *store;
@@ -123,7 +123,7 @@ static GLboolean alloc_texmat_data( GLcontext *ctx,
}
-static void free_texmat_data( struct gl_pipeline_stage *stage )
+static void free_texmat_data( struct tnl_pipeline_stage *stage )
{
struct texmat_stage_data *store = TEXMAT_STAGE_DATA(stage);
GLuint i;
@@ -137,9 +137,9 @@ static void free_texmat_data( struct gl_pipeline_stage *stage )
}
}
-struct gl_pipeline_stage *_tnl_texture_transform_stage( GLcontext *ctx )
+struct tnl_pipeline_stage *_tnl_texture_transform_stage( GLcontext *ctx )
{
- struct gl_pipeline_stage *stage = CALLOC_STRUCT( gl_pipeline_stage );
+ struct tnl_pipeline_stage *stage = CALLOC_STRUCT( tnl_pipeline_stage );
stage->name = "texture transform";
stage->recheck = _NEW_TEXTURE|_NEW_TEXTURE_MATRIX;
diff --git a/src/mesa/tnl/t_vb_vertex.c b/src/mesa/tnl/t_vb_vertex.c
index 3f33181e345..5a1e2c4dbea 100644
--- a/src/mesa/tnl/t_vb_vertex.c
+++ b/src/mesa/tnl/t_vb_vertex.c
@@ -1,4 +1,4 @@
-/* $Id: t_vb_vertex.c,v 1.14.2.2 2002/10/17 14:26:37 keithw Exp $ */
+/* $Id: t_vb_vertex.c,v 1.14.2.3 2003/01/16 00:38:45 keithw Exp $ */
/*
* Mesa 3-D graphics library
@@ -131,7 +131,7 @@ static void (*(usercliptab[5]))( GLcontext *,
static GLboolean run_vertex_stage( GLcontext *ctx,
- struct gl_pipeline_stage *stage )
+ struct tnl_pipeline_stage *stage )
{
struct vertex_stage_data *store = (struct vertex_stage_data *)stage->privatePtr;
TNLcontext *tnl = TNL_CONTEXT(ctx);
@@ -221,13 +221,13 @@ static GLboolean run_vertex_stage( GLcontext *ctx,
}
-static void check_vertex( GLcontext *ctx, struct gl_pipeline_stage *stage )
+static void check_vertex( GLcontext *ctx, struct tnl_pipeline_stage *stage )
{
stage->active = !ctx->VertexProgram.Enabled;
}
static GLboolean init_vertex_stage( GLcontext *ctx,
- struct gl_pipeline_stage *stage )
+ struct tnl_pipeline_stage *stage )
{
struct vertex_buffer *VB = &TNL_CONTEXT(ctx)->vb;
struct vertex_stage_data *store;
@@ -256,7 +256,7 @@ static GLboolean init_vertex_stage( GLcontext *ctx,
return stage->run( ctx, stage );
}
-static void dtr( struct gl_pipeline_stage *stage )
+static void dtr( struct tnl_pipeline_stage *stage )
{
struct vertex_stage_data *store = VERTEX_STAGE_DATA(stage);
@@ -273,9 +273,9 @@ static void dtr( struct gl_pipeline_stage *stage )
-struct gl_pipeline_stage *_tnl_vertex_transform_stage( GLcontext *ctx )
+struct tnl_pipeline_stage *_tnl_vertex_transform_stage( GLcontext *ctx )
{
- struct gl_pipeline_stage *stage = CALLOC_STRUCT( gl_pipeline_stage );
+ struct tnl_pipeline_stage *stage = CALLOC_STRUCT( tnl_pipeline_stage );
stage->name = "texture transform";
stage->recheck = 0;
diff --git a/src/mesa/tnl/t_vtx_api.c b/src/mesa/tnl/t_vtx_api.c
index 4338978056c..d167ffd252c 100644
--- a/src/mesa/tnl/t_vtx_api.c
+++ b/src/mesa/tnl/t_vtx_api.c
@@ -42,7 +42,7 @@ USE OR OTHER DEALINGS IN THE SOFTWARE.
/* Versions of all the entrypoints for situations where codegen isn't
* available. This is slowed significantly by all the gumph necessary
- * to get to the tnl pointer.
+ * to get to the tnl pointer, which can be avoided with codegen.
*
* Note: Only one size for each attribute may be active at once.
* Eg. if Color3f is installed/active, then Color4f may not be, even
@@ -187,10 +187,7 @@ static void *lookup_or_generate( GLuint attr, GLuint sz, GLuint v,
{
GET_CURRENT_CONTEXT( ctx );
TNLcontext *tnl = TNL_CONTEXT(ctx);
- struct dynfn *dfn;
void *ptr = 0;
- int isvertex = (attr == 0);
- int key;
/* This will remove any installed handlers for attr with different
* sz, will flush, copy and expand the copied vertices if sz won't
@@ -200,24 +197,31 @@ static void *lookup_or_generate( GLuint attr, GLuint sz, GLuint v,
if (tnl->vtx.attrib_sz[attr] != sz)
tnl_fixup_vertex( ctx, attr, sz );
- if (isvertex)
- key = tnl->vtx.vertex_size;
- else
- key = (GLuint)tnl->vtx.attrptr[attr];
- for (dfn = tnl->vtx.generated[sz-1][v][isvertex] ; dfn ; dfn = dfn->next) {
- if (dfn->key == key) {
- ptr = dfn->code;
- break;
+ {
+ struct dynfn *dfn;
+ int isvertex = (attr == 0);
+ int key;
+
+ if (isvertex)
+ key = tnl->vtx.vertex_size;
+ else
+ key = (GLuint)tnl->vtx.attrptr[attr];
+
+ for (dfn = tnl->vtx.generated[sz-1][v][isvertex]; dfn; dfn = dfn->next) {
+ if (dfn->key == key) {
+ ptr = dfn->code;
+ break;
+ }
}
- }
- if (ptr == 0) {
- dfn = tnl->vtx.codegen[sz-1][v][isvertex]( ctx, key );
- if (dfn) {
- ptr = dfn->code;
- dfn->next = tnl->vtx.generated[sz-1][v][isvertex];
- tnl->vtx.generated[sz-1][v][isvertex] = dfn;
+ if (ptr == 0) {
+ dfn = tnl->vtx.codegen[sz-1][v][isvertex]( ctx, key );
+ if (dfn) {
+ ptr = dfn->code;
+ dfn->next = tnl->vtx.generated[sz-1][v][isvertex];
+ tnl->vtx.generated[sz-1][v][isvertex] = dfn;
+ }
}
}
diff --git a/src/mesa/tnl/t_vtx_exec.c b/src/mesa/tnl/t_vtx_exec.c
index 64965a40958..dc06ca2741c 100644
--- a/src/mesa/tnl/t_vtx_exec.c
+++ b/src/mesa/tnl/t_vtx_exec.c
@@ -47,39 +47,238 @@ USE OR OTHER DEALINGS IN THE SOFTWARE.
#include "tnl/t_context.h"
#include "tnl/t_array_api.h"
+static GLint min_sz[TNL_ATTRIB_MAX] = {
+ 2, /* VERT_ATTRIB_POS */
+ 1, /* VERT_ATTRIB_WEIGHT */
+ 3, /* VERT_ATTRIB_NORMAL */
+ 3, /* VERT_ATTRIB_COLOR0 */
+ 3, /* VERT_ATTRIB_COLOR1 */
+ 1, /* VERT_ATTRIB_FOG */
+ 1, /* VERT_ATTRIB_SIX */
+ 1, /* VERT_ATTRIB_SEVEN */
+ 2, /* VERT_ATTRIB_TEX0 */
+ 2, /* VERT_ATTRIB_TEX1 */
+ 2, /* VERT_ATTRIB_TEX2 */
+ 2, /* VERT_ATTRIB_TEX3 */
+ 2, /* VERT_ATTRIB_TEX4 */
+ 2, /* VERT_ATTRIB_TEX5 */
+ 2, /* VERT_ATTRIB_TEX6 */
+ 2, /* VERT_ATTRIB_TEX7 */
+ 4, /* MAT_ATTRIB_FRONT_AMBIENT */
+ 4, /* MAT_ATTRIB_FRONT_DIFFUSE */
+ 4, /* MAT_ATTRIB_FRONT_SPECULAR */
+ 4, /* MAT_ATTRIB_FRONT_EMISSION */
+ 1, /* MAT_ATTRIB_FRONT_SHININESS */
+ 3, /* MAT_ATTRIB_FRONT_INDEXES */
+ 4, /* MAT_ATTRIB_BACK_AMBIENT */
+ 4, /* MAT_ATTRIB_BACK_DIFFUSE */
+ 4, /* MAT_ATTRIB_BACK_SPECULAR */
+ 4, /* MAT_ATTRIB_BACK_EMISSION */
+ 3, /* MAT_ATTRIB_BACK_SHININESS */
+ 1, /* MAT_ATTRIB_BACK_INDEXES */
+ 1, /* VERT_ATTRIB_INDEX */
+ 1, /* VERT_ATTRIB_EDGEFLAG */
+ 1, /* VERT_ATTRIB_POINTSIZE */
+ 3, /* VERT_ATTRIB_BACK_COLOR0 */
+ 3, /* VERT_ATTRIB_BACK_COLOR1 */
+ 1, /* VERT_ATTRIB_BACK_INDEX */
+};
+
-void tnl_copy_to_current( GLcontext *ctx, struct tnl_vtx_block *v )
+/* NOTE: can precompute all this stuff:
+ */
+static void *init_current_arrays( GLcontext *ctx )
{
TNLcontext *tnl = TNL_CONTEXT(ctx);
- GLint i, update = 0;
+ int i;
- assert(ctx->Driver.NeedFlush & FLUSH_UPDATE_CURRENT);
+ for (i = 0 ; i <= VERT_ATTRIB_EDGEFLAG ; i++) {
+ struct gl_client_array *array = &tnl->exec.Current[i];
- for (i = 0 ; i < 16 ; i++)
- if (tnl->vtx.attrib_sz[i])
- COPY_SZ( ctx->Current.Attrib[i],
- &(tnl->vtx.attrptr[i][0].f),
- tnl->vtx.attrib_sz[i] );
+ array->Stride = 0;
+ array->StrideB = 0;
- if (tnl->vtx.attrib_sz[VERT_ATTRIB_INDEX])
- ctx->Current.Index = tnl->vtx.attrptr[VERT_ATTRIB_INDEX][0].ui;
+ if (i < VERT_ATTRIB_MAX) {
+ array->Ptr = ctx->Current.Attrib[i];
+/* array->Size = sz_4f(ctx->Current.Attrib[i]); */
+ array->Type = GL_FLOAT;
+ }
+ else if (i <= VERT_ATTRIB_MAT_BACK_INDEXES) {
+ array->Ptr =
+ ctx->Light.Material.Attrib[i-VERT_ATTRIB_MAT_BACK_INDEXES];
+ array->Size = min_sz[i];
+ array->Type = GL_FLOAT;
+ }
+ else if (i == VERT_ATTRIB_INDEX) {
+ array->Ptr = &ctx->Current.Index;
+ array->Size = 1;
+ array->Type = GL_UNSIGNED_INT;
+ }
+ else if (i == VERT_ATTRIB_EDGEFLAG) {
+ array->Ptr = &ctx->Current.Edgeflag;
+ array->Size = 1;
+ array->Type = GL_UNSIGNED_INT;
+ }
+ }
+}
- if (tnl->vtx.attrib_sz[VERT_ATTRIB_EDGEFLAG])
- ctx->Current.EdgeFlag = tnl->vtx.attrptr[VERT_ATTRIB_EDGEFLAG][0].ui;
- for (i = 0 ; i < MAT_ATTRIB_MAX ; i++ ) {
- if (tnl->vtx.attrib_sz[i + VERT_ATTRIB_MAT_FRONT_EMISSION]) {
- COPY_SZ( ctx->Light.Material.Attrib[i],
- &(tnl->vtx.attrptr[i+VERT_ATTRIB_MAT_FRONT_EMISSION][0].f),
- tnl->vtx.attrib_sz[i]);
- update |= 1 << i;
- }
+static GLint sz_4f( const GLfloat *f )
+{
+ if (f[3] != 1.0) return 4;
+ if (f[2] != 0.0) return 3;
+ if (f[1] != 0.0) return 2;
+ return 1;
+}
- if (update)
- _mesa_update_material( ctx, update );
+static GLint get_attrib_sz( GLcontext *ctx, GLint i )
+{
+ if (i <= VERT_ATTRIB_TEX7)
+ return sz_4f(ctx->Current.Attrib[i]);
+ else
+ return min_sz[i];
+}
+
+static void bind_current( GLcontext *ctx, GLint i )
+{
+ get_current_array( ctx, i, &tnl->vb.Attrib[i] );
+}
+
+/* Need to increment v->vert_store->ref_count???
+ */
+static void bind_vert( GLcontext *ctx, struct tnl_vtx_node *v,
+ GLint i, GLint offset )
+{
+ struct gl_client_array *array = &tnl->vb.Attrib[i];
+ array->Stride = v->vert_size * sizeof(union uif);
+ array->StrideB = v->vert_size * sizeof(union uif);
+ array->Ptr = v->verts[offset];
+ array->Size = v->attrib_sz[i];
+ array->Type = attrib_type[i]; /* always the same */
+}
+
+
+/* Allocate an array big enough, copy wrapped vertices to array,
+ * extend last vertex to end:
+ *
+ * Allocated data will have to be from a tnl_vtx_store struct, and be
+ * refcounted.
+ *
+ * Can special case wrap.nr == 1 --> bind_current.
+ * Can special case where all wrapped vertices have the same value
+ * for this attribute --> bind_current again.
+ */
+static void bind_wrapped( GLcontext *ctx, struct tnl_vtx_node *v, GLint i )
+{
+ struct gl_client_array *array = &tnl->vb.Attrib[i];
+
+ get_wrap_array( ctx, i, &wrap );
+
+ /* How does this get freed?
+ */
+ alloc_array( ctx, wrap->Size, &tnl->vb.Attrib[i],
+ v->vertex_count + tnl->wrap.nr );
+
+
+ copy_wrap_array( &tnl->vb.Attrib[i], tnl->wrap.nr, &current );
+ extend_array( &tnl->vb.Attrib[i], tnl->wrap.nr,
+ v->vert_count + tnl->wrap.nr );
+}
+
+
+/* Current is like wrapped with stride==0. Can they be unified?
+ */
+static void bind_current_and_vert( GLcontext *ctx, struct tnl_vtx_node *v,
+ GLint i )
+{
+ struct gl_client_array current;
+
+ get_current_array( ctx, i, &current );
+
+ if (current->Size > v->attrib_sz[i]) {
+ /* Need to allocate a wider array & copy:
+ */
+ }
+ else {
+ /* Bind vertex data in place, leaving room for wrapped data:
+ */
+ get_vert_array( ctx, i, &tnl->vb.Attrib[i], - tnl->wrap.nr );
+
+ /* Copy current into wrap slots
+ */
+ copy_wrap_array( &tnl->vb.Attrib[i], tnl->wrap.nr, &current );
+ }
+}
+
+static void bind_wrapped_and_vert( GLcontext *ctx, struct tnl_vtx_node *v,
+ GLint i )
+{
+ struct gl_client_array wrap;
+
+ get_wrap_array( ctx, i, &wrap );
+
+ if (wrap->Size > v->attrib_sz[i]) {
+ /* Need to allocate a wider array & copy:
+ */
}
+ else {
+ /* Bind vertex data in place, leaving room for wrapped data:
+ */
+ get_vert_array( ctx, i, &tnl->vb.Attrib[i], - tnl->wrap.nr );
- ctx->Driver.NeedFlush &= ~FLUSH_UPDATE_CURRENT;
+ /* Copy current into wrap slots
+ */
+ copy_wrap_array( &tnl->vb.Attrib[i], tnl->wrap.nr, &wrap );
+ }
+}
+
+
+/* This is the tricky bit, as always. Pull saved (wrapped) vertices
+ * out of their temporary storage and prepend them to the incoming
+ * tnl_vtx_node.
+ *
+ * Will the vertices fit into the space left for them? Do the vertex
+ * sizes match? If not, fallback.
+ *
+ * .. actually it looks like this should be part of the 'bind'
+ * operation, avoiding a fallback in favor of a copy.
+ *
+ */
+static bind_wrapped_and_verts( GLcontext *ctx, struct tnl_vtx_node *v )
+{
+
+ if (tnl->exec.wrap_nr) {
+ for (i = 0 ; i < TNL_ATTRIB_MAX ; i++) {
+ if (tnl->wrap.attrib_sz[i] && v->attrib_sz[i])
+ bind_wrapped_and_vert( tnl, v, i );
+ else if (tnl->wrap.attrib_sz[i])
+ bind_wrapped( tnl, i );
+ else if (v->attrib_sz[i])
+ bind_current_and_vert( tnl, v, i );
+ else {
+ /* This is already done */
+ /* bind_current( tnl, v, i ); */
+ }
+ }
+ }
+ else {
+ for (i = 0 ; i < TNL_ATTRIB_MAX ; i++) {
+ if (v->attrib_sz[i])
+ bind_vert( tnl, v, i );
+ else
+ bind_current( tnl, v, i );
+ }
+ }
+
+ for (i = 0 ; i < TNL_ATTRIB_MAX; i++)
+ tnl->vb.Attrib[i] = &tnl->exec.Attrib[i];
+
+ tnl->vb.Count = v->vert_count + tnl->exec.wrap_nr;
+ tnl->vb.Elts = 0;
+ tnl->vb.Primitive = &tnl->exec.Primitive;
+ tnl->vb.NrPrimitives = tnl->exec.NrPrimitives;
+ tnl->vb.NormalLengthPtr = 0;
+ tnl->vb.PointSizePtr = 0;
}
static GLboolean discrete_gl_prim[GL_POLYGON+1] = {
@@ -140,10 +339,10 @@ static void optimize_prims( TNLcontext *tnl )
/* Build a primitive list from the begin/end buffer.
*/
-static void build_prims( TNLcontext *tnl )
+static void build_prims( TNLcontext *tnl, struct tnl_vtx_node *v )
{
int i, j;
- struct tnl_be *be = tnl->vtx.be;
+ struct tnl_be *be = v->be;
struct tnl_prim *prim = tnl->primlist;
GLenum state = ctx->Driver.CurrentExecPrimitive;
@@ -159,7 +358,7 @@ static void build_prims( TNLcontext *tnl )
/* Convert begin/ends into prims
*/
- for (i = 0 ; i < tnl->vtx.be_count ; i++) {
+ for (i = 0 ; i < v->be_count ; i++) {
switch (be[i].type) {
case TNL_BEGIN:
if (state != PRIM_OUTSIDE_BEGIN_END ||
@@ -183,9 +382,8 @@ static void build_prims( TNLcontext *tnl )
}
}
- if (state != PRIM_OUTSIDE_BEGIN_END) {
- prim[j].end = tnl->vtx.initial_counter - tnl->vtx.counter;
- }
+ if (state != PRIM_OUTSIDE_BEGIN_END)
+ prim[j].end = v->vert_count;
}
@@ -206,10 +404,10 @@ static void copy_vertex( TNLcontext *tnl, GLuint n, GLfloat *dst )
}
}
-static GLuint copy_wrapped_verts( TNLcontext *tnl, GLfloat (*tmp)[15] )
+static GLuint copy_wrapped_verts( TNLcontext *tnl, struct tnl_vtx_node *v )
{
GLuint ovf, i;
- GLuint nr = (tnl->initial_counter - tnl->counter) - tnl->primlist[tnl->nrprims].start;
+ GLuint nr = v->vert_count - tnl->primlist[tnl->nrprims].start;
if (MESA_VERBOSE & DEBUG_VFMT)
_mesa_debug(NULL, "%s %d verts\n", __FUNCTION__, nr);
@@ -271,59 +469,94 @@ static GLuint copy_wrapped_verts( TNLcontext *tnl, GLfloat (*tmp)[15] )
}
-static void save_wrapped_verts( TNLcontext *tnl )
+static void save_wrapped_verts( TNLcontext *tnl, struct tnl_vtx_node *v )
{
- tnl->wrap.nr_verts = copy_wrapped_verts( tnl );
+ if (ctx->Driver.CurrentExecPrimitive != PRIM_OUTSIDE_BEGIN_END)
+ tnl->wrap.nr_verts = copy_wrapped_verts( tnl, v );
+ else
+ tnl->wrap.nr_verts = 0;
}
-
-static void emit_wrapped_verts( TNLcontext *tnl )
+/* This must be done for each node. To do it only when outside
+ * begin/end, would need to take wrapped vertices into account (which
+ * wouldn't necessarily be a bad thing).
+ */
+static void copy_to_current( GLcontext *ctx, struct tnl_vtx_node *v )
{
- /* Reemit saved vertices
- * *** POSSIBLY IN NEW FORMAT
- * --> Can't always extend at end of vertex
- */
- for (i = 0 ; i < nrverts; i++) {
- if (MESA_VERBOSE & DEBUG_VERTS) {
- int j;
- _mesa_debug(NULL, "re-emit vertex %d to %p\n", i, tnl->dmaptr);
- if (MESA_VERBOSE & DEBUG_VERBOSE)
- for (j = 0 ; j < tnl->vertex_size; j++)
- _mesa_debug(NULL, "\t%08x/%f\n", *(int*)&tmp[i][j], tmp[i][j]);
+ TNLcontext *tnl = TNL_CONTEXT(ctx);
+ GLint i;
+ const union uif *vert = v->verts + (v->vert_count-1) * v->vert_size;
+ const GLubyte *attrib_sz = v->attrib_sz;
+
+ for (i = 0 ; i < 16 ; i++)
+ if (attrib_sz[i]) {
+ COPY_SZ( ctx->Current.Attrib[i], &(vert->f), attrib_sz[i] );
+ vert += attrib_sz[i];
}
- memcpy( tnl->dmaptr, tmp[i], tnl->vertex_size * 4 );
- tnl->dmaptr += tnl->vertex_size;
- tnl->counter--;
+ for (i = 0 ; i < MAT_ATTRIB_MAX ; i++ ) {
+ GLuint update = 0;
+
+ if (attrib_sz[i + VERT_ATTRIB_MAT_FRONT_EMISSION]) {
+ COPY_SZ( ctx->Light.Material.Attrib[i], &(vert->f), attrib_sz[i]);
+ vert += attrib_sz[i];
+ update |= 1 << i;
+ }
+
+ if (update)
+ _mesa_update_material( ctx, update );
}
-}
+ if (attrib_sz[VERT_ATTRIB_INDEX]) {
+ ctx->Current.Index = vert->ui;
+ vert++;
+ }
+
+ if (attrib_sz[VERT_ATTRIB_EDGEFLAG]) {
+ ctx->Current.EdgeFlag = vert->ui;
+ vert++;
+ }
+
+
+
+ if (ctx->Light.ColorMaterialEnabled) {
+ }
+}
/* Bind vertex buffer pointers, run pipeline:
*/
-void _tnl_execute_buffer( TNLcontext *tnl, struct tnl_vtx_block *v )
+void _tnl_execute_buffer( GLcontext *ctx, struct tnl_vtx_block *v )
{
- /* Bring back wrapped vertices:
+ TNLcontext *tnl = TNL_CONTEXT(ctx);
+
+ /* Bring back wrapped vertices and bind (with the new verts) into the VB:
*/
- revive_wrapped_verts( tnl, v );
+ emit_wrapped_verts_bind_vb( tnl, v );
- /* Build primitive list from begin/end events in buffer
+ /* Build primitive list from begin/end events in buffer (taking
+ * into account wrapped vertices).
+ *
+ * Also updates ctx->Driver.CurrentExecPrimitive:
*/
build_prims( tnl, v );
- /* Bind the arrays and run the pipeline
+ /* Run the pipeline:
*/
- bind_vertex_buffer( tnl, v );
tnl->Driver.RunPipeline( ctx, &tnl->vb );
- /* Copy wrapped vertices for next time::
+ /* Copy wrapped vertices for next time. Need to save from bound
+ * data, not from incoming verts which would be easier.
*/
save_wrapped_verts( tnl, v );
+
+ /* Copy to current:
+ */
+ copy_to_current( ctx, v );
}