meow-7.2.2
Brad Payne (Vir Linden) 2011-10-31 11:35:22 -04:00
commit 51c7887f8d
9 changed files with 105 additions and 27 deletions

View File

@ -1821,6 +1821,7 @@ void LLPrivateMemoryPool::LLChunkHashElement::remove(LLPrivateMemoryPool::LLMemo
//class LLPrivateMemoryPoolManager
//--------------------------------------------------------------------
LLPrivateMemoryPoolManager* LLPrivateMemoryPoolManager::sInstance = NULL ;
BOOL LLPrivateMemoryPoolManager::sPrivatePoolEnabled = FALSE ;
std::vector<LLPrivateMemoryPool*> LLPrivateMemoryPoolManager::sDanglingPoolList ;
LLPrivateMemoryPoolManager::LLPrivateMemoryPoolManager(BOOL enabled, U32 max_pool_size)
@ -1832,7 +1833,7 @@ LLPrivateMemoryPoolManager::LLPrivateMemoryPoolManager(BOOL enabled, U32 max_poo
mPoolList[i] = NULL ;
}
mPrivatePoolEnabled = enabled ;
sPrivatePoolEnabled = enabled ;
const U32 MAX_POOL_SIZE = 256 * 1024 * 1024 ; //256 MB
mMaxPrivatePoolSize = llmax(max_pool_size, MAX_POOL_SIZE) ;
@ -1917,7 +1918,7 @@ void LLPrivateMemoryPoolManager::destroyClass()
LLPrivateMemoryPool* LLPrivateMemoryPoolManager::newPool(S32 type)
{
if(!mPrivatePoolEnabled)
if(!sPrivatePoolEnabled)
{
return NULL ;
}
@ -2015,7 +2016,11 @@ void LLPrivateMemoryPoolManager::freeMem(LLPrivateMemoryPool* poolp, void* addr
}
else
{
if(!sInstance) //the private memory manager is destroyed, try the dangling list
if(!sPrivatePoolEnabled)
{
free(addr) ; //private pool is disabled.
}
else if(!sInstance) //the private memory manager is destroyed, try the dangling list
{
for(S32 i = 0 ; i < sDanglingPoolList.size(); i++)
{
@ -2036,12 +2041,13 @@ void LLPrivateMemoryPoolManager::freeMem(LLPrivateMemoryPool* poolp, void* addr
addr = NULL ;
break ;
}
}
}
llassert_always(!addr) ; //addr should be release before hitting here!
}
else
{
llerrs << "private pool is used before initialized.!" << llendl ;
}
llassert_always(!addr) ; //addr should be release before hitting here!
free(addr) ;
}
}

View File

@ -394,12 +394,12 @@ public:
LLPrivateMemoryPool* newPool(S32 type) ;
void deletePool(LLPrivateMemoryPool* pool) ;
private:
static LLPrivateMemoryPoolManager* sInstance ;
std::vector<LLPrivateMemoryPool*> mPoolList ;
BOOL mPrivatePoolEnabled;
private:
std::vector<LLPrivateMemoryPool*> mPoolList ;
U32 mMaxPrivatePoolSize;
static LLPrivateMemoryPoolManager* sInstance ;
static BOOL sPrivatePoolEnabled;
static std::vector<LLPrivateMemoryPool*> sDanglingPoolList ;
public:
//debug and statistics info.

View File

@ -1031,6 +1031,8 @@ BOOL LLWindowWin32::switchContext(BOOL fullscreen, const LLCoordScreen &size, BO
mhInstance,
NULL);
LL_INFOS("Window") << "window is created." << llendl ;
//-----------------------------------------------------------------------
// Create GL drawing context
//-----------------------------------------------------------------------
@ -1120,6 +1122,8 @@ BOOL LLWindowWin32::switchContext(BOOL fullscreen, const LLCoordScreen &size, BO
return FALSE;
}
LL_INFOS("Window") << "Drawing context is created." << llendl ;
gGLManager.initWGL();
if (wglChoosePixelFormatARB)
@ -1256,7 +1260,7 @@ BOOL LLWindowWin32::switchContext(BOOL fullscreen, const LLCoordScreen &size, BO
LL_INFOS("Window") << "Choosing pixel formats: " << num_formats << " pixel formats returned" << LL_ENDL;
}
LL_INFOS("Window") << "pixel formats done." << llendl ;
S32 swap_method = 0;
S32 cur_format = num_formats-1;
@ -1306,6 +1310,8 @@ BOOL LLWindowWin32::switchContext(BOOL fullscreen, const LLCoordScreen &size, BO
mhInstance,
NULL);
LL_INFOS("Window") << "recreate window done." << llendl ;
if (!(mhDC = GetDC(mWindowHandle)))
{
close();

View File

@ -1970,6 +1970,8 @@ bool LLAppViewer::initThreads()
static const bool enable_threads = true;
#endif
LLImage::initClass();
LLVFSThread::initClass(enable_threads && false);
LLLFSThread::initClass(enable_threads && false);
@ -1979,8 +1981,7 @@ bool LLAppViewer::initThreads()
LLAppViewer::sTextureFetch = new LLTextureFetch(LLAppViewer::getTextureCache(),
sImageDecodeThread,
enable_threads && true,
app_metrics_qa_mode);
LLImage::initClass();
app_metrics_qa_mode);
if (LLFastTimer::sLog || LLFastTimer::sMetricLog)
{
@ -3084,6 +3085,8 @@ void LLAppViewer::handleViewerCrash()
llinfos << "Last render pool type: " << LLPipeline::sCurRenderPoolType << llendl ;
LLMemory::logMemoryInfo(true) ;
//print out recorded call stacks if there are any.
LLError::LLCallStacks::print();

View File

@ -403,11 +403,9 @@ bool LLAppViewerWin32::initHardwareTest()
//
if (FALSE == gSavedSettings.getBOOL("NoHardwareProbe"))
{
BOOL vram_only = !gSavedSettings.getBOOL("ProbeHardwareOnStartup");
// per DEV-11631 - disable hardware probing for everything
// but vram.
vram_only = TRUE;
BOOL vram_only = TRUE;
LLSplashScreen::update(LLTrans::getString("StartupDetectingHardware"));

View File

@ -1641,8 +1641,8 @@ void LLTextureCache::purgeTextures(bool validate)
{
purge_count++;
LL_DEBUGS("TextureCache") << "PURGING: " << filename << LL_ENDL;
removeEntry(idx, entries[idx], filename) ;
cache_size -= entries[idx].mBodySize;
removeEntry(idx, entries[idx], filename) ;
}
}
@ -1879,13 +1879,12 @@ void LLTextureCache::removeEntry(S32 idx, Entry& entry, std::string& filename)
file_maybe_exists = false;
}
}
mTexturesSizeTotal -= entry.mBodySize;
entry.mImageSize = -1;
entry.mBodySize = 0;
mHeaderIDMap.erase(entry.mID);
mTexturesSizeMap.erase(entry.mID);
mTexturesSizeTotal -= entry.mBodySize;
mTexturesSizeMap.erase(entry.mID);
mFreeList.insert(idx);
}

