Support unspecified linear size in DDS files

Not all exporters choose to populate that (optional) header field.

(cherry picked from commit a344d7f906)
This commit is contained in:
LunaticInAHat 2023-12-19 13:23:42 -05:00 committed by Yuri Sizov
parent c8fabac8c7
commit afac25a3f8
1 changed files with 6 additions and 2 deletions

View File

@ -220,8 +220,12 @@ Ref<Resource> ResourceFormatDDS::load(const String &p_path, const String &p_orig
//compressed bc
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<Resource>());
ERR_FAIL_COND_V(!(flags & DDSD_LINEARSIZE), Ref<Resource>());
if (flags & DDSD_LINEARSIZE) {
ERR_FAIL_COND_V_MSG(size != pitch, Ref<Resource>(), "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<Resource>(), "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);