Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support unspecified linear size in DDS files #86336

Merged
merged 1 commit into from
Dec 20, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions modules/dds/texture_loader_dds.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -404,8 +404,11 @@ Ref<Resource> 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<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);
Expand Down
Loading