From 0cb28418d06c30e431bdff515c1d36a812d5950d Mon Sep 17 00:00:00 2001 From: Keith Whitwell Date: Wed, 13 Feb 2002 00:53:19 +0000 Subject: More suport for t&l drivers Fix GLuint compare bugs Fix RESET_STIPPLE calls --- src/mesa/tnl/t_context.c | 20 +++++++++++++------- src/mesa/tnl/t_context.h | 9 ++++++++- src/mesa/tnl/t_imm_api.c | 19 ++++++++++++++++++- src/mesa/tnl/t_imm_dlist.c | 3 ++- src/mesa/tnl/t_imm_exec.c | 10 +++++----- src/mesa/tnl/t_imm_fixup.c | 21 +++++++++++++-------- src/mesa/tnl/t_vb_light.c | 4 ++-- src/mesa/tnl/t_vb_lighttmp.h | 12 ++++++------ src/mesa/tnl/t_vb_render.c | 6 +++--- src/mesa/tnl/t_vb_rendertmp.h | 39 +++++++++++++++++++++++---------------- src/mesa/tnl/tnl.h | 5 ++++- 11 files changed, 97 insertions(+), 51 deletions(-) (limited to 'src/mesa/tnl') diff --git a/src/mesa/tnl/t_context.c b/src/mesa/tnl/t_context.c index ae1d7f5361..2cea4b1dcd 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.23 2001/12/18 04:06:46 brianp Exp $ */ +/* $Id: t_context.c,v 1.24 2002/02/13 00:53:20 keithw Exp $ */ /* * Mesa 3-D graphics library @@ -33,6 +33,7 @@ #include "mtypes.h" #include "mem.h" #include "dlist.h" +#include "light.h" #include "vtxfmt.h" #include "t_context.h" @@ -125,6 +126,8 @@ _tnl_CreateContext( GLcontext *ctx ) tnl->Driver.Render.PrimTabElts = _tnl_render_tab_elts; tnl->Driver.Render.PrimTabVerts = _tnl_render_tab_verts; + tnl->Driver.NotifyMaterialChange = _mesa_validate_all_lighting_tables; + return GL_TRUE; @@ -220,16 +223,19 @@ void _tnl_need_dlist_loopback( GLcontext *ctx, GLboolean mode ) { TNLcontext *tnl = TNL_CONTEXT(ctx); - if (tnl->LoopbackDListCassettes != mode) { - tnl->LoopbackDListCassettes = mode; - } + tnl->LoopbackDListCassettes = mode; } void _tnl_need_dlist_norm_lengths( GLcontext *ctx, GLboolean mode ) { TNLcontext *tnl = TNL_CONTEXT(ctx); - if (tnl->CalcDListNormalLengths != mode) { - tnl->CalcDListNormalLengths = mode; - } + tnl->CalcDListNormalLengths = mode; +} + +void +_tnl_isolate_materials( GLcontext *ctx, GLboolean mode ) +{ + TNLcontext *tnl = TNL_CONTEXT(ctx); + tnl->IsolateMaterials = mode; } diff --git a/src/mesa/tnl/t_context.h b/src/mesa/tnl/t_context.h index db0bd7a474..98ff545604 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.37 2002/01/22 14:35:16 brianp Exp $ */ +/* $Id: t_context.h,v 1.38 2002/02/13 00:53:20 keithw Exp $ */ /* * Mesa 3-D graphics library @@ -386,6 +386,12 @@ struct tnl_device_driver { * and grab/release hardware locks. */ + void (*NotifyMaterialChange)(GLcontext *ctx); + /* Alert tnl-aware drivers of changes to material, especially in + * exec_empty_cassette, which doesn't otherwise reach the driver. + * --> Need to be able to disable exec_empty_cassette??? + */ + /*** *** Rendering -- These functions called only from t_vb_render.c ***/ @@ -524,6 +530,7 @@ typedef struct { GLboolean NeedNdcCoords; GLboolean LoopbackDListCassettes; GLboolean CalcDListNormalLengths; + GLboolean IsolateMaterials; /* Derived state and storage for _tnl_eval_vb: */ diff --git a/src/mesa/tnl/t_imm_api.c b/src/mesa/tnl/t_imm_api.c index dd90dbe540..d19f6a6e00 100644 --- a/src/mesa/tnl/t_imm_api.c +++ b/src/mesa/tnl/t_imm_api.c @@ -1,4 +1,4 @@ -/* $Id: t_imm_api.c,v 1.24 2002/01/22 14:35:16 brianp Exp $ */ +/* $Id: t_imm_api.c,v 1.25 2002/02/13 00:53:20 keithw Exp $ */ /* * Mesa 3-D graphics library @@ -553,6 +553,8 @@ static void _tnl_Normal3fv( const GLfloat *v ) { NORMALF( v[0], v[1], v[2] ); +/* struct immediate *IM = (struct immediate *)(((GLcontext *) _glapi_Context)->swtnl_im); */ +/* IM->Flag[IM->Count] = VERT_NORM; */ } @@ -1154,6 +1156,7 @@ static void _tnl_Materialfv( GLenum face, GLenum pname, const GLfloat *params ) { GET_CURRENT_CONTEXT(ctx); + TNLcontext *tnl = TNL_CONTEXT(ctx); struct immediate *IM = TNL_CURRENT_IM(ctx); GLuint count = IM->Count; struct gl_material *mat; @@ -1162,6 +1165,14 @@ _tnl_Materialfv( GLenum face, GLenum pname, const GLfloat *params ) if (bitmask == 0) return; + if (tnl->IsolateMaterials && + !(IM->BeginState & VERT_BEGIN_1)) /* heuristic */ + { + _tnl_flush_immediate( IM ); + IM = TNL_CURRENT_IM(ctx); + count = IM->Count; + } + if (!(IM->Flag[count] & VERT_BIT_MATERIAL)) { if (!IM->Material) { IM->Material = (struct gl_material (*)[2]) @@ -1227,6 +1238,12 @@ _tnl_Materialfv( GLenum face, GLenum pname, const GLfloat *params ) mat[1].DiffuseIndex = params[1]; mat[1].SpecularIndex = params[2]; } + + if (tnl->IsolateMaterials && + !(IM->BeginState & VERT_BEGIN_1)) /* heuristic */ + { + _tnl_flush_immediate( IM ); + } } void _tnl_imm_vtxfmt_init( GLcontext *ctx ) diff --git a/src/mesa/tnl/t_imm_dlist.c b/src/mesa/tnl/t_imm_dlist.c index 125dbc5ed6..dfc4e7795d 100644 --- a/src/mesa/tnl/t_imm_dlist.c +++ b/src/mesa/tnl/t_imm_dlist.c @@ -1,4 +1,4 @@ -/* $Id: t_imm_dlist.c,v 1.37 2002/01/22 14:35:16 brianp Exp $ */ +/* $Id: t_imm_dlist.c,v 1.38 2002/02/13 00:53:20 keithw Exp $ */ /* * Mesa 3-D graphics library @@ -339,6 +339,7 @@ execute_compiled_cassette( GLcontext *ctx, void *data ) } if (tnl->LoopbackDListCassettes) { +/* (tnl->IsolateMaterials && (IM->OrFlag & VERT_MATERIAL)) ) { */ fixup_compiled_primitives( ctx, IM ); loopback_compiled_cassette( ctx, IM ); restore_compiled_primitives( ctx, IM ); diff --git a/src/mesa/tnl/t_imm_exec.c b/src/mesa/tnl/t_imm_exec.c index 056df78d0a..bc35480acc 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.35 2002/01/22 14:35:16 brianp Exp $ */ +/* $Id: t_imm_exec.c,v 1.36 2002/02/13 00:53:20 keithw Exp $ */ /* * Mesa 3-D graphics library @@ -149,7 +149,7 @@ void _tnl_copy_to_current( GLcontext *ctx, struct immediate *IM, if (ctx->Light.ColorMaterialEnabled) { _mesa_update_color_material( ctx, ctx->Current.Attrib[VERT_ATTRIB_COLOR0] ); - _mesa_validate_all_lighting_tables( ctx ); + TNL_CONTEXT(ctx)->Driver.NotifyMaterialChange( ctx ); } } @@ -175,7 +175,7 @@ void _tnl_copy_to_current( GLcontext *ctx, struct immediate *IM, IM->Material[IM->LastMaterial], IM->MaterialOrMask ); - _mesa_validate_all_lighting_tables( ctx ); + TNL_CONTEXT(ctx)->Driver.NotifyMaterialChange( ctx ); } } @@ -356,7 +356,7 @@ static void _tnl_vb_bind_immediate( GLcontext *ctx, struct immediate *IM ) } } - if ((inputs & VERT_BIT_MATERIAL) && IM->Material) { + if ((inputs & IM->OrFlag & VERT_BIT_MATERIAL) && IM->Material) { VB->MaterialMask = IM->MaterialMask + start; VB->Material = IM->Material + start; } @@ -482,7 +482,7 @@ void _tnl_execute_cassette( GLcontext *ctx, struct immediate *IM ) if (tnl->pipeline.build_state_changes) _tnl_validate_pipeline( ctx ); - if (IM->CopyStart == IM->Count) { + if (0 && IM->CopyStart == IM->Count) { exec_empty_cassette( ctx, IM ); } else if ((IM->CopyOrFlag & VERT_BITS_DATA) == VERT_BIT_ELT && diff --git a/src/mesa/tnl/t_imm_fixup.c b/src/mesa/tnl/t_imm_fixup.c index d08c162efe..8e3f52e621 100644 --- a/src/mesa/tnl/t_imm_fixup.c +++ b/src/mesa/tnl/t_imm_fixup.c @@ -1,4 +1,4 @@ -/* $Id: t_imm_fixup.c,v 1.33 2002/01/22 14:35:16 brianp Exp $ */ +/* $Id: t_imm_fixup.c,v 1.34 2002/02/13 00:53:20 keithw Exp $ */ /* * Mesa 3-D graphics library @@ -396,6 +396,8 @@ copy_material( struct immediate *next, struct immediate *prev, GLuint dst, GLuint src ) { +/* fprintf(stderr, "%s\n", __FUNCTION__); */ + if (next->Material == 0) { next->Material = (struct gl_material (*)[2]) MALLOC( sizeof(struct gl_material) * IMM_SIZE * 2 ); @@ -461,6 +463,7 @@ void _tnl_copy_immediate_vertices( GLcontext *ctx, struct immediate *next ) GLuint dst = next->CopyStart+i; next->Elt[dst] = prev->Elt[src]; next->Flag[dst] = VERT_BIT_ELT; + elts[i+offset] = dst; } /* fprintf(stderr, "ADDING VERT_BIT_ELT!\n"); */ next->CopyOrFlag |= VERT_BIT_ELT; @@ -551,14 +554,14 @@ void _tnl_copy_immediate_vertices( GLcontext *ctx, struct immediate *next ) next->CopyOrFlag |= prev->Flag[src] & (VERT_BITS_FIXUP| VERT_BIT_MATERIAL| VERT_BIT_POS); + elts[i+offset] = dst; } } - if (--tnl->ExecCopySource->ref_count == 0) + if (--tnl->ExecCopySource->ref_count == 0) _tnl_free_immediate( tnl->ExecCopySource ); - - tnl->ExecCopySource = 0; - tnl->ExecCopyCount = 0; + + tnl->ExecCopySource = next; next->ref_count++; } @@ -766,17 +769,19 @@ _tnl_get_exec_copy_verts( GLcontext *ctx, struct immediate *IM ) /* fprintf(stderr, "_tnl_get_exec_copy_verts %s\n", */ /* _mesa_lookup_enum_by_nr(prim)); */ - ASSERT(tnl->ExecCopySource == 0); + if (tnl->ExecCopySource) + if (--tnl->ExecCopySource->ref_count == 0) + _tnl_free_immediate( tnl->ExecCopySource ); if (prim == GL_POLYGON+1) { + tnl->ExecCopySource = 0; tnl->ExecCopyCount = 0; tnl->ExecCopyTexSize = 0; tnl->ExecParity = 0; } else { /* Remember this immediate as the one to copy from. */ - IM->ref_count++; - tnl->ExecCopySource = IM; + tnl->ExecCopySource = IM; IM->ref_count++; tnl->ExecCopyCount = 0; tnl->ExecCopyTexSize = IM->CopyTexSize; diff --git a/src/mesa/tnl/t_vb_light.c b/src/mesa/tnl/t_vb_light.c index 32444ee3aa..99f15d8036 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.17 2002/01/22 14:35:17 brianp Exp $ */ +/* $Id: t_vb_light.c,v 1.18 2002/02/13 00:53:20 keithw Exp $ */ /* * Mesa 3-D graphics library @@ -232,7 +232,7 @@ static GLboolean run_validate_lighting( GLcontext *ctx, /* This and the above should only be done on _NEW_LIGHT: */ - _mesa_validate_all_lighting_tables( ctx ); + TNL_CONTEXT(ctx)->Driver.NotifyMaterialChange( ctx ); /* Now run the stage... */ diff --git a/src/mesa/tnl/t_vb_lighttmp.h b/src/mesa/tnl/t_vb_lighttmp.h index ef25cd69bc..aac8890180 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.24 2002/01/22 14:35:17 brianp Exp $ */ +/* $Id: t_vb_lighttmp.h,v 1.25 2002/02/13 00:53:20 keithw Exp $ */ /* * Mesa 3-D graphics library @@ -163,7 +163,7 @@ static void TAG(light_rgba_spec)( GLcontext *ctx, _mesa_update_material( ctx, new_material[j], new_material_mask[j] ); if ( CHECK_VALIDATE(j) ) { - _mesa_validate_all_lighting_tables( ctx ); + TNL_CONTEXT(ctx)->Driver.NotifyMaterialChange( ctx ); UNCLAMPED_FLOAT_TO_CHAN(sumA[0], ctx->Light.Material[0].Diffuse[3]); if (IDX & LIGHT_TWOSIDE) UNCLAMPED_FLOAT_TO_CHAN(sumA[1], ctx->Light.Material[1].Diffuse[3]); @@ -375,7 +375,7 @@ static void TAG(light_rgba)( GLcontext *ctx, _mesa_update_material( ctx, new_material[j], new_material_mask[j] ); if ( CHECK_VALIDATE(j) ) { - _mesa_validate_all_lighting_tables( ctx ); + TNL_CONTEXT(ctx)->Driver.NotifyMaterialChange( ctx ); UNCLAMPED_FLOAT_TO_CHAN(sumA[0], ctx->Light.Material[0].Diffuse[3]); if (IDX & LIGHT_TWOSIDE) UNCLAMPED_FLOAT_TO_CHAN(sumA[1], ctx->Light.Material[1].Diffuse[3]); @@ -576,7 +576,7 @@ static void TAG(light_fast_rgba_single)( GLcontext *ctx, _mesa_update_material( ctx, new_material[j], new_material_mask[j] ); if ( CHECK_VALIDATE(j) ) - _mesa_validate_all_lighting_tables( ctx ); + TNL_CONTEXT(ctx)->Driver.NotifyMaterialChange( ctx ); /* No attenuation, so incoporate _MatAmbient into base color. @@ -708,7 +708,7 @@ static void TAG(light_fast_rgba)( GLcontext *ctx, _mesa_update_material( ctx, new_material[j], new_material_mask[j] ); if ( CHECK_VALIDATE(j) ) { - _mesa_validate_all_lighting_tables( ctx ); + TNL_CONTEXT(ctx)->Driver.NotifyMaterialChange( ctx ); UNCLAMPED_FLOAT_TO_CHAN(sumA[0], ctx->Light.Material[0].Diffuse[3]); if (IDX & LIGHT_TWOSIDE) UNCLAMPED_FLOAT_TO_CHAN(sumA[1], @@ -853,7 +853,7 @@ static void TAG(light_ci)( GLcontext *ctx, _mesa_update_material( ctx, new_material[j], new_material_mask[j] ); if ( CHECK_VALIDATE(j) ) - _mesa_validate_all_lighting_tables( ctx ); + TNL_CONTEXT(ctx)->Driver.NotifyMaterialChange( ctx ); diffuse[0] = specular[0] = 0.0F; diff --git a/src/mesa/tnl/t_vb_render.c b/src/mesa/tnl/t_vb_render.c index 5ccec25cb2..1721b88323 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.27 2002/01/22 14:35:17 brianp Exp $ */ +/* $Id: t_vb_render.c,v 1.28 2002/02/13 00:53:20 keithw Exp $ */ /* * Mesa 3-D graphics library @@ -142,7 +142,7 @@ do { \ #define TAG(x) clip_##x##_verts #define INIT(x) tnl->Driver.Render.PrimitiveNotify( ctx, x ) -#define RESET_STIPPLE tnl->Driver.Render.ResetLineStipple( ctx ) +#define RESET_STIPPLE if (stipple) tnl->Driver.Render.ResetLineStipple( ctx ) #define RESET_OCCLUSION ctx->OcclusionResult = GL_TRUE #define PRESERVE_VB_DEFS #include "t_vb_rendertmp.h" @@ -229,7 +229,7 @@ static void clip_elt_triangles( GLcontext *ctx, (void) (LineFunc && TriangleFunc && QuadFunc); \ (void) elt; (void) stipple -#define RESET_STIPPLE tnl->Driver.Render.ResetLineStipple( ctx ) +#define RESET_STIPPLE if (stipple) tnl->Driver.Render.ResetLineStipple( ctx ) #define RESET_OCCLUSION ctx->OcclusionResult = GL_TRUE #define INIT(x) tnl->Driver.Render.PrimitiveNotify( ctx, x ) #define RENDER_TAB_QUALIFIER diff --git a/src/mesa/tnl/t_vb_rendertmp.h b/src/mesa/tnl/t_vb_rendertmp.h index 7e9f6842c7..16528db6ad 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.8 2001/03/12 00:48:44 gareth Exp $ */ +/* $Id: t_vb_rendertmp.h,v 1.9 2002/02/13 00:53:20 keithw Exp $ */ /* * Mesa 3-D graphics library @@ -90,8 +90,8 @@ static void TAG(render_lines)( GLcontext *ctx, RESET_OCCLUSION; INIT(GL_LINES); for (j=start+1; j