mirror of
https://github.com/hrydgard/ppsspp.git
synced 2026-09-05 20:25:25 +02:00
Optimize LoadClut a little
This commit is contained in:
@@ -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.
|
||||
|
||||
@@ -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; }
|
||||
|
||||
Reference in New Issue
Block a user