From 43969ca15f4e46d8338c669e2ed1d5d953206724 Mon Sep 17 00:00:00 2001 From: Chuck Walbourn Date: Fri, 17 Aug 2018 17:31:23 -0700 Subject: [PATCH] Fixed problem loading DDS files that use FOURCC but have extra irrelevant bits set --- DirectXTex/DirectXTexDDS.cpp | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/DirectXTex/DirectXTexDDS.cpp b/DirectXTex/DirectXTexDDS.cpp index 7b3f8a7..70b4f34 100644 --- a/DirectXTex/DirectXTexDDS.cpp +++ b/DirectXTex/DirectXTexDDS.cpp @@ -166,14 +166,15 @@ namespace { const LegacyDDS* entry = &g_LegacyDDSMap[index]; - if (ddpfFlags == entry->ddpf.flags) + if ((ddpfFlags & DDS_FOURCC) && (entry->ddpf.flags & DDS_FOURCC)) { - if (entry->ddpf.flags & DDS_FOURCC) - { - if (ddpf.fourCC == entry->ddpf.fourCC) - break; - } - else if (entry->ddpf.flags & DDS_PAL8) + // In case of FourCC codes, ignore any other bits in ddpf.flags + if (ddpf.fourCC == entry->ddpf.fourCC) + break; + } + else if (ddpfFlags == entry->ddpf.flags) + { + if (entry->ddpf.flags & DDS_PAL8) { if (ddpf.RGBBitCount == entry->ddpf.RGBBitCount) break;