Sign in to follow this  
Sir Sapo

Loading Textures Quickly

Recommended Posts

Hey everyone, In my project, I have to load up about 100 textures(128x128) into memory at the beginning of each level, and this process is taking upwards of 1 minute to load. My question is, does anyone know of anyway to speed this process up, or should I focus my effort on something else? Thanks

Share this post


Link to post
Share on other sites
One way is to store all the files in some kind of larger archive, load that into memory and do all the decoding/conversion using memory mapped IO rather than Disk IO. Also, the next best thing would be to not use an encoded or compressed format. The fastest being just raw RGBA bytes in a file - the idea being you just load the file: disk->RAM->OpenGL with little or no processing. I wouldn't advise this method if you dont wont to have to distribute your game on an eight DVD box set [wink]

Share this post


Link to post
Share on other sites
Quote:
Original post by silvermace
Also, the next best thing would be to not use an encoded or compressed format.


I'm sure that's not true. The processor can churn it's way through data much faster than you can get it off the hard drive, so wouldn't it be faster to have a small file and take a little time to decompress it? The processor is not the bottleneck here, it's the hard drive.

Share this post


Link to post
Share on other sites
Thanks for the replies,

The textures are saved as 24bit .BMPs, so no compression there (unless I'm mistaken).

Also, I was wondering, would it be beneficial for me to store my textures as .PNGs? I assume it is easier to read 50kb from memory rather than 3MB, but does it really take that much power/time to decompress them?

Share this post


Link to post
Share on other sites
I've managed to load reasonably sized png's (bigger than 128x128 anyway) over about 10-15 frames at 70fps, while the game was running. And I was drawing it as it loaded using interlacing too. I never got round to trying it with much else going on though. Loading png's can be a bit of a pain though, libpng could be more friendly.

Share this post


Link to post
Share on other sites
Store your textures with DXTC if at all possible. That way, you stream less data, and your CPU never has to compress or decompress anything. Also, it's almost certainly a bad idea to have 100 128x128 textures; you'll do a lot of texture state churning, reducing performance. Better: one 128x12800 texture (or similar).

Share this post


Link to post
Share on other sites
Quote:
Original post by Sir Sapo
Hey everyone,

In my project, I have to load up about 100 textures(128x128) into memory at the beginning of each level, and this process is taking upwards of 1 minute to load. My question is, does anyone know of anyway to speed this process up, or should I focus my effort on something else?

Thanks


your texture loading routine is horribly inefficent (unless this is for a pocket calculator)
compression etc aint the proper solution.
are u doing something crazy like loading the images one byte at a time?

Share this post


Link to post
Share on other sites

Sir Sapo,

all in all, i would go by Sneftel's way, because DXTC decompression can be done on the hardware directly with nearly no (on todays gfxboards!) performance penalty; using DXTC compression has only some performance breaks when creating/saving the texture to disk (e.g. withing your graphic/paint application), because compressing an image down to DXTC will take some time (depending on your machine speed).

Apart from that, i see no other proper solution for decreasing the loading time significantly, because: loading 3MB from disk, means loading 3MB from the disk. Storing all the stuff in an archive (how games like doom/quake doing it) will not bring you that boost, you are expecting.

Share this post


Link to post
Share on other sites
Does that include sending the textures to the video card or just loading into system memory? If the former, read this pdf to get optimal texture transfer rates. Even if you just mean loading into system memory, it's still a good read.

Share this post


Link to post
Share on other sites
Guest Anonymous Poster

I agree with everybody who suggests DXT texture formats. For example, 3MB RGB texture file can be reduced to around 700kb in size which is definetely faster to load. DX comes with handy commands to load those files.

Usually maximum texture size is around 2048x2048, and when packing things in one texture, it isn't possible to make repeating textures.

Share this post


Link to post
Share on other sites
That seems to be about 6mb and a minute is an extremely excessive time. If you are using a component to load the bitmaps then look at what other properties you have to access the pixels. Generally there is a method to access individual pixels which is extremely slow and a way to access scanlines which is substantially faster. Like 10 to 100 times faster.

Share this post


Link to post
Share on other sites
the AP is correct
100 textures(128x128) @ 1 minute to load
== just over 0.5secs per 128x128 texture

had a quick look at my logfile (some textures are dxt5 thus 4:1 compression + some are uncompressed)

this is uncompressed
secs 0.000104203 textures/mapicons.dds 128 128
vs --0.5000000

major difference!!

secs 0.000267911 textures/effects/wormholeBM.dds 256 256
secs 0.000241092 textures/effects/energy_rings.dds 256 256
secs 0.00406001 textures/terrain/reddirt.dds 1024 1024
secs 0.00455952 textures/terrain/sand2.dds 1024 1024
secs 0.000989511 textures/terrain/sandRGB_BM.dds 512 512
secs 0.000104203 textures/mapicons.dds 128 128
secs 0.00245757 textures/alphabet1.dds 512 256
secs 0.00236511 textures/alphabet2.dds 512 256
secs 0.000816584 textures/background.dds 512 512

Share this post


Link to post
Share on other sites

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