diff options
author | Keith Whitwell <[email protected]> | 2005-04-22 12:51:19 +0000 |
---|---|---|
committer | Keith Whitwell <[email protected]> | 2005-04-22 12:51:19 +0000 |
commit | 6f973f33679e034b7cb63806f1ddfabdbdd70123 (patch) | |
tree | 31580bc32d1b87a3dddd8f7c8bc5f404b407c637 /src/mesa/tnl/t_vb_vertex.c | |
parent | 6a13c7da4c79f7e811fbddc68f59441070ff0cc8 (diff) |
Simplify the pipeline_stage structure
- remove input/output fields, input tracking removed.
- remove state fields, the validate function now called
on every statechange.
- add an explicit 'create' function.
Add in code to build vertex program to implement current t&l state. Still
disabled, but turn on with a #define in t_vp_build.h.
Diffstat (limited to 'src/mesa/tnl/t_vb_vertex.c')
-rw-r--r-- | src/mesa/tnl/t_vb_vertex.c | 215 |
1 files changed, 74 insertions, 141 deletions
diff --git a/src/mesa/tnl/t_vb_vertex.c b/src/mesa/tnl/t_vb_vertex.c index ec303187a54..b3defaad05e 100644 --- a/src/mesa/tnl/t_vb_vertex.c +++ b/src/mesa/tnl/t_vb_vertex.c @@ -47,14 +47,6 @@ struct vertex_stage_data { GLubyte *clipmask; GLubyte ormask; GLubyte andmask; - - - /* Need these because it's difficult to replay the sideeffects - * analytically. - */ - GLvector4f *save_eyeptr; - GLvector4f *save_clipptr; - GLvector4f *save_ndcptr; }; #define VERTEX_STAGE_DATA(stage) ((struct vertex_stage_data *)stage->privatePtr) @@ -134,137 +126,90 @@ static GLboolean run_vertex_stage( GLcontext *ctx, TNLcontext *tnl = TNL_CONTEXT(ctx); struct vertex_buffer *VB = &tnl->vb; - ASSERT(!ctx->VertexProgram._Enabled); - - if (stage->changed_inputs) { - - if (ctx->_NeedEyeCoords) { - /* Separate modelview transformation: - * Use combined ModelProject to avoid some depth artifacts - */ - if (ctx->ModelviewMatrixStack.Top->type == MATRIX_IDENTITY) - VB->EyePtr = VB->ObjPtr; - else - VB->EyePtr = TransformRaw( &store->eye, - ctx->ModelviewMatrixStack.Top, - VB->ObjPtr); -#if 0 - /* examine some eye coordinates */ - { - GLuint i; - GLfloat *v = VB->EyePtr->start; - for (i = 0; i < 4; i++) { - _mesa_printf("eye[%d] = %g, %g, %g, %g\n", - i, v[0], v[1], v[2], v[3]); - v += 4; - } - } -#endif - } - - VB->ClipPtr = TransformRaw( &store->clip, - &ctx->_ModelProjectMatrix, - VB->ObjPtr ); - - /* Drivers expect this to be clean to element 4... - */ - switch (VB->ClipPtr->size) { - case 1: - /* impossible */ - case 2: - _mesa_vector4f_clean_elem( VB->ClipPtr, VB->Count, 2 ); - /* fall-through */ - case 3: - _mesa_vector4f_clean_elem( VB->ClipPtr, VB->Count, 3 ); - /* fall-through */ - case 4: - break; - } - -#if 0 - /* examine some clip coordinates */ - { - GLuint i; - GLfloat *v = VB->ClipPtr->start; - for (i = 0; i < 4; i++) { - _mesa_printf("clip[%d] = %g, %g, %g, %g\n", - i, v[0], v[1], v[2], v[3]); - v += 4; - } - } -#endif - - /* Cliptest and perspective divide. Clip functions must clear - * the clipmask. + if (ctx->VertexProgram._Enabled) + return GL_TRUE; + + if (ctx->_NeedEyeCoords) { + /* Separate modelview transformation: + * Use combined ModelProject to avoid some depth artifacts */ - store->ormask = 0; - store->andmask = CLIP_ALL_BITS; - - if (tnl->NeedNdcCoords) { - VB->NdcPtr = - _mesa_clip_tab[VB->ClipPtr->size]( VB->ClipPtr, - &store->proj, - store->clipmask, - &store->ormask, - &store->andmask ); - } - else { - VB->NdcPtr = NULL; - _mesa_clip_np_tab[VB->ClipPtr->size]( VB->ClipPtr, - NULL, - store->clipmask, - &store->ormask, - &store->andmask ); - } + if (ctx->ModelviewMatrixStack.Top->type == MATRIX_IDENTITY) + VB->EyePtr = VB->ObjPtr; + else + VB->EyePtr = TransformRaw( &store->eye, + ctx->ModelviewMatrixStack.Top, + VB->ObjPtr); + } - if (store->andmask) - return GL_FALSE; + VB->ClipPtr = TransformRaw( &store->clip, + &ctx->_ModelProjectMatrix, + VB->ObjPtr ); + /* Drivers expect this to be clean to element 4... + */ + switch (VB->ClipPtr->size) { + case 1: + /* impossible */ + case 2: + _mesa_vector4f_clean_elem( VB->ClipPtr, VB->Count, 2 ); + /* fall-through */ + case 3: + _mesa_vector4f_clean_elem( VB->ClipPtr, VB->Count, 3 ); + /* fall-through */ + case 4: + break; + } - /* Test userclip planes. This contributes to VB->ClipMask, so - * is essentially required to be in this stage. - */ - if (ctx->Transform.ClipPlanesEnabled) { - usercliptab[VB->ClipPtr->size]( ctx, - VB->ClipPtr, - store->clipmask, - &store->ormask, - &store->andmask ); - - if (store->andmask) - return GL_FALSE; - } - - VB->ClipAndMask = store->andmask; - VB->ClipOrMask = store->ormask; - VB->ClipMask = store->clipmask; - - store->save_eyeptr = VB->EyePtr; - store->save_clipptr = VB->ClipPtr; - store->save_ndcptr = VB->NdcPtr; + + /* Cliptest and perspective divide. Clip functions must clear + * the clipmask. + */ + store->ormask = 0; + store->andmask = CLIP_ALL_BITS; + + if (tnl->NeedNdcCoords) { + VB->NdcPtr = + _mesa_clip_tab[VB->ClipPtr->size]( VB->ClipPtr, + &store->proj, + store->clipmask, + &store->ormask, + &store->andmask ); } else { - /* Replay the sideeffects. - */ - VB->EyePtr = store->save_eyeptr; - VB->ClipPtr = store->save_clipptr; - VB->NdcPtr = store->save_ndcptr; - VB->ClipMask = store->clipmask; - VB->ClipAndMask = store->andmask; - VB->ClipOrMask = store->ormask; + VB->NdcPtr = NULL; + _mesa_clip_np_tab[VB->ClipPtr->size]( VB->ClipPtr, + NULL, + store->clipmask, + &store->ormask, + &store->andmask ); + } + + if (store->andmask) + return GL_FALSE; + + + /* Test userclip planes. This contributes to VB->ClipMask, so + * is essentially required to be in this stage. + */ + if (ctx->Transform.ClipPlanesEnabled) { + usercliptab[VB->ClipPtr->size]( ctx, + VB->ClipPtr, + store->clipmask, + &store->ormask, + &store->andmask ); + if (store->andmask) return GL_FALSE; } + VB->ClipAndMask = store->andmask; + VB->ClipOrMask = store->ormask; + VB->ClipMask = store->clipmask; + return GL_TRUE; } -static void check_vertex( GLcontext *ctx, struct tnl_pipeline_stage *stage ) -{ - stage->active = !ctx->VertexProgram._Enabled; -} - static GLboolean init_vertex_stage( GLcontext *ctx, struct tnl_pipeline_stage *stage ) { @@ -289,10 +234,7 @@ static GLboolean init_vertex_stage( GLcontext *ctx, !store->proj.data) return GL_FALSE; - /* Now run the stage. - */ - stage->run = run_vertex_stage; - return stage->run( ctx, stage ); + return GL_TRUE; } static void dtr( struct tnl_pipeline_stage *stage ) @@ -314,18 +256,9 @@ static void dtr( struct tnl_pipeline_stage *stage ) const struct tnl_pipeline_stage _tnl_vertex_transform_stage = { "modelview/project/cliptest/divide", - _NEW_PROGRAM, /* check_state: only care about vertex prog */ - _MESA_NEW_NEED_EYE_COORDS | /* run_state: when to invalidate / re-run */ - _NEW_MODELVIEW| - _NEW_PROJECTION| - _NEW_PROGRAM| - _NEW_TRANSFORM, - GL_TRUE, /* active */ - _TNL_BIT_POS, /* inputs */ - _TNL_BIT_POS, /* outputs */ - 0, /* changed_inputs */ NULL, /* private data */ + init_vertex_stage, dtr, /* destructor */ - check_vertex, /* check */ - init_vertex_stage /* run -- initially set to init */ + NULL, + run_vertex_stage /* run -- initially set to init */ }; |