Optimize LoadClut a little

This commit is contained in:
Henrik Rydgard
2013-11-12 17:06:03 +01:00
parent b04f6b562b
commit 4b98e0d6d6
2 changed files with 16 additions and 1 deletions
+15 -1
View File
@@ -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.
+1
View File
@@ -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<GEPaletteFormat>(clutformat & 3); }
int getClutIndexShift() const { return (clutformat >> 2) & 0x1F; }
int getClutIndexMask() const { return (clutformat >> 8) & 0xFF; }