View previous topic :: View next topic |
Author |
Message |
mh

Joined: 12 Jan 2008 Posts: 909
|
Posted: Tue Jun 15, 2010 10:03 pm Post subject: GLQuake Memory Saving |
|
|
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:
Code: | tx = Hunk_AllocName (sizeof(texture_t) +pixels, loadname ); |
with
Code: | tx = Hunk_AllocName (sizeof(texture_t), loadname ); |
remove
Code: | // the pixels immediately follow the structures
memcpy ( tx+1, mt+1, pixels); |
change
Code: | tx->gl_texturenum = GL_LoadTexture (mt->name, tx->width, tx->height, (byte *)(tx+1), true, false); |
to
Code: | tx->gl_texturenum = GL_LoadTexture (mt->name, tx->width, tx->height, (byte *)(mt+1), true, false); |
change
to
Now on to the render.h changes.
change
Code: | void R_InitSky (struct texture_s *mt); // called at level load |
to
Code: | void R_InitSky (struct miptex_s *mt); // called at level load |
And lastly the gl_warp.c changes
replace
Code: | void R_InitSky (texture_t *mt) |
with
Code: | void R_InitSky (miptex_t *mt) |
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. _________________ DirectQ Engine - New release 1.8.666a, 9th August 2010
MHQuake Blog (General)
Direct3D 8 Quake Engines
Last edited by mh on Tue Jun 15, 2010 10:13 pm; edited 1 time in total |
|
Back to top |
|
 |
Downsider

Joined: 16 Sep 2008 Posts: 478
|
Posted: Tue Jun 15, 2010 10:06 pm Post subject: Re: GLQuake Memory Saving |
|
|
mh wrote: |
In Mod_LoadTextures, replace:
Code: | tx = Hunk_AllocName (sizeof(texture_t) +pixels, loadname ); |
with
Code: | tx = Hunk_AllocName (sizeof(texture_t) +pixels, loadname ); |
|
It's the same? :O
Cool tutorial, though. |
|
Back to top |
|
 |
mh

Joined: 12 Jan 2008 Posts: 909
|
|
Back to top |
|
 |
leileilol

Joined: 15 Oct 2004 Posts: 1321
|
Posted: Tue Jun 15, 2010 11:09 pm Post subject: |
|
|
Another waste is the MDL files. They're all UVmapped too efficiently, there is no way to fix that by engine so for them to be happy with GLQuake one would have to make new UVs and power of 16 texture sizes for more memory efficiency and cpu efficiency too so there's less resampling to do on load.
I'd do it if I ever got a binary patcher to work. I'd only submit it as a binary patch form that depends on registered pak1.pak that then patches a whole new pak2.pak (unaffecting pak1 of course) _________________
 |
|
Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2004 phpBB Group
|