mirror of
https://github.com/izzy2lost/ppsspp.git
synced 2026-03-10 12:43:04 -07:00
Use sceKernelDcacheWritebackAll() as a hint only.
This commit is contained in:
@@ -1104,14 +1104,21 @@ void GLES_GPU::DoBlockTransfer() {
|
||||
|
||||
// TODO: Notify all overlapping FBOs that they need to reload.
|
||||
|
||||
TextureCache_Invalidate(dstBasePtr + dstY * dstStride + dstX, height * dstStride + width * bpp);
|
||||
TextureCache_Invalidate(dstBasePtr + dstY * dstStride + dstX, height * dstStride + width * bpp, true);
|
||||
}
|
||||
|
||||
void GLES_GPU::InvalidateCache(u32 addr, int size) {
|
||||
if (size > 0)
|
||||
TextureCache_Invalidate(addr, size);
|
||||
TextureCache_Invalidate(addr, size, true);
|
||||
else
|
||||
TextureCache_Clear(true);
|
||||
TextureCache_InvalidateAll(true);
|
||||
}
|
||||
|
||||
void GLES_GPU::InvalidateCacheHint(u32 addr, int size) {
|
||||
if (size > 0)
|
||||
TextureCache_Invalidate(addr, size, false);
|
||||
else
|
||||
TextureCache_InvalidateAll(false);
|
||||
}
|
||||
|
||||
void GLES_GPU::Flush() {
|
||||
|
||||
@@ -49,6 +49,7 @@ public:
|
||||
virtual void BeginFrame();
|
||||
virtual void UpdateStats();
|
||||
virtual void InvalidateCache(u32 addr, int size);
|
||||
virtual void InvalidateCacheHint(u32 addr, int size);
|
||||
virtual void DeviceLost(); // Only happens on Android. Drop all textures and shaders.
|
||||
|
||||
virtual void DumpNextFrame();
|
||||
|
||||
@@ -33,13 +33,14 @@ struct TexCacheEntry
|
||||
u32 addr;
|
||||
u32 hash;
|
||||
int frameCounter;
|
||||
u32 numMips;
|
||||
u32 format;
|
||||
u32 clutaddr;
|
||||
u32 clutformat;
|
||||
u32 cluthash;
|
||||
int dim;
|
||||
GLuint texture;
|
||||
bool invalidHint;
|
||||
u32 hash2;
|
||||
};
|
||||
|
||||
typedef std::map<u64, TexCacheEntry> TexCache;
|
||||
@@ -106,7 +107,7 @@ void TextureCache_Decimate()
|
||||
}
|
||||
}
|
||||
|
||||
void TextureCache_Invalidate(u32 addr, int size)
|
||||
void TextureCache_Invalidate(u32 addr, int size, bool force)
|
||||
{
|
||||
u32 addr_end = addr + size;
|
||||
|
||||
@@ -118,14 +119,30 @@ void TextureCache_Invalidate(u32 addr, int size)
|
||||
|
||||
if (invalidate)
|
||||
{
|
||||
glDeleteTextures(1, &iter->second.texture);
|
||||
cache.erase(iter++);
|
||||
if (force)
|
||||
{
|
||||
glDeleteTextures(1, &iter->second.texture);
|
||||
cache.erase(iter++);
|
||||
}
|
||||
else
|
||||
{
|
||||
iter->second.invalidHint = true;
|
||||
++iter;
|
||||
}
|
||||
}
|
||||
else
|
||||
++iter;
|
||||
}
|
||||
}
|
||||
|
||||
void TextureCache_InvalidateAll(bool force)
|
||||
{
|
||||
if (force)
|
||||
TextureCache_Clear(true);
|
||||
else
|
||||
TextureCache_Invalidate(0, 0xFFFFFFFF, force);
|
||||
}
|
||||
|
||||
int TextureCache_NumLoadedTextures()
|
||||
{
|
||||
return cache.size();
|
||||
@@ -635,8 +652,8 @@ void PSPSetTexture()
|
||||
u8 *texptr = Memory::GetPointer(texaddr);
|
||||
u32 texhash = texptr ? *(u32*)texptr : 0;
|
||||
|
||||
u64 cachekey = texaddr ^ clutaddr;
|
||||
cachekey |= (u64) texhash << 32;
|
||||
u64 cachekey = texaddr ^ texhash;
|
||||
cachekey |= (u64) clutaddr << 32;
|
||||
TexCache::iterator iter = cache.find(cachekey);
|
||||
if (iter != cache.end())
|
||||
{
|
||||
@@ -657,6 +674,22 @@ void PSPSetTexture()
|
||||
entry.cluthash != Memory::Read_U32(entry.clutaddr)))
|
||||
match = false;
|
||||
|
||||
// This has been invalidated, check it more thoroughly.
|
||||
if (entry.invalidHint) {
|
||||
int bufw = gstate.texbufwidth[0] & 0x3ff;
|
||||
|
||||
u32 check = 0;
|
||||
for (int i = 0; i < bufw; i += 4) {
|
||||
check += Memory::Read_U32(texaddr + i);
|
||||
}
|
||||
|
||||
if (check == entry.hash2) {
|
||||
entry.invalidHint = false;
|
||||
} else {
|
||||
match = false;
|
||||
}
|
||||
}
|
||||
|
||||
if (match) {
|
||||
//got one!
|
||||
entry.frameCounter = gpuStats.numFrames;
|
||||
@@ -705,6 +738,9 @@ void PSPSetTexture()
|
||||
int w = 1 << (gstate.texsize[0] & 0xf);
|
||||
int h = 1 << ((gstate.texsize[0]>>8) & 0xf);
|
||||
|
||||
for (int i = 0; i < bufw; i += 4)
|
||||
entry.hash2 += Memory::Read_U32(texaddr + i);
|
||||
|
||||
gstate_c.curTextureWidth=w;
|
||||
gstate_c.curTextureHeight=h;
|
||||
GLenum dstFmt = 0;
|
||||
|
||||
@@ -25,5 +25,6 @@ void TextureCache_Init();
|
||||
void TextureCache_Shutdown();
|
||||
void TextureCache_Clear(bool delete_them);
|
||||
void TextureCache_Decimate(); // Run this once per frame to get rid of old textures.
|
||||
void TextureCache_Invalidate(u32 addr, int size);
|
||||
void TextureCache_Invalidate(u32 addr, int size, bool force);
|
||||
void TextureCache_InvalidateAll(bool force);
|
||||
int TextureCache_NumLoadedTextures();
|
||||
|
||||
@@ -71,6 +71,7 @@ public:
|
||||
// Invalidate any cached content sourced from the specified range.
|
||||
// If size = -1, invalidate everything.
|
||||
virtual void InvalidateCache(u32 addr, int size) = 0;
|
||||
virtual void InvalidateCacheHint(u32 addr, int size) = 0;
|
||||
|
||||
// Internal hack to avoid interrupts from "PPGe" drawing (utility UI, etc)
|
||||
virtual void EnableInterrupts(bool enable) = 0;
|
||||
|
||||
@@ -745,3 +745,8 @@ void NullGPU::InvalidateCache(u32 addr, int size)
|
||||
{
|
||||
// Nothing to invalidate.
|
||||
}
|
||||
|
||||
void NullGPU::InvalidateCacheHint(u32 addr, int size)
|
||||
{
|
||||
// Nothing to invalidate.
|
||||
}
|
||||
|
||||
@@ -39,6 +39,7 @@ public:
|
||||
virtual void CopyDisplayToOutput() {}
|
||||
virtual void UpdateStats();
|
||||
virtual void InvalidateCache(u32 addr, int size);
|
||||
virtual void InvalidateCacheHint(u32 addr, int size);
|
||||
virtual void Flush() {}
|
||||
|
||||
virtual void DeviceLost() {}
|
||||
|
||||
Reference in New Issue
Block a user