diff options
author | Keith Whitwell <[email protected]> | 2001-01-13 05:48:25 +0000 |
---|---|---|
committer | Keith Whitwell <[email protected]> | 2001-01-13 05:48:25 +0000 |
commit | 321f67c4729adeebd7aa9ef9e22c95e709952851 (patch) | |
tree | 8661da8a994f3c554c4428afdd53642c0814854b /src/mesa/tnl | |
parent | a087c7421bef25747e1d692f62062393d849c501 (diff) |
Fix crash in book/stencil.
Allow drivers to perform the perspective divide themselves. Assembly
to do cliptesting without perspective divide for size-4 vectors.
Diffstat (limited to 'src/mesa/tnl')
-rw-r--r-- | src/mesa/tnl/t_context.c | 14 | ||||
-rw-r--r-- | src/mesa/tnl/t_context.h | 6 | ||||
-rw-r--r-- | src/mesa/tnl/t_imm_exec.c | 21 | ||||
-rw-r--r-- | src/mesa/tnl/t_vb_cliptmp.h | 45 | ||||
-rw-r--r-- | src/mesa/tnl/t_vb_vertex.c | 56 | ||||
-rw-r--r-- | src/mesa/tnl/tnl.h | 12 |
6 files changed, 89 insertions, 65 deletions
diff --git a/src/mesa/tnl/t_context.c b/src/mesa/tnl/t_context.c index 93886b71101..e0d254edf33 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.9 2001/01/08 21:56:00 keithw Exp $ */ +/* $Id: t_context.c,v 1.10 2001/01/13 05:48:25 keithw Exp $ */ /* * Mesa 3-D graphics library @@ -104,6 +104,8 @@ _tnl_CreateContext( GLcontext *ctx ) _tnl_eval_init( ctx ); _tnl_install_pipeline( ctx, _tnl_default_pipeline ); + + tnl->NeedProjCoords = GL_TRUE; /* Hook our functions into exec and compile dispatch tables. */ @@ -195,3 +197,13 @@ _tnl_wakeup_save_exec( GLcontext *ctx ) ctx->Save->Begin = _tnl_save_Begin; } + +void +_tnl_need_projected_coords( GLcontext *ctx, GLboolean mode ) +{ + TNLcontext *tnl = TNL_CONTEXT(ctx); + if (tnl->NeedProjCoords != mode) { + tnl->NeedProjCoords = mode; + _tnl_InvalidateState( ctx, _NEW_PROJECTION ); + } +} diff --git a/src/mesa/tnl/t_context.h b/src/mesa/tnl/t_context.h index 8e3952a4127..d49c8542418 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.9 2001/01/05 02:26:49 keithw Exp $ */ +/* $Id: t_context.h,v 1.10 2001/01/13 05:48:26 keithw Exp $ */ /* * Mesa 3-D graphics library @@ -412,6 +412,10 @@ typedef struct { GLuint DlistPrimitiveLength; GLuint DlistLastPrimitive; + /* Probably need a better configuration mechanism: + */ + GLboolean NeedProjCoords; + /* Derived state and storage for _tnl_eval_vb: */ struct tnl_eval_store eval; diff --git a/src/mesa/tnl/t_imm_exec.c b/src/mesa/tnl/t_imm_exec.c index e8904dfd1ec..6feff8464fd 100644 --- a/src/mesa/tnl/t_imm_exec.c +++ b/src/mesa/tnl/t_imm_exec.c @@ -1,4 +1,4 @@ -/* $Id: t_imm_exec.c,v 1.6 2001/01/08 21:56:00 keithw Exp $ */ +/* $Id: t_imm_exec.c,v 1.7 2001/01/13 05:48:26 keithw Exp $ */ /* * Mesa 3-D graphics library @@ -357,16 +357,21 @@ static void exec_elt_cassette( GLcontext *ctx, struct immediate *IM ) */ void _tnl_run_empty_cassette( GLcontext *ctx, struct immediate *IM ) { - GLuint start = IM->CopyStart; - copy_to_current( ctx, IM, IM->OrFlag ); - if (IM->OrFlag & VERT_MATERIAL) - gl_update_material( ctx, IM->Material[start], IM->MaterialMask[start] ); + if (IM->OrFlag & (VERT_RGBA|VERT_MATERIAL)) { + GLuint start = IM->CopyStart; - if (IM->OrFlag & VERT_RGBA) - if (ctx->Light.ColorMaterialEnabled) - gl_update_color_material( ctx, ctx->Current.Color ); + if (IM->OrFlag & VERT_MATERIAL) + gl_update_material( ctx, IM->Material[start], + IM->MaterialMask[start] ); + + if (IM->OrFlag & VERT_RGBA) + if (ctx->Light.ColorMaterialEnabled) + gl_update_color_material( ctx, ctx->Current.Color ); + + gl_validate_all_lighting_tables( ctx ); + } } diff --git a/src/mesa/tnl/t_vb_cliptmp.h b/src/mesa/tnl/t_vb_cliptmp.h index 5957f4960cc..56f2031c90e 100644 --- a/src/mesa/tnl/t_vb_cliptmp.h +++ b/src/mesa/tnl/t_vb_cliptmp.h @@ -1,4 +1,4 @@ -/* $Id: t_vb_cliptmp.h,v 1.5 2001/01/05 02:26:49 keithw Exp $ */ +/* $Id: t_vb_cliptmp.h,v 1.6 2001/01/13 05:48:26 keithw Exp $ */ /* * Mesa 3-D graphics library @@ -115,29 +115,32 @@ do { \ } while (0) -/* Project if necessary. - */ static void TAG(build_proj_verts)( GLcontext *ctx ) { struct vertex_buffer *VB = &TNL_CONTEXT(ctx)->vb; - GLfloat (*coord)[4] = VB->ClipPtr->data; - GLfloat (*proj)[4] = VB->ProjectedClipPtr->data; - GLuint last = VB->LastClipped; - GLuint i; - - for (i = VB->FirstClipped; i < last; i++) { - if (VB->ClipMask[i] == 0) { - if (SIZE == 4 && W(i) != 0.0F) { - GLfloat wInv = 1.0F / W(i); - proj[i][0] = X(i) * wInv; - proj[i][1] = Y(i) * wInv; - proj[i][2] = Z(i) * wInv; - proj[i][3] = wInv; - } else { - proj[i][0] = X(i); - proj[i][1] = Y(i); - proj[i][2] = Z(i); - proj[i][3] = W(i); + + /* Project if necessary. + */ + if (VB->ProjectedClipPtr) { + GLfloat (*coord)[4] = VB->ClipPtr->data; + GLfloat (*proj)[4] = VB->ProjectedClipPtr->data; + GLuint last = VB->LastClipped; + GLuint i; + + for (i = VB->FirstClipped; i < last; i++) { + if (VB->ClipMask[i] == 0) { + if (SIZE == 4 && W(i) != 0.0F) { + GLfloat wInv = 1.0F / W(i); + proj[i][0] = X(i) * wInv; + proj[i][1] = Y(i) * wInv; + proj[i][2] = Z(i) * wInv; + proj[i][3] = wInv; + } else { + proj[i][0] = X(i); + proj[i][1] = Y(i); + proj[i][2] = Z(i); + proj[i][3] = W(i); + } } } } diff --git a/src/mesa/tnl/t_vb_vertex.c b/src/mesa/tnl/t_vb_vertex.c index 7667d423a8b..0c163ee4f31 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.1 2000/12/26 05:09:33 keithw Exp $ */ +/* $Id: t_vb_vertex.c,v 1.2 2001/01/13 05:48:26 keithw Exp $ */ /* * Mesa 3-D graphics library @@ -134,7 +134,8 @@ static GLboolean run_vertex_stage( GLcontext *ctx, struct gl_pipeline_stage *stage ) { struct vertex_stage_data *store = (struct vertex_stage_data *)stage->private; - struct vertex_buffer *VB = &TNL_CONTEXT(ctx)->vb; + TNLcontext *tnl = TNL_CONTEXT(ctx); + struct vertex_buffer *VB = &tnl->vb; if (stage->changed_inputs) { @@ -172,12 +173,36 @@ static GLboolean run_vertex_stage( GLcontext *ctx, store->ormask = 0; store->andmask = CLIP_ALL_BITS; - VB->ProjectedClipPtr = - gl_clip_tab[VB->ClipPtr->size]( VB->ClipPtr, - &store->proj, - store->clipmask, - &store->ormask, - &store->andmask ); + if (tnl->NeedProjCoords) { + VB->ProjectedClipPtr = + gl_clip_tab[VB->ClipPtr->size]( VB->ClipPtr, + &store->proj, + store->clipmask, + &store->ormask, + &store->andmask ); + + /* Drivers expect this to be size 4... + */ + if (VB->ProjectedClipPtr->size < 4) { + ASSERT(VB->ProjectedClipPtr == VB->ClipPtr); + if (VB->ProjectedClipPtr->flags & VEC_NOT_WRITEABLE) { + ASSERT(VB->ProjectedClipPtr == VB->ObjPtr); + VB->import_data( ctx, VERT_OBJ, VEC_NOT_WRITEABLE ); + VB->ProjectedClipPtr = VB->ClipPtr = VB->ObjPtr; + } + if (VB->ClipPtr->size == 2) + gl_vector4f_clean_elem( VB->ClipPtr, VB->Count, 2 ); + gl_vector4f_clean_elem( VB->ClipPtr, VB->Count, 3 ); + VB->ClipPtr->size = 4; + } + } else { + VB->ProjectedClipPtr = 0; + gl_clip_np_tab[VB->ClipPtr->size]( VB->ClipPtr, + 0, + store->clipmask, + &store->ormask, + &store->andmask ); + } if (store->andmask) return GL_FALSE; @@ -203,21 +228,6 @@ static GLboolean run_vertex_stage( GLcontext *ctx, if (VB->ClipPtr == VB->ObjPtr && (VB->importable_data & VERT_OBJ)) VB->importable_data |= VERT_CLIP; - /* Drivers expect this to be size 4... - */ - if (VB->ProjectedClipPtr->size < 4) { - ASSERT(VB->ProjectedClipPtr == VB->ClipPtr); - if (VB->ProjectedClipPtr->flags & VEC_NOT_WRITEABLE) { - ASSERT(VB->ProjectedClipPtr == VB->ObjPtr); - VB->import_data( ctx, VERT_OBJ, VEC_NOT_WRITEABLE ); - VB->ProjectedClipPtr = VB->ClipPtr = VB->ObjPtr; - } - if (VB->ClipPtr->size == 2) - gl_vector4f_clean_elem( VB->ClipPtr, VB->Count, 2 ); - gl_vector4f_clean_elem( VB->ClipPtr, VB->Count, 3 ); - VB->ClipPtr->size = 4; - } - store->save_eyeptr = VB->EyePtr; store->save_clipptr = VB->ClipPtr; store->save_projptr = VB->ProjectedClipPtr; diff --git a/src/mesa/tnl/tnl.h b/src/mesa/tnl/tnl.h index f95ce0e5037..eb8e9054a9c 100644 --- a/src/mesa/tnl/tnl.h +++ b/src/mesa/tnl/tnl.h @@ -59,17 +59,7 @@ _tnl_wakeup_exec( GLcontext *ctx ); extern void _tnl_wakeup_save_exec( GLcontext *ctx ); - -/* Functions to assist driver t&l modules which have to fallback to - * this module in the middle of a begin/end pair. Use this instead of - * glBegin() to identify the primitive as wrapped: - * - * Even with this it's difficult to see how the drivers are going to - * replay any glMaterial commands received in the few vertices before - * the fallback. - */ extern void -_tnl_fallback_begin( GLcontext *ctx, GLenum mode ); - +_tnl_need_projected_coords( GLcontext *ctx, GLboolean flag ); #endif |