View File

@ -417,6 +417,48 @@ const S32 min_non_tex_system_mem = (128<<20); // 128 MB
F32 texmem_lower_bound_scale = 0.85f;
F32 texmem_middle_bound_scale = 0.925f;
//static
bool LLViewerTexture::isMemoryForTextureLow()
{
const static S32 MIN_FREE_TEXTURE_MEMORY = 5 ; //MB
const static S32 MIN_FREE_MAIN_MEMORy = 100 ; //MB
bool low_mem = false ;
if (gGLManager.mHasATIMemInfo)
{
S32 meminfo[4];
glGetIntegerv(GL_TEXTURE_FREE_MEMORY_ATI, meminfo);
if(meminfo[0] / 1024 < MIN_FREE_TEXTURE_MEMORY)
{
low_mem = true ;
}
}
#if 0 //ignore nVidia cards
else if (gGLManager.mHasNVXMemInfo)
{
S32 free_memory;
glGetIntegerv(GL_GPU_MEMORY_INFO_CURRENT_AVAILABLE_VIDMEM_NVX, &free_memory);
if(free_memory / 1024 < MIN_FREE_TEXTURE_MEMORY)
{
low_mem = true ;
}
}
#endif
if(!low_mem) //check main memory, only works for windows.
{
LLMemory::updateMemoryInfo() ;
if(LLMemory::getAvailableMemKB() / 1024 < MIN_FREE_MAIN_MEMORy)
{
low_mem = true ;
}
}
return low_mem ;
}
//static
void LLViewerTexture::updateClass(const F32 velocity, const F32 angular_velocity)
{
@ -449,6 +491,11 @@ void LLViewerTexture::updateClass(const F32 velocity, const F32 angular_velocity
sEvaluationTimer.reset();
}
}
else if(sEvaluationTimer.getElapsedTimeF32() > discard_delta_time && isMemoryForTextureLow())
{
sDesiredDiscardBias += discard_bias_delta;
sEvaluationTimer.reset();
}
else if (sDesiredDiscardBias > 0.0f &&
BYTES_TO_MEGA_BYTES(sBoundTextureMemoryInBytes) < sMaxBoundTextureMemInMegaBytes * texmem_lower_bound_scale &&
BYTES_TO_MEGA_BYTES(sTotalTextureMemoryInBytes) < sMaxTotalTextureMemInMegaBytes * texmem_lower_bound_scale)

View File

@ -267,6 +267,7 @@ private:
/*virtual*/ LLImageGL* getGLTexture() const ;
virtual void switchToCachedImage();
static bool isMemoryForTextureLow() ;
protected:
LLUUID mID;
S32 mBoostLevel; // enum describing priority level

View File

@ -530,9 +530,11 @@ void LLViewerTextureList::removeImageFromList(LLViewerFetchedTexture *image)
}
llerrs << "LLViewerTextureList::removeImageFromList - Image not in list" << llendl;
}
if(mImageList.erase(image) != 1)
S32 count = mImageList.erase(image) ;
if(count != 1)
{
llerrs << "Error happens when remove image from mImageList!" << llendl ;
llerrs << "Error happens when remove image from mImageList: " << count << llendl ;
}
image->setInImageList(FALSE) ;
@ -1053,6 +1055,13 @@ S32 LLViewerTextureList::getMaxVideoRamSetting(bool get_recommended)
// Treat any card with < 32 MB (shudder) as having 32 MB
// - it's going to be swapping constantly regardless
S32 max_vram = gGLManager.mVRAM;
if(gGLManager.mIsATI)
{
//shrink the availabe vram for ATI cards because some of them do not handel texture swapping well.
max_vram *= 0.75f;
}
max_vram = llmax(max_vram, getMinVideoRamSetting());
max_texmem = max_vram;
if (!get_recommended)
@ -1060,10 +1069,19 @@ S32 LLViewerTextureList::getMaxVideoRamSetting(bool get_recommended)
}
else
{
if (get_recommended)
max_texmem = 128;
else
if (!get_recommended)
{
max_texmem = 512;
}
else if (gSavedSettings.getBOOL("NoHardwareProbe")) //did not do hardware detection at startup
{
max_texmem = 512;
}
else
{
max_texmem = 128;
}
llwarns << "VRAM amount not detected, defaulting to " << max_texmem << " MB" << llendl;
}