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

DXT5: Fix decoding of alpha channel for textures with a non-mod-4 width. #18554

Merged
merged 2 commits into from
Dec 15, 2023
Merged
Changes from 1 commit
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
Prev Previous commit
DXT5: Fix decoding of alpha channel for textures with a non-mod-4 width.
hrydgard committed Dec 15, 2023
commit acbc9dc94fa0e750deed186738bfc71bf66395f4
5 changes: 3 additions & 2 deletions GPU/Common/TextureDecoder.cpp
Original file line number Diff line number Diff line change
@@ -566,10 +566,11 @@ void DXTDecoder::WriteColorsDXT3(u32 *dst, const DXT3Block *src, int pitch, int

void DXTDecoder::WriteColorsDXT5(u32 *dst, const DXT5Block *src, int pitch, int width, int height) {
// 48 bits, 3 bit index per pixel, 12 bits per line.
u64 alphadata = ((u64)(u16)src->alphadata1 << 32) | (u32)src->alphadata2;
u64 allAlpha = ((u64)(u16)src->alphadata1 << 32) | (u32)src->alphadata2;

for (int y = 0; y < height; y++) {
int colordata = src->color.lines[y];
uint32_t colordata = src->color.lines[y];
uint32_t alphadata = allAlpha >> (12 * y);
for (int x = 0; x < width; x++) {
dst[x] = colors_[colordata & 3] | (alpha_[alphadata & 7] << 24);
colordata >>= 2;