how to speed up texture loading?

Started by
23 comments, last by MasterWorks 18 years, 10 months ago
Well, I have an annoying problem. In my DX8 game during loading, I must load cc 7000 textures ( or more), and because of game loading after few restarts(debugging or similar)i'm getting a little bit nervous :). Is there any way to speed up this process? This is an isometric game so every animation is handled as set of textures (one character animation is 520 texture long, for example). I was thinking about something like this, but don't know how to do it: - setting up one animation in an large custom file - load custom file in one step - decompress file in memory - load from memory Anyway, is this going to speed up whole process? And how can be done this?
Advertisement
Having 7000 ID3DTexture9 objects is not a good idea. Try to batch up all textures belonging to one animation in one texture. Then load that texture and animate the texture coordinates.

I don't really know how you are doing your drawing, but it should be quite simple. That will save you a lot of overhead and make the loading faster.

If you want, you could also try batching up some of the animations in one texture. In general having a big texture (1024*1024) is a lot better than many small ones, as it will save you state changes.
Hopefully these are pretty small textures!

In any case, one convenient way to batch these textures together would be to use volume (3D) textures. Then the animation is easy too, as it's just a matter of animating the third texture coordinate. You can save volume textures as .dds files and load them as a single chunk.
Well yaeh. I tried that, but that solution gave me much more headache, than simple texture loading. That it is because the textures are not fixed size, and also they aren't all pow^2, so in this solution I have pixels lost, the textures are not so sharp etc...
And then if animation is 128x128 big, this means that in texture of 1024x1024 size I have only 64 animations (in my character animations of 570 frames this is not enough).
And last thing, if I know well some older cards cannot load textures of that size..
Quote:Original post by ganchmaster
Hopefully these are pretty small textures!

In any case, one convenient way to batch these textures together would be to use volume (3D) textures. Then the animation is easy too, as it's just a matter of animating the third texture coordinate. You can save volume textures as .dds files and load them as a single chunk.


yes. these are pretty small textures, but I have also big ones.
Can I have in the volume texture, textures of variable sizes? And volume textures aren't depended on video card, I mean all video cards can open volume textures?
I think your setup is fine, as long as the video card supports the image sizes in memory. It would be bad if it tried to pad the images to make them square or powers of 2.

To speed it up, you might want to consider compressing the textures on the hard drive, and storing all related textures in one file. Load each file in, uncompress, then transfer the data to individual texture surfaces. This should speed up loading time considerably, depending on the type of images you use and the type of compression you try.

You could just save the textures as PNG (decent compression), then create a simple tool to shove all of one animation's frames into a single file (just store each file's byte data in sequence). In your engine, load the whole file into memory at once, then use the DirectX texture LoadFromMemory functions to store each texture.

Just some ideas.
Quote:Original post by Jiia

You could just save the textures as PNG (decent compression), then create a simple tool to shove all of one animation's frames into a single file (just store each file's byte data in sequence). In your engine, load the whole file into memory at once, then use the DirectX texture LoadFromMemory functions to store each texture.
.


My textures are already in PNG format, and I come to similar solution of my problem.
But DXLoadTetxureFromMemory will speed up the whole process? I dont want to link 7000 textures if there are no speedup improvement.

And how about the BIG game-developing companies? They how solve this kind of problems?

Quote:Original post by streamer
But DXLoadTetxureFromMemory will speed up the whole process? I dont want to link 7000 textures if there are no speedup improvement.

There's an easy way to test it. Create a file sized by about the size of one your images. Open it, allocate it's size, read it from file, close the file, then delete the memory, 7000 times. Then create a single file 7000 times larger. Open it, allocate, read, close, then delete, once. I would expect about 300% speed increase, but that's just a random guess. I might be totally wrong. Easy to test, though.
Quote:Original post by Jiia
Quote:Original post by streamer
But DXLoadTetxureFromMemory will speed up the whole process? I dont want to link 7000 textures if there are no speedup improvement.

There's an easy way to test it. Create a file sized by about the size of one your images. Open it, allocate it's size, read it from file, close the file, then delete the memory, 7000 times. Then create a single file 7000 times larger. Open it, allocate, read, close, then delete, once. I would expect about 300% speed increase, but that's just a random guess. I might be totally wrong. Easy to test, though.


Yeah you were right :) It is much more faster. I just don't know how will DXLoadTextureFromMemory behave in my program. But this seams to be a right point. Again, lot of changes in code. I think this will be one more sleepless night.
Thanx
Quote:Original post by streamer
I just don't know how will DXLoadTextureFromMemory behave in my program. But this seams to be a right point. Again, lot of changes in code. I think this will be one more sleepless night

It's incredibly simple. Instead of passing a filename, you just pass the memory pointer and byte size. The hard part would be combining all of your files as you update art [smile]

This topic is closed to new replies.

Advertisement