Author Topic: Texture/ memory usage ?!  (Read 1940 times)

Offline arianaa30

  • byte
  • *
  • Posts: 44
    • View Profile
Texture/ memory usage ?!
« on: June 16, 2012, 04:32:20 am »
Hi there,
I'm getting out of memory from my demo! I'm just using maybe 10 objects (mostly md2, but did not activated the animations), with their textures. I've read the wiki, and some related comments about memory savings. However I know the size of textures is not important, but still wondering! the whole resources are just 2.4 mb! I'm using some common textures; 256x256, or some of them are 512...In a typical game, it is the same way.
Does it matter, for textures where I add them to texture manager? should they be set in the beginning?! and what about the blitting? One of my textures is a sky; so I blit it (a typical 24bit 512 texture).

Offline zammbi

  • float
  • ****
  • Posts: 360
    • View Profile
Re: Texture/ memory usage ?!
« Reply #1 on: June 16, 2012, 06:15:39 am »
How big is the heap size on the device?
If it's 16 megs 512x512 images would quickly make it run out of memory.
512x512 is about 1 meg in ram I believe.

Offline arianaa30

  • byte
  • *
  • Posts: 44
    • View Profile
Re: Texture/ memory usage ?!
« Reply #2 on: June 16, 2012, 09:09:45 am »
Hi,
Well, at this point, I'm just using Android's simulator, sdk 2.2 . The heap size is 24.

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 11777
    • View Profile
    • http://www.jpct.net
Re: Texture/ memory usage ?!
« Reply #3 on: June 16, 2012, 10:40:58 am »
The resources use 2.4mb in COMPRESSED format. After loading them, they are all uncompressed. If your md2 contains keyframes, try to limit the number to the needed minimum. Key frames require quite a lot of memory. And why do you think that texture size is not important? 512*512*4=1mb*2 (for the local copy in VM memory)+mip maps ~ 2.5mb for each 512*512 texture. Try to default the textures to 4bpp or use the new Virtualizer class. The wiki contains almost everything you need to know: http://www.jpct.net/wiki/index.php/Reducing_memory_usage

Offline arianaa30

  • byte
  • *
  • Posts: 44
    • View Profile
Re: Texture/ memory usage ?!
« Reply #4 on: June 18, 2012, 09:36:41 pm »
ummm, so you mean even if I do not animate the .md2 files, the feyframes will use memory, right?
I've activated the tricks about 4bpp and others in the wiki. I've converted the 512x512 files to 256, and the 32bits to 8 bits. hopefully it worked somehow, but I still had to remove some objects. They are necessary to add.
Thanks for your helps.

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 11777
    • View Profile
    • http://www.jpct.net
Re: Texture/ memory usage ?!
« Reply #5 on: June 18, 2012, 11:38:47 pm »
ummm, so you mean even if I do not animate the .md2 files, the feyframes will use memory, right?
Yes, of course they do. Key frames are pretty expensive memory wise. That's why the desktop version has the option to remove animation sequences from a loaded md2 animation. The idea is to load the md2 with the desktop version, remove all the sequences that you don't want and serialize the result to load it back into jPCT-AE.

What's the polygon count of your animated objects?

Offline arianaa30

  • byte
  • *
  • Posts: 44
    • View Profile
Re: Texture/ memory usage ?!
« Reply #6 on: June 18, 2012, 11:44:06 pm »
I see. Removing them seems to be a bit hard!
Well, I'm using a .md2 model viewer, and it says it has 16 frames and 554 triangles.
One of them which after removing, things got better, had 198 keyframes!! however the size was just 250kB.
« Last Edit: June 18, 2012, 11:47:07 pm by arianaa30 »

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 11777
    • View Profile
    • http://www.jpct.net
Re: Texture/ memory usage ?!
« Reply #7 on: June 18, 2012, 11:48:06 pm »
It not hard actually. You can do it in jPCT-AE itself, if you don't want to bother with the desktop version and serialized objects. However, it's only possible if your file contains sequences that you don't use. The "normal" md2 from Quake2 usually defines a lot the sequences for walking, running, taunting, shooting, dying...and you might not need of them in your game. Then you can savely remove the ones that you don't need. If that doesn't apply to you, then the only way is to reduce the number of keyframes itself...if possible.

Offline arianaa30

  • byte
  • *
  • Posts: 44
    • View Profile
Re: Texture/ memory usage ?!
« Reply #8 on: June 19, 2012, 01:06:28 am »
That sounds good.
Thanks a lot for your helps guys.
Egon, I'm developing my game on top of your demo for jPCT-AE (the one with grass, rock and two trees). Aren't you planning to create a visual plugin for your game engine in eclipse to help to at least place the 3D objects in the world? (like what Jigloo does). It could be nice since each time translating an object, and then watching the output is bothersome :)

Offline vickt

  • byte
  • *
  • Posts: 9
    • View Profile
Re: Texture/ memory usage ?!
« Reply #9 on: June 20, 2012, 12:39:19 am »