VRAM and loading images...

BlitzMax Forums/BlitzMax Beginners Area/VRAM and loading images...

ragtag(Posted 2006) [#1]
If I'm understanding it correctly every image I load (i.e. run LoadImage) consumes a bit of VRAM ( width*heigh*4 = bytes of VRAM ), evne if it's not drawn on the screen.

Is it likely to cause trouble if I use big images, e.g. wider than 512 or 1024 pixels. And does it matter if the image is square or not?

How do I control what's in VRAM and what is not? (clear the TImage variable?)

And would it slow things down much to just load images when they are needed.

Ragnar


kronholm(Posted 2006) [#2]
As far as square or not, I think it does matter. As I read it, if you load a 1000x200 picture, it will blitz will still treat it as a 1000x1000 picture. That's why, especially with animation stripes, it's important to use the whole square, not just make one long row of images after another.


Scott Shaver(Posted 2006) [#3]
From a few other posts


You have to remember that your images will be rounded up in size to the nearest power of two.

If you've got a 2600x2600-pixel image and are splitting it up in to 8x8=64 blocks, each pixel block is 325x325 in size. These blocks are rounded up in size to the next power of two - 512x512. In 32-bit graphics modes, each 512x512 texture takes up 1MB of VRAM but only 412k of that is tile data. If you run out of VRAM the texture data has to be shunted from system RAM to VRAM each cycle, which is very slow!

I reckon that if you split your image into blocks of a fixed size (say 64 or 128 pixels wide) you'll see a big increase in performance.





So, I have some textures which are 256x128. Do you think
that I'm wasting half of my video memory on those? Is a
square image always better?
...
They're rounded to a power of 2, not a square power of 2. 256x128 will not need to be rounded at all, it's a perfect size.
...
Not always, no. Graphics cards that can only handle square textures are few, and far between, especially these days.




The combined size in pixels of all your images multiplied by 4 should give you a rough estimate on how much memory is being used on a 32-bit display.



http://www.opengl.org/resources/tutorials/sig99/advanced99/notes/node50.html


Dreamora(Posted 2006) [#4]
You can't control whats in VRAM.

If you use DirectX then only the textures are in VRAM that are needed at the moment. Thats managed through DirectX.

If you use OpenGL, then you can't do anything about it. This needs the texture in VRAM as OpenGL does not offer its own management (you would need to write an own management).


But to tell the truth: If Mark would take the time to implement DXTC / S3TC, all this stupid VRAM problems would be solved ... The textures take up only 1/3 to 1/6 of their actual size in VRAM, especially with larger texture this is definitely a must have.
It was already missing in Blitz3D which is really an overkill as this technology is standard to graphic cards for 4-6 years now!


ragtag(Posted 2006) [#5]
Thanks for the info. Very helpful to know.

Ragnar

------------------------------------------------------------------
Check out Alrea 51 Blackjack at http://www.ragtag.net/games