From 88f3b89a2cb77766d2009b9868c44e03abe2dbb2 Mon Sep 17 00:00:00 2001 From: Keith Whitwell Date: Thu, 28 Dec 2000 22:11:04 +0000 Subject: [PATCH] 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/Makefile.X11 | 3 +- src/mesa/array_cache/ac_import.c | 12 +++++++- src/mesa/drivers/glide/fxdd.c | 28 ++++++++++------- src/mesa/drivers/glide/fxdrv.h | 5 ++- src/mesa/drivers/glide/fxvbtmp.h | 43 ++++++++++++++++++++++++-- src/mesa/main/Makefile.X11 | 3 +- src/mesa/main/config.h | 4 +-- src/mesa/main/varray.c | 4 ++- src/mesa/math/m_norm_tmp.h | 4 +-- 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 +++++++++++-- 17 files changed, 197 insertions(+), 62 deletions(-) diff --git a/src/mesa/Makefile.X11 b/src/mesa/Makefile.X11 index 9ea476376da..d5ab089af1d 100644 --- a/src/mesa/Makefile.X11 +++ b/src/mesa/Makefile.X11 @@ -1,4 +1,4 @@ -# $Id: Makefile.X11,v 1.36 2000/12/26 05:09:27 keithw Exp $ +# $Id: Makefile.X11,v 1.37 2000/12/28 22:11:04 keithw Exp $ # Mesa 3-D graphics library # Version: 3.5 @@ -160,6 +160,7 @@ DRIVER_SOURCES = \ FX/fxtexman.c \ FX/fxtris.c \ FX/fxvb.c \ + FX/fxsimplerender.c \ FX/fxglidew.c \ X/glxapi.c \ X/fakeglx.c \ diff --git a/src/mesa/array_cache/ac_import.c b/src/mesa/array_cache/ac_import.c index ca971dc1d84..e7fb795ef50 100644 --- a/src/mesa/array_cache/ac_import.c +++ b/src/mesa/array_cache/ac_import.c @@ -1,4 +1,4 @@ -/* $Id: ac_import.c,v 1.1 2000/12/26 15:14:04 keithw Exp $ */ +/* $Id: ac_import.c,v 1.2 2000/12/28 22:11:05 keithw Exp $ */ /* * Mesa 3-D graphics library @@ -45,6 +45,8 @@ static void reset_texcoord( GLcontext *ctx, GLuint unit ) { ACcontext *ac = AC_CONTEXT(ctx); +/* fprintf(stderr, "%s %d\n", __FUNCTION__, unit); */ + if (ctx->Array._Enabled & _NEW_ARRAY_TEXCOORD(unit)) ac->Current.TexCoord[unit] = &ctx->Array.TexCoord[unit]; else { @@ -69,6 +71,8 @@ static void reset_vertex( GLcontext *ctx ) ac->Current.Vertex = &ctx->Array.Vertex; ac->Writeable.Vertex = GL_FALSE; ac->NewArrayState &= ~_NEW_ARRAY_VERTEX; + +/* fprintf(stderr, "%s\n", __FUNCTION__); */ } @@ -178,6 +182,8 @@ static void import_texcoord( GLcontext *ctx, GLuint unit, ASSERT(stride == 4*sizeof(GLfloat) || stride == 0); ASSERT(ac->count - ac->start < ctx->Const.MaxArrayLockSize); +/* fprintf(stderr, "%s %d old ptr %p\n", __FUNCTION__, unit, from->Ptr); */ + _math_trans_4f( to->Ptr, from->Ptr, from->StrideB, @@ -191,6 +197,8 @@ static void import_texcoord( GLcontext *ctx, GLuint unit, to->Type = GL_FLOAT; ac->Current.TexCoord[unit] = to; ac->Writeable.TexCoord[unit] = GL_TRUE; + +/* fprintf(stderr, "%s %d new ptr %p\n", __FUNCTION__, unit, to->Ptr); */ } static void import_vertex( GLcontext *ctx, @@ -200,6 +208,8 @@ static void import_vertex( GLcontext *ctx, struct gl_client_array *from = ac->Current.Vertex; struct gl_client_array *to = &ac->Cache.Vertex; +/* fprintf(stderr, "(ac) %s\n", __FUNCTION__); */ + /* Limited choices at this stage: */ ASSERT(type == GL_FLOAT); diff --git a/src/mesa/drivers/glide/fxdd.c b/src/mesa/drivers/glide/fxdd.c index 3bbe42328a9..0f1ace3ee0d 100644 --- a/src/mesa/drivers/glide/fxdd.c +++ b/src/mesa/drivers/glide/fxdd.c @@ -61,6 +61,8 @@ #include "tnl/tnl.h" #include "array_cache/acache.h" +#include "tnl/t_pipeline.h" + /* These lookup table are used to extract RGB values in [0,255] from * 16-bit pixel values. */ @@ -645,25 +647,21 @@ static const GLubyte *fxDDGetString(GLcontext *ctx, GLenum name) } } -#if 0 -static const struct gl_pipeline_stage * const fx_pipeline[] = { +static const struct gl_pipeline_stage *fx_pipeline[] = { &_tnl_update_material_stage, + /* TODO: Add the fastpath here */ &_tnl_vertex_transform_stage, &_tnl_normal_transform_stage, - &_tnl_lighting_stage, /* OMIT: fog coordinate stage */ + &_tnl_lighting_stage, + &_tnl_fog_coordinate_stage, /* TODO: Omit fog stage */ &_tnl_texgen_stage, &_tnl_texture_transform_stage, &_tnl_point_attenuation_stage, - &_fx_fast_render_stage, /* ADD: the fastpath as a render stage */ + &fx_render_stage, /* ADD: render simple unclipped vb's */ &_tnl_render_stage, /* KEEP: the old render stage for fallbacks */ - 0 + 0, }; -#else -/* Need to turn off tnl fogging, both the stage and the clipping in - * _tnl_render_stage. Could insert a dummy stage that did nothing but - * provided storage that clipping could spin on? - */ -#endif + @@ -771,6 +769,9 @@ int fxDDInitFxMesaContext( fxMesaContext fxMesa ) _tnl_CreateContext( fxMesa->glCtx ); _swsetup_CreateContext( fxMesa->glCtx ); + _tnl_destroy_pipeline( fxMesa->glCtx ); + _tnl_install_pipeline( fxMesa->glCtx, fx_pipeline ); + fxAllocVB( fxMesa->glCtx ); fxSetupDDPointers(fxMesa->glCtx); @@ -780,6 +781,11 @@ int fxDDInitFxMesaContext( fxMesaContext fxMesa ) _swrast_allow_vertex_fog( fxMesa->glCtx, GL_FALSE ); _swrast_allow_pixel_fog( fxMesa->glCtx, GL_TRUE ); + /* Tell tnl not to calculate or use vertex fog factors. (Needed to + * tell render stage not to clip fog coords). + */ +/* _tnl_calculate_vertex_fog( fxMesa->glCtx, GL_FALSE ); */ + fxDDInitExtensions(fxMesa->glCtx); #ifdef FXVTXFMT diff --git a/src/mesa/drivers/glide/fxdrv.h b/src/mesa/drivers/glide/fxdrv.h index 4e4eea96a3b..2f62133221f 100644 --- a/src/mesa/drivers/glide/fxdrv.h +++ b/src/mesa/drivers/glide/fxdrv.h @@ -100,7 +100,6 @@ typedef union { typedef struct { GrVertex v; GLfloat clip[4]; - GLfloat win[4]; GLfloat texcoord[2][2]; GLubyte mask; GLfloat normal[3]; /* for replay & fallback */ @@ -630,4 +629,8 @@ extern void fxDDCheckVtxfmt( GLcontext *ctx ); extern void fx_update_lighting( GLcontext *ctx ); extern void fxDDInitVtxfmt( GLcontext *ctx ); +/* fxsimplerender + */ +extern const struct gl_pipeline_stage fx_render_stage; + #endif diff --git a/src/mesa/drivers/glide/fxvbtmp.h b/src/mesa/drivers/glide/fxvbtmp.h index 5f3a293650a..af21fc40af2 100644 --- a/src/mesa/drivers/glide/fxvbtmp.h +++ b/src/mesa/drivers/glide/fxvbtmp.h @@ -56,8 +56,47 @@ static void NAME(GLcontext *ctx, GLuint start, GLuint end, GLuint newinputs) if (IND & SETUP_RGBA) color = VB->ColorPtr[0]->data; - for (i = start ; i < end ; i++, v++) { - if (!clipmask[i]) { + if (VB->ClipOrMask) { + for (i = start ; i < end ; i++, v++) { + if (!clipmask[i]) { + if (IND & SETUP_XYZW) { + v->v.x = s[0] * proj[i][0] + s[12]; + v->v.y = s[5] * proj[i][1] + s[13]; + v->v.ooz = s[10] * proj[i][2] + s[14]; + v->v.oow = proj[i][3]; + + if (IND & SETUP_SNAP) { +#if defined(USE_IEEE) + const float snapper = (3L<<18); + v->v.x += snapper; + v->v.x -= snapper; + v->v.y += snapper; + v->v.y -= snapper; +#else + v->v.x = ((int)(v->v.x*16.0f)) * (1.0f/16.0f); + v->v.y = ((int)(v->v.y*16.0f)) * (1.0f/16.0f); +#endif + } + } + if (IND & SETUP_RGBA) { + UBYTE_COLOR_TO_FLOAT_255_COLOR2(v->v.r, color[i][0]); + UBYTE_COLOR_TO_FLOAT_255_COLOR2(v->v.g, color[i][1]); + UBYTE_COLOR_TO_FLOAT_255_COLOR2(v->v.b, color[i][2]); + UBYTE_COLOR_TO_FLOAT_255_COLOR2(v->v.a, color[i][3]); + } + if (IND & SETUP_TMU0) { + v->v.tmuvtx[0].sow = sscale0*tmu0_data[i][0]*v->v.oow; + v->v.tmuvtx[0].tow = tscale0*tmu0_data[i][1]*v->v.oow; + } + if (IND & SETUP_TMU1) { + v->v.tmuvtx[1].sow = sscale1*tmu1_data[i][0]*v->v.oow; + v->v.tmuvtx[1].tow = tscale1*tmu1_data[i][1]*v->v.oow; + } + } + } + } + else { + for (i = start ; i < end ; i++, v++) { if (IND & SETUP_XYZW) { v->v.x = s[0] * proj[i][0] + s[12]; v->v.y = s[5] * proj[i][1] + s[13]; diff --git a/src/mesa/main/Makefile.X11 b/src/mesa/main/Makefile.X11 index 9ea476376da..d5ab089af1d 100644 --- a/src/mesa/main/Makefile.X11 +++ b/src/mesa/main/Makefile.X11 @@ -1,4 +1,4 @@ -# $Id: Makefile.X11,v 1.36 2000/12/26 05:09:27 keithw Exp $ +# $Id: Makefile.X11,v 1.37 2000/12/28 22:11:04 keithw Exp $ # Mesa 3-D graphics library # Version: 3.5 @@ -160,6 +160,7 @@ DRIVER_SOURCES = \ FX/fxtexman.c \ FX/fxtris.c \ FX/fxvb.c \ + FX/fxsimplerender.c \ FX/fxglidew.c \ X/glxapi.c \ X/fakeglx.c \ diff --git a/src/mesa/main/config.h b/src/mesa/main/config.h index 1b3c4f0f271..fd2e1b599a6 100644 --- a/src/mesa/main/config.h +++ b/src/mesa/main/config.h @@ -1,4 +1,4 @@ -/* $Id: config.h,v 1.25 2000/12/26 05:09:28 keithw Exp $ */ +/* $Id: config.h,v 1.26 2000/12/28 22:11:05 keithw Exp $ */ /* * Mesa 3-D graphics library @@ -103,7 +103,7 @@ #define MAX_TEXTURE_LEVELS 12 /* Number of texture units - GL_ARB_multitexture */ -#define MAX_TEXTURE_UNITS 4 +#define MAX_TEXTURE_UNITS 8 /* Maximum viewport/image size: */ #define MAX_WIDTH 2048 diff --git a/src/mesa/main/varray.c b/src/mesa/main/varray.c index 9fa20997cf9..0050d9a1a17 100644 --- a/src/mesa/main/varray.c +++ b/src/mesa/main/varray.c @@ -1,4 +1,4 @@ -/* $Id: varray.c,v 1.34 2000/12/26 05:09:29 keithw Exp $ */ +/* $Id: varray.c,v 1.35 2000/12/28 22:11:05 keithw Exp $ */ /* * Mesa 3-D graphics library @@ -411,6 +411,8 @@ _mesa_TexCoordPointer(GLint size, GLenum type, GLsizei stride, const GLvoid *ptr ctx->NewState |= _NEW_ARRAY; ctx->Array.NewState |= _NEW_ARRAY_VERTEX; +/* fprintf(stderr, "%s ptr %p\n", __FUNCTION__, ptr); */ + if (ctx->Driver.TexCoordPointer) ctx->Driver.TexCoordPointer( ctx, size, type, stride, ptr ); } diff --git a/src/mesa/math/m_norm_tmp.h b/src/mesa/math/m_norm_tmp.h index e87d38297c0..45111a41294 100644 --- a/src/mesa/math/m_norm_tmp.h +++ b/src/mesa/math/m_norm_tmp.h @@ -1,4 +1,4 @@ -/* $Id: m_norm_tmp.h,v 1.2 2000/11/19 23:42:33 jtaylor Exp $ */ +/* $Id: m_norm_tmp.h,v 1.3 2000/12/28 22:11:05 keithw Exp $ */ /* * Mesa 3-D graphics library @@ -77,8 +77,6 @@ TAG(transform_normalize_normals)( const GLmatrix *mat, } } else { - /* scale has been snapped to 1.0 if it is close. - */ if (scale != 1.0) { m0 *= scale, m4 *= scale, m8 *= scale; m1 *= scale, m5 *= scale, m9 *= scale; diff --git a/src/mesa/tnl/t_array_import.c b/src/mesa/tnl/t_array_import.c index 1cfed067647..fc2c3d19447 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 44e3a598ecb..e6a37f81015 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 a11217e4374..e22661e7ea9 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 f9b12126a83..1549fa53af4 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 d55ab48c56d..5da75db53bf 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 34acfcfe554..1aeb014e159 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 1311d5721fc..1d0a1aaf152 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 bd77b9668a0..5712d342d27 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