Graphics Memory Estimation?
by Clint Herron · in Torque Game Builder · 01/04/2007 (6:23 pm) · 4 replies
Hello!
In working on a TGB game, I could really use a hand guesstimating what to tell my graphic artists what the limits are for the assets. I would like to fit my game into 250-300 megs of RAM on a user's machine if possible, but certainly no more than 400 megs of RAM.
Currently, art assets are my only real user of memory -- there is no sound.
I've got several images I'm pre-loading into the game. These are all 32 bit jpgs with a separate alpha map image.
(8) 1024 x 1024
(16) 1024 x 768
(18) 640 x 480
Just doing simple pixel math and figuring 4 bytes per pixel lands me at just over 100 megs of RAM to load all of these graphics into memory.
However, when I run this thing in actuality, TGB takes up a little more than 600 megs of RAM (even when running it as a packaged game).
Clearly I'm not estimating something properly, or I'm doing something drastically wrong in my loading of assets. I have several animations that reference many of these image maps, but I was under the impression that things like that didn't create multiple copies in memory.
Could someone give me a hand in knowing how to have better memory optimization? 600 mb of RAM for a dinky 2d game seems pretty crazy to me.
Thanks!
Respectfully,
clint
In working on a TGB game, I could really use a hand guesstimating what to tell my graphic artists what the limits are for the assets. I would like to fit my game into 250-300 megs of RAM on a user's machine if possible, but certainly no more than 400 megs of RAM.
Currently, art assets are my only real user of memory -- there is no sound.
I've got several images I'm pre-loading into the game. These are all 32 bit jpgs with a separate alpha map image.
(8) 1024 x 1024
(16) 1024 x 768
(18) 640 x 480
Just doing simple pixel math and figuring 4 bytes per pixel lands me at just over 100 megs of RAM to load all of these graphics into memory.
However, when I run this thing in actuality, TGB takes up a little more than 600 megs of RAM (even when running it as a packaged game).
Clearly I'm not estimating something properly, or I'm doing something drastically wrong in my loading of assets. I have several animations that reference many of these image maps, but I was under the impression that things like that didn't create multiple copies in memory.
Could someone give me a hand in knowing how to have better memory optimization? 600 mb of RAM for a dinky 2d game seems pretty crazy to me.
Thanks!
Respectfully,
clint
About the author
#2
Thats 96mb already, not counting in Mipmaps (which would add another 1/3 to 1/2 of that amount)
Then you mention seperate alpha maps. This once again adds another 96mb (don't assume TGB internally switches to A8 or something similar when using those textures)
640x480 either becomes 1024x512 or 1024x1024 (6600 / 6800 do not seem to support non square on some driver versions), so this adds once again 18 * 2 / 4 mb thus 32 / 64mb + the same amount for alpha maps once again.
So even if we do not count in the effect of mipmaps, this means that you are using around 96+96 = 192 + 64 or 128 mb = 256 / 320 MB just for those pictures.
BUT: this assumes that these pictures are not animations or something like that which you use with cell mode and the padding flag, because if so, all these calculations are wrong because it will need more RAM due to the fact that 1024x1024 will be split up into sub sections of non power of 2 textures combined into new power of two. So if you use cell with filterpad, you will end up having quite some more than this amount.
What you need to do in this case is: Allow unload in the settings of the media and unload media after levels.
Surely this will add loading times to your level, but thats after all the only solution for low RAM systems that can't hold the whole game in RAM.
Loading the whole media for a whole game upfront will most likely always cause such problems if targeted at 1024 upwards resolutions. (there is a reason current gen games need 3 - 5 GB on hard disks, this has actually nothing to do with sound or code I fear)
01/05/2007 (2:27 am)
1024x1024 and 1024x768 both go to 1024x1024 which means 4MB eachThats 96mb already, not counting in Mipmaps (which would add another 1/3 to 1/2 of that amount)
Then you mention seperate alpha maps. This once again adds another 96mb (don't assume TGB internally switches to A8 or something similar when using those textures)
640x480 either becomes 1024x512 or 1024x1024 (6600 / 6800 do not seem to support non square on some driver versions), so this adds once again 18 * 2 / 4 mb thus 32 / 64mb + the same amount for alpha maps once again.
So even if we do not count in the effect of mipmaps, this means that you are using around 96+96 = 192 + 64 or 128 mb = 256 / 320 MB just for those pictures.
BUT: this assumes that these pictures are not animations or something like that which you use with cell mode and the padding flag, because if so, all these calculations are wrong because it will need more RAM due to the fact that 1024x1024 will be split up into sub sections of non power of 2 textures combined into new power of two. So if you use cell with filterpad, you will end up having quite some more than this amount.
What you need to do in this case is: Allow unload in the settings of the media and unload media after levels.
Surely this will add loading times to your level, but thats after all the only solution for low RAM systems that can't hold the whole game in RAM.
Loading the whole media for a whole game upfront will most likely always cause such problems if targeted at 1024 upwards resolutions. (there is a reason current gen games need 3 - 5 GB on hard disks, this has actually nothing to do with sound or code I fear)
#3
1) If im using 32bit png files does it get split out into a seperate alpha channel once its in memory? (ie is there a 4mb benefit for using 1024x1024 png instead of jpg w/ alpha?)
2) Anybody have a suggestion on what the friendly limit o ram should restrain myself to should be for a casualcore game? My gut says 256-384 but I'd like opinions from people..
PS @Marc thanks for the heads up on the filterPad texture increase, gonna go trim some maps...
01/10/2007 (6:32 am)
I've got 2 related questions.1) If im using 32bit png files does it get split out into a seperate alpha channel once its in memory? (ie is there a 4mb benefit for using 1024x1024 png instead of jpg w/ alpha?)
2) Anybody have a suggestion on what the friendly limit o ram should restrain myself to should be for a casualcore game? My gut says 256-384 but I'd like opinions from people..
PS @Marc thanks for the heads up on the filterPad texture increase, gonna go trim some maps...
#4
www.garagegames.com/index.php?sec=mg&mod=resource&page=view&qid=10656
After I figured out how to use it, my memory usage dropped from 280 MB to 90 MB.
01/13/2007 (8:17 pm)
I'm also working on a similar problem right now. I've started to get it worked out. My suggestion is to look at this helpful resource about dynamic image loading: www.garagegames.com/index.php?sec=mg&mod=resource&page=view&qid=10656
After I figured out how to use it, my memory usage dropped from 280 MB to 90 MB.
Torque Owner Maurice Ribble