Skip to content

Commit 9f4ac3c

Browse files
committed
Merge pull request #103259 from BlueCube3310/bcdec-fix-realign
bcdec: Fix unnecessary alignment of texture resolution when only one of its dimensions isn't divisible by 4
2 parents 39c201c + a22c16c commit 9f4ac3c

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

modules/bcdec/image_decompress_bcdec.cpp

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -158,9 +158,12 @@ void image_decompress_bcdec(Image *p_image) {
158158

159159
// Compressed images' dimensions should be padded to the upper multiple of 4.
160160
// If they aren't, they need to be realigned (the actual data is correctly padded though).
161-
if (width % 4 != 0 || height % 4 != 0) {
162-
int new_width = width + (4 - (width % 4));
163-
int new_height = height + (4 - (height % 4));
161+
const bool need_width_realign = width % 4 != 0;
162+
const bool need_height_realign = height % 4 != 0;
163+
164+
if (need_width_realign || need_height_realign) {
165+
int new_width = need_width_realign ? width + (4 - (width % 4)) : width;
166+
int new_height = need_height_realign ? height + (4 - (height % 4)) : height;
164167

165168
print_verbose(vformat("Compressed image's dimensions are not multiples of 4 (%dx%d), aligning to (%dx%d)", width, height, new_width, new_height));
166169

0 commit comments

Comments
 (0)