Size of Textures in Memory

Started by
8 comments, last by Promit 18 years, 11 months ago
Does anyone know if the size of a texture in memory directly related to its dimensions or its file size( ie. 128kb)? Would using compressed TGAs or PNGs instead of BMPs reduce the amount of memory required to run the game? Right now I am loading 100 24bit BMP images as textures into my program and it takes up about 500MB of RAM. Would switching to a compressed file format reduce the amount of RAM it uses? [Edited by - Sir Sapo on May 29, 2005 4:59:12 PM]
My Current Project Angels 22 (4E5)
Advertisement
Quote:Original post by Sir Sapo
Right now I am loading 100 24bit BMP images as textures into my program and it takes up about 500MB of RAM. Would switching to a compressed file format reduce the amount of RAM it uses?


I'm only 90% sure on this, but I'm pretty confident that it wouldn't, since OpenGL has no texture compression (I think there's an extenion for it?). Since when you read that texture data in from the compressed format, you're uncompressing it and storing it as an array of bytes (redundant data and all) in the end, just as though you were loading straight from a bitmap.
OK, then why does my game take up so much RAM? I loaded up the sim-game IL2 Sturmovik and it takes up half the RAM my game takes when running and my game is just a side scroller.

Would it have anything to do with how I handle my textures?

They are only loaded once, at the beginning of the program.
When I need to draw the level, I call a function called RenderLevel which has the parameter: GLuint tex[100].
When RenderLevel is called, it uses the tex[] parameter to get the texture data to draw the level.

I have a suspicion that I am doing this wrong and that it is eating up resources.
My Current Project Angels 22 (4E5)
Quote:Original post by HopeDagger
Quote:Original post by Sir Sapo
Right now I am loading 100 24bit BMP images as textures into my program and it takes up about 500MB of RAM. Would switching to a compressed file format reduce the amount of RAM it uses?


I'm only 90% sure on this, but I'm pretty confident that it wouldn't, since OpenGL has no texture compression (I think there's an extenion for it?).


Since OGL 1.3 GL_ARB_texture_compression is part of the OGL core.
It supports the standard S3TC formats (aka DXTn compression).
You can use GL_EXT_texture_compression_s3tc (part of OGL 1.1) and some drivers
also implement GL_S3_s3tc.
You can lookup the texture size computation formula for the format at MSDN.


HTH,
Pat
Quote:Original post by Sir Sapo
They are only loaded once, at the beginning of the program.


just out of intrest, once you've loaded the textures and given the data to OpenGL do you delete the copy in system ram?

the total size the textures take up varies depending on all kinds of conditions, dimentions and colour depth being the main two (mipmaps also effect it but are not a huge factor I admit), also if you are using texture compression (as darookie pointed out, which isnt the same as PNG or TGA compression).

The size in texture memory depends on what internal format you've asked the driver to use. The size in RAM, if you keep it, is obviously related to the file size.

It sounds to me like you're either storing the images on purpose, or you've forgotten to delete the textures and so they've leaked all over the place.

(P.S. Consider PNG as an alternative to BMP.)
SlimDX | Ventspace Blog | Twitter | Diverse teams make better games. I am currently hiring capable C++ engine developers in Baltimore, MD.
Quote:Original post by _the_phantom_
Quote:Original post by Sir Sapo
They are only loaded once, at the beginning of the program.


just out of intrest, once you've loaded the textures and given the data to OpenGL do you delete the copy in system ram?

the total size the textures take up varies depending on all kinds of conditions, dimentions and colour depth being the main two (mipmaps also effect it but are not a huge factor I admit), also if you are using texture compression (as darookie pointed out, which isnt the same as PNG or TGA compression).


What do you mean delete the copy in system RAM?
My Current Project Angels 22 (4E5)
Well...uh...if you're loading an image, you need to load it in RAM first, from the file. That's the pointer you pass to glTexImage2D.

But you have to delete that pointer afterwards...
SlimDX | Ventspace Blog | Twitter | Diverse teams make better games. I am currently hiring capable C++ engine developers in Baltimore, MD.
Yeah I'm doing that, sorry I didn't understand what you were saying. BTW, Whats the texture compression thing you mentioned?
My Current Project Angels 22 (4E5)
Lots of graphics hardware has the ability to store textures in compressed form in video RAM and do decompression of a specific texel on the fly when it's requested. The available compression methods in GL are easy to use -- simply specify an alternate value to the internalformat parameter in glTexImageXD. The relevant extensions are ARB_texture_compression and EXT_texture_compression_s3tc. If you're loading an image that is already compressed on disk, the ARB extension defines CompressedTexImageXD for you to use.
SlimDX | Ventspace Blog | Twitter | Diverse teams make better games. I am currently hiring capable C++ engine developers in Baltimore, MD.

This topic is closed to new replies.

Advertisement