summaryrefslogtreecommitdiffstats
path: root/src/mesa/tnl
diff options
context:
space:
mode:
authorBrian Paul <[email protected]>2001-12-18 04:06:44 +0000
committerBrian Paul <[email protected]>2001-12-18 04:06:44 +0000
commit30f51ae067379c2b3573c06b707d25a9704df7be (patch)
tree401d75d291724d0d3a47be29d4d3512dcdb66a5a /src/mesa/tnl
parent645ced29552da1af5c759d0497d98c8f55b72935 (diff)
Replace old matrix stacks with new code based on struct matrix_stack.
Moved vertex program hash table into shared context state. Implemented reference counting for vertex programs. Replaced tnl "ProjectedClip" with "Ndc" (normalized device coordinates).
Diffstat (limited to 'src/mesa/tnl')
-rw-r--r--src/mesa/tnl/t_context.c8
-rw-r--r--src/mesa/tnl/t_context.h6
-rw-r--r--src/mesa/tnl/t_vb_fog.c4
-rw-r--r--src/mesa/tnl/t_vb_normals.c6
-rw-r--r--src/mesa/tnl/t_vb_program.c15
-rw-r--r--src/mesa/tnl/t_vb_texmat.c5
-rw-r--r--src/mesa/tnl/t_vb_vertex.c27
7 files changed, 36 insertions, 35 deletions
diff --git a/src/mesa/tnl/t_context.c b/src/mesa/tnl/t_context.c
index 130a3febe50..ae1d7f53611 100644
--- a/src/mesa/tnl/t_context.c
+++ b/src/mesa/tnl/t_context.c
@@ -1,4 +1,4 @@
-/* $Id: t_context.c,v 1.22 2001/07/19 15:54:35 brianp Exp $ */
+/* $Id: t_context.c,v 1.23 2001/12/18 04:06:46 brianp Exp $ */
/*
* Mesa 3-D graphics library
@@ -102,7 +102,7 @@ _tnl_CreateContext( GLcontext *ctx )
_tnl_install_pipeline( ctx, _tnl_default_pipeline );
- tnl->NeedProjCoords = GL_TRUE;
+ tnl->NeedNdcCoords = GL_TRUE;
tnl->LoopbackDListCassettes = GL_FALSE;
tnl->CalcDListNormalLengths = GL_TRUE;
@@ -210,8 +210,8 @@ void
_tnl_need_projected_coords( GLcontext *ctx, GLboolean mode )
{
TNLcontext *tnl = TNL_CONTEXT(ctx);
- if (tnl->NeedProjCoords != mode) {
- tnl->NeedProjCoords = mode;
+ if (tnl->NeedNdcCoords != mode) {
+ tnl->NeedNdcCoords = mode;
_tnl_InvalidateState( ctx, _NEW_PROJECTION );
}
}
diff --git a/src/mesa/tnl/t_context.h b/src/mesa/tnl/t_context.h
index dd0bfad5b61..7b1954a2057 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.33 2001/12/14 02:51:44 brianp Exp $ */
+/* $Id: t_context.h,v 1.34 2001/12/18 04:06:46 brianp Exp $ */
/*
* Mesa 3-D graphics library
@@ -260,7 +260,7 @@ typedef struct vertex_buffer
GLvector4f *ObjPtr; /* VERT_OBJ_BIT */
GLvector4f *EyePtr; /* VERT_EYE */
GLvector4f *ClipPtr; /* VERT_CLIP */
- GLvector4f *ProjectedClipPtr; /* VERT_CLIP (2) */
+ GLvector4f *NdcPtr; /* VERT_CLIP (2) */
GLubyte ClipOrMask; /* VERT_CLIP (3) */
GLubyte *ClipMask; /* VERT_CLIP (4) */
GLvector3f *NormalPtr; /* VERT_NORMAL_BIT */
@@ -535,7 +535,7 @@ typedef struct {
/* Probably need a better configuration mechanism:
*/
- GLboolean NeedProjCoords;
+ GLboolean NeedNdcCoords;
GLboolean LoopbackDListCassettes;
GLboolean CalcDListNormalLengths;
diff --git a/src/mesa/tnl/t_vb_fog.c b/src/mesa/tnl/t_vb_fog.c
index 9e3d440b6a0..eebeba265b3 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.13 2001/12/14 02:51:45 brianp Exp $ */
+/* $Id: t_vb_fog.c,v 1.14 2001/12/18 04:06:46 brianp Exp $ */
/*
* Mesa 3-D graphics library
@@ -145,7 +145,7 @@ static GLboolean run_fog_stage( GLcontext *ctx,
VB->FogCoordPtr = &store->fogcoord;
if (!ctx->_NeedEyeCoords) {
- GLfloat *m = ctx->ModelView.m;
+ const GLfloat *m = ctx->ModelviewMatrixStack.Top->m;
GLfloat plane[4];
/* Use this to store calculated eye z values:
diff --git a/src/mesa/tnl/t_vb_normals.c b/src/mesa/tnl/t_vb_normals.c
index aff84b08485..457acd2b522 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.10 2001/12/14 02:51:45 brianp Exp $ */
+/* $Id: t_vb_normals.c,v 1.11 2001/12/18 04:06:46 brianp Exp $ */
/*
* Mesa 3-D graphics library
@@ -62,7 +62,7 @@ static GLboolean run_normal_stage( GLcontext *ctx,
ASSERT(store->NormalTransform);
if (stage->changed_inputs)
- store->NormalTransform( &ctx->ModelView,
+ store->NormalTransform( ctx->ModelviewMatrixStack.Top,
ctx->_ModelViewInvScale,
VB->NormalPtr,
VB->NormalLengthPtr,
@@ -84,7 +84,7 @@ static GLboolean run_validate_normal_stage( GLcontext *ctx,
if (ctx->_NeedEyeCoords) {
GLuint transform = NORM_TRANSFORM_NO_ROT;
- if (ctx->ModelView.flags & (MAT_FLAG_GENERAL |
+ if (ctx->ModelviewMatrixStack.Top->flags & (MAT_FLAG_GENERAL |
MAT_FLAG_ROTATION |
MAT_FLAG_GENERAL_3D |
MAT_FLAG_PERSPECTIVE))
diff --git a/src/mesa/tnl/t_vb_program.c b/src/mesa/tnl/t_vb_program.c
index b713031decb..aea3c868aca 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.4 2001/12/15 22:31:23 brianp Exp $ */
+/* $Id: t_vb_program.c,v 1.5 2001/12/18 04:06:46 brianp Exp $ */
/*
* Mesa 3-D graphics library
@@ -718,7 +718,6 @@ static GLboolean run_vp( GLcontext *ctx, struct gl_pipeline_stage *stage )
struct vp_stage_data *store = VP_STAGE_DATA(stage);
struct vertex_buffer *VB = &tnl->vb;
struct vp_machine *machine = &(ctx->VertexProgram.Machine);
- struct vp_program *program;
GLint i;
/* convenience pointers */
@@ -734,9 +733,6 @@ static GLboolean run_vp( GLcontext *ctx, struct gl_pipeline_stage *stage )
GLfloat (*texture2)[4] = (GLfloat (*)[4]) store->texCoord[2].data;
GLfloat (*texture3)[4] = (GLfloat (*)[4]) store->texCoord[3].data;
- program = (struct vp_program *) _mesa_HashLookup(ctx->VertexProgram.HashTable, ctx->VertexProgram.Binding);
- assert(program);
-
_mesa_init_tracked_matrices(ctx);
_mesa_init_vp_registers(ctx); /* sets temp regs to (0,0,0,1) */
@@ -770,7 +766,8 @@ static GLboolean run_vp( GLcontext *ctx, struct gl_pipeline_stage *stage )
}
/* execute the program */
- _mesa_exec_program(ctx, program);
+ ASSERT(ctx->VertexProgram.Current);
+ _mesa_exec_program(ctx, ctx->VertexProgram.Current);
#if 0
printf("Output %d: %f, %f, %f, %f\n", i,
@@ -819,8 +816,8 @@ static GLboolean run_vp( GLcontext *ctx, struct gl_pipeline_stage *stage )
store->ormask = 0;
store->andmask = CLIP_ALL_BITS;
- if (tnl->NeedProjCoords) {
- VB->ProjectedClipPtr =
+ if (tnl->NeedNdcCoords) {
+ VB->NdcPtr =
_mesa_clip_tab[VB->ClipPtr->size]( VB->ClipPtr,
&store->ndcCoords,
store->clipmask,
@@ -829,7 +826,7 @@ static GLboolean run_vp( GLcontext *ctx, struct gl_pipeline_stage *stage )
}
else {
- VB->ProjectedClipPtr = 0;
+ VB->NdcPtr = 0;
_mesa_clip_np_tab[VB->ClipPtr->size]( VB->ClipPtr,
0,
store->clipmask,
diff --git a/src/mesa/tnl/t_vb_texmat.c b/src/mesa/tnl/t_vb_texmat.c
index a0ed3e58990..8cff96a74aa 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.6 2001/12/14 02:51:45 brianp Exp $ */
+/* $Id: t_vb_texmat.c,v 1.7 2001/12/18 04:06:46 brianp Exp $ */
/*
* Mesa 3-D graphics library
@@ -86,7 +86,8 @@ static GLboolean run_texmat_stage( GLcontext *ctx,
for (i = 0 ; i < ctx->Const.MaxTextureUnits ; i++)
if (ctx->Texture._TexMatEnabled & ENABLE_TEXMAT(i)) {
if (stage->changed_inputs & VERT_TEX(i))
- (void) TransformRaw( &store->texcoord[i], &ctx->TextureMatrix[i],
+ (void) TransformRaw( &store->texcoord[i],
+ ctx->TextureMatrixStack[i].Top,
VB->TexCoordPtr[i]);
VB->TexCoordPtr[i] = &store->texcoord[i];
diff --git a/src/mesa/tnl/t_vb_vertex.c b/src/mesa/tnl/t_vb_vertex.c
index f54d73bd628..8ceb9dbdafd 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.10 2001/12/14 02:51:45 brianp Exp $ */
+/* $Id: t_vb_vertex.c,v 1.11 2001/12/18 04:06:46 brianp Exp $ */
/*
* Mesa 3-D graphics library
@@ -57,7 +57,7 @@ struct vertex_stage_data {
*/
GLvector4f *save_eyeptr;
GLvector4f *save_clipptr;
- GLvector4f *save_projptr;
+ GLvector4f *save_ndcptr;
};
#define VERTEX_STAGE_DATA(stage) ((struct vertex_stage_data *)stage->privatePtr)
@@ -142,16 +142,18 @@ static GLboolean run_vertex_stage( GLcontext *ctx,
if (ctx->_NeedEyeCoords) {
/* Separate modelview and project transformations:
*/
- if (ctx->ModelView.type == MATRIX_IDENTITY)
+ if (ctx->ModelviewMatrixStack.Top->type == MATRIX_IDENTITY)
VB->EyePtr = VB->ObjPtr;
else
- VB->EyePtr = TransformRaw( &store->eye, &ctx->ModelView,
+ VB->EyePtr = TransformRaw( &store->eye,
+ ctx->ModelviewMatrixStack.Top,
VB->ObjPtr);
- if (ctx->ProjectionMatrix.type == MATRIX_IDENTITY)
+ if (ctx->ProjectionMatrixStack.Top->type == MATRIX_IDENTITY)
VB->ClipPtr = VB->EyePtr;
else
- VB->ClipPtr = TransformRaw( &store->clip, &ctx->ProjectionMatrix,
+ VB->ClipPtr = TransformRaw( &store->clip,
+ ctx->ProjectionMatrixStack.Top,
VB->EyePtr );
}
else {
@@ -184,16 +186,17 @@ static GLboolean run_vertex_stage( GLcontext *ctx,
store->ormask = 0;
store->andmask = CLIP_ALL_BITS;
- if (tnl->NeedProjCoords) {
- VB->ProjectedClipPtr =
+ if (tnl->NeedNdcCoords) {
+ VB->NdcPtr =
_mesa_clip_tab[VB->ClipPtr->size]( VB->ClipPtr,
&store->proj,
store->clipmask,
&store->ormask,
&store->andmask );
- } else {
- VB->ProjectedClipPtr = 0;
+ }
+ else {
+ VB->NdcPtr = 0;
_mesa_clip_np_tab[VB->ClipPtr->size]( VB->ClipPtr,
0,
store->clipmask,
@@ -227,14 +230,14 @@ static GLboolean run_vertex_stage( GLcontext *ctx,
store->save_eyeptr = VB->EyePtr;
store->save_clipptr = VB->ClipPtr;
- store->save_projptr = VB->ProjectedClipPtr;
+ store->save_ndcptr = VB->NdcPtr;
}
else {
/* Replay the sideeffects.
*/
VB->EyePtr = store->save_eyeptr;
VB->ClipPtr = store->save_clipptr;
- VB->ProjectedClipPtr = store->save_projptr;
+ VB->NdcPtr = store->save_ndcptr;
VB->ClipMask = store->clipmask;
VB->ClipOrMask = store->ormask;
if (VB->ClipPtr == VB->ObjPtr && (VB->importable_data & VERT_OBJ_BIT))