From b2980c1b70bd2c5a643d704a68a4868a06dbcaf6 Mon Sep 17 00:00:00 2001 From: havoc Date: Fri, 8 Jan 2010 08:53:30 +0000 Subject: [PATCH] more memory savings git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@9813 d7cf8633-e32d-0410-b094-e92efae38249 --- cl_main.c | 14 +++++++------- cl_particles.c | 11 ++++------- quakedef.h | 18 ++++++++++++++++++ 3 files changed, 29 insertions(+), 14 deletions(-) diff --git a/cl_main.c b/cl_main.c index 75239c08..6553fce1 100644 --- a/cl_main.c +++ b/cl_main.c @@ -133,15 +133,15 @@ void CL_ClearState(void) // tweak these if the game runs out cl.max_csqcrenderentities = 0; - cl.max_entities = 256; - cl.max_static_entities = 256; - cl.max_effects = 256; - cl.max_beams = 256; + cl.max_entities = MAX_ENITIES_INITIAL; + cl.max_static_entities = MAX_STATICENTITIES; + cl.max_effects = MAX_EFFECTS; + cl.max_beams = MAX_BEAMS; cl.max_dlights = MAX_DLIGHTS; cl.max_lightstyle = MAX_LIGHTSTYLES; cl.max_brushmodel_entities = MAX_EDICTS; - cl.max_particles = 8192; // grows dynamically - cl.max_decals = 2048; // grows dynamically + cl.max_particles = MAX_PARTICLES_INITIAL; // grows dynamically + cl.max_decals = MAX_DECALS_INITIAL; // grows dynamically cl.max_showlmps = 0; cl.num_dlights = 0; @@ -2309,7 +2309,7 @@ void CL_Init (void) r_refdef.scene.maxentities = MAX_EDICTS + 256 + 512; r_refdef.scene.entities = (entity_render_t **)Mem_Alloc(cls.permanentmempool, sizeof(entity_render_t *) * r_refdef.scene.maxentities); - r_refdef.scene.maxtempentities = 4096; // FIXME: make this grow + r_refdef.scene.maxtempentities = MAX_TEMPENTITIES; // FIXME: make this grow r_refdef.scene.tempentities = (entity_render_t *)Mem_Alloc(cls.permanentmempool, sizeof(entity_render_t) * r_refdef.scene.maxtempentities); CL_InitInput (); diff --git a/cl_particles.c b/cl_particles.c index 1fb4623c..5229124a 100644 --- a/cl_particles.c +++ b/cl_particles.c @@ -24,9 +24,6 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include "image.h" #include "r_shadow.h" -#define ABSOLUTE_MAX_PARTICLES 1<<24 // upper limit on cl.max_particles -#define ABSOLUTE_MAX_DECALS 1<<24 // upper limit on cl.max_decals - // must match ptype_t values particletype_t particletype[pt_total] = { @@ -2353,10 +2350,10 @@ killdecal: while (cl.num_decals > 0 && cl.decals[cl.num_decals - 1].typeindex == 0) cl.num_decals--; - if (cl.num_decals == cl.max_decals && cl.max_decals < ABSOLUTE_MAX_DECALS) + if (cl.num_decals == cl.max_decals && cl.max_decals < MAX_DECALS) { decal_t *olddecals = cl.decals; - cl.max_decals = min(cl.max_decals * 2, ABSOLUTE_MAX_DECALS); + cl.max_decals = min(cl.max_decals * 2, MAX_DECALS); cl.decals = (decal_t *) Mem_Alloc(cls.levelmempool, cl.max_decals * sizeof(decal_t)); memcpy(cl.decals, olddecals, cl.num_decals * sizeof(decal_t)); Mem_Free(olddecals); @@ -2810,10 +2807,10 @@ killparticle: while (cl.num_particles > 0 && cl.particles[cl.num_particles - 1].typeindex == 0) cl.num_particles--; - if (cl.num_particles == cl.max_particles && cl.max_particles < ABSOLUTE_MAX_PARTICLES) + if (cl.num_particles == cl.max_particles && cl.max_particles < MAX_PARTICLES) { particle_t *oldparticles = cl.particles; - cl.max_particles = min(cl.max_particles * 2, ABSOLUTE_MAX_PARTICLES); + cl.max_particles = min(cl.max_particles * 2, MAX_PARTICLES); cl.particles = (particle_t *) Mem_Alloc(cls.levelmempool, cl.max_particles * sizeof(particle_t)); memcpy(cl.particles, oldparticles, cl.num_particles * sizeof(particle_t)); Mem_Free(oldparticles); diff --git a/quakedef.h b/quakedef.h index 61fe80c2..4c75fc10 100644 --- a/quakedef.h +++ b/quakedef.h @@ -109,6 +109,15 @@ extern char engineversion[128]; #define MAX_DECALSYSTEM_QUEUE 64 #define PAINTBUFFER_SIZE 512 #define MAX_BINDMAPS 8 +#define MAX_PARTICLES_INITIAL 32768 +#define MAX_PARTICLES 32768 +#define MAX_DECALS_INITIAL 1024 +#define MAX_DECALS 1024 +#define MAX_ENITIES_INITIAL 256 +#define MAX_STATICENTITIES 256 +#define MAX_EFFECTS 16 +#define MAX_BEAMS 16 +#define MAX_TEMPENTITIES 256 #else #define MAX_INPUTLINE 16384 ///< maximum length of console commandline, QuakeC strings, and many other text processing buffers #define CON_TEXTSIZE 1048576 ///< max scrollback buffer characters in console @@ -166,6 +175,15 @@ extern char engineversion[128]; #define MAX_DECALSYSTEM_QUEUE 1024 #define PAINTBUFFER_SIZE 2048 #define MAX_BINDMAPS 8 +#define MAX_PARTICLES_INITIAL 8192 ///< initial allocation for cl.particles +#define MAX_PARTICLES 1048576 ///< upper limit on cl.particles size +#define MAX_DECALS_INITIAL 8192 ///< initial allocation for cl.decals +#define MAX_DECALS 1048576 ///< upper limit on cl.decals size +#define MAX_ENITIES_INITIAL 256 ///< initial size of cl.entities +#define MAX_STATICENTITIES 256 ///< limit on size of cl.static_entities +#define MAX_EFFECTS 256 ///< limit on size of cl.effects +#define MAX_BEAMS 256 ///< limit on size of cl.beams +#define MAX_TEMPENTITIES 4096 ///< max number of temporary models visible per frame (certain sprite effects, certain types of CSQC entities also use this) #endif -- 2.39.2