From 88f3b89a2cb77766d2009b9868c44e03abe2dbb2 Mon Sep 17 00:00:00 2001 From: Keith Whitwell Date: Thu, 28 Dec 2000 22:11:04 +0000 Subject: Add render stage for unclipped vb's to fx driver. Bump MAX_TEXTURE_UNITS to 8 Fix mem. leak in destroy_lists Fix crash in q3 (cva generally) --- src/mesa/tnl/t_array_import.c | 36 ++++++++++++++++++----------- src/mesa/tnl/t_imm_alloc.c | 14 ++++++++---- src/mesa/tnl/t_imm_dlist.c | 53 +++++++++++++++++++++++++++++++++---------- src/mesa/tnl/t_imm_exec.c | 6 ++++- src/mesa/tnl/t_imm_fixup.c | 12 +++++++++- src/mesa/tnl/t_vb_cliptmp.h | 4 ++-- src/mesa/tnl/t_vb_render.c | 6 +++-- src/mesa/tnl/t_vb_rendertmp.h | 22 +++++++++++++++--- 8 files changed, 114 insertions(+), 39 deletions(-) (limited to 'src/mesa/tnl') diff --git a/src/mesa/tnl/t_array_import.c b/src/mesa/tnl/t_array_import.c index 1cfed06764..fc2c3d1944 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.2 2000/12/27 19:57:37 keithw Exp $ */ +/* $Id: t_array_import.c,v 1.3 2000/12/28 22:11:05 keithw Exp $ */ /* * Mesa 3-D graphics library @@ -62,7 +62,7 @@ static void _tnl_import_vertex( GLcontext *ctx, inputs->Obj.stride = tmp->StrideB; inputs->Obj.size = tmp->Size; inputs->Obj.flags &= ~(VEC_BAD_STRIDE|VEC_NOT_WRITEABLE); - if (stride != 4*sizeof(GLfloat)) + if (inputs->Obj.stride != 4*sizeof(GLfloat)) inputs->Obj.flags |= VEC_BAD_STRIDE; if (!is_writeable) inputs->Obj.flags |= VEC_NOT_WRITEABLE; @@ -84,7 +84,7 @@ static void _tnl_import_normal( GLcontext *ctx, inputs->Normal.start = (GLfloat *)tmp->Ptr; inputs->Normal.stride = tmp->StrideB; inputs->Normal.flags &= ~(VEC_BAD_STRIDE|VEC_NOT_WRITEABLE); - if (stride != 3*sizeof(GLfloat)) + if (inputs->Normal.stride != 3*sizeof(GLfloat)) inputs->Normal.flags |= VEC_BAD_STRIDE; if (!is_writeable) inputs->Normal.flags |= VEC_NOT_WRITEABLE; @@ -110,7 +110,7 @@ static void _tnl_import_color( GLcontext *ctx, inputs->Color.start = (GLubyte *)tmp->Ptr; inputs->Color.stride = tmp->StrideB; inputs->Color.flags &= ~(VEC_BAD_STRIDE|VEC_NOT_WRITEABLE); - if (stride != 4*sizeof(GLubyte)) + if (inputs->Color.stride != 4*sizeof(GLubyte)) inputs->Color.flags |= VEC_BAD_STRIDE; if (!is_writeable) inputs->Color.flags |= VEC_NOT_WRITEABLE; @@ -135,7 +135,7 @@ static void _tnl_import_secondarycolor( GLcontext *ctx, inputs->SecondaryColor.start = (GLubyte *)tmp->Ptr; inputs->SecondaryColor.stride = tmp->StrideB; inputs->SecondaryColor.flags &= ~(VEC_BAD_STRIDE|VEC_NOT_WRITEABLE); - if (stride != 4*sizeof(GLubyte)) + if (inputs->SecondaryColor.stride != 4*sizeof(GLubyte)) inputs->SecondaryColor.flags |= VEC_BAD_STRIDE; if (!is_writeable) inputs->SecondaryColor.flags |= VEC_NOT_WRITEABLE; @@ -157,7 +157,7 @@ static void _tnl_import_fogcoord( GLcontext *ctx, inputs->FogCoord.start = (GLfloat *)tmp->Ptr; inputs->FogCoord.stride = tmp->StrideB; inputs->FogCoord.flags &= ~(VEC_BAD_STRIDE|VEC_NOT_WRITEABLE); - if (stride != sizeof(GLfloat)) + if (inputs->FogCoord.stride != sizeof(GLfloat)) inputs->FogCoord.flags |= VEC_BAD_STRIDE; if (!is_writeable) inputs->FogCoord.flags |= VEC_NOT_WRITEABLE; @@ -179,7 +179,7 @@ static void _tnl_import_index( GLcontext *ctx, inputs->Index.start = (GLuint *)tmp->Ptr; inputs->Index.stride = tmp->StrideB; inputs->Index.flags &= ~(VEC_BAD_STRIDE|VEC_NOT_WRITEABLE); - if (stride != sizeof(GLuint)) + if (inputs->Index.stride != sizeof(GLuint)) inputs->Index.flags |= VEC_BAD_STRIDE; if (!is_writeable) inputs->Index.flags |= VEC_NOT_WRITEABLE; @@ -195,6 +195,9 @@ static void _tnl_import_texcoord( GLcontext *ctx, struct gl_client_array *tmp; GLboolean is_writeable = 0; +/* fprintf(stderr, "%s %d before wr %d ptr %p\n", __FUNCTION__, i, writeable, */ +/* inputs->TexCoord[i].data); */ + tmp = _ac_import_texcoord(ctx, i, GL_FLOAT, stride ? 4*sizeof(GLfloat) : 0, 0, @@ -206,10 +209,13 @@ static void _tnl_import_texcoord( GLcontext *ctx, inputs->TexCoord[i].stride = tmp->StrideB; inputs->TexCoord[i].size = tmp->Size; inputs->TexCoord[i].flags &= ~(VEC_BAD_STRIDE|VEC_NOT_WRITEABLE); - if (stride != 4*sizeof(GLfloat)) + if (inputs->TexCoord[i].stride != 4*sizeof(GLfloat)) inputs->TexCoord[i].flags |= VEC_BAD_STRIDE; if (!is_writeable) inputs->TexCoord[i].flags |= VEC_NOT_WRITEABLE; + +/* fprintf(stderr, "%s %d before wr %d ptr %p\n", __FUNCTION__, i, is_writeable, */ +/* inputs->TexCoord[i].data); */ } @@ -230,7 +236,7 @@ static void _tnl_import_edgeflag( GLcontext *ctx, inputs->EdgeFlag.start = (GLubyte *)tmp->Ptr; inputs->EdgeFlag.stride = tmp->StrideB; inputs->EdgeFlag.flags &= ~(VEC_BAD_STRIDE|VEC_NOT_WRITEABLE); - if (stride != sizeof(GLubyte)) + if (inputs->EdgeFlag.stride != sizeof(GLubyte)) inputs->EdgeFlag.flags |= VEC_BAD_STRIDE; if (!is_writeable) inputs->EdgeFlag.flags |= VEC_NOT_WRITEABLE; @@ -256,6 +262,8 @@ static void _tnl_upgrade_client_data( GLcontext *ctx, if ((required & VERT_CLIP) && VB->ClipPtr == VB->ObjPtr) required |= VERT_OBJ; +/* _tnl_print_vert_flags("_tnl_upgrade_client_data", required); */ + if ((required & VERT_OBJ) && (VB->ObjPtr->flags & flags)) { ASSERT(VB->ObjPtr == &inputs->Obj); _tnl_import_vertex( ctx, writeable, stride ); @@ -330,9 +338,9 @@ void _tnl_vb_bind_arrays( GLcontext *ctx, GLint start, GLsizei count ) VB->Material = 0; VB->Flag = 0; -/* _tnl_print_vert_flags("_tnl_print_vert_flags: inputs", inputs); */ -/* _tnl_print_vert_flags("_tnl_print_vert_flags: imports", imports); */ -/* _tnl_print_vert_flags("_tnl_print_vert_flags: _Enabled", ctx->Array._Enabled); */ +/* _tnl_print_vert_flags("_tnl_vb_bind_arrays: inputs", inputs); */ +/* _tnl_print_vert_flags("_tnl_vb_bind_arrays: imports", imports); */ +/* _tnl_print_vert_flags("_tnl_vb_bind_arrays: _Enabled", ctx->Array._Enabled); */ if (inputs & VERT_OBJ) { if (imports & VERT_OBJ) { @@ -409,7 +417,9 @@ void _tnl_vb_bind_arrays( GLcontext *ctx, GLint start, GLsizei count ) VB->Primitive = tnl->tmp_primitive; VB->PrimitiveLength = tnl->tmp_primitive_length; VB->import_data = _tnl_upgrade_client_data; - VB->importable_data = imports; + VB->importable_data = imports & VERT_FIXUP; +/* _tnl_print_vert_flags("_tnl_vb_bind_arrays: importable", VB->importable_data); */ + } diff --git a/src/mesa/tnl/t_imm_alloc.c b/src/mesa/tnl/t_imm_alloc.c index 44e3a598ec..e6a37f8101 100644 --- a/src/mesa/tnl/t_imm_alloc.c +++ b/src/mesa/tnl/t_imm_alloc.c @@ -1,4 +1,4 @@ -/* $Id: t_imm_alloc.c,v 1.1 2000/12/26 05:09:32 keithw Exp $ */ +/* $Id: t_imm_alloc.c,v 1.2 2000/12/28 22:11:05 keithw Exp $ */ /* * Mesa 3-D graphics library @@ -34,10 +34,10 @@ #include "t_imm_alloc.h" + static int id = 0; struct immediate *_tnl_alloc_immediate( GLcontext *ctx ) { - static int id = 0; struct immediate *IM = ALIGN_MALLOC_STRUCT( immediate, 32 ); GLuint j; @@ -80,6 +80,7 @@ struct immediate *_tnl_alloc_immediate( GLcontext *ctx ) void _tnl_free_immediate( struct immediate *IM ) { + static int freed = 0; GLuint j; if (IM->NormalLengths) { @@ -92,12 +93,15 @@ void _tnl_free_immediate( struct immediate *IM ) FREE( IM->MaterialMask ); IM->Material = 0; IM->MaterialMask = 0; - - for (j = 1; j < IM->MaxTextureUnits; j++) - ALIGN_FREE( IM->TexCoord[j] ); } + for (j = 1; j < IM->MaxTextureUnits; j++) + ALIGN_FREE( IM->TexCoord[j] ); + + ALIGN_FREE( IM ); + freed++; +/* printf("outstanding %d\n", id - freed); */ } diff --git a/src/mesa/tnl/t_imm_dlist.c b/src/mesa/tnl/t_imm_dlist.c index a11217e437..e22661e7ea 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.3 2000/12/27 21:49:40 keithw Exp $ */ +/* $Id: t_imm_dlist.c,v 1.4 2000/12/28 22:11:05 keithw Exp $ */ /* * Mesa 3-D graphics library @@ -112,6 +112,8 @@ _tnl_compile_cassette( GLcontext *ctx, struct immediate *IM ) return; node->IM = im; im->ref_count++; +/* fprintf(stderr, "%s id %d refcount %d\n", __FUNCTION__, */ +/* im->id, im->ref_count); */ node->Start = im->Start; node->Count = im->Count; node->BeginState = im->BeginState; @@ -142,6 +144,10 @@ _tnl_compile_cassette( GLcontext *ctx, struct immediate *IM ) if (!new_im) return; new_im->ref_count++; im->ref_count--; /* remove CURRENT_IM reference */ +/* fprintf(stderr, "%s id %d refcount %d\n", __FUNCTION__, */ +/* im->id, im->ref_count); */ +/* fprintf(stderr, "%s id %d refcount %d\n", __FUNCTION__, */ +/* new_im->id, new_im->ref_count); */ ASSERT(im->ref_count > 0); SET_IMMEDIATE( ctx, new_im ); _tnl_reset_input( ctx, IMM_MAX_COPIED_VERTS, @@ -230,20 +236,23 @@ execute_compiled_cassette( GLcontext *ctx, void *data ) } - /* Lazy optimization of the cassette. + /* Lazy optimization of the cassette. Need to make these switchable + * or otherwise more useful for t&l cards. */ -/* if (ctx->Transform.Normalize && !node->have_normal_lengths) { */ +#if 0 + if (ctx->Transform.Normalize && !node->have_normal_lengths) { -/* if (!IM->NormalLengths) */ -/* IM->NormalLengths = (GLfloat *)MALLOC(sizeof(GLfloat) * IMM_SIZE); */ + if (!IM->NormalLengths) + IM->NormalLengths = (GLfloat *)MALLOC(sizeof(GLfloat) * IMM_SIZE); -/* calc_normal_lengths( IM->NormalLengths + IM->Start, */ -/* (const GLfloat (*)[3])(IM->Normal + IM->Start), */ -/* IM->Flag + IM->Start, */ -/* IM->Count - IM->Start); */ + calc_normal_lengths( IM->NormalLengths + IM->Start, + (const GLfloat (*)[3])(IM->Normal + IM->Start), + IM->Flag + IM->Start, + IM->Count - IM->Start); -/* node->have_normal_lengths = GL_TRUE; */ -/* } */ + node->have_normal_lengths = GL_TRUE; + } +#endif #if 0 @@ -268,6 +277,10 @@ destroy_compiled_cassette( GLcontext *ctx, void *data ) { TNLvertexcassette *node = (TNLvertexcassette *)data; +/* fprintf(stderr, "destroy_compiled_cassette node->IM id %d ref_count: %d\n", */ +/* node->IM->id, */ +/* node->IM->ref_count-1); */ + if ( --node->IM->ref_count == 0 ) _tnl_free_immediate( node->IM ); } @@ -328,9 +341,20 @@ _tnl_EndList( GLcontext *ctx ) TNLcontext *tnl = TNL_CONTEXT(ctx); struct immediate *IM = TNL_CURRENT_IM(ctx); + ctx->swtnl_im = 0; IM->ref_count--; - if (IM == tnl->ExecCopySource) +/* fprintf(stderr, "%s id %d refcount %d\n", __FUNCTION__, */ +/* IM->id, IM->ref_count); */ + if (IM == tnl->ExecCopySource) { IM->ref_count--; +/* fprintf(stderr, "%s id %d refcount %d\n", __FUNCTION__, */ +/* IM->id, IM->ref_count); */ + } else { +/* fprintf(stderr, "%s id %d refcount %d\n", __FUNCTION__, */ +/* tnl->ExecCopySource->id, tnl->ExecCopySource->ref_count-1); */ + if ( --tnl->ExecCopySource->ref_count == 0 ) + _tnl_free_immediate( tnl->ExecCopySource ); + } /* If this one isn't free, get a clean one. (Otherwise we'll be * using one that's already half full). @@ -342,9 +366,14 @@ _tnl_EndList( GLcontext *ctx ) tnl->ExecCopySource = IM; IM->ref_count++; +/* fprintf(stderr, "%s id %d refcount %d\n", __FUNCTION__, */ +/* IM->id, IM->ref_count); */ + SET_IMMEDIATE( ctx, IM ); IM->ref_count++; +/* fprintf(stderr, "%s id %d refcount %d\n", __FUNCTION__, */ +/* IM->id, IM->ref_count); */ _tnl_reset_input( ctx, IMM_MAX_COPIED_VERTS, 0, 0 ); diff --git a/src/mesa/tnl/t_imm_exec.c b/src/mesa/tnl/t_imm_exec.c index f9b12126a8..1549fa53af 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.3 2000/12/27 22:52:45 keithw Exp $ */ +/* $Id: t_imm_exec.c,v 1.4 2000/12/28 22:11:05 keithw Exp $ */ /* * Mesa 3-D graphics library @@ -474,11 +474,15 @@ void _tnl_imm_init( GLcontext *ctx ) ctx->swtnl_im = _tnl_alloc_immediate( ctx ); TNL_CURRENT_IM(ctx)->ref_count++; +/* fprintf(stderr, "%s id %d refcount %d\n", __FUNCTION__, */ +/* TNL_CURRENT_IM(ctx)->id, TNL_CURRENT_IM(ctx)->ref_count); */ tnl->ExecCopyTexSize = 0; tnl->ExecCopyCount = 0; tnl->ExecCopySource = TNL_CURRENT_IM(ctx); TNL_CURRENT_IM(ctx)->ref_count++; +/* fprintf(stderr, "%s id %d refcount %d\n", __FUNCTION__, */ +/* TNL_CURRENT_IM(ctx)->id, TNL_CURRENT_IM(ctx)->ref_count); */ TNL_CURRENT_IM(ctx)->CopyStart = IMM_MAX_COPIED_VERTS; gl_vector4f_init( &tmp->Obj, 0, 0 ); diff --git a/src/mesa/tnl/t_imm_fixup.c b/src/mesa/tnl/t_imm_fixup.c index d55ab48c56..5da75db53b 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.1 2000/12/26 05:09:32 keithw Exp $ */ +/* $Id: t_imm_fixup.c,v 1.2 2000/12/28 22:11:05 keithw Exp $ */ /* * Mesa 3-D graphics library @@ -432,11 +432,17 @@ static void copy_vertices( GLcontext *ctx, } ASSERT(prev == tnl->ExecCopySource); + +/* fprintf(stderr, "%s id %d refcount %d\n", __FUNCTION__, */ +/* tnl->ExecCopySource->id, tnl->ExecCopySource->ref_count-1); */ + if (--tnl->ExecCopySource->ref_count == 0) _tnl_free_immediate( tnl->ExecCopySource ); next->ref_count++; tnl->ExecCopySource = next; +/* fprintf(stderr, "%s id %d refcount %d\n", __FUNCTION__, */ +/* next->id, next->ref_count); */ tnl->ExecCopyElts[0] = next->Start-3; tnl->ExecCopyElts[1] = next->Start-2; tnl->ExecCopyElts[2] = next->Start-1; @@ -726,10 +732,14 @@ _tnl_get_exec_copy_verts( GLcontext *ctx, struct immediate *IM ) if (tnl->ExecCopySource != IM) { +/* fprintf(stderr, "%s id %d refcount %d\n", __FUNCTION__, */ +/* tnl->ExecCopySource->id, tnl->ExecCopySource->ref_count-1); */ if (--tnl->ExecCopySource->ref_count == 0) _tnl_free_immediate( tnl->ExecCopySource ); IM->ref_count++; tnl->ExecCopySource = IM; +/* fprintf(stderr, "%s id %d refcount %d\n", __FUNCTION__, */ +/* tnl->ExecCopySource->id, tnl->ExecCopySource->ref_count); */ } if (prim == GL_POLYGON+1) { diff --git a/src/mesa/tnl/t_vb_cliptmp.h b/src/mesa/tnl/t_vb_cliptmp.h index 34acfcfe55..1aeb014e15 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.3 2000/12/27 21:49:40 keithw Exp $ */ +/* $Id: t_vb_cliptmp.h,v 1.4 2000/12/28 22:11:05 keithw Exp $ */ /* * Mesa 3-D graphics library @@ -361,7 +361,7 @@ static void TAG(viewclip_polygon)( GLcontext *ctx, newvert = interp( ctx, t, idxPrev, idx, GL_FALSE ); \ } \ clipmask[newvert] = mask; \ - outlist[outcount++] = newvert; \ + outlist[outcount++] = newvert; \ } \ \ idxPrev = idx; \ diff --git a/src/mesa/tnl/t_vb_render.c b/src/mesa/tnl/t_vb_render.c index 1311d5721f..1d0a1aaf15 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.3 2000/12/27 21:49:40 keithw Exp $ */ +/* $Id: t_vb_render.c,v 1.4 2000/12/28 22:11:06 keithw Exp $ */ /* * Mesa 3-D graphics library @@ -520,6 +520,8 @@ static GLboolean run_render( GLcontext *ctx, render_func *tab; GLint pass = 0; +/* return GL_FALSE; */ + VB->interpfunc = (void *)RENDER_STAGE_DATA(stage)->interp; if (new_inputs) { @@ -615,7 +617,7 @@ static void check_render( GLcontext *ctx, struct gl_pipeline_stage *stage ) } } } - else if (ctx->Light.ShadeModel==GL_SMOOTH) + else { interp |= INTERP_INDEX; inputs |= VERT_INDEX; diff --git a/src/mesa/tnl/t_vb_rendertmp.h b/src/mesa/tnl/t_vb_rendertmp.h index bd77b9668a..5712d342d2 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.2 2000/12/27 19:57:37 keithw Exp $ */ +/* $Id: t_vb_rendertmp.h,v 1.3 2000/12/28 22:11:06 keithw Exp $ */ /* * Mesa 3-D graphics library @@ -39,7 +39,7 @@ #ifndef NEED_EDGEFLAG_SETUP #define NEED_EDGEFLAG_SETUP 0 #define EDGEFLAG_GET(a) 0 -#define EDGEFLAG_SET(a,b) +#define EDGEFLAG_SET(a,b) (void)b #endif #ifndef RESET_STIPPLE @@ -68,6 +68,7 @@ static void TAG(render_points)( GLcontext *ctx, LOCAL_VARS; (void) flags; +/* fprintf(stderr, "%s %d..%d\n", __FUNCTION__, start, count); */ RESET_OCCLUSION; INIT(GL_POINTS); RENDER_POINTS( start, count ); @@ -83,6 +84,7 @@ static void TAG(render_lines)( GLcontext *ctx, LOCAL_VARS; (void) flags; +/* fprintf(stderr, "%s %d..%d\n", __FUNCTION__, start, count); */ RESET_OCCLUSION; INIT(GL_LINES); for (j=start+1; j