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.
CodeAngry
  • 12,760
  • 3
  • 50
  • 57

1 Answers1

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.

Chuck Walbourn
  • 38,259
  • 2
  • 58
  • 81
  • I ended up using your code. And no legacy support needed. My DDS-es are written with my custom **texconv** tool *(where I added the -ip flag that you didn't accept)* or NVidia Tool Texture Cubes. – CodeAngry Jul 12 '20 at 00:09
  • DDSTextureLoader is definitely the way to go then. – Chuck Walbourn Jul 12 '20 at 01:52
  • BTW I'm down to just 8 bits of my 64-bit options quad-word in ``texconv`` so I need to be careful about new command-line options for that tool or I'll need to work the whole options system. I have already merged a few seldom-used options to recover a few bits, and I have some variants that use a few bits as well. – Chuck Walbourn Jul 12 '20 at 04:28
  • The code does show that it's "built on the fly". :) – CodeAngry Jul 27 '20 at 04:25