Skip to content

Commit

Permalink
Round DDS width/height to next divisor multiple for block compression
Browse files Browse the repository at this point in the history
(cherry picked from commit e297506)
  • Loading branch information
Spartan322 committed Jan 4, 2025
1 parent be54dec commit 3e49107
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions modules/dds/texture_loader_dds.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -404,6 +404,15 @@ Ref<Resource> ResourceFormatDDS::load(const String &p_path, const String &p_orig

if (info.compressed) {
// BC compressed.
w += w % info.divisor;
h += h % info.divisor;
if (w != width) {
WARN_PRINT(vformat("%s: DDS width '%d' is not divisible by %d. This is not allowed as per the DDS specification, attempting to load anyway.", f->get_path(), width, info.divisor));
}
if (h != height) {
WARN_PRINT(vformat("%s: DDS height '%d' is not divisible by %d. This is not allowed as per the DDS specification, attempting to load anyway.", f->get_path(), height, info.divisor));
}

uint32_t size = MAX(info.divisor, w) / info.divisor * MAX(info.divisor, h) / info.divisor * info.block_size;

if (flags & DDSD_LINEARSIZE) {
Expand Down

0 comments on commit 3e49107

Please sign in to comment.