From a344d7f9065af4762bc4c9dba90d40c52f9102e4 Mon Sep 17 00:00:00 2001 From: LunaticInAHat Date: Tue, 19 Dec 2023 13:23:42 -0500 Subject: [PATCH] Support unspecified linear size in DDS files Not all exporters choose to populate that (optional) header field. --- modules/dds/texture_loader_dds.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/modules/dds/texture_loader_dds.cpp b/modules/dds/texture_loader_dds.cpp index 5bd8598f4a7..b2de6b656ef 100644 --- a/modules/dds/texture_loader_dds.cpp +++ b/modules/dds/texture_loader_dds.cpp @@ -404,8 +404,11 @@ Ref ResourceFormatDDS::load(const String &p_path, const String &p_orig // BC compressed. uint32_t size = MAX(info.divisor, w) / info.divisor * MAX(info.divisor, h) / info.divisor * info.block_size; - ERR_FAIL_COND_V(size != pitch, Ref()); - ERR_FAIL_COND_V(!(flags & DDSD_LINEARSIZE), Ref()); + if (flags & DDSD_LINEARSIZE) { + ERR_FAIL_COND_V_MSG(size != pitch, Ref(), "DDS header flags specify that a linear size of the top-level image is present, but the specified size does not match the expected value."); + } else { + ERR_FAIL_COND_V_MSG(pitch != 0, Ref(), "DDS header flags specify that no linear size will given for the top-level image, but a non-zero linear size value is present in the header."); + } for (uint32_t i = 1; i < mipmaps; i++) { w = MAX(1u, w >> 1);