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

bcdec: Fix unnecessary alignment of texture resolution when only one of its dimensions isn't divisible by 4 #103259

Merged
merged 1 commit into from
Feb 25, 2025
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
9 changes: 6 additions & 3 deletions modules/bcdec/image_decompress_bcdec.cpp
Original file line number Diff line number Diff line change
@@ -158,9 +158,12 @@ void image_decompress_bcdec(Image *p_image) {

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

if (need_width_realign || need_height_realign) {
int new_width = need_width_realign ? width + (4 - (width % 4)) : width;
int new_height = need_height_realign ? height + (4 - (height % 4)) : height;

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