VideoCommon: Fixed the crash when the code cache of DLCache is full.

git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@6299 8ced0084-cf51-0410-be5f-012b33b47a6e
This commit is contained in:
nodchip 2010-10-22 03:50:44 +00:00
parent 4c4348a0a7
commit e9d115a8b1
1 changed files with 12 additions and 0 deletions

View File

@ -40,6 +40,7 @@
#include "VideoConfig.h"
#define DL_CODE_CACHE_SIZE (1024*1024*16)
#define DL_CODE_CLEAR_THRESHOLD (256 * 1024)
extern int frameCount;
using namespace Gen;
@ -605,6 +606,11 @@ void ProgressiveCleanup()
}
}
static size_t GetSpaceLeft()
{
return DL_CODE_CACHE_SIZE - (emitter.GetCodePtr() - dlcode_cache);
}
} // namespace
// NOTE - outside the namespace on purpose.
@ -614,6 +620,12 @@ bool HandleDisplayList(u32 address, u32 size)
if(!g_ActiveConfig.bDlistCachingEnable)
return false;
if(size == 0) return false;
// Is this thread safe?
if (DLCache::GetSpaceLeft() < DL_CODE_CLEAR_THRESHOLD) {
DLCache::Clear();
}
u64 dl_id = DLCache::CreateMapId(address, size);
DLCache::DLMap::iterator iter = DLCache::dl_map.find(dl_id);