diff options
author | Keith Whitwell <keith@tungstengraphics.com> | 2002-10-17 14:26:37 +0000 |
---|---|---|
committer | Keith Whitwell <keith@tungstengraphics.com> | 2002-10-17 14:26:37 +0000 |
commit | e3223ef497fc297e8f194244e47c6566198e9ef6 (patch) | |
tree | 5c7a2e60fa32ced2f1a2095c70db95c4f3cf519b | |
parent | 9cfc9dc28b469b65bfd89d6c95b01d51639e9a4b (diff) |
Checkpoint:
- Need 64 bits to talk about stage input/outputs.
- Change driver 'Points' func to just a single 'Point'
- Initialize pipeline stages with a funciton call instead of
static copy of the stage
-rw-r--r-- | src/mesa/tnl/t_array_api.c | 21 | ||||
-rw-r--r-- | src/mesa/tnl/t_array_import.c | 58 | ||||
-rw-r--r-- | src/mesa/tnl/t_context.h | 146 | ||||
-rw-r--r-- | src/mesa/tnl/t_pipeline.c | 67 | ||||
-rw-r--r-- | src/mesa/tnl/t_vb_fog.c | 54 | ||||
-rw-r--r-- | src/mesa/tnl/t_vb_light.c | 138 | ||||
-rw-r--r-- | src/mesa/tnl/t_vb_normals.c | 29 | ||||
-rw-r--r-- | src/mesa/tnl/t_vb_points.c | 30 | ||||
-rw-r--r-- | src/mesa/tnl/t_vb_program.c | 58 | ||||
-rw-r--r-- | src/mesa/tnl/t_vb_render.c | 89 | ||||
-rw-r--r-- | src/mesa/tnl/t_vb_rendertmp.h | 6 | ||||
-rw-r--r-- | src/mesa/tnl/t_vb_texgen.c | 57 | ||||
-rw-r--r-- | src/mesa/tnl/t_vb_texmat.c | 49 | ||||
-rw-r--r-- | src/mesa/tnl/t_vb_vertex.c | 84 | ||||
-rw-r--r-- | src/mesa/tnl/t_vtx_api.c | 16 |
15 files changed, 449 insertions, 453 deletions
diff --git a/src/mesa/tnl/t_array_api.c b/src/mesa/tnl/t_array_api.c index 95552c9d7e..5ab0cc0e5e 100644 --- a/src/mesa/tnl/t_array_api.c +++ b/src/mesa/tnl/t_array_api.c @@ -1,4 +1,4 @@ -/* $Id: t_array_api.c,v 1.27.2.1 2002/10/15 16:56:52 keithw Exp $ */ +/* $Id: t_array_api.c,v 1.27.2.2 2002/10/17 14:26:37 keithw Exp $ */ /* * Mesa 3-D graphics library @@ -150,9 +150,13 @@ _tnl_DrawArrays(GLenum mode, GLint start, GLsizei count) /* Locked drawarrays. Reuse any previously transformed data. */ _tnl_vb_bind_arrays( ctx, ctx->Array.LockFirst, ctx->Array.LockCount ); - VB->FirstPrimitive = start; - VB->Primitive[start] = mode | PRIM_BEGIN | PRIM_END | PRIM_LAST; - VB->PrimitiveLength[start] = count; + + VB->Primitive = &tmp_prim; + VB->Primitive[0].flags = mode | PRIM_BEGIN | PRIM_END | PRIM_LAST; + VB->Primitive[0].start = start; + VB->Primitive[0].finish = start + count; + VB->NrPrimitives = 1; + tnl->Driver.RunPipeline( ctx ); } else { @@ -229,9 +233,12 @@ _tnl_DrawArrays(GLenum mode, GLint start, GLsizei count) _tnl_vb_bind_arrays( ctx, j - minimum, j + nr ); - VB->FirstPrimitive = 0; - VB->Primitive[0] = mode | PRIM_BEGIN | PRIM_END | PRIM_LAST; - VB->PrimitiveLength[0] = nr + minimum; + VB->Primitive = &tmp_prim; + VB->Primitive[0].flags = mode | PRIM_BEGIN | PRIM_END | PRIM_LAST; + VB->Primitive[0].start = 0; + VB->Primitive[0].finish = nr + minimum; + VB->NrPrimitives = 1; + tnl->pipeline.run_input_changes |= ctx->Array._Enabled; tnl->Driver.RunPipeline( ctx ); tnl->pipeline.run_input_changes |= ctx->Array._Enabled; diff --git a/src/mesa/tnl/t_array_import.c b/src/mesa/tnl/t_array_import.c index 749cc56ad2..957b2888ac 100644 --- a/src/mesa/tnl/t_array_import.c +++ b/src/mesa/tnl/t_array_import.c @@ -1,4 +1,4 @@ -/* $Id: t_array_import.c,v 1.25.2.1 2002/10/15 16:56:52 keithw Exp $ */ +/* $Id: t_array_import.c,v 1.25.2.2 2002/10/17 14:26:37 keithw Exp $ */ /* * Mesa 3-D graphics library @@ -58,15 +58,15 @@ static void _tnl_import_vertex( GLcontext *ctx, writeable, &is_writeable); - inputs->Obj.data = (GLfloat (*)[4]) tmp->Ptr; - inputs->Obj.start = (GLfloat *) tmp->Ptr; - inputs->Obj.stride = tmp->StrideB; - inputs->Obj.size = tmp->Size; - inputs->Obj.flags &= ~(VEC_BAD_STRIDE|VEC_NOT_WRITEABLE); - if (inputs->Obj.stride != 4*sizeof(GLfloat)) - inputs->Obj.flags |= VEC_BAD_STRIDE; + inputs->Attribs[VERT_ATTRIB_POS].data = (GLfloat (*)[4]) tmp->Ptr; + inputs->Attribs[VERT_ATTRIB_POS].start = (GLfloat *) tmp->Ptr; + inputs->Attribs[VERT_ATTRIB_POS].stride = tmp->StrideB; + inputs->Attribs[VERT_ATTRIB_POS].size = tmp->Size; + inputs->Attribs[VERT_ATTRIB_POS].flags &= ~(VEC_BAD_STRIDE|VEC_NOT_WRITEABLE); + if (inputs->Attribs[VERT_ATTRIB_POS].stride != 4*sizeof(GLfloat)) + inputs->Attribs[VERT_ATTRIB_POS].flags |= VEC_BAD_STRIDE; if (!is_writeable) - inputs->Obj.flags |= VEC_NOT_WRITEABLE; + inputs->Attribs[VERT_ATTRIB_POS].flags |= VEC_NOT_WRITEABLE; } static void _tnl_import_normal( GLcontext *ctx, @@ -288,20 +288,20 @@ void _tnl_vb_bind_arrays( GLcontext *ctx, GLint start, GLsizei count ) if (inputs & VERT_BIT_POS) { _tnl_import_vertex( ctx, 0, 0 ); - tmp->Obj.count = VB->Count; - VB->ObjPtr = &tmp->Obj; + tmp->Attribs[VERT_ATTRIB_POS].count = VB->Count; + VB->AttribPtr[VERT_ATTRIB_POS] = &tmp->Obj; } if (inputs & VERT_BIT_NORMAL) { _tnl_import_normal( ctx, 0, 0 ); - tmp->Normal.count = VB->Count; - VB->NormalPtr = &tmp->Normal; + tmp->Attribs[VERT_ATTRIB_NORMAL].count = VB->Count; + VB->AttribPtr[VERT_ATTRIB_NORMAL] = &tmp->Attribs[VERT_ATTRIB_NORMAL]; } if (inputs & VERT_BIT_COLOR0) { _tnl_import_color( ctx, 0, 0, 0 ); - VB->ColorPtr[0] = &tmp->Color; - VB->ColorPtr[1] = 0; + VB->AttribPtr[VERT_ATTRIB_COLOR0] = &tmp->Attribs[VERT_ATTRIB_COLOR0]; + VB->AttribPtr[VERT_ATTRIB_BACK_COLOR0] = 0; } if (inputs & VERT_BITS_TEX_ANY) { @@ -309,8 +309,9 @@ void _tnl_vb_bind_arrays( GLcontext *ctx, GLint start, GLsizei count ) for (unit = 0; unit < ctx->Const.MaxTextureUnits; unit++) { if (inputs & VERT_BIT_TEX(unit)) { _tnl_import_texcoord( ctx, unit, GL_FALSE, GL_FALSE ); - tmp->TexCoord[unit].count = VB->Count; - VB->TexCoordPtr[unit] = &tmp->TexCoord[unit]; + tmp->Attribs[VERT_ATTRIB_TEX0+unit].count = VB->Count; + VB->AttribPtr[VERT_ATTRIB_TEX0+unit] = + &tmp->Attribs[VERT_ATTRIB_TEX0+unit]; } } } @@ -324,30 +325,35 @@ void _tnl_vb_bind_arrays( GLcontext *ctx, GLint start, GLsizei count ) VB->IndexPtr[1] = 0; } - if (inputs & VERT_BIT_FOG) { - _tnl_import_fogcoord( ctx, 0, 0 ); - tmp->FogCoord.count = VB->Count; - VB->FogCoordPtr = &tmp->FogCoord; - } - if (inputs & VERT_BIT_EDGEFLAG) { _tnl_import_edgeflag( ctx, GL_TRUE, sizeof(GLboolean) ); VB->EdgeFlag = (GLboolean *) tmp->EdgeFlag.data; } + + if (inputs & VERT_BIT_FOG) { + _tnl_import_fogcoord( ctx, 0, 0 ); + tmp->Attribs[VERT_ATTRIB_FOG].count = VB->Count; + VB->AttribPtr[VERT_ATTRIB_FOG] = &tmp->Attribs[VERT_ATTRIB_FOG]; + } + if (inputs & VERT_BIT_COLOR1) { _tnl_import_secondarycolor( ctx, 0, 0, 0 ); - VB->SecondaryColorPtr[0] = &tmp->SecondaryColor; - VB->SecondaryColorPtr[1] = 0; + tmp->Attribs[VERT_ATTRIB_COLOR1].count = VB->Count; + VB->AttribPtr[VERT_ATTRIB_COLOR1] = &tmp->Attribs[VERT_ATTRIB_COLOR1]; + VB->AttribPtr[VERT_ATTRIB_BACK_COLOR1] = 0; } } - /* XXX not 100% sure this is finished. Keith should probably inspect. */ + /* If vertex programs are enabled, vertex-attrib arrays override + * the old type arrays, where enabled. + */ if (ctx->VertexProgram.Enabled) { GLuint index; for (index = 0; index < VERT_ATTRIB_MAX; index++) { /* XXX check program->InputsRead to reduce work here */ _tnl_import_attrib( ctx, index, GL_FALSE, GL_TRUE ); + VB->AttribPtr[index].count = VB->Count; VB->AttribPtr[index] = &tmp->Attribs[index]; } } diff --git a/src/mesa/tnl/t_context.h b/src/mesa/tnl/t_context.h index 39aa01e005..beab24abb6 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.1 2002/10/15 16:56:52 keithw Exp $ */ +/* $Id: t_context.h,v 1.43.2.2 2002/10/17 14:26:37 keithw Exp $ */ /* * Mesa 3-D graphics library @@ -45,59 +45,34 @@ /** - * Flags that describe the inputs and outputs of pipeline stages. We - * reuse the VERT_BIT_* flags defined in mtypes.h and add a bunch of - * new ones. - */ -#define VERT_ATTRIB_INDEX VERT_ATTRIB_SIX -#define VERT_ATTRIB_EDGEFLAG VERT_ATTRIB_SEVEN -/* */ -#define VERT_ATTRIB_MAT_FRONT_AMBIENT 16 -#define VERT_ATTRIB_MAT_FRONT_DIFFUSE 17 -#define VERT_ATTRIB_MAT_FRONT_SPECULAR 18 -#define VERT_ATTRIB_MAT_FRONT_EMISSION 19 -#define VERT_ATTRIB_MAT_FRONT_SHININESS 20 -#define VERT_ATTRIB_MAT_FRONT_INDEXES 21 -#define VERT_ATTRIB_MAT_BACK_AMBIENT 22 -#define VERT_ATTRIB_MAT_BACK_DIFFUSE 23 -#define VERT_ATTRIB_MAT_BACK_SPECULAR 24 -#define VERT_ATTRIB_MAT_BACK_EMISSION 25 -#define VERT_ATTRIB_MAT_BACK_SHININESS 26 -#define VERT_ATTRIB_MAT_BACK_INDEXES 27 -#define VERT_ATTRIB_BACK_COLOR0 28 -#define VERT_ATTRIB_BACK_COLOR1 29 -#define VERT_ATTRIB_BACK_INDEX 30 - -/* bits 0..5 defined in mtypes.h */ -#define VERT_BIT_INDEX VERT_BIT_SIX /* a free vertex attrib bit */ -#define VERT_BIT_EDGEFLAG VERT_BIT_SEVEN /* a free vertex attrib bit */ -/* bits 8..15 defined in mtypes.h */ -#define VERT_BIT_MAT_FRONT_AMBIENT (1 << 16) -#define VERT_BIT_MAT_FRONT_DIFFUSE (1 << 17) -#define VERT_BIT_MAT_FRONT_SPECULAR (1 << 18) -#define VERT_BIT_MAT_FRONT_EMISSION (1 << 19) -#define VERT_BIT_MAT_FRONT_SHININESS (1 << 20) -#define VERT_BIT_MAT_FRONT_INDEXES (1 << 21) -#define VERT_BIT_MAT_BACK_AMBIENT (1 << 22) -#define VERT_BIT_MAT_BACK_DIFFUSE (1 << 23) -#define VERT_BIT_MAT_BACK_SPECULAR (1 << 24) -#define VERT_BIT_MAT_BACK_EMISSION (1 << 25) -#define VERT_BIT_MAT_BACK_SHININESS (1 << 26) -#define VERT_BIT_MAT_BACK_INDEXES (1 << 27) -#define VERT_BIT_BACK_COLOR (1 << 28) -#define VERT_BIT_BACK_SPECULAR (1 << 29) - - -#define VERT_BITS_MATERIAL (VERT_BIT_MAT_FRONT_AMBIENT | \ - VERT_BIT_MAT_FRONT_DIFFUSE | \ - VERT_BIT_MAT_FRONT_SPECULAR | \ - VERT_BIT_MAT_FRONT_EMISSION | \ - VERT_BIT_MAT_FRONT_SHININESS_INDEXES | \ - VERT_BIT_MAT_BACK_AMBIENT | \ - VERT_BIT_MAT_BACK_DIFFUSE | \ - VERT_BIT_MAT_BACK_SPECULAR | \ - VERT_BIT_MAT_BACK_EMISSION | \ - VERT_BIT_MAT_BACK_SHININESS_INDEXES) + * Extend the VERT_ATTRIB_ definitions from mtypes.h. Don't bother + * defining the VERT_BIT equivalents as we have to use 2 32bit bitsets + * to talk about these now. + */ +#define VERT_ATTRIB_INDEX 16 /* not naturally a float */ +#define VERT_ATTRIB_EDGEFLAG 17 /* not naturally a float */ +#define VERT_ATTRIB_POINTSIZE 18 +#define VERT_ATTRIB_MAT_FRONT_AMBIENT 19 +#define VERT_ATTRIB_MAT_FRONT_DIFFUSE 20 +#define VERT_ATTRIB_MAT_FRONT_SPECULAR 21 +#define VERT_ATTRIB_MAT_FRONT_EMISSION 22 +#define VERT_ATTRIB_MAT_FRONT_SHININESS 23 +#define VERT_ATTRIB_MAT_FRONT_INDEXES 24 +#define VERT_ATTRIB_MAT_BACK_AMBIENT 25 +#define VERT_ATTRIB_MAT_BACK_DIFFUSE 26 +#define VERT_ATTRIB_MAT_BACK_SPECULAR 27 +#define VERT_ATTRIB_MAT_BACK_EMISSION 28 +#define VERT_ATTRIB_MAT_BACK_SHININESS 29 +#define VERT_ATTRIB_MAT_BACK_INDEXES 30 +#define VERT_ATTRIB_BACK_COLOR0 31 +#define VERT_ATTRIB_BACK_COLOR1 32 +#define VERT_ATTRIB_BACK_INDEX 33 + +#define TEST_BIT( bset, bit ) (bset[bit/32] & (1<<(bit&31))) +#define SET_BIT( bset, bit ) (bset[bit/32] |= (1<<(bit&31))) +#define CLEAR_BIT( bset, bit ) (bset[bit/32] &= ~(1<<(bit&31))) + + /* Numbers for sizing immediate structs. @@ -111,14 +86,17 @@ struct vertex_block { GLuint refcount; GLuint vertex_format[4]; - GLubyte *verts; + GLuint vertex_size; + GLuint block_size; + GLubyte verts[1]; } -struct r200_prim { +struct tnl_prim +{ GLuint start; GLuint end; - GLuint prim; + GLuint flags; }; @@ -144,7 +122,6 @@ typedef struct vertex_buffer GLvector4f *EyePtr; GLvector4f *ClipPtr; GLvector4f *NdcPtr; - GLubyte ClipOrMask; GLubyte *ClipMask; GLfloat *NormalLengthPtr; GLvector4f *PointSizePtr; /* why not just a float *? */ @@ -152,9 +129,14 @@ typedef struct vertex_buffer struct tnl_prim *Primitive; /* primitive descriptors */ GLuint nrPrimitives; /* nr */ - /* All other vertex data - */ GLvector4f *AttribPtr[TNL_ATTRIB_MAX]; + /* All other vertex data. Edgeflag & Index are included in here as + * 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 @@ -183,12 +165,12 @@ struct gl_pipeline_stage { */ GLboolean active; /* True if runnable in current state */ - GLuint inputs; /* VERT_* inputs to the stage */ - GLuint outputs; /* VERT_* outputs of the stage */ + GLuint inputs[2]; /* VERT_* inputs to the stage */ + GLuint outputs[2]; /* VERT_* outputs of the stage */ /* Set in _tnl_run_pipeline(): */ - GLuint changed_inputs; /* Generated value -- inputs to the + GLuint changed_inputs[2]; /* Generated value -- inputs to the * stage that have changed since last * call to 'run'. */ @@ -222,8 +204,8 @@ struct gl_pipeline { GLuint build_state_trigger; /* state changes which require build */ GLuint build_state_changes; /* state changes since last build */ GLuint run_state_changes; /* state changes since last run */ - GLuint run_input_changes; /* VERT_* changes since last run */ - GLuint inputs; /* VERT_* inputs to pipeline */ + GLuint run_input_changes[2]; /* VERT_* changes since last run */ + GLuint inputs[2]; /* VERT_* inputs to pipeline */ struct gl_pipeline_stage stages[MAX_PIPELINE_STAGES+1]; GLuint nr_stages; }; @@ -235,11 +217,10 @@ struct tnl_eval_store { GLuint EvalMap1AttribFlags; /* GL_NV_vertex_program */ GLuint EvalMap2AttribFlags; /* GL_NV_vertex_program */ GLuint EvalNewState; - struct immediate *im; /* used for temporary data */ }; -typedef void (*points_func)( GLcontext *ctx, GLuint first, GLuint last ); +typedef void (*point_func)( GLcontext *ctx, GLuint v1 ); typedef void (*line_func)( GLcontext *ctx, GLuint v1, GLuint v2 ); typedef void (*triangle_func)( GLcontext *ctx, GLuint v1, GLuint v2, GLuint v3 ); @@ -271,11 +252,6 @@ struct tnl_device_driver { /* Alert tnl-aware drivers of changes to material. */ - GLboolean (*NotifyBegin)(GLcontext *ctx, GLenum p); - /* Allow drivers to hook in optimized begin/end engines. - * Return value: GL_TRUE - driver handled the begin - * GL_FALSE - driver didn't handle the begin - */ /*** *** Rendering -- These functions called only from t_vb_render.c @@ -314,7 +290,7 @@ struct tnl_device_driver { void (*ClippedLine)( GLcontext *ctx, GLuint v0, GLuint v1 ); /* Render a line between the two vertices given by indexes v0 and v1. */ - points_func Points; /* must now respect vb->elts */ + point_func Point; line_func Line; triangle_func Triangle; quad_func Quad; @@ -371,7 +347,9 @@ typedef struct { /* Display list extensions */ - GLuint opcode_vertex_cassette; + GLuint opcode_vertex_block; + GLuint opcode_begin; + GLuint opcode_end; /* Pipeline */ @@ -382,16 +360,7 @@ typedef struct { */ struct vertex_arrays imm_inputs; struct vertex_arrays array_inputs; - GLuint *tmp_primitive; - GLuint *tmp_primitive_length; - - /* Set when executing an internally generated begin/end object. If - * such an object is encountered in a display list, it will be - * replayed only if the list is outside any existing begin/end - * objects. - */ - GLboolean ReplayHardBeginEnd; - + /* Note which vertices need copying over succesive immediates. * Will add save versions to precompute vertex copying where * possible. @@ -399,14 +368,8 @@ typedef struct { struct vertex_block *ExecCopySource; GLuint ExecCopyCount; GLuint ExecCopyElts[IMM_MAX_COPIED_VERTS]; - GLuint ExecCopyTexSize; GLuint ExecParity; - GLuint DlistPrimitive; - GLuint DlistPrimitiveLength; - GLuint DlistLastPrimitive; - - /* Probably need a better configuration mechanism: */ GLboolean NeedNdcCoords; @@ -419,7 +382,8 @@ typedef struct { struct tnl_eval_store eval; /* We have our own dispatch table for EXECUTE modes. In COMPILE - * and COMPILE_AND_EXECUTE, we plug directly into ctx->Save. + * and COMPILE_AND_EXECUTE, we plug directly into ctx->Save? + * */ struct _glapi_table *Exec; /* Execute funcs */ diff --git a/src/mesa/tnl/t_pipeline.c b/src/mesa/tnl/t_pipeline.c index 47a3b32260..065a0766ba 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.1 2002/10/15 16:56:52 keithw Exp $ */ +/* $Id: t_pipeline.c,v 1.22.2.2 2002/10/17 14:26:37 keithw Exp $ */ /* * Mesa 3-D graphics library @@ -51,10 +51,12 @@ void _tnl_install_pipeline( GLcontext *ctx, ASSERT(pipe->nr_stages == 0); pipe->run_state_changes = ~0; - pipe->run_input_changes = ~0; + pipe->run_input_changes[0] = ~0; + pipe->run_input_changes[1] = ~0; pipe->build_state_changes = ~0; pipe->build_state_trigger = 0; - pipe->inputs = 0; + pipe->inputs[0] = 0; + pipe->inputs[1] = 0; /* Create a writeable copy of each stage. */ @@ -87,30 +89,44 @@ void _tnl_validate_pipeline( GLcontext *ctx ) struct gl_pipeline *pipe = &tnl->pipeline; struct gl_pipeline_stage *s = pipe->stages; GLuint newstate = pipe->build_state_changes; - GLuint generated = 0; - GLuint changed_inputs = 0; - - pipe->inputs = 0; + GLuint generated[2]; + GLuint changed_inputs[2]; + + generated[0] = 0; + generated[1] = 0; + changed_inputs[0] = 0; + changed_inputs[1] = 0; + pipe->inputs[0] = 0; + pipe->inputs[1] = 0; pipe->build_state_changes = 0; for ( ; s->check ; s++) { - s->changed_inputs |= s->inputs & changed_inputs; + s->changed_inputs[0] |= s->inputs[0] & changed_inputs[0]; + s->changed_inputs[1] |= s->inputs[1] & changed_inputs[1]; if (s->check_state & newstate) { if (s->active) { - GLuint old_outputs = s->outputs; + GLuint old_outputs[2]; + old_outputs[0] = s->outputs[0]; + old_outputs[1] = s->outputs[1]; + s->check(ctx, s); - if (!s->active) - changed_inputs |= old_outputs; + + if (!s->active) { + changed_inputs[0] |= old_outputs[0]; + changed_inputs[1] |= old_outputs[1]; + } } else s->check(ctx, s); } if (s->active) { - pipe->inputs |= s->inputs & ~generated; - generated |= s->outputs; + pipe->inputs[0] |= s->inputs[0] & ~generated[0]; + pipe->inputs[1] |= s->inputs[1] & ~generated[1]; + generated[0] |= s->outputs[1]; + generated[0] |= s->outputs[1]; } } } @@ -124,12 +140,15 @@ void _tnl_run_pipeline( GLcontext *ctx ) struct gl_pipeline *pipe = &tnl->pipeline; struct gl_pipeline_stage *s = pipe->stages; GLuint changed_state = pipe->run_state_changes; - GLuint changed_inputs = pipe->run_input_changes; + GLuint changed_inputs[2]; GLboolean running = GL_TRUE; unsigned short __tmp; + changed_inputs[0] = pipe->run_input_changes[0]; + changed_inputs[1] = pipe->run_input_changes[1]; + pipe->run_input_changes[0] = 0; + pipe->run_input_changes[1] = 0; pipe->run_state_changes = 0; - pipe->run_input_changes = 0; /* Done elsewhere. */ @@ -143,18 +162,24 @@ void _tnl_run_pipeline( GLcontext *ctx ) * state-changes. */ for ( ; s->run ; s++) { - s->changed_inputs |= s->inputs & changed_inputs; + s->changed_inputs[0] |= s->inputs[0] & changed_inputs[0]; + s->changed_inputs[1] |= s->inputs[1] & changed_inputs[1]; - if (s->run_state & changed_state) - s->changed_inputs = s->inputs; + if (s->run_state & changed_state) { + s->changed_inputs[0] = s->inputs[0]; + s->changed_inputs[1] = s->inputs[1]; + } if (s->active && running) { - if (s->changed_inputs) - changed_inputs |= s->outputs; + if (s->changed_inputs[0] | s->changed_inputs[1]) { + changed_inputs[0] |= s->outputs[0]; + changed_inputs[1] |= s->outputs[1]; + } running = s->run( ctx, s ); - s->changed_inputs = 0; + s->changed_inputs[0] = 0; + s->changed_inputs[1] = 0; } } diff --git a/src/mesa/tnl/t_vb_fog.c b/src/mesa/tnl/t_vb_fog.c index 32b4039b36..62b67b7c9b 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.1 2002/10/15 16:56:52 keithw Exp $ */ +/* $Id: t_vb_fog.c,v 1.17.2.2 2002/10/17 14:26:37 keithw Exp $ */ /* * Mesa 3-D graphics library @@ -147,6 +147,7 @@ static GLboolean run_fog_stage( GLcontext *ctx, if (!ctx->_NeedEyeCoords) { const GLfloat *m = ctx->ModelviewMatrixStack.Top->m; GLfloat plane[4]; + GLint sz = VB->AttrPtr[VERT_ATTR_POS]->size; /* Use this to store calculated eye z values: */ @@ -160,18 +161,15 @@ static GLboolean run_fog_stage( GLcontext *ctx, /* Full eye coords weren't required, just calculate the * eye Z values. */ - _mesa_dotprod_tab[VB->ObjPtr->size]( (GLfloat *) input->data, - 4 * sizeof(GLfloat), - VB->ObjPtr, plane ); + _mesa_dotprod_tab[sz]( (GLfloat *) input->data, + 4 * sizeof(GLfloat), + VB->ObjPtr, plane ); - input->count = VB->ObjPtr->count; + input->count = VB->Count; } else { input = &store->input; - if (VB->EyePtr->size < 2) - _mesa_vector4f_clean_elem( VB->EyePtr, VB->Count, 2 ); - input->data = (GLfloat (*)[4]) &(VB->EyePtr->data[0][2]); input->start = VB->EyePtr->start+2; input->stride = VB->EyePtr->stride; @@ -194,11 +192,15 @@ static GLboolean run_fog_stage( GLcontext *ctx, static void check_fog_stage( GLcontext *ctx, struct gl_pipeline_stage *stage ) { stage->active = ctx->Fog.Enabled && !ctx->VertexProgram.Enabled; - - if (ctx->Fog.FogCoordinateSource == GL_FRAGMENT_DEPTH_EXT) - stage->inputs = VERT_BIT_EYE; - else - stage->inputs = VERT_BIT_FOG; + + if (ctx->Fog.FogCoordinateSource == GL_FRAGMENT_DEPTH_EXT) { + SET_BIT(stage->inputs, VERT_BIT_POS); + CLEAR_BIT(stage->inputs, VERT_BIT_FOG); + } + else { + CLEAR_BIT(stage->inputs, VERT_BIT_POS); + SET_BIT(stage->inputs, VERT_BIT_FOG); + } } @@ -238,17 +240,17 @@ static void free_fog_data( struct gl_pipeline_stage *stage ) } -const struct gl_pipeline_stage _tnl_fog_coordinate_stage = +struct gl_pipeline_stage *_tnl_fog_stage( GLcontext *ctx ) { - "build fog coordinates", /* name */ - _NEW_FOG, /* check_state */ - _NEW_FOG, /* run_state */ - GL_FALSE, /* active? */ - 0, /* inputs */ - VERT_BIT_FOG, /* outputs */ - 0, /* changed_inputs */ - NULL, /* private_data */ - free_fog_data, /* dtr */ - check_fog_stage, /* check */ - alloc_fog_data /* run -- initially set to init. */ -}; + stage = CALLOC_STRUCT( gl_pipeline_stage ); + + stage->name = "fog"; + stage->recheck = _NEW_FOG; + stage->recalc = _NEW_FOG; + stage->active = GL_FALSE; + stage->destroy = free_fog_data; + stage->check = check_fog_stage; + stage->run = alloc_fog_data; + + return stage; +} diff --git a/src/mesa/tnl/t_vb_light.c b/src/mesa/tnl/t_vb_light.c index 1735e7ac7d..3e57d7f149 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.1 2002/10/15 16:56:52 keithw Exp $ */ +/* $Id: t_vb_light.c,v 1.18.2.2 2002/10/17 14:26:37 keithw Exp $ */ /* * Mesa 3-D graphics library @@ -40,9 +40,9 @@ #include "t_context.h" #include "t_pipeline.h" -#define LIGHT_TWOSIDE 0x2 -#define LIGHT_COLORMATERIAL 0x4 -#define MAX_LIGHT_FUNC 0x8 +#define LIGHT_TWOSIDE 0x1 +#define LIGHT_MATERIAL 0x2 +#define MAX_LIGHT_FUNC 0x4 typedef void (*light_func)( GLcontext *ctx, struct vertex_buffer *VB, @@ -50,7 +50,6 @@ typedef void (*light_func)( GLcontext *ctx, GLvector4f *input ); struct light_stage_data { - struct gl_client_array FloatColor; struct gl_client_array LitColor[2]; struct gl_client_array LitSecondary[2]; GLvector1ui LitIndex[2]; @@ -74,15 +73,15 @@ static light_func _tnl_light_ci_tab[MAX_LIGHT_FUNC]; #define IDX (0) #include "t_vb_lighttmp.h" -#define TAG(x) x##_tw +#define TAG(x) x##_twoside #define IDX (LIGHT_TWOSIDE) #include "t_vb_lighttmp.h" -#define TAG(x) x##_cm +#define TAG(x) x##_mat #define IDX (LIGHT_MATERIAL) #include "t_vb_lighttmp.h" -#define TAG(x) x##_tw_cm +#define TAG(x) x##_twoside_mat #define IDX (LIGHT_TWOSIDE|LIGHT_MATERIAL) #include "t_vb_lighttmp.h" @@ -93,9 +92,9 @@ static void init_lighting( void ) if (!done) { init_light_tab(); - init_light_tab_tw(); - init_light_tab_cm(); - init_light_tab_tw_cm(); + init_light_tab_twoside(); + init_light_tab_mat(); + init_light_tab_twoside_mat(); done = 1; } } @@ -107,19 +106,14 @@ static GLboolean run_lighting( GLcontext *ctx, struct gl_pipeline_stage *stage ) TNLcontext *tnl = TNL_CONTEXT(ctx); struct vertex_buffer *VB = &tnl->vb; GLvector4f *input = ctx->_NeedEyeCoords ? VB->EyePtr : VB->ObjPtr; - GLuint ind; + GLuint ind = 0; - /* Make sure we can talk about elements 0..2 in the vector we are - * lighting. - */ - if (input->size <= 2) { - if (stage->changed_inputs & (VERT_BIT_EYE|VERT_BIT_POS)) { - copy_data( input, stage->pos_tmp ); - _mesa_vector4f_clean_elem(input, VB->Count, 2); - } + if ((ctx->Light.ColorMaterialEnabled && (VB->Active & VERT_BITS_COLOR)) || + VB->Active & VERT_BITS_MATERIAL) + ind |= LIGHT_MATERIAL; - input = stage->postmp; - } + if (ctx->Light.Model.TwoSide) + ind |= LIGHT_TWOSIDE; /* The individual functions know about replaying side-effects * vs. full re-execution. @@ -155,13 +149,7 @@ static GLboolean run_validate_lighting( GLcontext *ctx, else tab = _tnl_light_ci_tab; - if (ctx->Light.ColorMaterialEnabled) - ind |= LIGHT_COLORMATERIAL; - - if (ctx->Light.Model.TwoSide) - ind |= LIGHT_TWOSIDE; - - LIGHT_STAGE_DATA(stage)->light_func_tab = &tab[ind]; + LIGHT_STAGE_DATA(stage)->light_func_tab = tab; /* This and the above should only be done on _NEW_LIGHT: */ @@ -173,13 +161,13 @@ static GLboolean run_validate_lighting( GLcontext *ctx, return stage->run( ctx, stage ); } -static void alloc_4chan( struct gl_client_array *a, GLuint sz ) +static void alloc_4f( struct gl_client_array *a, GLuint sz ) { - a->Ptr = ALIGN_MALLOC( sz * sizeof(GLchan) * 4, 32 ); + a->Ptr = ALIGN_MALLOC( sz * sizeof(GLfloat) * 4, 32 ); a->Size = 4; - a->Type = CHAN_TYPE; + a->Type = GL_FLOAT; a->Stride = 0; - a->StrideB = sizeof(GLchan) * 4; + a->StrideB = sizeof(GLfloat) * 4; a->Enabled = 0; a->Flags = 0; } @@ -204,12 +192,10 @@ static GLboolean run_init_lighting( GLcontext *ctx, */ init_lighting(); - store->FloatColor.Ptr = 0; - - alloc_4chan( &store->LitColor[0], size ); - alloc_4chan( &store->LitColor[1], size ); - alloc_4chan( &store->LitSecondary[0], size ); - alloc_4chan( &store->LitSecondary[1], size ); + alloc_4f( &store->LitColor[0], size ); + alloc_4f( &store->LitColor[1], size ); + alloc_4f( &store->LitSecondary[0], size ); + alloc_4f( &store->LitSecondary[1], size ); _mesa_vector1ui_alloc( &store->LitIndex[0], 0, size, 32 ); _mesa_vector1ui_alloc( &store->LitIndex[1], 0, size, 32 ); @@ -232,19 +218,23 @@ static void check_lighting( GLcontext *ctx, struct gl_pipeline_stage *stage ) if (stage->active) { if (stage->privatePtr) stage->run = run_validate_lighting; - stage->inputs = VERT_BIT_NORMAL|VERT_BIT_MATERIAL; + if (ctx->Light._NeedVertices) - stage->inputs |= VERT_BIT_EYE; /* effectively, even when lighting in obj */ - if (ctx->Light.ColorMaterialEnabled) - stage->inputs |= VERT_BIT_COLOR0; + SET_BIT(stage->inputs, VERT_ATTRIB_POS); + else + CLEAR_BIT(stage->inputs, VERT_ATTRIB_POS); - stage->outputs = VERT_BIT_COLOR0; - if (ctx->Light.Model.ColorControl == GL_SEPARATE_SPECULAR_COLOR) - stage->outputs |= VERT_BIT_COLOR1; + if (ctx->Light.Model.ColorControl == GL_SEPARATE_SPECULAR_COLOR) { + SET_BIT(stage->outputs, VERT_BIT_COLOR1); + SET_BIT(stage->outputs, VERT_BIT_BACK_COLOR1); + } + else { + CLEAR_BIT(stage->outputs, VERT_BIT_COLOR1); + CLEAR_BIT(stage->outputs, VERT_BIT_BACK_COLOR1); + } } } - static void dtr( struct gl_pipeline_stage *stage ) { struct light_stage_data *store = LIGHT_STAGE_DATA(stage); @@ -255,9 +245,6 @@ static void dtr( struct gl_pipeline_stage *stage ) ALIGN_FREE( store->LitSecondary[0].Ptr ); ALIGN_FREE( store->LitSecondary[1].Ptr ); - if (store->FloatColor.Ptr) - ALIGN_FREE( store->FloatColor.Ptr ); - _mesa_vector1ui_free( &store->LitIndex[0] ); _mesa_vector1ui_free( &store->LitIndex[1] ); FREE( store ); @@ -265,19 +252,40 @@ static void dtr( struct gl_pipeline_stage *stage ) } } -const struct gl_pipeline_stage _tnl_lighting_stage = +struct gl_pipeline_stage *_tnl_lighting_stage( GLcontext *ctx ) { - "lighting", /* name */ - _NEW_LIGHT, /* recheck */ - _NEW_LIGHT|_NEW_MODELVIEW, /* recalc -- modelview dependency - * otherwise not captured by inputs - * (which may be VERT_BIT_POS) */ - GL_FALSE, /* active? */ - 0, /* inputs */ - 0, /* outputs */ - 0, /* changed_inputs */ - NULL, /* private_data */ - dtr, /* destroy */ - check_lighting, /* check */ - run_init_lighting /* run -- initially set to ctr */ -}; + stage = CALLOC_STRUCT( gl_pipeline_stage ); + + stage->name = "lighting"; + stage->recheck = _NEW_LIGHT; + stage->recalc = _NEW_LIGHT|_NEW_MODELVIEW; + stage->active = GL_FALSE; + stage->destroy = dtr; + stage->check = check_lighting; + stage->run = run_init_lighting; + + SET_BIT(stage->inputs, VERT_ATTRIB_NORMAL); + SET_BIT(stage->inputs, VERT_ATTRIB_MAT_FRONT_AMBIENT); + SET_BIT(stage->inputs, VERT_ATTRIB_MAT_FRONT_DIFFUSE); + SET_BIT(stage->inputs, VERT_ATTRIB_MAT_FRONT_SPECULAR); + SET_BIT(stage->inputs, VERT_ATTRIB_MAT_FRONT_EMISSION); + SET_BIT(stage->inputs, VERT_ATTRIB_MAT_FRONT_SHININESS); + SET_BIT(stage->inputs, VERT_ATTRIB_MAT_FRONT_INDEXES); + SET_BIT(stage->inputs, VERT_ATTRIB_MAT_BACK_AMBIENT); + SET_BIT(stage->inputs, VERT_ATTRIB_MAT_BACK_DIFFUSE); + SET_BIT(stage->inputs, VERT_ATTRIB_MAT_BACK_SPECULAR); + SET_BIT(stage->inputs, VERT_ATTRIB_MAT_BACK_EMISSION); + SET_BIT(stage->inputs, VERT_ATTRIB_MAT_BACK_SHININESS); + SET_BIT(stage->inputs, VERT_ATTRIB_MAT_BACK_INDEXES); + + if (ctx->Visual.rgbMode) { + SET_BIT(stage->outputs, VERT_ATTRIB_COLOR0); + SET_BIT(stage->outputs, VERT_ATTRIB_BACK_COLOR0); + } + else { + SET_BIT(stage->outputs, VERT_BIT_INDEX0); + SET_BIT(stage->outputs, VERT_BIT_BACK_INDEX0); + } + + return stage; +} diff --git a/src/mesa/tnl/t_vb_normals.c b/src/mesa/tnl/t_vb_normals.c index 57a947d83b..4aa5cba389 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.1 2002/10/15 16:56:52 keithw Exp $ */ +/* $Id: t_vb_normals.c,v 1.15.2.2 2002/10/17 14:26:37 keithw Exp $ */ /* * Mesa 3-D graphics library @@ -183,17 +183,20 @@ static void free_normal_data( struct gl_pipeline_stage *stage ) -const struct gl_pipeline_stage _tnl_normal_transform_stage = +struct gl_pipeline_stage *_tnl_normal_transform_stage( GLcontext *ctx ) { - "normal transform", /* name */ - _TNL_NEW_NORMAL_TRANSFORM, /* re-check */ - _TNL_NEW_NORMAL_TRANSFORM, /* re-run */ - GL_FALSE, /* active? */ - VERT_BIT_NORMAL, /* inputs */ - VERT_BIT_NORMAL, /* outputs */ - 0, /* changed_inputs */ - NULL, /* private data */ - free_normal_data, /* destructor */ - check_normal_transform, /* check */ - alloc_normal_data /* run -- initially set to alloc */ + struct gl_pipeline_stage *stage = CALLOC_STRUCT( gl_pipeline_stage ); + + stage->name = "normal transform"; + stage->recheck = _TNL_NEW_NORMAL_TRANSFORM; + stage->recalc = _TNL_NEW_NORMAL_TRANSFORM; + stage->active = GL_FALSE; + stage->destroy = free_normal_data; + stage->check = check_normal_transform; + stage->run = alloc_normal_data; + + SET_BIT(stage->inputs, VERT_ATTRIB_NORMAL); + SET_BIT(stage->outputs, VERT_ATTRIB_NORMAL); + + return stage; }; diff --git a/src/mesa/tnl/t_vb_points.c b/src/mesa/tnl/t_vb_points.c index 21832d47e8..92eb796524 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 2002/01/22 14:35:17 brianp Exp $ */ +/* $Id: t_vb_points.c,v 1.8.2.1 2002/10/17 14:26:37 keithw Exp $ */ /* * Mesa 3-D graphics library @@ -108,17 +108,21 @@ static void free_point_data( struct gl_pipeline_stage *stage ) } } -const struct gl_pipeline_stage _tnl_point_attenuation_stage = + +struct gl_pipeline_stage *_tnl_normal_transform_stage( GLcontext *ctx ) { - "point size attenuation", /* name */ - _NEW_POINT, /* build_state_change */ - _NEW_POINT, /* run_state_change */ - GL_FALSE, /* active */ - VERT_BIT_EYE, /* inputs */ - VERT_BIT_POINT_SIZE, /* outputs */ - 0, /* changed_inputs (temporary value) */ - NULL, /* stage private data */ - free_point_data, /* destructor */ - check_point_size, /* check */ - alloc_point_data /* run -- initially set to alloc data */ + struct gl_pipeline_stage *stage = CALLOC_STRUCT( gl_pipeline_stage ); + + stage->name = "normal transform"; + stage->recheck = _NEW_POINT; + stage->recalc = _NEW_POINT; + stage->active = GL_FALSE; + stage->destroy = free_point_data; + stage->check = check_point_size; + stage->run = alloc_point_data; + + SET_BIT(stage->inputs, VERT_ATTRIB_POS); + SET_BIT(stage->outputs, VERT_ATTRIB_POINTSIZE); + + return stage; }; diff --git a/src/mesa/tnl/t_vb_program.c b/src/mesa/tnl/t_vb_program.c index 24a24e4816..f99f8d2251 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.1 2002/10/15 16:56:52 keithw Exp $ */ +/* $Id: t_vb_program.c,v 1.14.2.2 2002/10/17 14:26:37 keithw Exp $ */ /* * Mesa 3-D graphics library @@ -279,8 +279,7 @@ static GLboolean run_vp( GLcontext *ctx, struct gl_pipeline_stage *stage ) * clipping planes, but they're not supported by vertex programs. */ - VB->ClipOrMask = store->ormask; - VB->ClipMask = store->clipmask; + VB->ClipMask = store->clipormask ? store->clipmask : 0; return GL_TRUE; } @@ -403,21 +402,13 @@ static void check_vp( GLcontext *ctx, struct gl_pipeline_stage *stage ) * which the program needs for inputs. */ - stage->inputs = ctx->VertexProgram.Current->InputsRead; - -#if 000 - if (stage->privatePtr) - stage->run = run_validate_program; - stage->inputs = VERT_BIT_NORMAL|VERT_BIT_MATERIAL; - if (ctx->Light._NeedVertices) - stage->inputs |= VERT_BIT_EYE; /* effectively, even when lighting in obj */ - if (ctx->Light.ColorMaterialEnabled) - stage->inputs |= VERT_BIT_COLOR0; - - stage->outputs = VERT_BIT_COLOR0; - if (ctx->Light.Model.ColorControl == GL_SEPARATE_SPECULAR_COLOR) - stage->outputs |= VERT_BIT_COLOR1; -#endif + stage->inputs[0] = ctx->VertexProgram.Current->InputsRead; + stage->inputs[1] = 0; + + /* But what about the outputs??? + */ + stage->outputs[0] = stage->inputs[0] | VERT_BIT_POS | VERT_BIT_COLOR0; + stage->outputs[1] = stage->inputs[1]; } } @@ -445,22 +436,17 @@ static void dtr( struct gl_pipeline_stage *stage ) } } -/** - * Public description of this pipeline stage. - */ -const struct gl_pipeline_stage _tnl_vertex_program_stage = +struct gl_pipeline_stage *_tnl_vertex_program_stage( GLcontext *ctx ) { - "vertex-program", - _NEW_ALL, /*XXX FIX */ /* recheck */ - _NEW_ALL, /*XXX FIX */ /* recalc -- modelview dependency - * otherwise not captured by inputs - * (which may be VERT_BIT_POS) */ - GL_FALSE, /* active */ - /*0*/ VERT_BIT_POS, /* inputs XXX OK? */ - VERT_BIT_CLIP | VERT_BIT_COLOR0, /* outputs XXX OK? */ - 0, /* changed_inputs */ - NULL, /* private_data */ - dtr, /* destroy */ - check_vp, /* check */ - run_init_vp /* run -- initially set to ctr */ -}; + struct gl_pipeline_stage *stage = CALLOC_STRUCT( gl_pipeline_stage ); + + stage->name = "vertex-program"; + stage->recheck = _NEW_ALL; + stage->recalc = _NEW_ALL; + stage->active = GL_FALSE; + stage->destroy = dtr; + stage->check = check_vp; + stage->run = run_init_vp; + + return stage; +} diff --git a/src/mesa/tnl/t_vb_render.c b/src/mesa/tnl/t_vb_render.c index 7a06719007..6b09002d25 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.1 2002/10/15 16:56:52 keithw Exp $ */ +/* $Id: t_vb_render.c,v 1.31.2.2 2002/10/17 14:26:37 keithw Exp $ */ /* * Mesa 3-D graphics library @@ -93,8 +93,8 @@ /* Vertices, with the possibility of clipping. */ -#define RENDER_POINTS( start, count ) \ - tnl->Driver.Render.Points( ctx, start, count ) +#define RENDER_POINT( v1 ) \ + if (!mask[v1]) PointFunc( ctx, v1 ) #define RENDER_LINE( v1, v2 ) \ do { \ @@ -134,11 +134,12 @@ do { \ const GLuint * const elt = VB->Elts; \ const GLubyte *mask = VB->ClipMask; \ const GLuint sz = VB->ClipPtr->size; \ + const point_func PointFunc = tnl->Driver.Render.Point; \ const line_func LineFunc = tnl->Driver.Render.Line; \ const triangle_func TriangleFunc = tnl->Driver.Render.Triangle; \ const quad_func QuadFunc = tnl->Driver.Render.Quad; \ const GLboolean stipple = ctx->Line.StippleFlag; \ - (void) (LineFunc && TriangleFunc && QuadFunc); \ + (void) (LineFunc && TriangleFunc && QuadFunc && PointFunc); \ (void) elt; (void) mask; (void) sz; (void) stipple; #define TAG(x) clip_##x##_verts @@ -205,8 +206,8 @@ static void clip_elt_triangles( GLcontext *ctx, /* Vertices, no clipping. */ -#define RENDER_POINTS( start, count ) \ - tnl->Driver.Render.Points( ctx, start, count ) +#define RENDER_POINT( v1 ) \ + PointFunc( ctx, v1 ) #define RENDER_LINE( v1, v2 ) \ LineFunc( ctx, v1, v2 ) @@ -223,11 +224,12 @@ static void clip_elt_triangles( GLcontext *ctx, TNLcontext *tnl = TNL_CONTEXT(ctx); \ struct vertex_buffer *VB = &tnl->vb; \ const GLuint * const elt = VB->Elts; \ + const point_func PointFunc = tnl->Driver.Render.Point; \ const line_func LineFunc = tnl->Driver.Render.Line; \ const triangle_func TriangleFunc = tnl->Driver.Render.Triangle; \ const quad_func QuadFunc = tnl->Driver.Render.Quad; \ const GLboolean stipple = ctx->Line.StippleFlag; \ - (void) (LineFunc && TriangleFunc && QuadFunc); \ + (void) (LineFunc && TriangleFunc && QuadFunc && PointFunc); \ (void) elt; (void) stipple #define RESET_STIPPLE if (stipple) tnl->Driver.Render.ResetLineStipple( ctx ) @@ -293,7 +295,7 @@ static GLboolean run_render( GLcontext *ctx, ASSERT(tnl->Driver.Render.BuildVertices); ASSERT(tnl->Driver.Render.PrimitiveNotify); - ASSERT(tnl->Driver.Render.Points); + ASSERT(tnl->Driver.Render.Point); ASSERT(tnl->Driver.Render.Line); ASSERT(tnl->Driver.Render.Triangle); ASSERT(tnl->Driver.Render.Quad); @@ -306,7 +308,7 @@ static GLboolean run_render( GLcontext *ctx, tnl->Driver.Render.BuildVertices( ctx, 0, VB->Count, new_inputs ); - if (VB->ClipOrMask) { + if (VB->ClipMask) { tab = VB->Elts ? clip_render_tab_elts : clip_render_tab_verts; clip_render_tab_elts[GL_TRIANGLES] = clip_elt_triangles; } @@ -358,41 +360,45 @@ static GLboolean run_render( GLcontext *ctx, */ static void check_render( GLcontext *ctx, struct gl_pipeline_stage *stage ) { - GLuint inputs = VERT_BIT_CLIP; GLuint i; + stage->inputs[0] = 0; + stage->inputs[1] = 0; + + SET_BIT(stage->inputs, VERT_ATTRIB_POS); + if (ctx->Visual.rgbMode) { - inputs |= VERT_BIT_COLOR0; + SET_BIT(stage->inputs, VERT_ATTRIB_COLOR0); if (ctx->_TriangleCaps & DD_SEPARATE_SPECULAR) - inputs |= VERT_BIT_COLOR1; + SET_BIT(stage->inputs, VERT_ATTRIB_COLOR1); if (ctx->Texture._EnabledUnits) { for (i = 0 ; i < ctx->Const.MaxTextureUnits ; i++) { if (ctx->Texture.Unit[i]._ReallyEnabled) - inputs |= VERT_BIT_TEX(i); + SET_BIT(stage->inputs, VERT_ATTRIB_TEX0 + i); } } } else { - inputs |= VERT_BIT_INDEX; + SET_BIT(stage->inputs, VERT_ATTRIB_INDEX); } if (ctx->Point._Attenuated) - inputs |= VERT_BIT_POINT_SIZE; + SET_BIT(stage->inputs, VERT_ATTRIB_POINTSIZE); /* How do drivers turn this off? */ if (ctx->Fog.Enabled) - inputs |= VERT_BIT_FOG; + SET_BIT(stage->inputs, VERT_ATTRIB_FOG); if (ctx->_TriangleCaps & DD_TRI_UNFILLED) - inputs |= VERT_BIT_EDGEFLAG; + SET_BIT(stage->inputs, VERT_ATTRIB_EDGEFLAG); + /* ??? */ if (ctx->RenderMode==GL_FEEDBACK) - inputs |= VERT_BITS_TEX_ANY; - - stage->inputs = inputs; + for (i = 0 ; i < ctx->Const.MaxTextureUnits ; i++) + SET_BIT(stage->inputs, VERT_ATTRIB_TEX0 + i); } @@ -403,25 +409,26 @@ static void dtr( struct gl_pipeline_stage *stage ) } -const struct gl_pipeline_stage _tnl_render_stage = + +struct gl_pipeline_stage *_tnl_render_stage( GLcontext *ctx ) { - "render", /* name */ - (_NEW_BUFFERS | - _DD_NEW_SEPARATE_SPECULAR | - _DD_NEW_FLATSHADE | - _NEW_TEXTURE| - _NEW_LIGHT| - _NEW_POINT| - _NEW_FOG| - _DD_NEW_TRI_UNFILLED | - _NEW_RENDERMODE), /* re-check (new inputs, interp function) */ - 0, /* re-run (always runs) */ - GL_TRUE, /* active? */ - 0, /* inputs (set in check_render) */ - 0, /* outputs */ - 0, /* changed_inputs */ - NULL, /* private data */ - dtr, /* destructor */ - check_render, /* check */ - run_render /* run */ -}; + struct gl_pipeline_stage *stage = CALLOC_STRUCT( gl_pipeline_stage ); + + stage->name = "render"; + stage->recheck = (_NEW_BUFFERS | + _DD_NEW_SEPARATE_SPECULAR | + _DD_NEW_FLATSHADE | + _NEW_TEXTURE| + _NEW_LIGHT| + _NEW_POINT| + _NEW_FOG| + _DD_NEW_TRI_UNFILLED | + _NEW_RENDERMODE); + stage->recalc = 0; /* always reruns */ + stage->active = GL_TRUE; + stage->destroy = dtr; + stage->check = check_render; + stage->run = run_render; + + return stage; +} diff --git a/src/mesa/tnl/t_vb_rendertmp.h b/src/mesa/tnl/t_vb_rendertmp.h index 16528db6ad..037b112aa8 100644 --- a/src/mesa/tnl/t_vb_rendertmp.h +++ b/src/mesa/tnl/t_vb_rendertmp.h @@ -1,4 +1,4 @@ -/* $Id: t_vb_rendertmp.h,v 1.9 2002/02/13 00:53:20 keithw Exp $ */ +/* $Id: t_vb_rendertmp.h,v 1.9.2.1 2002/10/17 14:26:37 keithw Exp $ */ /* * Mesa 3-D graphics library @@ -74,7 +74,9 @@ static void TAG(render_points)( GLcontext *ctx, RESET_OCCLUSION; INIT(GL_POINTS); - RENDER_POINTS( start, count ); + for (j=start; j<count; j++ ) { + RENDER_POINT( ELT(j) ); + } POSTFIX; } diff --git a/src/mesa/tnl/t_vb_texgen.c b/src/mesa/tnl/t_vb_texgen.c index a3c63e0e74..eacb5a735d 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.1 2002/10/15 16:56:53 keithw Exp $ */ +/* $Id: t_vb_texgen.c,v 1.13.2.2 2002/10/17 14:26:37 keithw Exp $ */ /* * Mesa 3-D graphics library @@ -588,36 +588,27 @@ static void check_texgen( GLcontext *ctx, struct gl_pipeline_stage *stage ) stage->active = 0; if (ctx->Texture._TexGenEnabled && !ctx->VertexProgram.Enabled) { - GLuint inputs = 0; - GLuint outputs = 0; - if (ctx->Texture._GenFlags & TEXGEN_OBJ_LINEAR) - inputs |= VERT_BIT_POS; + stage->inputs[0] = 0; + stage->inputs[1] = 0; + stage->outputs[0] = 0; + stage->outputs[1] = 0; - if (ctx->Texture._GenFlags & TEXGEN_NEED_EYE_COORD) - inputs |= VERT_BIT_EYE; + if (ctx->Texture._GenFlags & (TEXGEN_OBJ_LINEAR|TEXGEN_NEED_EYE_COORD)) + SET_BIT(stage->inputs, VERT_ATTRIB_POS); if (ctx->Texture._GenFlags & TEXGEN_NEED_NORMALS) - inputs |= VERT_BIT_NORMAL; + SET_BIT(stage->inputs, VERT_ATTRIB_NORMAL); for (i = 0 ; i < ctx->Const.MaxTextureUnits ; i++) - if (ctx->Texture._TexGenEnabled & ENABLE_TEXGEN(i)) - { - outputs |= VERT_BIT_TEX(i); - - /* Need the original input in case it contains a Q coord: - * (sigh) - */ - inputs |= VERT_BIT_TEX(i); - - /* Something for Feedback? */ + if (ctx->Texture._TexGenEnabled & ENABLE_TEXGEN(i)) { + SET_BIT(stage->outputs, VERT_ATTRIB_TEX0+i); + SET_BIT(stage->inputs, VERT_ATTRIB_TEX0+i); } if (stage->privatePtr) stage->run = run_validate_texgen_stage; stage->active = 1; - stage->inputs = inputs; - stage->outputs = outputs; } } @@ -672,17 +663,17 @@ static void free_texgen_data( struct gl_pipeline_stage *stage ) -const struct gl_pipeline_stage _tnl_texgen_stage = +struct gl_pipeline_stage *_tnl_texgen_stage( GLcontext *ctx ) { - "texgen", /* name */ - _NEW_TEXTURE, /* when to call check() */ - _NEW_TEXTURE, /* when to invalidate stored data */ - GL_FALSE, /* active? */ - 0, /* inputs */ - 0, /* outputs */ - 0, /* changed_inputs */ - NULL, /* private data */ - free_texgen_data, /* destructor */ - check_texgen, /* check */ - alloc_texgen_data /* run -- initially set to alloc data */ -}; + struct gl_pipeline_stage *stage = CALLOC_STRUCT( gl_pipeline_stage ); + + stage->name = "texgen"; + stage->recheck = _NEW_TEXTURE; + stage->recalc = _NEW_TEXTURE; + stage->active = GL_FALSE; + stage->destroy = free_texgen_data; + stage->check = check_texgen; + stage->run = alloc_texgen_data; + + return stage; +} diff --git a/src/mesa/tnl/t_vb_texmat.c b/src/mesa/tnl/t_vb_texmat.c index 61214ffc30..0b26737056 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.1 2002/10/15 16:56:53 keithw Exp $ */ +/* $Id: t_vb_texmat.c,v 1.8.2.2 2002/10/17 14:26:37 keithw Exp $ */ /* * Mesa 3-D graphics library @@ -61,15 +61,18 @@ static void check_texmat( GLcontext *ctx, struct gl_pipeline_stage *stage ) stage->active = 0; if (ctx->Texture._TexMatEnabled && !ctx->VertexProgram.Enabled) { - GLuint flags = 0; - - for (i = 0 ; i < ctx->Const.MaxTextureUnits ; i++) - if (ctx->Texture._TexMatEnabled & ENABLE_TEXMAT(i)) - flags |= VERT_BIT_TEX(i); - stage->active = 1; - stage->inputs = flags; - stage->outputs = flags; + stage->inputs[0] = 0; + stage->inputs[1] = 0; + stage->outputs[0] = 0; + stage->outputs[1] = 0; + + for (i = 0 ; i < ctx->Const.MaxTextureUnits ; i++) { + if (ctx->Texture._TexMatEnabled & ENABLE_TEXMAT(i)) { + SET_BIT(stage->outputs, VERT_ATTRIB_TEX0+i); + SET_BIT(stage->inputs, VERT_ATTRIB_TEX0+i); + } + } } } @@ -134,19 +137,19 @@ static void free_texmat_data( struct gl_pipeline_stage *stage ) } } +struct gl_pipeline_stage *_tnl_texture_transform_stage( GLcontext *ctx ) +{ + struct gl_pipeline_stage *stage = CALLOC_STRUCT( gl_pipeline_stage ); + + stage->name = "texture transform"; + stage->recheck = _NEW_TEXTURE|_NEW_TEXTURE_MATRIX; + stage->recalc = _NEW_TEXTURE|_NEW_TEXTURE_MATRIX; + stage->active = GL_FALSE; + stage->destroy = free_texmat_data; + stage->check = check_texmat; + stage->run = alloc_texmat_data; + + return stage; +} -const struct gl_pipeline_stage _tnl_texture_transform_stage = -{ - "texture transform", /* name */ - _NEW_TEXTURE|_NEW_TEXTURE_MATRIX, /* check_state */ - _NEW_TEXTURE|_NEW_TEXTURE_MATRIX, /* run_state */ - GL_FALSE, /* active? */ - 0, /* inputs */ - 0, /* outputs */ - 0, /* changed_inputs */ - NULL, /* private data */ - free_texmat_data, /* destructor */ - check_texmat, /* check */ - alloc_texmat_data, /* run -- initially set to init */ -}; diff --git a/src/mesa/tnl/t_vb_vertex.c b/src/mesa/tnl/t_vb_vertex.c index 0d99b86d68..3f33181e34 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.1 2002/10/15 16:56:53 keithw Exp $ */ +/* $Id: t_vb_vertex.c,v 1.14.2.2 2002/10/17 14:26:37 keithw Exp $ */ /* * Mesa 3-D graphics library @@ -143,35 +143,18 @@ static GLboolean run_vertex_stage( GLcontext *ctx, /* Separate modelview transformation: * Use combined ModelProject to avoid some depth artifacts */ - if (ctx->ModelviewMatrixStack.Top->type == MATRIX_IDENTITY) - VB->EyePtr = VB->AttrPtr[VERT_ATTRIB_POS]; - else - VB->EyePtr = TransformRaw( &store->eye, - ctx->ModelviewMatrixStack.Top, - VB->AttrPtr[VERT_ATTRIB_POS]); - - /* Need to make sure ClipPtr is clean to element 4, hence the - * second & third conditions: - */ - if (ctx->ProjectionMatrixStack.Top->type == MATRIX_IDENTITY && - (ctx->ModelviewMatrixStack.Top->type != MATRIX_IDENTITY || - VB->EyePtr->Size == 4)) - VB->ClipPtr = VB->EyePtr; - else - VB->ClipPtr = TransformRaw( &store->clip, - &ctx->_ModelProjectMatrix, - VB->AttrPtr[VERT_ATTRIB_POS] ); + VB->EyePtr = TransformRaw( &store->eye, + ctx->ModelviewMatrixStack.Top, + VB->AttrPtr[VERT_ATTRIB_POS]); + + VB->ClipPtr = TransformRaw( &store->clip, + &ctx->_ModelProjectMatrix, + VB->AttrPtr[VERT_ATTRIB_POS] ); } else { - /* Combined modelviewproject transform: - */ - if (ctx->_ModelProjectMatrix.type == MATRIX_IDENTITY && - VB->AttrPtr[VERT_ATTRIB_POS]->Size == 4) - VB->ClipPtr = VB->AttrPtr[VERT_ATTRIB_POS]; - else - VB->ClipPtr = TransformRaw( &store->clip, - &ctx->_ModelProjectMatrix, - VB->AttrPtr[VERT_ATTRIB_POS] ); + VB->ClipPtr = TransformRaw( &store->clip, + &ctx->_ModelProjectMatrix, + VB->AttrPtr[VERT_ATTRIB_POS] ); } @@ -217,8 +200,7 @@ static GLboolean run_vertex_stage( GLcontext *ctx, return GL_FALSE; } - VB->ClipOrMask = store->ormask; - VB->ClipMask = store->clipmask; + VB->ClipMask = store->ormask ? store->clipmask : 0; store->save_eyeptr = VB->EyePtr; store->save_clipptr = VB->ClipPtr; @@ -230,8 +212,7 @@ static GLboolean run_vertex_stage( GLcontext *ctx, VB->EyePtr = store->save_eyeptr; VB->ClipPtr = store->save_clipptr; VB->NdcPtr = store->save_ndcptr; - VB->ClipMask = store->clipmask; - VB->ClipOrMask = store->ormask; + VB->ClipMask = store->ormask ? store->clipmask : 0; if (store->andmask) return GL_FALSE; } @@ -291,20 +272,27 @@ static void dtr( struct gl_pipeline_stage *stage ) } -const struct gl_pipeline_stage _tnl_vertex_transform_stage = + +struct gl_pipeline_stage *_tnl_vertex_transform_stage( GLcontext *ctx ) { - "modelview/project/cliptest/divide", - 0, /* re-check -- always on */ - _MESA_NEW_NEED_EYE_COORDS | - _NEW_MODELVIEW| - _NEW_PROJECTION| - _NEW_TRANSFORM, /* re-run */ - GL_TRUE, /* active */ - VERT_BIT_POS, /* inputs */ - VERT_BIT_EYE|VERT_BIT_CLIP, /* outputs */ - 0, /* changed_inputs */ - NULL, /* private data */ - dtr, /* destructor */ - check_vertex, /* check */ - init_vertex_stage /* run -- initially set to init */ -}; + struct gl_pipeline_stage *stage = CALLOC_STRUCT( gl_pipeline_stage ); + + stage->name = "texture transform"; + stage->recheck = 0; + stage->recalc = (_MESA_NEW_NEED_EYE_COORDS | + _NEW_MODELVIEW| + _NEW_PROJECTION| + _NEW_TRANSFORM); + + stage->active = GL_TRUE; + stage->destroy = dtr; + stage->check = check_vertex; + stage->run = init_vertex_stage; + + SET_BIT( stage->inputs, VERT_ATTRIB_POS ); + SET_BIT( stage->outputs, VERT_ATTRIB_POS ); + + return stage; +} + + diff --git a/src/mesa/tnl/t_vtx_api.c b/src/mesa/tnl/t_vtx_api.c index c935248add..17fd5b7fa2 100644 --- a/src/mesa/tnl/t_vtx_api.c +++ b/src/mesa/tnl/t_vtx_api.c @@ -471,26 +471,26 @@ static void _tnl_Materialfv( GLenum face, GLenum pname, switch (pname) { case GL_EMISSION: - MAT( VERT_ATTRIB_FRONT_EMMISSION, 4, face, params ); + MAT( VERT_ATTRIB_MAT_FRONT_EMMISSION, 4, face, params ); break; case GL_AMBIENT: - MAT( VERT_ATTRIB_FRONT_AMBIENT, 4, face, params ); + MAT( VERT_ATTRIB_MAT_FRONT_AMBIENT, 4, face, params ); break; case GL_DIFFUSE: - MAT( VERT_ATTRIB_FRONT_DIFFUSE, 4, face, params ); + MAT( VERT_ATTRIB_MAT_FRONT_DIFFUSE, 4, face, params ); break; case GL_SPECULAR: - MAT( VERT_ATTRIB_FRONT_SPECULAR, 4, face, params ); + MAT( VERT_ATTRIB_MAT_FRONT_SPECULAR, 4, face, params ); break; case GL_SHININESS: - MAT( VERT_ATTRIB_FRONT_SHININESS, 1, face, params ); + MAT( VERT_ATTRIB_MAT_FRONT_SHININESS, 1, face, params ); break; case GL_COLOR_INDEXES: - MAT( VERT_ATTRIB_FRONT_EMMISSION, 3, face, params ); /* ??? */ + MAT( VERT_ATTRIB_MAT_FRONT_INDEXES, 3, face, params ); /* ??? */ break; case GL_AMBIENT_AND_DIFFUSE: - MAT( VERT_ATTRIB_FRONT_AMBIENT, 4, face, params ); - MAT( VERT_ATTRIB_FRONT_DIFFUSE, 4, face, params ); + MAT( VERT_ATTRIB_MAT_FRONT_AMBIENT, 4, face, params ); + MAT( VERT_ATTRIB_MAT_FRONT_DIFFUSE, 4, face, params ); break; default: _mesa_error( ctx, GL_INVALID_ENUM, where ); |