IWICDdsDecoder fails to load Cube maps

1

I created a Texture Cube with NVidia's Texture Exporter Tool but I cannot load it with IWICDdsDecoder.

It fails with 0x88982f61 : The image header is unrecognized..

On the other hand, normal 2D textures (Dimension = WICDdsTexture2D) created with NVTET load correctly and work well.

Does IWICDdsLoader support Cube Maps and if not, why is the WICDdsDimension.WICDdsTextureCube specified?

Partial loader code that works for normal WICDdsTexture2D textures written by the NVTET.

HRESULT lResult;

WICStream lStream;
lResult = gFactory->CreateStream(&lStream);
if (FAILED(lResult)) return lResult;

lResult = lStream->InitializeFromFilename(aPath, GENERIC_READ);
if (FAILED(lResult)) return lResult;

WICBitmapDecoder lBitmapDecoder;
lResult = gFactory->CreateDecoder(GUID_ContainerFormatDds, nullptr, &lBitmapDecoder);
if (FAILED(lResult)) return lResult;

lResult = lBitmapDecoder->Initialize(lStream, WICDecodeMetadataCacheOnDemand);
if (FAILED(lResult)) return lResult; // <-- it fails here!
// 0x88982f61 : The image header is unrecognized.

WICDdsDecoder lDecoder(lBitmapDecoder);
if (!lDecoder) return E_NOINTERFACE;

WICDdsParameters lParameters{};
lResult = lDecoder->GetParameters(&lParameters);
if (FAILED(lResult)) return lResult;
if (lParameters.Dimension != WICDdsTextureCube) return E_FAIL;

// etc.
textures
direct3d11
wic
dds-format
asked on Stack Overflow Jul 4, 2020 by CodeAngry

1 Answer

1

The built-in WIC DDS codec introduced in Windows 8.1 is designed to support WebGL. It only supports DXT1-5 (BC1-3) format textures. This is documented on Microsoft Docs.

For efficient loading of DDS files (all DXGI formats & complex surface constructs), take a look at DDSTextureLoader for DX11 or DX12. This module is available integrated into the DirectX Tool Kit and as standalone versions in the DirectXTex project.

If you need support for legacy Direct3D 9 era format DDS files, format conversion, etc. see the DirectXTex DDS codec.

See this blog post for more background on modern DDS texture handling.

There is also a Direct3D 9 version of DDSTextureLoader available if needed in the DirectXTex project. See this blog post for details.

answered on Stack Overflow Jul 7, 2020 by Chuck Walbourn • edited Jul 7, 2020 by Chuck Walbourn

User contributions licensed under CC BY-SA 3.0