Sign in to follow this  

Size of Textures in Memory

This topic is 4593 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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]

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites
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).

Share this post


Link to post
Share on other sites
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.)

Share this post


Link to post
Share on other sites
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?

Share this post


Link to post
Share on other sites
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...

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites

This topic is 4593 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this