Skip to content

Commit

Permalink
Merge pull request #99600 from Spartan322/permit/non-spec-dds
Browse files Browse the repository at this point in the history
Round DDS width/height to next divisor multiple for block compression
  • Loading branch information
Repiteo committed Nov 27, 2024
2 parents ed443cc + e297506 commit 7ddc076
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 @@ -289,6 +289,15 @@ static Ref<Image> _dds_load_layer(Ref<FileAccess> p_file, DDSFormat p_dds_format

if (info.compressed) {
// BC compressed.
w += w % info.divisor;
h += h % info.divisor;
if (w != p_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.", p_file->get_path(), p_width, info.divisor));
}
if (h != p_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.", p_file->get_path(), p_height, info.divisor));
}

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

if (p_flags & DDSD_LINEARSIZE) {
Expand Down

0 comments on commit 7ddc076

Please sign in to comment.