diff --git a/GPU/Common/TextureDecoder.h b/GPU/Common/TextureDecoder.h index 84ba1f6878..87efe8ef33 100644 --- a/GPU/Common/TextureDecoder.h +++ b/GPU/Common/TextureDecoder.h @@ -204,6 +204,17 @@ inline void DeIndexTexture4Optimal(u16 *dest, const u8 *indexed, int length } } +inline void DeIndexTexture4OptimalRev(u16 *dest, const u8 *indexed, int length, u16 color) { + const u16_le *indexed16 = (const u16_le *)indexed; + const u32 color32 = (color << 16) | color; + u32 *dest32 = (u32 *)dest; + for (int i = 0; i < length / 2; i += 2) { + u16 index = *indexed16++; + dest32[i + 0] = color32 | ((index & 0x00f0) << 24) | ((index & 0x000f) << 12); + dest32[i + 1] = color32 | ((index & 0xf000) << 16) | ((index & 0x0f00) << 4); + } +} + template inline void DeIndexTexture4(ClutT *dest, const u32 texaddr, int length, const ClutT *clut) { const u8 *indexed = (const u8 *) Memory::GetPointer(texaddr); diff --git a/GPU/Directx9/TextureCacheDX9.cpp b/GPU/Directx9/TextureCacheDX9.cpp index 117e878115..a5f5933ddb 100644 --- a/GPU/Directx9/TextureCacheDX9.cpp +++ b/GPU/Directx9/TextureCacheDX9.cpp @@ -1451,7 +1451,7 @@ void *TextureCacheDX9::DecodeTextureLevel(GETextureFormat format, GEPaletteForma texByteAlign = 2; if (!swizzled) { if (clutAlphaLinear_ && mipmapShareClut) { - DeIndexTexture4Optimal(tmpTexBuf16.data(), texptr, bufw * h, clutAlphaLinearColor_); + DeIndexTexture4OptimalRev(tmpTexBuf16.data(), texptr, bufw * h, clutAlphaLinearColor_); } else { DeIndexTexture4(tmpTexBuf16.data(), texptr, bufw * h, clut); } @@ -1459,7 +1459,7 @@ void *TextureCacheDX9::DecodeTextureLevel(GETextureFormat format, GEPaletteForma tmpTexBuf32.resize(std::max(bufw, w) * h); UnswizzleFromMem(texptr, bufw, h, 0); if (clutAlphaLinear_ && mipmapShareClut) { - DeIndexTexture4Optimal(tmpTexBuf16.data(), (const u8 *)tmpTexBuf32.data(), bufw * h, clutAlphaLinearColor_); + DeIndexTexture4OptimalRev(tmpTexBuf16.data(), (const u8 *)tmpTexBuf32.data(), bufw * h, clutAlphaLinearColor_); } else { DeIndexTexture4(tmpTexBuf16.data(), (const u8 *)tmpTexBuf32.data(), bufw * h, clut); }