Loading Textures Quickly

Started by
11 comments, last by zedzeek 18 years, 5 months ago
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
My Current Project Angels 22 (4E5)
Advertisement
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]
"I am a donut! Ask not how many tris/batch, but rather how many batches/frame!" -- Matthias Wloka & Richard Huddy, (GDC, DirectX 9 Performance)

http://www.silvermace.com/ -- My personal website
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.
___________________________________________________David OlsenIf I've helped you, please vote for PigeonGrape!
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?
My Current Project Angels 22 (4E5)
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.
___________________________________________________David OlsenIf I've helped you, please vote for PigeonGrape!
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).
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?


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.
Alex BakerComputer science is dealing with computers as much as astronomy is dealing with telescopes.
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.

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.

This topic is closed to new replies.

Advertisement