mirror of
https://github.com/microsoft/DirectXTex.git
synced 2025-07-12 05:00:14 +02:00
Support DDS files with non-standard nVidia Texture Tools flags
This commit is contained in:
parent
983bb95575
commit
6fcd00fdbd
@ -155,15 +155,22 @@ namespace
|
|||||||
// FourCC CTX1 (Xbox 360 only)
|
// FourCC CTX1 (Xbox 360 only)
|
||||||
// FourCC EAR, EARG, ET2, ET2A (Ericsson Texture Compression)
|
// FourCC EAR, EARG, ET2, ET2A (Ericsson Texture Compression)
|
||||||
|
|
||||||
DXGI_FORMAT GetDXGIFormat(const DDS_PIXELFORMAT& ddpf, DWORD flags, _Inout_ DWORD& convFlags)
|
DXGI_FORMAT GetDXGIFormat(const DDS_HEADER& hdr, const DDS_PIXELFORMAT& ddpf, DWORD flags, _Inout_ DWORD& convFlags)
|
||||||
{
|
{
|
||||||
|
uint32_t ddpfFlags = ddpf.dwFlags;
|
||||||
|
if (hdr.dwReserved1[9] == MAKEFOURCC('N', 'V', 'T', 'T'))
|
||||||
|
{
|
||||||
|
// Clear out non-standard nVidia DDS flags
|
||||||
|
ddpfFlags &= ~0xC0000000 /* DDPF_SRGB | DDPF_NORMAL */;
|
||||||
|
}
|
||||||
|
|
||||||
const size_t MAP_SIZE = sizeof(g_LegacyDDSMap) / sizeof(LegacyDDS);
|
const size_t MAP_SIZE = sizeof(g_LegacyDDSMap) / sizeof(LegacyDDS);
|
||||||
size_t index = 0;
|
size_t index = 0;
|
||||||
for (index = 0; index < MAP_SIZE; ++index)
|
for (index = 0; index < MAP_SIZE; ++index)
|
||||||
{
|
{
|
||||||
const LegacyDDS* entry = &g_LegacyDDSMap[index];
|
const LegacyDDS* entry = &g_LegacyDDSMap[index];
|
||||||
|
|
||||||
if (ddpf.dwFlags == entry->ddpf.dwFlags)
|
if (ddpfFlags == entry->ddpf.dwFlags)
|
||||||
{
|
{
|
||||||
if (entry->ddpf.dwFlags & DDS_FOURCC)
|
if (entry->ddpf.dwFlags & DDS_FOURCC)
|
||||||
{
|
{
|
||||||
@ -245,6 +252,12 @@ namespace
|
|||||||
cflags ^= CONV_FLAGS_SWIZZLE;
|
cflags ^= CONV_FLAGS_SWIZZLE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ((hdr.dwReserved1[9] == MAKEFOURCC('N', 'V', 'T', 'T'))
|
||||||
|
&& (ddpf.dwFlags & 0x40000000 /* DDPF_SRGB */))
|
||||||
|
{
|
||||||
|
format = MakeSRGB(format);
|
||||||
|
}
|
||||||
|
|
||||||
convFlags = cflags;
|
convFlags = cflags;
|
||||||
|
|
||||||
return format;
|
return format;
|
||||||
@ -409,7 +422,7 @@ namespace
|
|||||||
// Note there's no way for a legacy Direct3D 9 DDS to express a '1D' texture
|
// Note there's no way for a legacy Direct3D 9 DDS to express a '1D' texture
|
||||||
}
|
}
|
||||||
|
|
||||||
metadata.format = GetDXGIFormat(pHeader->ddspf, flags, convFlags);
|
metadata.format = GetDXGIFormat(*pHeader, pHeader->ddspf, flags, convFlags);
|
||||||
|
|
||||||
if (metadata.format == DXGI_FORMAT_UNKNOWN)
|
if (metadata.format == DXGI_FORMAT_UNKNOWN)
|
||||||
return HRESULT_FROM_WIN32(ERROR_NOT_SUPPORTED);
|
return HRESULT_FROM_WIN32(ERROR_NOT_SUPPORTED);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user