batch/fast loading of DDS files

Started by
5 comments, last by EddHead 18 years, 9 months ago
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!
Jayanth.KRaptor Entertainment Pvt. Ltd.http://www.raptorentertainment.com---------------------------------------------------------Why Mr. Anderson? Why? ...Why keep fighting? Do you think you're fighting for something - for more than your survival? Can you tell me what it is? Do you even know? Is it freedom, or truth, perhaps peace, could it be for love? Illusions Mr. Anderson, vagaries of perception. Temporary constructs of a feeble human intellect trying desperately to justify an existence without meaning or purpose.
Advertisement
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)?
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.
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.
Jayanth.KRaptor Entertainment Pvt. Ltd.http://www.raptorentertainment.com---------------------------------------------------------Why Mr. Anderson? Why? ...Why keep fighting? Do you think you're fighting for something - for more than your survival? Can you tell me what it is? Do you even know? Is it freedom, or truth, perhaps peace, could it be for love? Illusions Mr. Anderson, vagaries of perception. Temporary constructs of a feeble human intellect trying desperately to justify an existence without meaning or purpose.
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.


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.
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?
Jayanth.KRaptor Entertainment Pvt. Ltd.http://www.raptorentertainment.com---------------------------------------------------------Why Mr. Anderson? Why? ...Why keep fighting? Do you think you're fighting for something - for more than your survival? Can you tell me what it is? Do you even know? Is it freedom, or truth, perhaps peace, could it be for love? Illusions Mr. Anderson, vagaries of perception. Temporary constructs of a feeble human intellect trying desperately to justify an existence without meaning or purpose.

This topic is closed to new replies.

Advertisement