To use cTGA/TGA for textures?

Moderator
Posts: 522
Joined: 2002.04
Post: #1
Howdy,

I was considering mmap'ing cTGA or TGA or .dds (if I figure it out) textures to cut down on loading times. Right now I use either DevIL or QuickTime to load textures and could use a speed boost. I've read people on here say using TGA was bad. Why is that?

Aside: Here is a NeHe tutorial about 'em : http://nehe.gamedev.net/data/lessons/les...?lesson=33

-Jon
Quote this message in a reply
Oldtimer
Posts: 834
Joined: 2002.09
Post: #2
The only drawback I can see with TGA is that it doesn't compress at all. For large textures, this might be a loss. If you have cartoonish or heavily alpha-masked textures, cTGA might be a good compression, since it does RLE. Some real-world benchmarks: El Ballo had terrible problems with loading times reaching upwards of 35 seconds. I'm loading 160 MB worth of textures at startup on Mac OS X, since I figured I might as well pull everything into memory and let the VM sort 'em out. With cTGA, I crunched the texture library down to below 80 MB, which ended up speeding the load times to below ten seconds.

TGA is superb for OpenGL, since you can just upload the pixel chunk onto the card as it is - no need to parse the actual pixels. If you don't have GL_BGRA you'll need to swizzle the pixels into RGBA, but most cards do BGRA. (Correct me if I'm wrong here - is that a driver issue rather a hardware issue?) For cTGA, you need to decompress the RLE stream, which is really quick.

I guess it comes down to what type of textures you're using - cTGA won't do squat with photorealistic surface textures for instance.
Quote this message in a reply
Sage
Posts: 1,232
Joined: 2002.10
Post: #3
TGA's RLE compression is just awful. You're much better off using PNG if you want lossless compression. If you don't require an alpha channel, use JPG.

This has been discussed several times already. This post has some numbers.

[Edit:] Here's another old post with numbers.
Quote this message in a reply
Sage
Posts: 1,232
Joined: 2002.10
Post: #4
All GPUs under OS X support RGBA and BGRA. The fast format for 32bit texture upload is GL_BGRA, GL_UNSIGNED_INT_8_8_8_8_REV. It's up to you to pick an image library that formats the data in that order (QuickTime will, NSImage won't.)
Quote this message in a reply
Moderator
Posts: 522
Joined: 2002.04
Post: #5
arekkusu Wrote:TGA's RLE compression is just awful. You're much better off using PNG if you want lossless compression. If you don't require an alpha channel, use JPG.

This has been discussed several times already. This post has some numbers.

[Edit:] Here's another old post with numbers.

Like I mentioned above, I'm going for load times here, not file sizes. I understand that file sizes both compressed and uncompressed will be smaller for png24 and png. Is there any other reason besides file sizes?

-Jon
Quote this message in a reply
Sage
Posts: 1,232
Joined: 2002.10
Post: #6
Your CPU is much faster than your disk drive. It takes longer to read 20 megs from disk than it does to read 2 megs and uncompress it.
Quote this message in a reply
DoG
Moderator
Posts: 869
Joined: 2003.01
Post: #7
Not even speaking about QT being optimised more than you'll ever be able to do so for your own code.
Quote this message in a reply
Moderator
Posts: 522
Joined: 2002.04
Post: #8
DoG Wrote:Not even speaking about QT being optimised more than you'll ever be able to do so for your own code.

That doesn't have much to do with what I asked. OK. A simple "No, the file size and its effects are the drawbacks," would be sufficient.

At any rate, I've got some stuff for dds textures so I'm going to mmap those and screw RLE TGA and TGA.

-Jon
Quote this message in a reply
Post Reply