dds file throws unsupported DirectX format

Discussion area about developing with Ogre-Next (2.1, 2.2 and beyond)


Post Reply
Hotshot5000
OGRE Contributor
OGRE Contributor
Posts: 226
Joined: Thu Oct 14, 2010 12:30 pm
x 56

dds file throws unsupported DirectX format

Post by Hotshot5000 »

DDSCodec::convertDXToOgreFormat() throws exception when called with parameter dxfmt=28. You can test with the following dds file: http://headwayentertainment.net/box0.dds. The dds file was create using the latest version of PVRTexTool (4.18.0 from the 2017 R1 SDK).

https://forum.keenswh.com/threads/dx11- ... r.7375544/. The first answer seems to have some info since we are using the fourCC and maybe the new DXGI header is messing with the decoder.
User avatar
dark_sylinc
OGRE Team Member
OGRE Team Member
Posts: 5299
Joined: Sat Jul 21, 2007 4:55 pm
Location: Buenos Aires, Argentina
x 1279
Contact:

Re: dds file throws unsupported DirectX format

Post by dark_sylinc »

Ugh. I was wondering about this 2 days ago.

DDS has its original header, and an extended header with updated DX10 formats.
Our DDS operates under the assumption that an encoder would write using the original header (which is bit- & mask-based for most formats, and FourCC based for some special formats) and only use the DX10 extended header for formats that can only be represented in that format. An encoder following this behavior would maximize support for older DDS viewers.

It seems PVRTexTool encoder decided to write the DX10 header version always. Simply opening the DDS file in another viewer and saving it could fix the issue.

Alternatively you can go to DDSCodec::convertDXToOgreFormat and add the format to the switch statement (and provide a pull request :) ).
The code is there, you just need to extend the switch statement with more values:

Code: Select all

switch (dxfmt) {
    case 80: // DXGI_FORMAT_BC4_UNORM
        return PF_BC4_UNORM;
    case 81: // DXGI_FORMAT_BC4_SNORM
        return PF_BC4_SNORM;
    case 83: // DXGI_FORMAT_BC5_UNORM
        return PF_BC5_UNORM;
    case 84: // DXGI_FORMAT_BC5_SNORM
        return PF_BC5_SNORM;
    case 95: // DXGI_FORMAT_BC6H_UF16
        return PF_BC6H_UF16;
    case 96: // DXGI_FORMAT_BC6H_SF16
        return PF_BC6H_SF16;
    case 98: // DXGI_FORMAT_BC7_UNORM
        return PF_BC7_UNORM;
    case 99: // DXGI_FORMAT_BC7_UNORM_SRGB
        return PF_BC7_UNORM_SRGB;
    default:
        OGRE_EXCEPT(Exception::ERR_ITEM_NOT_FOUND,
                    "Unsupported DirectX format found in DDS file",
                    "DDSCodec::convertDXToOgreFormat");
}
The numbers are based DXGI_FORMAT.
Note: IIRC, what MS calls DXGI_FORMAT_R8G8B8A8 I think Ogre calls it PF_A8B8G8R8.
Hotshot5000
OGRE Contributor
OGRE Contributor
Posts: 226
Joined: Thu Oct 14, 2010 12:30 pm
x 56

Re: dds file throws unsupported DirectX format

Post by Hotshot5000 »

Ok. I'll fix this tomorrow and provide a pull request. Doesn't seem to be too complicated, just map between the formats.
Hotshot5000
OGRE Contributor
OGRE Contributor
Posts: 226
Joined: Thu Oct 14, 2010 12:30 pm
x 56

Re: dds file throws unsupported DirectX format

Post by Hotshot5000 »

Hmmm... DXGI_FORMAT_R8G8B8A8_UNORM doesn't seem to have an equivalent in Ogre's PF. Should I convert to A8B8G8R8?
User avatar
dark_sylinc
OGRE Team Member
OGRE Team Member
Posts: 5299
Joined: Sat Jul 21, 2007 4:55 pm
Location: Buenos Aires, Argentina
x 1279
Contact:

Re: dds file throws unsupported DirectX format

Post by dark_sylinc »

Are you sure? Because it's either PF_A8B8G8R8 or PF_R8G8B8A8, just try and test.
Hotshot5000
OGRE Contributor
OGRE Contributor
Posts: 226
Joined: Thu Oct 14, 2010 12:30 pm
x 56

Re: dds file throws unsupported DirectX format

Post by Hotshot5000 »

dark_sylinc wrote:Are you sure? Because it's either PF_A8B8G8R8 or PF_R8G8B8A8, just try and test.
I thought that for normalized RGB (DXGI_FORMAT_R8G8B8A8_UNORM) I should be doing something special, but there is nothing to do actually.
Post Reply