GLQuake Memory Saving
Posted: Tue Jun 15, 2010 10:03 pm
GLQuake is very wasteful on memory. Here we're going to start saving some. This not only reduces overhead on Quake's Hunk memory (meaning that you can fit more stuff, bigger maps, etc in there), but will also speed up map loading times!
The first set of changes are in the texture loader. Break open gl_model.c and change the following.
In Mod_LoadTextures, replace:
with
remove
change
to
change
to
Now on to the render.h changes.
change
to
And lastly the gl_warp.c changes
replace
with
All we're doing here is avoiding allocating the texels from the BSP on the hunk. They're only ever used in the texture loader, so why waste perfectly good memory that could be put to better use holding something else? Also good for the PSP people trying to squeeze Quake into 32 MB. 
The saving for this one? I loaded e1m3, before was 421104 bytes for textures, after was 4992 bytes. That's almost half a MB wasted in stock GLQuake.
The first set of changes are in the texture loader. Break open gl_model.c and change the following.
In Mod_LoadTextures, replace:
Code: Select all
tx = Hunk_AllocName (sizeof(texture_t) +pixels, loadname );Code: Select all
tx = Hunk_AllocName (sizeof(texture_t), loadname );Code: Select all
// the pixels immediately follow the structures
memcpy ( tx+1, mt+1, pixels);Code: Select all
tx->gl_texturenum = GL_LoadTexture (mt->name, tx->width, tx->height, (byte *)(tx+1), true, false);Code: Select all
tx->gl_texturenum = GL_LoadTexture (mt->name, tx->width, tx->height, (byte *)(mt+1), true, false);Code: Select all
R_InitSky (tx);Code: Select all
R_InitSky (mt);change
Code: Select all
void R_InitSky (struct texture_s *mt); // called at level loadCode: Select all
void R_InitSky (struct miptex_s *mt); // called at level loadreplace
Code: Select all
void R_InitSky (texture_t *mt)Code: Select all
void R_InitSky (miptex_t *mt)The saving for this one? I loaded e1m3, before was 421104 bytes for textures, after was 4992 bytes. That's almost half a MB wasted in stock GLQuake.