Skip to content

Commit

Permalink
Merge pull request #57096 from lyuma/fix-3d-textures
Browse files Browse the repository at this point in the history
  • Loading branch information
akien-mga authored Jan 23, 2022
2 parents dd6e5b3 + e8da21d commit 81c28dd
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions modules/etcpak/image_compress_etcpak.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -152,14 +152,18 @@ void _compress_etcpak(EtcpakType p_compresstype, Image *r_img, float p_lossy_qua
are used for a 2x2 map, and texel 'a' is used for 1x1. Note that this is similar to, but distinct from,
the surface pitch, which can encompass additional padding beyond the physical surface size.
*/
int next_width = (width + 3) & ~3;
int next_height = (height + 3) & ~3;
int next_width = width <= 2 ? width : (width + 3) & ~3;
int next_height = height <= 2 ? height : (height + 3) & ~3;
if (next_width != width || next_height != height) {
r_img->resize(next_width, next_height, Image::INTERPOLATE_LANCZOS);
width = r_img->get_width();
height = r_img->get_height();
}
ERR_FAIL_COND(width % 4 != 0 || height % 4 != 0); // Should be guaranteed by above
// ERR_FAIL_COND(width % 4 != 0 || height % 4 != 0); // FIXME: No longer guaranteed.
// Multiple-of-4 should be guaranteed by above.
// However, power-of-two 3d textures will create Nx2 and Nx1 mipmap levels,
// which are individually compressed Image objects that violate the above rule.
// Hence, we allow Nx1 and Nx2 images through without forcing to multiple-of-4.

const uint8_t *src_read = r_img->get_data().ptr();

Expand Down

0 comments on commit 81c28dd

Please sign in to comment.