mirror of
https://github.com/hrydgard/ppsspp.git
synced 2025-04-02 11:01:50 -04:00
Plug a memory leak in the GLES texture cache. Fixes #9089
This commit is contained in:
parent
8eb668ea59
commit
98763655e7
2 changed files with 14 additions and 10 deletions
|
@ -601,11 +601,10 @@ void TextureCacheCommon::AttachFramebufferInvalid(TexCacheEntry *entry, VirtualF
|
||||||
}
|
}
|
||||||
|
|
||||||
void TextureCacheCommon::DetachFramebuffer(TexCacheEntry *entry, u32 address, VirtualFramebuffer *framebuffer) {
|
void TextureCacheCommon::DetachFramebuffer(TexCacheEntry *entry, u32 address, VirtualFramebuffer *framebuffer) {
|
||||||
const u64 cachekey = entry->CacheKey();
|
|
||||||
|
|
||||||
if (entry->framebuffer == framebuffer) {
|
if (entry->framebuffer == framebuffer) {
|
||||||
|
const u64 cachekey = entry->CacheKey();
|
||||||
cacheSizeEstimate_ += EstimateTexMemoryUsage(entry);
|
cacheSizeEstimate_ += EstimateTexMemoryUsage(entry);
|
||||||
entry->framebuffer = 0;
|
entry->framebuffer = nullptr;
|
||||||
fbTexInfo_.erase(cachekey);
|
fbTexInfo_.erase(cachekey);
|
||||||
host->GPUNotifyTextureAttachment(entry->addr);
|
host->GPUNotifyTextureAttachment(entry->addr);
|
||||||
}
|
}
|
||||||
|
|
|
@ -71,8 +71,11 @@ void TextureCacheGLES::SetFramebufferManager(FramebufferManagerGLES *fbManager)
|
||||||
|
|
||||||
void TextureCacheGLES::ReleaseTexture(TexCacheEntry *entry, bool delete_them) {
|
void TextureCacheGLES::ReleaseTexture(TexCacheEntry *entry, bool delete_them) {
|
||||||
DEBUG_LOG(G3D, "Deleting texture %i", entry->textureName);
|
DEBUG_LOG(G3D, "Deleting texture %i", entry->textureName);
|
||||||
if (delete_them)
|
if (delete_them) {
|
||||||
glDeleteTextures(1, &entry->textureName);
|
if (entry->textureName != 0) {
|
||||||
|
glDeleteTextures(1, &entry->textureName);
|
||||||
|
}
|
||||||
|
}
|
||||||
entry->textureName = 0;
|
entry->textureName = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -539,16 +542,18 @@ void TextureCacheGLES::BuildTexture(TexCacheEntry *const entry, bool replaceImag
|
||||||
// For the estimate, we assume cluts always point to 8888 for simplicity.
|
// For the estimate, we assume cluts always point to 8888 for simplicity.
|
||||||
cacheSizeEstimate_ += EstimateTexMemoryUsage(entry);
|
cacheSizeEstimate_ += EstimateTexMemoryUsage(entry);
|
||||||
|
|
||||||
// Always generate a texture name, we might need it if the texture is replaced later.
|
|
||||||
if (!replaceImages) {
|
|
||||||
entry->textureName = AllocTextureName();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (entry->framebuffer) {
|
if (entry->framebuffer) {
|
||||||
// Nothing else to do here.
|
// Nothing else to do here.
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Always generate a texture name unless it's a framebuffer, we might need it if the texture is replaced later.
|
||||||
|
if (!replaceImages) {
|
||||||
|
if (!entry->textureName) {
|
||||||
|
entry->textureName = AllocTextureName();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if ((entry->bufw == 0 || (gstate.texbufwidth[0] & 0xf800) != 0) && entry->addr >= PSP_GetKernelMemoryEnd()) {
|
if ((entry->bufw == 0 || (gstate.texbufwidth[0] & 0xf800) != 0) && entry->addr >= PSP_GetKernelMemoryEnd()) {
|
||||||
ERROR_LOG_REPORT(G3D, "Texture with unexpected bufw (full=%d)", gstate.texbufwidth[0] & 0xffff);
|
ERROR_LOG_REPORT(G3D, "Texture with unexpected bufw (full=%d)", gstate.texbufwidth[0] & 0xffff);
|
||||||
// Proceeding here can cause a crash.
|
// Proceeding here can cause a crash.
|
||||||
|
|
Loading…
Add table
Reference in a new issue