I cut him, but he didn't use less memory...

BlitzMax Forums/BlitzMax Programming/I cut him, but he didn't use less memory...

deps(Posted 2005) [#1]
Hi,

In another thread muk posted this link to some sprites and tilesets: www.reinerstileset.4players.de:1059/

I downloaded one of the sprites and wrote a small blitzmax app that loads and animates the bmp files. But they contain too much "empty space", or what do you call it, around the character. So i wrote a quick and dirty Sprite Optimizer (tm)(c)(r)(etc).
Since Sprite Optimizer (tm)(c)(r)(etc) cuts away all the unneeded pixels aroudn a sprite, the sprite should use less memory when stored in videoram. Well, it doesn't according to memalloced().
While I write this I realized that bmax should resize all images to the nearest power of 2 in order to make it compatible with older graphics cards (like mine, i guess), but some of the images gets cut so much that I believe it should be at least some small difference.

Anyway, to sum it all up:

1) Do memalloced() report video ram usage too?
2) If the graphic card compress the images, do memalloced() use that size instead of the "raw" size?

One character animations uses 19501652 bytes according to memalloced() (384 images), I hope this isn't true when it's stored in video ram.

Or am I way wrong here?


deps(Posted 2005) [#2]
Here is the source for my little app:


Compile and put the executable in a directory with a lot of BMP files.
Iterate files with UP/DOWN
iterate files 10 at a time with PGUP/PGDOWN
set start frame with S
set end frame with E
Run animation with ENTER


Hotcakes(Posted 2005) [#3]
FlushMem would be used to clear the memory of any graphics you are no longer using - but it is not guaranteed. The garbage collector ultimately decides when to clear memory. FlushMem doesn't say when to clear the memory, it says when to make a decision whether or not to clear the memory.

I don't think MemAlloced() report anything to do with vidram...
I don't think graphics in vidmem are compressed.

The size of memory your graphic is taking up in vidmem is (in worst case scenario, could vary) width*height*4. If one frame of your 384 frame anim takes up 50k uncompressed, then yes, that near-20meg figure looks about right.

It's not exactly right, though, because 384 does not divide into that figure evenly.


Dreamora(Posted 2005) [#4]
MemAlloced only reports system RAM. DX mode loads textures to SystemRAM, OpenGL loads it straight into VRAM. (you could force that for DX as well but its not a that good idea)

And no actuall the graphics are not S3TC (DXTC is the same) compressed.


deps(Posted 2005) [#5]
Thank you for the replies.