diff --git a/GPU/GLES/TextureCache.cpp b/GPU/GLES/TextureCache.cpp index 8edb791a22..112fff26e9 100644 --- a/GPU/GLES/TextureCache.cpp +++ b/GPU/GLES/TextureCache.cpp @@ -703,10 +703,24 @@ inline bool TextureCache::TexCacheEntry::Matches(u16 dim2, u8 format2, int maxLe void TextureCache::LoadClut() { u32 clutAddr = gstate.getClutAddress(); - clutTotalBytes_ = gstate.getClutLoadBytes(); if (Memory::IsValidAddress(clutAddr)) { +#if defined(_M_IX86) || defined(_M_X64) + int numBlocks = gstate.getClutLoadBlocks(); + clutTotalBytes_ = numBlocks * 32; + const __m128i *source = (const __m128i *)Memory::GetPointerUnchecked(clutAddr); + __m128i *dest = (__m128i *)clutBufRaw_; + for (int i = 0; i < numBlocks; i++, source += 2, dest += 2) { + __m128i data1 = _mm_loadu_si128(source); + __m128i data2 = _mm_loadu_si128(source + 1); + _mm_store_si128(dest, data1); + _mm_store_si128(dest + 1, data2); + } +#else + clutTotalBytes_ = gstate.getClutLoadBytes(); Memory::MemcpyUnchecked(clutBufRaw_, clutAddr, clutTotalBytes_); +#endif } else { + clutTotalBytes_ = gstate.getClutLoadBytes(); memset(clutBufRaw_, 0xFF, clutTotalBytes_); } // Reload the clut next time. diff --git a/GPU/GPUState.h b/GPU/GPUState.h index 2a78e02f5a..5e00234693 100644 --- a/GPU/GPUState.h +++ b/GPU/GPUState.h @@ -298,6 +298,7 @@ struct GPUgstate int getTextureEnvColB() const { return (texenvcolor>>16)&0xFF; } u32 getClutAddress() const { return (clutaddr & 0x00FFFFFF) | ((clutaddrupper << 8) & 0x0F000000); } int getClutLoadBytes() const { return (loadclut & 0x3F) * 32; } + int getClutLoadBlocks() const { return (loadclut & 0x3F); } GEPaletteFormat getClutPaletteFormat() { return static_cast(clutformat & 3); } int getClutIndexShift() const { return (clutformat >> 2) & 0x1F; } int getClutIndexMask() const { return (clutformat >> 8) & 0xFF; }