From 5223ee3d1b88a86b96fd5c54d77b7ea952de4a32 Mon Sep 17 00:00:00 2001 From: "Unknown W. Brackets" Date: Sun, 12 May 2013 09:15:31 -0700 Subject: [PATCH] Move the font clut opt check to clut load. And remove the report for mipmap sharing, seems to work... --- GPU/GLES/TextureCache.cpp | 52 ++++++++++++++++++--------------------- GPU/GLES/TextureCache.h | 3 +++ 2 files changed, 27 insertions(+), 28 deletions(-) diff --git a/GPU/GLES/TextureCache.cpp b/GPU/GLES/TextureCache.cpp index 977a3e40a7..9a87f33931 100644 --- a/GPU/GLES/TextureCache.cpp +++ b/GPU/GLES/TextureCache.cpp @@ -782,6 +782,26 @@ void TextureCache::UpdateCurrentClut() { Memory::Memcpy((u8 *)clutBuf_, clutAddr, clutTotalBytes); convertColors((u8 *)clutBuf_, getClutDestFormat(clutFormat), clutTotalBytes / clutColorBytes); clutHash_ = CityHash32((const char *)clutBuf_, clutTotalBytes); + + // Special optimization: fonts typically draw clut4 with just alpha values in a single color. + clutAlphaLinear_ = false; + clutAlphaLinearColor_ = 0; + if (gstate.clutformat == (0xC500FF00 | GE_CMODE_16BIT_ABGR4444)) { + const u16 *clut = GetCurrentClut(); + clutAlphaLinear_ = true; + clutAlphaLinearColor_ = clut[15] & 0xFFF0; + for (int i = 0; i < 16; ++i) { + if ((clut[i] & 0xf) != i) { + clutAlphaLinear_ = false; + break; + } + // Alpha 0 doesn't matter. + if (i != 0 && (clut[i] & 0xFFF0) != clutAlphaLinearColor_) { + clutAlphaLinear_ = false; + break; + } + } + } } else { memset(clutBuf_, 0xFF, clutTotalBytes); clutHash_ = 0; @@ -1074,9 +1094,6 @@ void *TextureCache::DecodeTextureLevel(u8 format, u8 clutformat, int level, u32 const bool mipmapShareClut = (gstate.texmode & 0x100) == 0; const int clutSharingOffset = mipmapShareClut ? 0 : level * 16; - if (mipmapShareClut) { - WARN_LOG_REPORT_ONCE(mipMapShareClut4, G3D, "Untested: mipmaps using separate cluts."); - } switch (clutformat) { case GE_CMODE_16BIT_BGR5650: @@ -1087,38 +1104,17 @@ void *TextureCache::DecodeTextureLevel(u8 format, u8 clutformat, int level, u32 tmpTexBufRearrange.resize(std::max(bufw, w) * h); const u16 *clut = GetCurrentClut() + clutSharingOffset; texByteAlign = 2; - - // Special optimization: fonts typically draw clut4 with just alpha values in a single color. - bool linearClut = false; - u16 linearColor = 0; - if (gstate.clutformat == (0xC500FF00 | GE_CMODE_16BIT_ABGR4444)) { - // TODO: Do this check once per CLUT load? - linearClut = true; - linearColor = clut[15] & 0xFFF0; - for (int i = 0; i < 16; ++i) { - if ((clut[i] & 0xf) != i) { - linearClut = false; - break; - } - // Alpha 0 doesn't matter. - if (i != 0 && (clut[i] & 0xFFF0) != linearColor) { - linearClut = false; - break; - } - } - } - if (!(gstate.texmode & 1)) { - if (linearClut) { - DeIndexTexture4Optimal(tmpTexBuf16.data(), texaddr, bufw * h, linearColor); + if (clutAlphaLinear_ && mipmapShareClut) { + DeIndexTexture4Optimal(tmpTexBuf16.data(), texaddr, bufw * h, clutAlphaLinearColor_); } else { DeIndexTexture4(tmpTexBuf16.data(), texaddr, bufw * h, clut); } } else { tmpTexBuf32.resize(std::max(bufw, w) * h); UnswizzleFromMem(texaddr, bufw, 0, level); - if (linearClut) { - DeIndexTexture4Optimal(tmpTexBuf16.data(), (u8 *)tmpTexBuf32.data(), bufw * h, linearColor); + if (clutAlphaLinear_ && mipmapShareClut) { + DeIndexTexture4Optimal(tmpTexBuf16.data(), (u8 *)tmpTexBuf32.data(), bufw * h, clutAlphaLinearColor_); } else { DeIndexTexture4(tmpTexBuf16.data(), (u8 *)tmpTexBuf32.data(), bufw * h, clut); } diff --git a/GPU/GLES/TextureCache.h b/GPU/GLES/TextureCache.h index ddbd33ca65..014aaf100c 100644 --- a/GPU/GLES/TextureCache.h +++ b/GPU/GLES/TextureCache.h @@ -129,6 +129,9 @@ private: u32 *clutBuf_; u32 clutHash_; + // True if the clut is just alpha values in the same order (RGBA4444-bit only.) + bool clutAlphaLinear_; + u16 clutAlphaLinearColor_; u32 lastBoundTexture; float maxAnisotropyLevel;