Texture Tools Exporter Cubemap Has Incorrect ArraySize

When exporting a BC6H (unsigned) cubemap from the Texture Tools Exporter, the resulting DDS file’s DX10 header has an arraySize of 6, and also has the DDS_RESOURCE_MISC_TEXTURECUBE flag set. This is incorrect - according to Microsoft’s documentation (DDS_HEADER_DXT10 structure (Dds.h) - Win32 apps | Microsoft Learn):

For a 2D texture that is also a cube-map texture, this number represents the number of cubes. This number is the same as the number in the NumCubes member of D3D10_TEXCUBE_ARRAY_SRV1 or D3D11_TEXCUBE_ARRAY_SRV). In this case, the DDS file contains arraySize * 6 2D textures. For more information about this case, see the miscFlag description.

Therefore, when exporting a standard cubemap and setting the DDS_RESOURCE_MISC_TEXTURECUBE flag, the arraySize should be 1, not 6. This logic can be verified by looking at the DDSTextureLoader in Microsoft’s DirectXTK (https://github.com/microsoft/DirectXTK/blob/main/Src/DDSTextureLoader.cpp#L483)

Heads up @nbickford :)

Hi AaronJ, thank you for the bug report!

I can confirm this is a bug in the 2023.1.0 exporter – I’ve got a hotfix patch in the release pipeline, and I’ll post an update here once I see it available online; its README.TXT will list a version number of 2023.1.1.

If you have access to the DDS header in your reader and need to handle files written by the reader with the bug, it’s possible to identify files created with the incorrect writer – they satisfy all 4 conditions below:

  • dwReserved1[9] in the DDS header is the 32-bit unsigned integer 0x3354564E (FourCC “NVT3”); and
  • dwReserved1[10] in the DDS header is 0 (the 2023.1.1 writer will have this set to 1 to indicate the writer version has changed); and
  • A DXT10 header extension exists (i.e. dwFourCC is the 32-bit unsigned integer 0x30315844, FourCC “DX10”); and
  • The DDSCAPS2_CUBEMAP flag bit is set in dwCaps2.

In this case, the arraySize should be divided by 6 to get the true number of elements. The 2023.1.1 reader has logic to automatically detect cubemaps written by 2023.1.0 and extract the correct data from them, and will also print whether the file was written by the old writer in the Input Information pane.

Incidentally, I believe this means the text “array size of 6” in the cube map example at DDS Cube Map Example - Win32 apps | Microsoft Learn is incorrect; an array size of 1 for a single cube map seems to match the spec and how other readers and writers process files.

Thanks again!

–Neil

Hi @AaronJ – Texture Tools Exporter version 2023.1.1 is now available on https://developer.nvidia.com/nvidia-texture-tools-exporter!

Due to hotfix patch constraints, the installer has the same name as 2023.1.0, but is slightly larger (37,958,464 bytes bytes for the standalone installer; 36,277,096 bytes for the Photoshop plugin installer).

Thanks again!

–Neil

Hey @nbickford - the new version of the exporter works perfectly, thanks for the fix! And thanks for the detailed info about how to detect the problematic data. Much appreciated!

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.