From: havoc Date: Tue, 21 Mar 2006 05:49:29 +0000 (+0000) Subject: renamed varray_ arrays to rsurface_array_, and they are no longer used outside the... X-Git-Tag: xonotic-v0.1.0preview~4165 X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=69a9f6bb4ea7d2a62b22238da58fe99d0ebd41d8;p=xonotic%2Fdarkplaces.git renamed varray_ arrays to rsurface_array_, and they are no longer used outside the surface rendering code, additionally they are now dynamically resized (saves a little memory) audited a lot of memory allocations and fixed a few significant leaks removed Host_ClearMemory as it was causing several memory leaks, and split cls.mempool into cls.levelmempool and cls.permanentmempool, cls.levelmempool is now emptied each level load (this also fixes those same leaks) merged r_shadow_mempool into r_main_mempool git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@6154 d7cf8633-e32d-0410-b094-e92efae38249 --- diff --git a/cl_main.c b/cl_main.c index d677dbb3..aea2bbde 100644 --- a/cl_main.c +++ b/cl_main.c @@ -89,27 +89,8 @@ void CL_ClearState(void) int i; entity_t *ent; - if (cl.entities) Mem_Free(cl.entities);cl.entities = NULL; - if (cl.csqcentities) Mem_Free(cl.csqcentities);cl.csqcentities = NULL; //[515]: csqc - if (cl.entities_active) Mem_Free(cl.entities_active);cl.entities_active = NULL; - if (cl.csqcentities_active) Mem_Free(cl.csqcentities_active);cl.csqcentities_active = NULL; //[515]: csqc - if (cl.static_entities) Mem_Free(cl.static_entities);cl.static_entities = NULL; - if (cl.temp_entities) Mem_Free(cl.temp_entities);cl.temp_entities = NULL; - if (cl.effects) Mem_Free(cl.effects);cl.effects = NULL; - if (cl.beams) Mem_Free(cl.beams);cl.beams = NULL; - if (cl.dlights) Mem_Free(cl.dlights);cl.dlights = NULL; - if (cl.lightstyle) Mem_Free(cl.lightstyle);cl.lightstyle = NULL; - if (cl.brushmodel_entities) Mem_Free(cl.brushmodel_entities);cl.brushmodel_entities = NULL; - if (cl.entitydatabase) EntityFrame_FreeDatabase(cl.entitydatabase);cl.entitydatabase = NULL; - if (cl.entitydatabase4) EntityFrame4_FreeDatabase(cl.entitydatabase4);cl.entitydatabase4 = NULL; - if (cl.entitydatabaseqw) EntityFrameQW_FreeDatabase(cl.entitydatabaseqw);cl.entitydatabaseqw = NULL; - if (cl.scores) Mem_Free(cl.scores);cl.scores = NULL; - if (cl.particles) Mem_Free(cl.particles);cl.particles = NULL; - - if (!sv.active) - Host_ClearMemory (); - // wipe the entire cl structure + Mem_EmptyPool(cls.levelmempool); memset (&cl, 0, sizeof(cl)); S_StopAllSounds(); @@ -148,18 +129,18 @@ void CL_ClearState(void) cl.num_effects = 0; cl.num_beams = 0; - cl.entities = (entity_t *)Mem_Alloc(cls.mempool, cl.max_entities * sizeof(entity_t)); - cl.csqcentities = (entity_t *)Mem_Alloc(cls.mempool, cl.max_csqcentities * sizeof(entity_t)); //[515]: csqc - cl.entities_active = (unsigned char *)Mem_Alloc(cls.mempool, cl.max_brushmodel_entities * sizeof(unsigned char)); - cl.csqcentities_active = (unsigned char *)Mem_Alloc(cls.mempool, cl.max_brushmodel_entities * sizeof(unsigned char)); //[515]: csqc - cl.static_entities = (entity_t *)Mem_Alloc(cls.mempool, cl.max_static_entities * sizeof(entity_t)); - cl.temp_entities = (entity_t *)Mem_Alloc(cls.mempool, cl.max_temp_entities * sizeof(entity_t)); - cl.effects = (cl_effect_t *)Mem_Alloc(cls.mempool, cl.max_effects * sizeof(cl_effect_t)); - cl.beams = (beam_t *)Mem_Alloc(cls.mempool, cl.max_beams * sizeof(beam_t)); - cl.dlights = (dlight_t *)Mem_Alloc(cls.mempool, cl.max_dlights * sizeof(dlight_t)); - cl.lightstyle = (lightstyle_t *)Mem_Alloc(cls.mempool, cl.max_lightstyle * sizeof(lightstyle_t)); - cl.brushmodel_entities = (int *)Mem_Alloc(cls.mempool, cl.max_brushmodel_entities * sizeof(int)); - cl.particles = (particle_t *) Mem_Alloc(cls.mempool, cl.max_particles * sizeof(particle_t)); + cl.entities = (entity_t *)Mem_Alloc(cls.levelmempool, cl.max_entities * sizeof(entity_t)); + cl.csqcentities = (entity_t *)Mem_Alloc(cls.levelmempool, cl.max_csqcentities * sizeof(entity_t)); //[515]: csqc + cl.entities_active = (unsigned char *)Mem_Alloc(cls.levelmempool, cl.max_brushmodel_entities * sizeof(unsigned char)); + cl.csqcentities_active = (unsigned char *)Mem_Alloc(cls.levelmempool, cl.max_brushmodel_entities * sizeof(unsigned char)); //[515]: csqc + cl.static_entities = (entity_t *)Mem_Alloc(cls.levelmempool, cl.max_static_entities * sizeof(entity_t)); + cl.temp_entities = (entity_t *)Mem_Alloc(cls.levelmempool, cl.max_temp_entities * sizeof(entity_t)); + cl.effects = (cl_effect_t *)Mem_Alloc(cls.levelmempool, cl.max_effects * sizeof(cl_effect_t)); + cl.beams = (beam_t *)Mem_Alloc(cls.levelmempool, cl.max_beams * sizeof(beam_t)); + cl.dlights = (dlight_t *)Mem_Alloc(cls.levelmempool, cl.max_dlights * sizeof(dlight_t)); + cl.lightstyle = (lightstyle_t *)Mem_Alloc(cls.levelmempool, cl.max_lightstyle * sizeof(lightstyle_t)); + cl.brushmodel_entities = (int *)Mem_Alloc(cls.levelmempool, cl.max_brushmodel_entities * sizeof(int)); + cl.particles = (particle_t *) Mem_Alloc(cls.levelmempool, cl.max_particles * sizeof(particle_t)); // LordHavoc: have to set up the baseline info for alpha and other stuff for (i = 0;i < cl.max_entities;i++) @@ -230,7 +211,7 @@ void CL_ExpandEntities(int num) oldmaxentities = cl.max_entities; oldentities = cl.entities; cl.max_entities = (num & ~255) + 256; - cl.entities = (entity_t *)Mem_Alloc(cls.mempool, cl.max_entities * sizeof(entity_t)); + cl.entities = (entity_t *)Mem_Alloc(cls.levelmempool, cl.max_entities * sizeof(entity_t)); memcpy(cl.entities, oldentities, oldmaxentities * sizeof(entity_t)); Mem_Free(oldentities); for (i = oldmaxentities;i < cl.max_entities;i++) @@ -255,7 +236,7 @@ void CL_ExpandCSQCEntities(int num) oldmaxentities = cl.max_csqcentities; oldentities = cl.csqcentities; cl.max_csqcentities = (num & ~255) + 256; - cl.csqcentities = Mem_Alloc(cls.mempool, cl.max_csqcentities * sizeof(entity_t)); + cl.csqcentities = Mem_Alloc(cls.levelmempool, cl.max_csqcentities * sizeof(entity_t)); memcpy(cl.csqcentities, oldentities, oldmaxentities * sizeof(entity_t)); Mem_Free(oldentities); for (i = oldmaxentities;i < cl.max_csqcentities;i++) @@ -1703,7 +1684,8 @@ void CL_Shutdown (void) CL_Particles_Shutdown(); CL_Parse_Shutdown(); - Mem_FreePool (&cls.mempool); + Mem_FreePool (&cls.permanentmempool); + Mem_FreePool (&cls.levelmempool); } /* @@ -1713,12 +1695,13 @@ CL_Init */ void CL_Init (void) { - cls.mempool = Mem_AllocPool("client", 0, NULL); + cls.levelmempool = Mem_AllocPool("client (per-level memory)", 0, NULL); + cls.permanentmempool = Mem_AllocPool("client (long term memory)", 0, NULL); memset(&r_refdef, 0, sizeof(r_refdef)); // max entities sent to renderer per frame r_refdef.maxentities = MAX_EDICTS + 256 + 512; - r_refdef.entities = (entity_render_t **)Mem_Alloc(cls.mempool, sizeof(entity_render_t *) * r_refdef.maxentities); + r_refdef.entities = (entity_render_t **)Mem_Alloc(cls.permanentmempool, sizeof(entity_render_t *) * r_refdef.maxentities); CL_InitInput (); diff --git a/cl_parse.c b/cl_parse.c index 92015008..4bde1fc3 100644 --- a/cl_parse.c +++ b/cl_parse.c @@ -586,7 +586,7 @@ static void QW_CL_ParseDownload(void) while (cls.qw_downloadmemorymaxsize < cls.qw_downloadmemorycursize + size) cls.qw_downloadmemorymaxsize *= 2; old = cls.qw_downloadmemory; - cls.qw_downloadmemory = Mem_Alloc(cls.mempool, cls.qw_downloadmemorymaxsize); + cls.qw_downloadmemory = Mem_Alloc(cls.permanentmempool, cls.qw_downloadmemorymaxsize); if (old) { memcpy(cls.qw_downloadmemory, old, cls.qw_downloadmemorycursize); @@ -748,7 +748,7 @@ void QW_CL_StartUpload(unsigned char *data, int size) Con_DPrintf("Starting upload of %d bytes...\n", size); - cls.qw_uploaddata = Mem_Alloc(cls.mempool, size); + cls.qw_uploaddata = Mem_Alloc(cls.permanentmempool, size); memcpy(cls.qw_uploaddata, data, size); cls.qw_uploadsize = size; cls.qw_uploadpos = 0; @@ -1016,7 +1016,7 @@ void CL_ParseServerInfo (void) i = MSG_ReadByte(); cl.qw_spectator = (i & 128) != 0; cl.playerentity = cl.viewentity = (i & 127) + 1; - cl.scores = (scoreboard_t *)Mem_Alloc(cls.mempool, cl.maxclients*sizeof(*cl.scores)); + cl.scores = (scoreboard_t *)Mem_Alloc(cls.levelmempool, cl.maxclients*sizeof(*cl.scores)); // get the full level name str = MSG_ReadString (); @@ -1059,7 +1059,7 @@ void CL_ParseServerInfo (void) Host_Error("Bad maxclients (%u) from server", cl.maxclients); return; } - cl.scores = (scoreboard_t *)Mem_Alloc(cls.mempool, cl.maxclients*sizeof(*cl.scores)); + cl.scores = (scoreboard_t *)Mem_Alloc(cls.levelmempool, cl.maxclients*sizeof(*cl.scores)); // parse gametype cl.gametype = MSG_ReadByte (); diff --git a/cl_video.c b/cl_video.c index 8d44d9ae..3bbe315a 100644 --- a/cl_video.c +++ b/cl_video.c @@ -60,7 +60,7 @@ static qboolean WakeVideo( clvideo_t * video ) return false; } - video->imagedata = Mem_Alloc( cls.mempool, video->cpif.width * video->cpif.height * cl_videobytesperpixel ); + video->imagedata = Mem_Alloc( cls.permanentmempool, video->cpif.width * video->cpif.height * cl_videobytesperpixel ); video->cpif.tex = R_LoadTexture2D( cl_videotexturepool, video->cpif.name, video->cpif.width, video->cpif.height, NULL, TEXTYPE_RGBA, 0, NULL ); @@ -91,7 +91,7 @@ static clvideo_t* OpenVideo( clvideo_t *video, const char *filename, const char video->cpif.tex = R_LoadTexture2D( cl_videotexturepool, video->cpif.name, video->cpif.width, video->cpif.height, NULL, TEXTYPE_RGBA, 0, NULL ); - video->imagedata = Mem_Alloc( cls.mempool, video->cpif.width * video->cpif.height * cl_videobytesperpixel ); + video->imagedata = Mem_Alloc( cls.permanentmempool, video->cpif.width * video->cpif.height * cl_videobytesperpixel ); return video; } diff --git a/client.h b/client.h index 88b9e71a..a1559169 100644 --- a/client.h +++ b/client.h @@ -424,8 +424,9 @@ typedef struct client_static_s { cactive_t state; - // all client memory allocations go in this pool - mempool_t *mempool; + // all client memory allocations go in these pools + mempool_t *levelmempool; + mempool_t *permanentmempool; // demo loop control // -1 = don't play demos diff --git a/gl_backend.c b/gl_backend.c index 1d0418f4..ddfe5bbc 100644 --- a/gl_backend.c +++ b/gl_backend.c @@ -1643,12 +1643,3 @@ void R_Mesh_Draw_ShowTris(int firstvertex, int numvertices, int numtriangles, co qglEnd(); CHECKGLERROR } - -// FIXME: someday this should be dynamically allocated and resized? -float varray_vertex3f[65536*3]; -float varray_svector3f[65536*3]; -float varray_tvector3f[65536*3]; -float varray_normal3f[65536*3]; -float varray_color4f[65536*4]; -float varray_texcoord3f[65536*3]; -float varray_vertex3f2[65536*3]; diff --git a/gl_backend.h b/gl_backend.h index dcb7ed97..3bdc2e60 100644 --- a/gl_backend.h +++ b/gl_backend.h @@ -108,13 +108,5 @@ void SCR_UpdateScreen(void); // invoke refresh of loading plaque (nothing else seen) void SCR_UpdateLoadingScreen(void); -extern float varray_vertex3f[65536*3]; -extern float varray_svector3f[65536*3]; -extern float varray_tvector3f[65536*3]; -extern float varray_normal3f[65536*3]; -extern float varray_color4f[65536*4]; -extern float varray_texcoord3f[65536*3]; -extern float varray_vertex3f2[65536*3]; - #endif diff --git a/gl_rmain.c b/gl_rmain.c index f79ac043..721b27ab 100644 --- a/gl_rmain.c +++ b/gl_rmain.c @@ -2534,6 +2534,29 @@ void R_UpdateAllTextureInfo(entity_render_t *ent) R_UpdateTextureInfo(ent, ent->model->data_textures + i); } +int rsurface_array_size = 0; +float *rsurface_array_vertex3f = NULL; +float *rsurface_array_svector3f = NULL; +float *rsurface_array_tvector3f = NULL; +float *rsurface_array_normal3f = NULL; +float *rsurface_array_color4f = NULL; +float *rsurface_array_texcoord3f = NULL; + +void R_Mesh_ResizeArrays(int newvertices) +{ + if (rsurface_array_size >= newvertices) + return; + if (rsurface_array_vertex3f) + Mem_Free(rsurface_array_vertex3f); + rsurface_array_size = (newvertices + 1023) & ~1023; + rsurface_array_vertex3f = Mem_Alloc(r_main_mempool, rsurface_array_size * sizeof(float[19])); + rsurface_array_svector3f = rsurface_array_vertex3f + rsurface_array_size * 3; + rsurface_array_tvector3f = rsurface_array_vertex3f + rsurface_array_size * 6; + rsurface_array_normal3f = rsurface_array_vertex3f + rsurface_array_size * 9; + rsurface_array_color4f = rsurface_array_vertex3f + rsurface_array_size * 12; + rsurface_array_texcoord3f = rsurface_array_vertex3f + rsurface_array_size * 16; +} + float *rsurface_vertex3f; float *rsurface_svector3f; float *rsurface_tvector3f; @@ -2542,15 +2565,17 @@ float *rsurface_lightmapcolor4f; void RSurf_SetVertexPointer(const entity_render_t *ent, const texture_t *texture, const msurface_t *surface, const vec3_t modelorg, qboolean generatenormals, qboolean generatetangents) { + if (rsurface_array_size < surface->groupmesh->num_vertices) + R_Mesh_ResizeArrays(surface->groupmesh->num_vertices); if ((ent->frameblend[0].lerp != 1 || ent->frameblend[0].frame != 0) && (surface->groupmesh->data_morphvertex3f || surface->groupmesh->data_vertexboneweights)) { - rsurface_vertex3f = varray_vertex3f; + rsurface_vertex3f = rsurface_array_vertex3f; Mod_Alias_GetMesh_Vertex3f(ent->model, ent->frameblend, surface->groupmesh, rsurface_vertex3f); if (generatetangents || (texture->textureflags & (Q3TEXTUREFLAG_AUTOSPRITE | Q3TEXTUREFLAG_AUTOSPRITE2))) { - rsurface_svector3f = varray_svector3f; - rsurface_tvector3f = varray_tvector3f; - rsurface_normal3f = varray_normal3f; + rsurface_svector3f = rsurface_array_svector3f; + rsurface_tvector3f = rsurface_array_tvector3f; + rsurface_normal3f = rsurface_array_normal3f; Mod_BuildTextureVectorsAndNormals(surface->num_firstvertex, surface->num_vertices, surface->num_triangles, rsurface_vertex3f, surface->groupmesh->data_texcoordtexture2f, surface->groupmesh->data_element3i + surface->num_firsttriangle * 3, rsurface_svector3f, rsurface_tvector3f, rsurface_normal3f, r_smoothnormals_areaweighting.integer); } else @@ -2559,7 +2584,7 @@ void RSurf_SetVertexPointer(const entity_render_t *ent, const texture_t *texture rsurface_tvector3f = NULL; if (generatenormals) { - rsurface_normal3f = varray_normal3f; + rsurface_normal3f = rsurface_array_normal3f; Mod_BuildNormals(surface->num_firstvertex, surface->num_vertices, surface->num_triangles, rsurface_vertex3f, surface->groupmesh->data_element3i + 3 * surface->num_firsttriangle, rsurface_normal3f, r_smoothnormals_areaweighting.integer); } else @@ -2605,12 +2630,12 @@ void RSurf_SetVertexPointer(const entity_render_t *ent, const texture_t *texture VectorSet(up, 0, 0, 1); } for (i = 0;i < 4;i++) - VectorMAMAMAM(1, center, v[i][0], forward, v[i][1], right, v[i][2], up, varray_vertex3f + (surface->num_firstvertex+i+j) * 3); + VectorMAMAMAM(1, center, v[i][0], forward, v[i][1], right, v[i][2], up, rsurface_array_vertex3f + (surface->num_firstvertex+i+j) * 3); } - rsurface_vertex3f = varray_vertex3f; - rsurface_svector3f = varray_svector3f; - rsurface_tvector3f = varray_tvector3f; - rsurface_normal3f = varray_normal3f; + rsurface_vertex3f = rsurface_array_vertex3f; + rsurface_svector3f = rsurface_array_svector3f; + rsurface_tvector3f = rsurface_array_tvector3f; + rsurface_normal3f = rsurface_array_normal3f; Mod_BuildTextureVectorsAndNormals(surface->num_firstvertex, surface->num_vertices, surface->num_triangles, rsurface_vertex3f, surface->groupmesh->data_texcoordtexture2f, surface->groupmesh->data_element3i + surface->num_firsttriangle * 3, rsurface_svector3f, rsurface_tvector3f, rsurface_normal3f, r_smoothnormals_areaweighting.integer); } R_Mesh_VertexPointer(rsurface_vertex3f); @@ -2647,7 +2672,7 @@ static void RSurf_DrawLightmap(const entity_render_t *ent, const texture_t *text int numverts = surface->num_vertices; v = rsurface_vertex3f + 3 * surface->num_firstvertex; c2 = rsurface_normal3f + 3 * surface->num_firstvertex; - c = varray_color4f + 4 * surface->num_firstvertex; + c = rsurface_array_color4f + 4 * surface->num_firstvertex; // q3-style directional shading for (i = 0;i < numverts;i++, v += 3, c2 += 3, c += 4) { @@ -2662,7 +2687,7 @@ static void RSurf_DrawLightmap(const entity_render_t *ent, const texture_t *text b = 1; a = 1; applycolor = false; - rsurface_lightmapcolor4f = varray_color4f; + rsurface_lightmapcolor4f = rsurface_array_color4f; } else { @@ -2676,7 +2701,7 @@ static void RSurf_DrawLightmap(const entity_render_t *ent, const texture_t *text { if (surface->lightmapinfo && surface->lightmapinfo->stainsamples) { - for (i = 0, c = varray_color4f + 4 * surface->num_firstvertex;i < surface->num_vertices;i++, c += 4) + for (i = 0, c = rsurface_array_color4f + 4 * surface->num_firstvertex;i < surface->num_vertices;i++, c += 4) { if (surface->lightmapinfo->samples) { @@ -2706,7 +2731,7 @@ static void RSurf_DrawLightmap(const entity_render_t *ent, const texture_t *text else VectorClear(c); } - rsurface_lightmapcolor4f = varray_color4f; + rsurface_lightmapcolor4f = rsurface_array_color4f; } else rsurface_lightmapcolor4f = surface->groupmesh->data_lightmapcolor4f; @@ -2717,7 +2742,7 @@ static void RSurf_DrawLightmap(const entity_render_t *ent, const texture_t *text { if (rsurface_lightmapcolor4f) { - for (i = 0, v = (rsurface_vertex3f + 3 * surface->num_firstvertex), c = (rsurface_lightmapcolor4f + 4 * surface->num_firstvertex), c2 = (varray_color4f + 4 * surface->num_firstvertex);i < surface->num_vertices;i++, v += 3, c += 4, c2 += 4) + for (i = 0, v = (rsurface_vertex3f + 3 * surface->num_firstvertex), c = (rsurface_lightmapcolor4f + 4 * surface->num_firstvertex), c2 = (rsurface_array_color4f + 4 * surface->num_firstvertex);i < surface->num_vertices;i++, v += 3, c += 4, c2 += 4) { f = 1 - VERTEXFOGTABLE(VectorDistance(v, modelorg)); c2[0] = c[0] * f; @@ -2728,7 +2753,7 @@ static void RSurf_DrawLightmap(const entity_render_t *ent, const texture_t *text } else { - for (i = 0, v = (rsurface_vertex3f + 3 * surface->num_firstvertex), c2 = (varray_color4f + 4 * surface->num_firstvertex);i < surface->num_vertices;i++, v += 3, c2 += 4) + for (i = 0, v = (rsurface_vertex3f + 3 * surface->num_firstvertex), c2 = (rsurface_array_color4f + 4 * surface->num_firstvertex);i < surface->num_vertices;i++, v += 3, c2 += 4) { f = 1 - VERTEXFOGTABLE(VectorDistance(v, modelorg)); c2[0] = f; @@ -2737,18 +2762,18 @@ static void RSurf_DrawLightmap(const entity_render_t *ent, const texture_t *text c2[3] = 1; } } - rsurface_lightmapcolor4f = varray_color4f; + rsurface_lightmapcolor4f = rsurface_array_color4f; } if (applycolor && rsurface_lightmapcolor4f) { - for (i = 0, c = (rsurface_lightmapcolor4f + 4 * surface->num_firstvertex), c2 = (varray_color4f + 4 * surface->num_firstvertex);i < surface->num_vertices;i++, c += 4, c2 += 4) + for (i = 0, c = (rsurface_lightmapcolor4f + 4 * surface->num_firstvertex), c2 = (rsurface_array_color4f + 4 * surface->num_firstvertex);i < surface->num_vertices;i++, c += 4, c2 += 4) { c2[0] = c[0] * r; c2[1] = c[1] * g; c2[2] = c[2] * b; c2[3] = c[3] * a; } - rsurface_lightmapcolor4f = varray_color4f; + rsurface_lightmapcolor4f = rsurface_array_color4f; } R_Mesh_ColorPointer(rsurface_lightmapcolor4f); GL_Color(r, g, b, a); @@ -2922,7 +2947,7 @@ static void R_DrawTextureSurfaceList(const entity_render_t *ent, texture_t *text m.tex[1] = R_GetTexture(layer->texture); m.texmatrix[1] = layer->texmatrix; m.texrgbscale[1] = layertexrgbscale; - m.pointer_color = varray_color4f; + m.pointer_color = rsurface_array_color4f; R_Mesh_State(&m); if (lightmode == 2) { @@ -2959,7 +2984,7 @@ static void R_DrawTextureSurfaceList(const entity_render_t *ent, texture_t *text memset(&m, 0, sizeof(m)); m.tex[0] = R_GetTexture(layer->texture); m.texmatrix[0] = layer->texmatrix; - m.pointer_color = varray_color4f; + m.pointer_color = rsurface_array_color4f; m.texrgbscale[0] = layertexrgbscale; R_Mesh_State(&m); if (lightmode == 2) @@ -2994,7 +3019,7 @@ static void R_DrawTextureSurfaceList(const entity_render_t *ent, texture_t *text memset(&m, 0, sizeof(m)); m.tex[0] = R_GetTexture(layer->texture); m.texmatrix[0] = layer->texmatrix; - m.pointer_color = varray_color4f; + m.pointer_color = rsurface_array_color4f; m.texrgbscale[0] = layertexrgbscale; R_Mesh_State(&m); for (texturesurfaceindex = 0;texturesurfaceindex < texturenumsurfaces;texturesurfaceindex++) @@ -3009,7 +3034,7 @@ static void R_DrawTextureSurfaceList(const entity_render_t *ent, texture_t *text m.tex[0] = R_GetTexture(layer->texture); m.texmatrix[0] = layer->texmatrix; m.texrgbscale[0] = layertexrgbscale; - m.pointer_color = varray_color4f; + m.pointer_color = rsurface_array_color4f; R_Mesh_State(&m); if (lightmode == 2) { @@ -3034,7 +3059,7 @@ static void R_DrawTextureSurfaceList(const entity_render_t *ent, texture_t *text memset(&m, 0, sizeof(m)); m.tex[0] = R_GetTexture(layer->texture); m.texmatrix[0] = layer->texmatrix; - m.pointer_color = varray_color4f; + m.pointer_color = rsurface_array_color4f; m.texrgbscale[0] = layertexrgbscale; R_Mesh_State(&m); for (texturesurfaceindex = 0;texturesurfaceindex < texturenumsurfaces;texturesurfaceindex++) @@ -3060,8 +3085,8 @@ static void R_DrawTextureSurfaceList(const entity_render_t *ent, texture_t *text RSurf_SetVertexPointer(ent, texture, surface, modelorg, false, false); if (layer->texture) R_Mesh_TexCoordPointer(0, 2, surface->groupmesh->data_texcoordtexture2f); - R_Mesh_ColorPointer(varray_color4f); - for (i = 0, v = (rsurface_vertex3f + 3 * surface->num_firstvertex), c = (varray_color4f + 4 * surface->num_firstvertex);i < surface->num_vertices;i++, v += 3, c += 4) + R_Mesh_ColorPointer(rsurface_array_color4f); + for (i = 0, v = (rsurface_vertex3f + 3 * surface->num_firstvertex), c = (rsurface_array_color4f + 4 * surface->num_firstvertex);i < surface->num_vertices;i++, v += 3, c += 4) { f = VERTEXFOGTABLE(VectorDistance(v, modelorg)); c[0] = layercolor[0]; diff --git a/gl_rsurf.c b/gl_rsurf.c index b8e1c3c5..fc04f244 100644 --- a/gl_rsurf.c +++ b/gl_rsurf.c @@ -295,17 +295,20 @@ void R_Stain (const vec3_t origin, float radius, int cr1, int cg1, int cb1, int static void R_DrawPortal_Callback(const entity_render_t *ent, int surfacenumber, const rtlight_t *rtlight) { const mportal_t *portal = (mportal_t *)ent; - int i; + int i, numpoints; float *v; rmeshstate_t m; + float vertex3f[POLYGONELEMENTS_MAXPOINTS*3]; GL_BlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); GL_DepthMask(false); GL_DepthTest(true); qglDisable(GL_CULL_FACE); R_Mesh_Matrix(&identitymatrix); + numpoints = min(portal->numpoints, POLYGONELEMENTS_MAXPOINTS); + memset(&m, 0, sizeof(m)); - m.pointer_vertex = varray_vertex3f; + m.pointer_vertex = vertex3f; R_Mesh_State(&m); i = surfacenumber; @@ -313,11 +316,9 @@ static void R_DrawPortal_Callback(const entity_render_t *ent, int surfacenumber, ((i & 0x0038) >> 3) * (1.0f / 7.0f), ((i & 0x01C0) >> 6) * (1.0f / 7.0f), 0.125f); - for (i = 0, v = varray_vertex3f;i < portal->numpoints;i++, v += 3) + for (i = 0, v = vertex3f;i < numpoints;i++, v += 3) VectorCopy(portal->points[i].position, v); - GL_LockArrays(0, portal->numpoints); - R_Mesh_Draw(0, portal->numpoints, portal->numpoints - 2, polygonelements); - GL_LockArrays(0, 0); + R_Mesh_Draw(0, numpoints, numpoints - 2, polygonelements); qglEnable(GL_CULL_FACE); } @@ -689,7 +690,7 @@ void R_Q1BSP_CompileShadowVolume(entity_render_t *ent, vec3_t relativelightorigi int surfacelistindex; float projectdistance = lightradius + model->radius*2 + r_shadow_projectdistance.value; texture_t *texture; - r_shadow_compilingrtlight->static_meshchain_shadow = Mod_ShadowMesh_Begin(r_shadow_mempool, 32768, 32768, NULL, NULL, NULL, false, false, true); + r_shadow_compilingrtlight->static_meshchain_shadow = Mod_ShadowMesh_Begin(r_main_mempool, 32768, 32768, NULL, NULL, NULL, false, false, true); R_Shadow_PrepareShadowMark(model->brush.shadowmesh->numtriangles); for (surfacelistindex = 0;surfacelistindex < numsurfaces;surfacelistindex++) { @@ -702,7 +703,7 @@ void R_Q1BSP_CompileShadowVolume(entity_render_t *ent, vec3_t relativelightorigi R_Shadow_MarkVolumeFromBox(surface->num_firstshadowmeshtriangle, surface->num_triangles, model->brush.shadowmesh->vertex3f, model->brush.shadowmesh->element3i, relativelightorigin, r_shadow_compilingrtlight->cullmins, r_shadow_compilingrtlight->cullmaxs, surface->mins, surface->maxs); } R_Shadow_VolumeFromList(model->brush.shadowmesh->numverts, model->brush.shadowmesh->numtriangles, model->brush.shadowmesh->vertex3f, model->brush.shadowmesh->element3i, model->brush.shadowmesh->neighbor3i, relativelightorigin, lightradius + model->radius + projectdistance, numshadowmark, shadowmarklist); - r_shadow_compilingrtlight->static_meshchain_shadow = Mod_ShadowMesh_Finish(r_shadow_mempool, r_shadow_compilingrtlight->static_meshchain_shadow, false, false); + r_shadow_compilingrtlight->static_meshchain_shadow = Mod_ShadowMesh_Finish(r_main_mempool, r_shadow_compilingrtlight->static_meshchain_shadow, false, false); } extern float *rsurface_vertex3f; diff --git a/host.c b/host.c index dfc42fa0..c3efe96f 100644 --- a/host.c +++ b/host.c @@ -519,25 +519,6 @@ void Host_ShutdownServer(void) } -/* -================ -Host_ClearMemory - -This clears all the memory used by both the client and server, but does -not reinitialize anything. -================ -*/ -void Host_ClearMemory (void) -{ - Con_DPrint("Clearing memory\n"); - Mod_ClearAll (); - - cls.signon = 0; - memset (&sv, 0, sizeof(sv)); - memset (&cl, 0, sizeof(cl)); -} - - //============================================================================ /* diff --git a/host_cmd.c b/host_cmd.c index bed286c7..9bd58db0 100644 --- a/host_cmd.c +++ b/host_cmd.c @@ -729,6 +729,7 @@ void Host_Loadgame_f (void) entnum++; } + Mem_Free(text); prog->num_edicts = entnum; sv.time = time; diff --git a/menu.c b/menu.c index 2ae3f637..cfa3bf38 100644 --- a/menu.c +++ b/menu.c @@ -1363,8 +1363,8 @@ static void M_Setup_Draw (void) menuplyr_width = image_width; menuplyr_height = image_height; Mem_Free(f); - menuplyr_pixels = (unsigned char *)Mem_Alloc(cls.mempool, menuplyr_width * menuplyr_height); - menuplyr_translated = (unsigned int *)Mem_Alloc(cls.mempool, menuplyr_width * menuplyr_height * 4); + menuplyr_pixels = (unsigned char *)Mem_Alloc(cls.permanentmempool, menuplyr_width * menuplyr_height); + menuplyr_translated = (unsigned int *)Mem_Alloc(cls.permanentmempool, menuplyr_width * menuplyr_height * 4); memcpy(menuplyr_pixels, data, menuplyr_width * menuplyr_height); Mem_Free(data); } diff --git a/meshqueue.c b/meshqueue.c index 69593bd8..b7087c01 100644 --- a/meshqueue.c +++ b/meshqueue.c @@ -49,7 +49,7 @@ void R_MeshQueue_Render(void) static void R_MeshQueue_EnlargeTransparentArray(int newtotal) { meshqueue_t *newarray; - newarray = (meshqueue_t *)Mem_Alloc(cls.mempool, newtotal * sizeof(meshqueue_t)); + newarray = (meshqueue_t *)Mem_Alloc(cls.permanentmempool, newtotal * sizeof(meshqueue_t)); if (mqt_array) { memcpy(newarray, mqt_array, mqt_total * sizeof(meshqueue_t)); @@ -167,11 +167,11 @@ void R_MeshQueue_BeginScene(void) mq_total = r_meshqueue_entries.integer; if (mq_array) Mem_Free(mq_array); - mq_array = (meshqueue_t *)Mem_Alloc(cls.mempool, mq_total * sizeof(meshqueue_t)); + mq_array = (meshqueue_t *)Mem_Alloc(cls.permanentmempool, mq_total * sizeof(meshqueue_t)); } if (mqt_array == NULL) - mqt_array = (meshqueue_t *)Mem_Alloc(cls.mempool, mqt_total * sizeof(meshqueue_t)); + mqt_array = (meshqueue_t *)Mem_Alloc(cls.permanentmempool, mqt_total * sizeof(meshqueue_t)); mq_count = 0; mqt_count = 0; diff --git a/model_alias.c b/model_alias.c index d9704c7f..d36e737a 100644 --- a/model_alias.c +++ b/model_alias.c @@ -205,6 +205,8 @@ static void Mod_MDLMD2MD3_TraceBox(model_t *model, int frame, trace_t *trace, co frameblend_t frameblend[4]; msurface_t *surface; surfmesh_t *mesh; + static int maxvertices = 0; + static float *vertex3f = NULL; memset(trace, 0, sizeof(*trace)); trace->fraction = 1; trace->realfraction = 1; @@ -224,8 +226,15 @@ static void Mod_MDLMD2MD3_TraceBox(model_t *model, int frame, trace_t *trace, co for (i = 0, surface = model->data_surfaces;i < model->num_surfaces;i++, surface++) { mesh = surface->groupmesh; - Mod_Alias_GetMesh_Vertex3f(model, frameblend, mesh, varray_vertex3f); - Collision_TraceLineTriangleMeshFloat(trace, start, end, mesh->num_triangles, mesh->data_element3i, varray_vertex3f, SUPERCONTENTS_SOLID, segmentmins, segmentmaxs); + if (maxvertices < mesh->num_vertices) + { + if (vertex3f) + Z_Free(vertex3f); + maxvertices = (mesh->num_vertices + 255) & ~255; + vertex3f = Z_Malloc(maxvertices * sizeof(float[3])); + } + Mod_Alias_GetMesh_Vertex3f(model, frameblend, mesh, vertex3f); + Collision_TraceLineTriangleMeshFloat(trace, start, end, mesh->num_triangles, mesh->data_element3i, vertex3f, SUPERCONTENTS_SOLID, segmentmins, segmentmaxs); } } else @@ -248,8 +257,15 @@ static void Mod_MDLMD2MD3_TraceBox(model_t *model, int frame, trace_t *trace, co for (i = 0, surface = model->data_surfaces;i < model->num_surfaces;i++, surface++) { mesh = surface->groupmesh; - Mod_Alias_GetMesh_Vertex3f(model, frameblend, mesh, varray_vertex3f); - Collision_TraceBrushTriangleMeshFloat(trace, thisbrush_start, thisbrush_end, mesh->num_triangles, mesh->data_element3i, varray_vertex3f, SUPERCONTENTS_SOLID, segmentmins, segmentmaxs); + if (maxvertices < mesh->num_vertices) + { + if (vertex3f) + Z_Free(vertex3f); + maxvertices = (mesh->num_vertices + 255) & ~255; + vertex3f = Z_Malloc(maxvertices * sizeof(float[3])); + } + Mod_Alias_GetMesh_Vertex3f(model, frameblend, mesh, vertex3f); + Collision_TraceBrushTriangleMeshFloat(trace, thisbrush_start, thisbrush_end, mesh->num_triangles, mesh->data_element3i, vertex3f, SUPERCONTENTS_SOLID, segmentmins, segmentmaxs); } } } diff --git a/model_shared.c b/model_shared.c index 8fa9a53f..5277a4e7 100644 --- a/model_shared.c +++ b/model_shared.c @@ -169,7 +169,12 @@ model_t *Mod_LoadModel(model_t *mod, qboolean crash, qboolean checkdisk, qboolea } } if (mod->loaded) - return mod; // already loaded + { + // already loaded + if (buf) + Mem_Free(buf); + return mod; + } Con_DPrintf("loading model %s\n", mod->name); // LordHavoc: unload the existing model in this slot (if there is one) @@ -230,15 +235,6 @@ model_t *Mod_LoadModel(model_t *mod, qboolean crash, qboolean checkdisk, qboolea return mod; } -/* -=================== -Mod_ClearAll -=================== -*/ -void Mod_ClearAll(void) -{ -} - void Mod_ClearUsed(void) { #if 0 diff --git a/model_shared.h b/model_shared.h index 206c9c93..4d47eecd 100644 --- a/model_shared.h +++ b/model_shared.h @@ -603,7 +603,6 @@ extern cvar_t r_fullbrights; void Mod_Init (void); model_t *Mod_LoadModel(model_t *mod, qboolean crash, qboolean checkdisk, qboolean isworldmodel); -void Mod_ClearAll (void); model_t *Mod_FindName (const char *name); model_t *Mod_ForName (const char *name, qboolean crash, qboolean checkdisk, qboolean isworldmodel); void Mod_UnloadModel (model_t *mod); diff --git a/protocol.c b/protocol.c index 3899b23e..ad544396 100644 --- a/protocol.c +++ b/protocol.c @@ -1087,7 +1087,7 @@ void EntityFrame_CL_ReadFrame(void) entity_t *ent; entityframe_database_t *d; if (!cl.entitydatabase) - cl.entitydatabase = EntityFrame_AllocDatabase(cls.mempool); + cl.entitydatabase = EntityFrame_AllocDatabase(cls.levelmempool); d = cl.entitydatabase; EntityFrame_Clear(f, NULL, -1); @@ -1357,7 +1357,7 @@ void EntityFrame4_CL_ReadFrame(void) entity_state_t *s; entityframe4_database_t *d; if (!cl.entitydatabase4) - cl.entitydatabase4 = EntityFrame4_AllocDatabase(cls.mempool); + cl.entitydatabase4 = EntityFrame4_AllocDatabase(cls.levelmempool); d = cl.entitydatabase4; // read the number of the frame this refers to referenceframenum = MSG_ReadLong(); @@ -2594,7 +2594,7 @@ void EntityFrameQW_CL_ReadFrame(qboolean delta) entityframeqw_snapshot_t *oldsnap, *newsnap; if (!cl.entitydatabaseqw) - cl.entitydatabaseqw = EntityFrameQW_AllocDatabase(cls.mempool); + cl.entitydatabaseqw = EntityFrameQW_AllocDatabase(cls.levelmempool); d = cl.entitydatabaseqw; newsnapindex = cls.netcon->qw.incoming_sequence & QW_UPDATE_MASK; diff --git a/prvm_edict.c b/prvm_edict.c index 150d72c1..e79cc5f1 100644 --- a/prvm_edict.c +++ b/prvm_edict.c @@ -1259,7 +1259,8 @@ void PRVM_LoadLNO( const char *progname ) { SafeWrite (h, statement_linenums, numstatements*sizeof(int)); */ if( (unsigned) filesize < (6 + prog->progs->numstatements) * sizeof( int ) ) { - return; + Mem_Free(lno); + return; } header = (unsigned int *) lno; diff --git a/quakedef.h b/quakedef.h index 57d2e537..f5c4d74b 100644 --- a/quakedef.h +++ b/quakedef.h @@ -236,7 +236,6 @@ extern int host_framecount; // not bounded in any way, changed at start of every frame, never reset extern double realtime; -void Host_ClearMemory(void); void Host_InitCommands(void); void Host_Init(void); void Host_Shutdown(void); diff --git a/r_shadow.c b/r_shadow.c index 2f24300b..fce43378 100644 --- a/r_shadow.c +++ b/r_shadow.c @@ -159,11 +159,12 @@ r_shadow_rendermode_t r_shadow_rendermode = R_SHADOW_RENDERMODE_NONE; r_shadow_rendermode_t r_shadow_lightingrendermode = R_SHADOW_RENDERMODE_NONE; r_shadow_rendermode_t r_shadow_shadowingrendermode = R_SHADOW_RENDERMODE_NONE; -mempool_t *r_shadow_mempool; - -int maxshadowelements; +int maxshadowtriangles; int *shadowelements; +int maxshadowvertices; +float *shadowvertex3f; + int maxshadowmark; int numshadowmark; int *shadowmark; @@ -267,8 +268,10 @@ void r_shadow_start(void) r_shadow_filters_texturepool = NULL; R_Shadow_ValidateCvars(); R_Shadow_MakeTextures(); - maxshadowelements = 0; + maxshadowtriangles = 0; shadowelements = NULL; + maxshadowvertices = 0; + shadowvertex3f = NULL; maxvertexupdate = 0; vertexupdate = NULL; vertexremap = NULL; @@ -294,10 +297,13 @@ void r_shadow_shutdown(void) r_shadow_attenuation3dtexture = NULL; R_FreeTexturePool(&r_shadow_texturepool); R_FreeTexturePool(&r_shadow_filters_texturepool); - maxshadowelements = 0; + maxshadowtriangles = 0; if (shadowelements) Mem_Free(shadowelements); shadowelements = NULL; + if (shadowvertex3f) + Mem_Free(shadowvertex3f); + shadowvertex3f = NULL; maxvertexupdate = 0; if (vertexupdate) Mem_Free(vertexupdate); @@ -405,10 +411,11 @@ void R_Shadow_Init(void) } Cmd_AddCommand("r_shadow_help", R_Shadow_Help_f, "prints documentation on console commands and variables used by realtime lighting and shadowing system"); R_Shadow_EditLights_Init(); - r_shadow_mempool = Mem_AllocPool("R_Shadow", 0, NULL); r_shadow_worldlightchain = NULL; - maxshadowelements = 0; + maxshadowtriangles = 0; shadowelements = NULL; + maxshadowvertices = 0; + shadowvertex3f = NULL; maxvertexupdate = 0; vertexupdate = NULL; vertexremap = NULL; @@ -447,17 +454,24 @@ matrix4x4_t matrix_attenuationz = } }; -int *R_Shadow_ResizeShadowElements(int numtris) +void R_Shadow_ResizeShadowArrays(int numvertices, int numtriangles) { // make sure shadowelements is big enough for this volume - if (maxshadowelements < numtris * 24) + if (maxshadowtriangles < numtriangles) { - maxshadowelements = numtris * 24; + maxshadowtriangles = numtriangles; if (shadowelements) Mem_Free(shadowelements); - shadowelements = (int *)Mem_Alloc(r_shadow_mempool, maxshadowelements * sizeof(int)); + shadowelements = (int *)Mem_Alloc(r_main_mempool, maxshadowtriangles * sizeof(int[24])); + } + // make sure shadowvertex3f is big enough for this volume + if (maxshadowvertices < numvertices) + { + maxshadowvertices = numvertices; + if (shadowvertex3f) + Mem_Free(shadowvertex3f); + shadowvertex3f = (float *)Mem_Alloc(r_main_mempool, maxshadowvertices * sizeof(float[6])); } - return shadowelements; } static void R_Shadow_EnlargeLeafSurfaceBuffer(int numleafs, int numsurfaces) @@ -471,8 +485,8 @@ static void R_Shadow_EnlargeLeafSurfaceBuffer(int numleafs, int numsurfaces) if (r_shadow_buffer_leaflist) Mem_Free(r_shadow_buffer_leaflist); r_shadow_buffer_numleafpvsbytes = numleafpvsbytes; - r_shadow_buffer_leafpvs = (unsigned char *)Mem_Alloc(r_shadow_mempool, r_shadow_buffer_numleafpvsbytes); - r_shadow_buffer_leaflist = (int *)Mem_Alloc(r_shadow_mempool, r_shadow_buffer_numleafpvsbytes * 8 * sizeof(*r_shadow_buffer_leaflist)); + r_shadow_buffer_leafpvs = (unsigned char *)Mem_Alloc(r_main_mempool, r_shadow_buffer_numleafpvsbytes); + r_shadow_buffer_leaflist = (int *)Mem_Alloc(r_main_mempool, r_shadow_buffer_numleafpvsbytes * 8 * sizeof(*r_shadow_buffer_leaflist)); } if (r_shadow_buffer_numsurfacepvsbytes < numsurfacepvsbytes) { @@ -481,8 +495,8 @@ static void R_Shadow_EnlargeLeafSurfaceBuffer(int numleafs, int numsurfaces) if (r_shadow_buffer_surfacelist) Mem_Free(r_shadow_buffer_surfacelist); r_shadow_buffer_numsurfacepvsbytes = numsurfacepvsbytes; - r_shadow_buffer_surfacepvs = (unsigned char *)Mem_Alloc(r_shadow_mempool, r_shadow_buffer_numsurfacepvsbytes); - r_shadow_buffer_surfacelist = (int *)Mem_Alloc(r_shadow_mempool, r_shadow_buffer_numsurfacepvsbytes * 8 * sizeof(*r_shadow_buffer_surfacelist)); + r_shadow_buffer_surfacepvs = (unsigned char *)Mem_Alloc(r_main_mempool, r_shadow_buffer_numsurfacepvsbytes); + r_shadow_buffer_surfacelist = (int *)Mem_Alloc(r_main_mempool, r_shadow_buffer_numsurfacepvsbytes * 8 * sizeof(*r_shadow_buffer_surfacelist)); } } @@ -496,8 +510,8 @@ void R_Shadow_PrepareShadowMark(int numtris) Mem_Free(shadowmark); if (shadowmarklist) Mem_Free(shadowmarklist); - shadowmark = (int *)Mem_Alloc(r_shadow_mempool, maxshadowmark * sizeof(*shadowmark)); - shadowmarklist = (int *)Mem_Alloc(r_shadow_mempool, maxshadowmark * sizeof(*shadowmarklist)); + shadowmark = (int *)Mem_Alloc(r_main_mempool, maxshadowmark * sizeof(*shadowmark)); + shadowmarklist = (int *)Mem_Alloc(r_main_mempool, maxshadowmark * sizeof(*shadowmarklist)); shadowmarkcount = 0; } shadowmarkcount++; @@ -524,8 +538,8 @@ int R_Shadow_ConstructShadowVolume(int innumvertices, int innumtris, const int * Mem_Free(vertexupdate); if (vertexremap) Mem_Free(vertexremap); - vertexupdate = (int *)Mem_Alloc(r_shadow_mempool, maxvertexupdate * sizeof(int)); - vertexremap = (int *)Mem_Alloc(r_shadow_mempool, maxvertexupdate * sizeof(int)); + vertexupdate = (int *)Mem_Alloc(r_main_mempool, maxvertexupdate * sizeof(int)); + vertexremap = (int *)Mem_Alloc(r_main_mempool, maxvertexupdate * sizeof(int)); vertexupdatenum = 0; } vertexupdatenum++; @@ -642,11 +656,11 @@ void R_Shadow_VolumeFromList(int numverts, int numtris, const float *invertex3f, if (!numverts || !nummarktris) return; // make sure shadowelements is big enough for this volume - if (maxshadowelements < nummarktris * 24) - R_Shadow_ResizeShadowElements((nummarktris + 256) * 24); - tris = R_Shadow_ConstructShadowVolume(numverts, numtris, elements, neighbors, invertex3f, &outverts, shadowelements, varray_vertex3f2, projectorigin, projectdistance, nummarktris, marktris); + if (maxshadowtriangles < nummarktris || maxshadowvertices < numverts) + R_Shadow_ResizeShadowArrays((numverts + 255) & ~255, (nummarktris + 255) & ~255); + tris = R_Shadow_ConstructShadowVolume(numverts, numtris, elements, neighbors, invertex3f, &outverts, shadowelements, shadowvertex3f, projectorigin, projectdistance, nummarktris, marktris); renderstats.lights_dynamicshadowtriangles += tris; - R_Shadow_RenderVolume(outverts, tris, varray_vertex3f2, shadowelements); + R_Shadow_RenderVolume(outverts, tris, shadowvertex3f, shadowelements); } void R_Shadow_MarkVolumeFromBox(int firsttriangle, int numtris, const float *invertex3f, const int *elements, const vec3_t projectorigin, const vec3_t lightmins, const vec3_t lightmaxs, const vec3_t surfacemins, const vec3_t surfacemaxs) @@ -692,7 +706,7 @@ void R_Shadow_RenderVolume(int numvertices, int numtriangles, const float *verte if (r_shadow_compilingrtlight) { // if we're compiling an rtlight, capture the mesh - Mod_ShadowMesh_AddMesh(r_shadow_mempool, r_shadow_compilingrtlight->static_meshchain_shadow, NULL, NULL, NULL, vertex3f, NULL, NULL, NULL, NULL, numtriangles, element3i); + Mod_ShadowMesh_AddMesh(r_main_mempool, r_shadow_compilingrtlight->static_meshchain_shadow, NULL, NULL, NULL, vertex3f, NULL, NULL, NULL, NULL, numtriangles, element3i); return; } renderstats.lights_shadowtriangles += numtriangles; @@ -928,9 +942,6 @@ void R_Shadow_RenderMode_Lighting(qboolean stenciltest, qboolean transparent) // do global setup needed for the chosen lighting mode if (r_shadow_rendermode == R_SHADOW_RENDERMODE_LIGHT_GLSL) { - R_Mesh_TexCoordPointer(1, 3, varray_svector3f); - R_Mesh_TexCoordPointer(2, 3, varray_tvector3f); - R_Mesh_TexCoordPointer(3, 3, varray_normal3f); R_Mesh_TexBind(0, R_GetTexture(r_texture_blanknormalmap)); // normal R_Mesh_TexBind(1, R_GetTexture(r_texture_white)); // diffuse R_Mesh_TexBind(2, R_GetTexture(r_texture_white)); // gloss @@ -1111,7 +1122,7 @@ static void R_Shadow_RenderSurfacesLighting_Light_Vertex_Shading(const msurface_ int numverts = surface->num_vertices; float *vertex3f = rsurface_vertex3f + 3 * surface->num_firstvertex; float *normal3f = rsurface_normal3f + 3 * surface->num_firstvertex; - float *color4f = varray_color4f + 4 * surface->num_firstvertex; + float *color4f = rsurface_array_color4f + 4 * surface->num_firstvertex; float dist, dot, distintensity, shadeintensity, v[3], n[3]; if (r_textureunits.integer >= 3) { @@ -1427,8 +1438,8 @@ static void R_Shadow_RenderSurfacesLighting_Light_Dot3_DiffusePass(const entity_ m.texmatrix[0] = texture->currenttexmatrix; m.texcubemap[1] = R_GetTexture(r_texture_normalizationcube); m.texcombinergb[1] = GL_DOT3_RGBA_ARB; - m.pointer_texcoord3f[1] = varray_texcoord3f; - R_Shadow_GenTexCoords_Diffuse_NormalCubeMap(varray_texcoord3f + 3 * surface->num_firstvertex, surface->num_vertices, rsurface_vertex3f + 3 * surface->num_firstvertex, rsurface_svector3f + 3 * surface->num_firstvertex, rsurface_tvector3f + 3 * surface->num_firstvertex, rsurface_normal3f + 3 * surface->num_firstvertex, r_shadow_entitylightorigin); + m.pointer_texcoord3f[1] = rsurface_array_texcoord3f; + R_Shadow_GenTexCoords_Diffuse_NormalCubeMap(rsurface_array_texcoord3f + 3 * surface->num_firstvertex, surface->num_vertices, rsurface_vertex3f + 3 * surface->num_firstvertex, rsurface_svector3f + 3 * surface->num_firstvertex, rsurface_tvector3f + 3 * surface->num_firstvertex, rsurface_normal3f + 3 * surface->num_firstvertex, r_shadow_entitylightorigin); m.tex3d[2] = R_GetTexture(r_shadow_attenuation3dtexture); m.pointer_texcoord3f[2] = rsurface_vertex3f; m.texmatrix[2] = r_shadow_entitytoattenuationxyz; @@ -1475,8 +1486,8 @@ static void R_Shadow_RenderSurfacesLighting_Light_Dot3_DiffusePass(const entity_ m.texmatrix[0] = texture->currenttexmatrix; m.texcubemap[1] = R_GetTexture(r_texture_normalizationcube); m.texcombinergb[1] = GL_DOT3_RGBA_ARB; - m.pointer_texcoord3f[1] = varray_texcoord3f; - R_Shadow_GenTexCoords_Diffuse_NormalCubeMap(varray_texcoord3f + 3 * surface->num_firstvertex, surface->num_vertices, rsurface_vertex3f + 3 * surface->num_firstvertex, rsurface_svector3f + 3 * surface->num_firstvertex, rsurface_tvector3f + 3 * surface->num_firstvertex, rsurface_normal3f + 3 * surface->num_firstvertex, r_shadow_entitylightorigin); + m.pointer_texcoord3f[1] = rsurface_array_texcoord3f; + R_Shadow_GenTexCoords_Diffuse_NormalCubeMap(rsurface_array_texcoord3f + 3 * surface->num_firstvertex, surface->num_vertices, rsurface_vertex3f + 3 * surface->num_firstvertex, rsurface_svector3f + 3 * surface->num_firstvertex, rsurface_tvector3f + 3 * surface->num_firstvertex, rsurface_normal3f + 3 * surface->num_firstvertex, r_shadow_entitylightorigin); R_Mesh_State(&m); GL_BlendFunc(GL_DST_ALPHA, GL_ZERO); GL_LockArrays(surface->num_firstvertex, surface->num_vertices); @@ -1507,8 +1518,8 @@ static void R_Shadow_RenderSurfacesLighting_Light_Dot3_DiffusePass(const entity_ m.texmatrix[0] = texture->currenttexmatrix; m.texcubemap[1] = R_GetTexture(r_texture_normalizationcube); m.texcombinergb[1] = GL_DOT3_RGBA_ARB; - m.pointer_texcoord3f[1] = varray_texcoord3f; - R_Shadow_GenTexCoords_Diffuse_NormalCubeMap(varray_texcoord3f + 3 * surface->num_firstvertex, surface->num_vertices, rsurface_vertex3f + 3 * surface->num_firstvertex, rsurface_svector3f + 3 * surface->num_firstvertex, rsurface_tvector3f + 3 * surface->num_firstvertex, rsurface_normal3f + 3 * surface->num_firstvertex, r_shadow_entitylightorigin); + m.pointer_texcoord3f[1] = rsurface_array_texcoord3f; + R_Shadow_GenTexCoords_Diffuse_NormalCubeMap(rsurface_array_texcoord3f + 3 * surface->num_firstvertex, surface->num_vertices, rsurface_vertex3f + 3 * surface->num_firstvertex, rsurface_svector3f + 3 * surface->num_firstvertex, rsurface_tvector3f + 3 * surface->num_firstvertex, rsurface_normal3f + 3 * surface->num_firstvertex, r_shadow_entitylightorigin); R_Mesh_State(&m); GL_ColorMask(0,0,0,1); GL_BlendFunc(GL_ONE, GL_ZERO); @@ -1537,8 +1548,8 @@ static void R_Shadow_RenderSurfacesLighting_Light_Dot3_DiffusePass(const entity_ m.texmatrix[0] = texture->currenttexmatrix; m.texcubemap[1] = R_GetTexture(r_texture_normalizationcube); m.texcombinergb[1] = GL_DOT3_RGBA_ARB; - m.pointer_texcoord3f[1] = varray_texcoord3f; - R_Shadow_GenTexCoords_Diffuse_NormalCubeMap(varray_texcoord3f + 3 * surface->num_firstvertex, surface->num_vertices, rsurface_vertex3f + 3 * surface->num_firstvertex, rsurface_svector3f + 3 * surface->num_firstvertex, rsurface_tvector3f + 3 * surface->num_firstvertex, rsurface_normal3f + 3 * surface->num_firstvertex, r_shadow_entitylightorigin); + m.pointer_texcoord3f[1] = rsurface_array_texcoord3f; + R_Shadow_GenTexCoords_Diffuse_NormalCubeMap(rsurface_array_texcoord3f + 3 * surface->num_firstvertex, surface->num_vertices, rsurface_vertex3f + 3 * surface->num_firstvertex, rsurface_svector3f + 3 * surface->num_firstvertex, rsurface_tvector3f + 3 * surface->num_firstvertex, rsurface_normal3f + 3 * surface->num_firstvertex, r_shadow_entitylightorigin); m.tex[2] = R_GetTexture(r_shadow_attenuation2dtexture); m.pointer_texcoord3f[2] = rsurface_vertex3f; m.texmatrix[2] = r_shadow_entitytoattenuationxyz; @@ -1591,8 +1602,8 @@ static void R_Shadow_RenderSurfacesLighting_Light_Dot3_DiffusePass(const entity_ m.texmatrix[0] = texture->currenttexmatrix; m.texcubemap[1] = R_GetTexture(r_texture_normalizationcube); m.texcombinergb[1] = GL_DOT3_RGBA_ARB; - m.pointer_texcoord3f[1] = varray_texcoord3f; - R_Shadow_GenTexCoords_Diffuse_NormalCubeMap(varray_texcoord3f + 3 * surface->num_firstvertex, surface->num_vertices, rsurface_vertex3f + 3 * surface->num_firstvertex, rsurface_svector3f + 3 * surface->num_firstvertex, rsurface_tvector3f + 3 * surface->num_firstvertex, rsurface_normal3f + 3 * surface->num_firstvertex, r_shadow_entitylightorigin); + m.pointer_texcoord3f[1] = rsurface_array_texcoord3f; + R_Shadow_GenTexCoords_Diffuse_NormalCubeMap(rsurface_array_texcoord3f + 3 * surface->num_firstvertex, surface->num_vertices, rsurface_vertex3f + 3 * surface->num_firstvertex, rsurface_svector3f + 3 * surface->num_firstvertex, rsurface_tvector3f + 3 * surface->num_firstvertex, rsurface_normal3f + 3 * surface->num_firstvertex, r_shadow_entitylightorigin); R_Mesh_State(&m); GL_BlendFunc(GL_DST_ALPHA, GL_ZERO); GL_LockArrays(surface->num_firstvertex, surface->num_vertices); @@ -1645,8 +1656,8 @@ static void R_Shadow_RenderSurfacesLighting_Light_Dot3_SpecularPass(const entity m.texmatrix[0] = texture->currenttexmatrix; m.texcubemap[1] = R_GetTexture(r_texture_normalizationcube); m.texcombinergb[1] = GL_DOT3_RGBA_ARB; - m.pointer_texcoord3f[1] = varray_texcoord3f; - R_Shadow_GenTexCoords_Specular_NormalCubeMap(varray_texcoord3f + 3 * surface->num_firstvertex, surface->num_vertices, rsurface_vertex3f + 3 * surface->num_firstvertex, rsurface_svector3f + 3 * surface->num_firstvertex, rsurface_tvector3f + 3 * surface->num_firstvertex, rsurface_normal3f + 3 * surface->num_firstvertex, r_shadow_entitylightorigin, r_shadow_entityeyeorigin); + m.pointer_texcoord3f[1] = rsurface_array_texcoord3f; + R_Shadow_GenTexCoords_Specular_NormalCubeMap(rsurface_array_texcoord3f + 3 * surface->num_firstvertex, surface->num_vertices, rsurface_vertex3f + 3 * surface->num_firstvertex, rsurface_svector3f + 3 * surface->num_firstvertex, rsurface_tvector3f + 3 * surface->num_firstvertex, rsurface_normal3f + 3 * surface->num_firstvertex, r_shadow_entitylightorigin, r_shadow_entityeyeorigin); R_Mesh_State(&m); GL_ColorMask(0,0,0,1); // this squares the result @@ -1703,8 +1714,8 @@ static void R_Shadow_RenderSurfacesLighting_Light_Dot3_SpecularPass(const entity m.texmatrix[0] = texture->currenttexmatrix; m.texcubemap[1] = R_GetTexture(r_texture_normalizationcube); m.texcombinergb[1] = GL_DOT3_RGBA_ARB; - m.pointer_texcoord3f[1] = varray_texcoord3f; - R_Shadow_GenTexCoords_Specular_NormalCubeMap(varray_texcoord3f + 3 * surface->num_firstvertex, surface->num_vertices, rsurface_vertex3f + 3 * surface->num_firstvertex, rsurface_svector3f + 3 * surface->num_firstvertex, rsurface_tvector3f + 3 * surface->num_firstvertex, rsurface_normal3f + 3 * surface->num_firstvertex, r_shadow_entitylightorigin, r_shadow_entityeyeorigin); + m.pointer_texcoord3f[1] = rsurface_array_texcoord3f; + R_Shadow_GenTexCoords_Specular_NormalCubeMap(rsurface_array_texcoord3f + 3 * surface->num_firstvertex, surface->num_vertices, rsurface_vertex3f + 3 * surface->num_firstvertex, rsurface_svector3f + 3 * surface->num_firstvertex, rsurface_tvector3f + 3 * surface->num_firstvertex, rsurface_normal3f + 3 * surface->num_firstvertex, r_shadow_entitylightorigin, r_shadow_entityeyeorigin); R_Mesh_State(&m); GL_ColorMask(0,0,0,1); // this squares the result @@ -1747,8 +1758,8 @@ static void R_Shadow_RenderSurfacesLighting_Light_Dot3_SpecularPass(const entity m.texmatrix[0] = texture->currenttexmatrix; m.texcubemap[1] = R_GetTexture(r_texture_normalizationcube); m.texcombinergb[1] = GL_DOT3_RGBA_ARB; - m.pointer_texcoord3f[1] = varray_texcoord3f; - R_Shadow_GenTexCoords_Specular_NormalCubeMap(varray_texcoord3f + 3 * surface->num_firstvertex, surface->num_vertices, rsurface_vertex3f + 3 * surface->num_firstvertex, rsurface_svector3f + 3 * surface->num_firstvertex, rsurface_tvector3f + 3 * surface->num_firstvertex, rsurface_normal3f + 3 * surface->num_firstvertex, r_shadow_entitylightorigin, r_shadow_entityeyeorigin); + m.pointer_texcoord3f[1] = rsurface_array_texcoord3f; + R_Shadow_GenTexCoords_Specular_NormalCubeMap(rsurface_array_texcoord3f + 3 * surface->num_firstvertex, surface->num_vertices, rsurface_vertex3f + 3 * surface->num_firstvertex, rsurface_svector3f + 3 * surface->num_firstvertex, rsurface_tvector3f + 3 * surface->num_firstvertex, rsurface_normal3f + 3 * surface->num_firstvertex, r_shadow_entitylightorigin, r_shadow_entityeyeorigin); R_Mesh_State(&m); GL_ColorMask(0,0,0,1); // this squares the result @@ -1877,7 +1888,7 @@ void R_Shadow_RenderSurfacesLighting_Light_Vertex_Pass(const msurface_t *surface newnumtriangles = 0; newe = newelements; } - if (VectorLength2(varray_color4f + e[0] * 4) + VectorLength2(varray_color4f + e[1] * 4) + VectorLength2(varray_color4f + e[2] * 4) >= 0.01) + if (VectorLength2(rsurface_array_color4f + e[0] * 4) + VectorLength2(rsurface_array_color4f + e[1] * 4) + VectorLength2(rsurface_array_color4f + e[2] * 4) >= 0.01) { newe[0] = e[0]; newe[1] = e[1]; @@ -1897,7 +1908,7 @@ void R_Shadow_RenderSurfacesLighting_Light_Vertex_Pass(const msurface_t *surface if (!draw) break; #else - for (i = 0, c = varray_color4f + 4 * surface->num_firstvertex;i < surface->num_vertices;i++, c += 4) + for (i = 0, c = rsurface_array_color4f + 4 * surface->num_firstvertex;i < surface->num_vertices;i++, c += 4) if (VectorLength2(c)) goto goodpass; break; @@ -1907,7 +1918,7 @@ goodpass: GL_LockArrays(0, 0); #endif // now reduce the intensity for the next overbright pass - for (i = 0, c = varray_color4f + 4 * surface->num_firstvertex;i < surface->num_vertices;i++, c += 4) + for (i = 0, c = rsurface_array_color4f + 4 * surface->num_firstvertex;i < surface->num_vertices;i++, c += 4) { c[0] = max(0, c[0] - 1); c[1] = max(0, c[1] - 1); @@ -1944,7 +1955,7 @@ static void R_Shadow_RenderSurfacesLighting_Light_Vertex(const entity_render_t * m.texmatrix[2] = r_shadow_entitytoattenuationz; } } - m.pointer_color = varray_color4f; + m.pointer_color = rsurface_array_color4f; R_Mesh_State(&m); for (surfacelistindex = 0;surfacelistindex < numsurfaces;surfacelistindex++) { @@ -2127,7 +2138,7 @@ void R_RTLight_Compile(rtlight_t *rtlight) R_Shadow_EnlargeLeafSurfaceBuffer(model->brush.num_leafs, model->num_surfaces); model->GetLightInfo(ent, rtlight->shadoworigin, rtlight->radius, rtlight->cullmins, rtlight->cullmaxs, r_shadow_buffer_leaflist, r_shadow_buffer_leafpvs, &numleafs, r_shadow_buffer_surfacelist, r_shadow_buffer_surfacepvs, &numsurfaces); numleafpvsbytes = (model->brush.num_leafs + 7) >> 3; - data = (unsigned char *)Mem_Alloc(r_shadow_mempool, sizeof(int) * numleafs + numleafpvsbytes + sizeof(int) * numsurfaces); + data = (unsigned char *)Mem_Alloc(r_main_mempool, sizeof(int) * numleafs + numleafpvsbytes + sizeof(int) * numsurfaces); rtlight->static_numleafs = numleafs; rtlight->static_numleafpvsbytes = numleafpvsbytes; rtlight->static_leaflist = (int *)data;data += sizeof(int) * numleafs; @@ -2587,7 +2598,7 @@ void R_Shadow_FreeCubemaps(void) dlight_t *R_Shadow_NewWorldLight(void) { dlight_t *light; - light = (dlight_t *)Mem_Alloc(r_shadow_mempool, sizeof(dlight_t)); + light = (dlight_t *)Mem_Alloc(r_main_mempool, sizeof(dlight_t)); light->next = r_shadow_worldlightchain; r_shadow_worldlightchain = light; return light; diff --git a/r_shadow.h b/r_shadow.h index cce21858..9181da99 100644 --- a/r_shadow.h +++ b/r_shadow.h @@ -29,8 +29,6 @@ extern cvar_t r_shadow_singlepassvolumegeneration; extern cvar_t r_shadow_texture3d; extern cvar_t gl_ext_stenciltwoside; -extern mempool_t *r_shadow_mempool; - void R_Shadow_Init(void); void R_Shadow_VolumeFromList(int numverts, int numtris, const float *invertex3f, const int *elements, const int *neighbors, const vec3_t projectorigin, float projectdistance, int nummarktris, const int *marktris); void R_Shadow_MarkVolumeFromBox(int firsttriangle, int numtris, const float *invertex3f, const int *elements, const vec3_t projectorigin, const vec3_t lightmins, const vec3_t lightmaxs, const vec3_t surfacemins, const vec3_t surfacemaxs); diff --git a/render.h b/render.h index ae732c04..faee70b5 100644 --- a/render.h +++ b/render.h @@ -258,6 +258,18 @@ void R_Draw2DCrosshair(void); void R_CalcBeam_Vertex3f(float *vert, const vec3_t org1, const vec3_t org2, float width); void R_DrawSprite(int blendfunc1, int blendfunc2, rtexture_t *texture, rtexture_t *fogtexture, int depthdisable, const vec3_t origin, const vec3_t left, const vec3_t up, float scalex1, float scalex2, float scaley1, float scaley2, float cr, float cg, float cb, float ca); +extern mempool_t *r_main_mempool; + +extern int rsurface_array_size; +extern float *rsurface_array_vertex3f; +extern float *rsurface_array_svector3f; +extern float *rsurface_array_tvector3f; +extern float *rsurface_array_normal3f; +extern float *rsurface_array_color4f; +extern float *rsurface_array_texcoord3f; + +void R_Mesh_ResizeArrays(int newvertices); + struct entity_render_s; struct texture_s; struct msurface_s; diff --git a/sv_main.c b/sv_main.c index 648e107b..e6ce9942 100644 --- a/sv_main.c +++ b/sv_main.c @@ -1702,8 +1702,6 @@ void SV_SpawnServer (const char *server) // // set up the new server // - Host_ClearMemory (); - memset (&sv, 0, sizeof(sv)); SV_VM_Setup(); @@ -1828,10 +1826,7 @@ void SV_SpawnServer (const char *server) } // load replacement entity file if found - entities = NULL; - if (sv_entpatch.integer) - entities = (char *)FS_LoadFile(va("maps/%s.ent", sv.name), tempmempool, true, NULL); - if (entities) + if (sv_entpatch.integer && (entities = (char *)FS_LoadFile(va("maps/%s.ent", sv.name), tempmempool, true, NULL))) { Con_Printf("Loaded maps/%s.ent\n", sv.name); PRVM_ED_LoadFromFile (entities); diff --git a/todo b/todo index 4ba10a29..0bdc8ea4 100644 --- a/todo +++ b/todo @@ -43,10 +43,12 @@ 0 bug darkplaces client: cl_movement 0 shouldn't be doing an input replay (SavageX) 0 bug darkplaces client: fix cl_bobmodel bug which momentarily jolts the gun when you pass through a trigger, pick up an item, etc, Sajt thinks this is related to console prints as well as centerprint (Sajt) 0 bug darkplaces client: prydon cursor highlighting of EF_SELECTABLE entities flickers with lower server framerate than client framerate (carni) +0 bug darkplaces csqc: after the drawqueue was eliminated, the CSQC probably can't draw 2D polygons the same way, so it may need fixing ([515]) 0 bug darkplaces csqc: engine-based rocket entities have a trail but they don't glow if csqc is used 0 bug darkplaces loader: make rtlight entity loader support q3map/q3map2 lights properly, they use a spawnflag for LINEAR mode, by default they use 1/(x*x) falloff (Carni, motorsep) 0 bug darkplaces loader: occasional crash due to memory corruption when doing "deathmatch 1;map start" during demo loop (Willis) 0 bug darkplaces renderer: glsl lighting path is not using GL_SRC_ALPHA, GL_ONE +0 bug darkplaces renderer: in full rtlighting mode, deluxemapping gloss still shows up (the diffuse and ambient does not) 0 bug darkplaces renderer: modify r_showtris_polygonoffset to push back all filled geometry, not lines, because polygonoffset will not affect GL_LINES at all 0 bug darkplaces renderer: monsters teleporting in really slow down rendering, perhaps the teleport light is casting huge shadows? new information suggests it is the particles. (romi, lcatlnx) 0 bug darkplaces renderer: r_glsl 1 mode has black grapple beam in nexuiz (SavageX) @@ -92,6 +94,7 @@ 0 change darkplaces renderer: rename r_drawportals to r_showportals, and move its declaration to gl_rmain.c 0 change darkplaces server: make viewmodel code precache a new model and set it, rather than changing the meaning of the player model 0 change darkplaces server: support sys_ticrate 0 as variable framerate mode +0 change dpmod: stop using playernogun/playergun models, go back to ordinary player.mdl, this saves a bit of memory 0 change zmodel: include the example script in the build zips, not just in the files directory 0 cleanup darkplaces cleanup: remove cgame* files and any references 0 cleanup darkplaces cleanup: remove ui.* files and any references diff --git a/wad.c b/wad.c index 3418f3c6..7087ce69 100644 --- a/wad.c +++ b/wad.c @@ -76,7 +76,7 @@ void *W_GetLumpName(const char *name) if (!wad_loaded) { wad_loaded = true; - if ((wad_base = FS_LoadFile ("gfx.wad", cls.mempool, false, &filesize))) + if ((wad_base = FS_LoadFile ("gfx.wad", cls.permanentmempool, false, &filesize))) { if (memcmp(wad_base, "WAD2", 4)) { diff --git a/zone.c b/zone.c index 1065ab7d..92cf1f35 100644 --- a/zone.c +++ b/zone.c @@ -413,7 +413,7 @@ void Mem_PrintStats(void) } } -void Mem_PrintList(int listallocations) +void Mem_PrintList(size_t minallocationsize) { mempool_t *pool; memheader_t *mem; @@ -424,8 +424,8 @@ void Mem_PrintList(int listallocations) { Con_Printf("%10luk (%10luk actual) %s (%+li byte change) %s\n", (unsigned long) ((pool->totalsize + 1023) / 1024), (unsigned long)((pool->realsize + 1023) / 1024), pool->name, (long)pool->totalsize - pool->lastchecksize, (pool->flags & POOLFLAG_TEMP) ? "TEMP" : ""); pool->lastchecksize = pool->totalsize; - if (listallocations) - for (mem = pool->chain;mem;mem = mem->next) + for (mem = pool->chain;mem;mem = mem->next) + if (mem->size >= minallocationsize) Con_Printf("%10lu bytes allocated at %s:%i\n", (unsigned long)mem->size, mem->filename, mem->fileline); } } @@ -435,17 +435,13 @@ void MemList_f(void) switch(Cmd_Argc()) { case 1: - Mem_PrintList(false); + Mem_PrintList(1<<30); Mem_PrintStats(); break; case 2: - if (!strcmp(Cmd_Argv(1), "all")) - { - Mem_PrintList(true); - Mem_PrintStats(); - break; - } - // drop through + Mem_PrintList(atoi(Cmd_Argv(1)) * 1024); + Mem_PrintStats(); + break; default: Con_Print("MemList_f: unrecognized options\nusage: memlist [all]\n"); break; @@ -482,7 +478,7 @@ void Memory_Shutdown (void) void Memory_Init_Commands (void) { Cmd_AddCommand ("memstats", MemStats_f, "prints memory system statistics"); - Cmd_AddCommand ("memlist", MemList_f, "prints memory pool information (and individual allocations if used as memlist all)"); + Cmd_AddCommand ("memlist", MemList_f, "prints memory pool information (or if used as memlist 5 lists individual allocations of 5K or larger, 0 lists all allocations)"); Cvar_RegisterVariable (&developer_memory); Cvar_RegisterVariable (&developer_memorydebug); }