Sign in to follow this  
EddHead

batch/fast loading of DDS files

Recommended Posts

EddHead    140
Is there a way i can use D3DXCreateTextureFromFileEx to batch load a set of DDS sprite pages faster, they're similar in format but extremely large in number, or is there a way in putting them into large files and using D3DXCreateTextureFromFileEx to read them thru it so that file read/write access times are reduced? thanks in advance! I use D3DXCreateTextureFromFileEx in a loop to get the files into a texture array which i use for sprite animations, need to speed them up as the App takes too long to load!

Share this post


Link to post
Share on other sites
d000hg    1199
Well if you have for example 8 animation sets each using 32 indicidual images, you could store all the images for one animation in a single larger file. This might be a bit quicker when running the animation since less SetTexture calls will be made, but you'd have to decide if you were happy using larger textures.

One question is why you use .dds files - since .bmp is the simpleset file fomat you'd imagine it would be fastest to load. .jpg is pretty complex so maybe takes longer to 'decode' to a surface. I don't know the .dds format and anyway I think it can vary depending on if you use compressed textures or whatever. .DDS also may be storing a mip-map chain for each texture which you may not want?

But are you SURE it's the texture loading? Can you tell us how many images you have to load (and the dimensions+image format) and how long it takes just to load the images (throw in a GetTickCount() or whatever before and after loading)?

Share this post


Link to post
Share on other sites
MasterWorks    496
Texture loading a lot of animation frames can definitely be slow. I combined my 16/32/64 frame animations into large single textures, and now I get faster rendering AND much faster loading.

Share this post


Link to post
Share on other sites
EddHead    140
They're already 512x256 sprite animation pages, i am building it for an isometric style engine with all animations in all directions. 8 sides 30-40 frames per animation. DDS files are the fastest and also the smallest i have seen to load, my problem is though with too many of them, can you tell me how large a texture i can go with the file? I also wanted to know if there are ways to override this function and get it to read thru a flat file, (all files put into one file) and skip the time required for format/file handling changes.

Thanks a bunch, i will check out the texture atlas method. theres a paper about it on nVidia, but i am still interested in the flat file method.

Share this post


Link to post
Share on other sites
Syranide    375
I hardly thing header detection and such is a problem, the problem I guess lies within reading 512x256 images and such, as first it will create a system copy, create a video memory texture, copy it to that, lock, perhaps generate mipmaps, filter and so on.

Everything needs to go to the video memory, I don't know, threading might help do it as you could simulatanously load many images... don't know if the driver allows it though or just stalls.

Share this post


Link to post
Share on other sites
With DDS, if you want mips, pre generate them and store them in the DDS. If you don't want mips, ensure you specify miplevels=1 when loading. If not, D3DX will decompress you DDS, shrink it, and compress each needed level. It takes a long time.

Other than that, you make a simple file format when you just append on each texture's name, size, and DDS file.

char texturename[32]
ulong texturefilesize
texturedata

Load the whole sucker into memory. Loop through each texture and use D3DXCreateTextureFromFileInMemoryEx(). The file overhead shouldn't be much of a problem. I'd suggest looking into the mip issues I mentioned above first.

Share this post


Link to post
Share on other sites
EddHead    140
Great Idea - Thanks a lot, I dont use Mipmaps, since i want them for an Isometric Animation Engine. miplevels = 1 and load from memory is great, will try it out very soon and get back.

Can you gimme some more code samples of loading a bunch of files directly into memory before using D3DXCreateTextureFromFileInMemoryEx?

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