DDSTextureLoader and auto-gen mipmaps?

May 8, 2013 at 6:35 PM
Hello all,

I am curious, why the DDSTextureLoader doesn't have the option to auto-gen mipmaps just like the WICTextureLoader? I understand that DDS files can already contain mipmap levels, but what if they don't? Couldn't we have the same option as the WICTextureLoader; to auto-gen mipmaps at run-time? Is there a technical reason why it hasn't been implemented before?

I might just change the DDSTextureLoader code myself and do it exactly like its done in the WICTextureLoader (of course only when the DDS file doesn't contain any mipmaps) but I was wondering if there was any oversights from my part regarding this?

I need it to auto-gen mipmaps because my application can load textures from anywhere (they are not contained with the application).

Thank you!
Coordinator
May 8, 2013 at 7:14 PM
The general design of DDSTextureLoader is assuming you have properly 'cooked' all the texture options into it them most efficiency for a DDS, and is very light-weight. The WICTextureLoader is already having to do a fairly heavy-weight conversion, so it's pretty easy to support auto-gen mips. Also, auto-gen mips is not supported on any device for DXT/BC compressed data which is the most common usage case for a .DDS file over a traditional image bitmap format.

Personally, I would assume that if someone loaded a DDS file without mips, it wasn't intended to be mipmapped in the first place, but I don't know enough about your scenario to be sure.

Another alternative is to use DirectXTex and so a software-based mipmap generation on a DDS if needed which can also do software-based decompression of DXT/BC data.
May 9, 2013 at 4:02 PM
Edited May 9, 2013 at 9:05 PM
I totally agree with you regarding the fact that if they didn't export mipmaps, it shouldn't be mipmapped in the first place. But it turns out that in my application I use the mipmaps to control a blurring effect on reflections or image based lighting maps, which can be controlled by the user, and also animated. Because of that, I still need my mipmaps regardless if they were exported in the DDS file or not.

In the light of this, do you still believe it doesn't have its place in the DDSTextureLoader? Or perhaps we should tell the users that if they use DDS files, they need to bake the mipmaps themselves? Its just a lot less elegant to not be able to generate them ourselves.
May 10, 2013 at 12:05 AM
Deathicon,

I needed a relatively seamless replacement for D3DX11CreateTextureFromFile(), which does such mipmap generation, so I ended up doing something similar to you. I am also in a position where the texture inputs are not necessarily artist-generated, and could require a lot of processing to use.

— Mauricio
Coordinator
May 10, 2013 at 12:41 AM
DirectXTex is a reasonable option to get full-featured support for scenarios like this, legacy .DDS file formats for conversion (say 24bpp which fail with DDSTextureLoader), general decompression and mip-gen.