Skip to main content
GameDev.net gamedev.net
🔒 Locked

Accelerated Texture Loading

Started by dragon9 Oct 4, 2002 at 12:36 PM 2 replies 300+ views
Original Post
dragon9
dragon9
In my project I am loading a scene with about 500 TGA''s of various resolutions with D3DXCreateTextureFromFileEx. It takes my system about 1 minute to to complete the load. I would like to accelerate this process. One idea I had was to combine the texture files into a single ''chunk'' file, load the whole thing into memory at once, and then use D3DXCreateTextureFromFileInMemoryEx to process the memory. Does anyone know how effective this would be, or have a better idea of how to do this? Thanks...
ph33r
ph33r
I would like to know the answer also.

I read that the largest texture you can load is 256x256 on most video cards, so I assume you would have to keep the texture no larger then 256x256 when you load it from your file.
S1CA
S1CA
The idea of packing them altogether as a big chunk and then loading that into memory is *potentially* a good one, it should make things a bit faster.

An expansion of the idea I''d suggest looking into would be the use of memory mapped files. With those the files *appear* to be in memory, but are really on disk, and for their loading you get to take advantage of the optimised disk buffering etc found in the Windows virtual memory system.

The majority of file loading time always comes from:

1) Accessing the media - a physical disk is always going to be far far slower than memory. The more data you read, the longer it takes. Reading sequentially is usually always much faster.

2) Opening and closing files - particularly on a "secure" OS such as Windows 2000, NT or XP.


Looking at those in turn and some other points:

1) Make the stuff read off physical media more quickly:
a. Make the files smaller - file compression (ZIP, ZLIB etc)
b. Make the files smaller - compressed file format (PNG etc)
c. Make the files smaller - lossy file formats (JPEG, DXT etc)
d. Read sequentially
e. Take advantage of hardware read buffering
f. Don''t seek too much on the media (by storing all files in one big file and reading sequentially you achieve this).


2) Don''t open and close files unnecessarily:
a. Use one big file
b. Open it when the program starts
c. Don''t close it until you absolutely need to


3) Graphics chips don''t texture from TGA files - so some conversion is taking place for each file. If your app say always creates textures as say 16bit, then each TGA file is likely to have up to 2x more data than is necessary.

If you roughly know the format you''ll be loading into, you can store in that format. This is easiest if you''re using DXTn compressed textures - you can store on disk in that format and save both loading and conversion time.

This is the way we do stuff on console games too - pre-process and pre-swizzle into internal hardware formats as an offline process to avoid it at load time.

--
Simon O''Connor
Creative Asylum Ltd
www.creative-asylum.com
Simon O'Connor | Technical Director (Newcastle) Lockwood Publishing | LinkedIn | Personal site
dragon9
dragon9
Thanks for the input. I will incorperate what I can into our project. Our ability to pre-process the data is somewhat limited for various reasons, but you have given me some food for thought.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.