V3 merge. Supposedly improves baked texture loading on other avatars. Also increase discard bias on ati if vram starts running out.
This commit is contained in:
@@ -75,6 +75,7 @@
|
|||||||
|
|
||||||
// statics
|
// statics
|
||||||
LLPointer<LLViewerTexture> LLViewerTexture::sNullImagep = NULL;
|
LLPointer<LLViewerTexture> LLViewerTexture::sNullImagep = NULL;
|
||||||
|
LLPointer<LLViewerTexture> LLViewerTexture::sBlackImagep = NULL;
|
||||||
LLPointer<LLViewerFetchedTexture> LLViewerFetchedTexture::sMissingAssetImagep = NULL;
|
LLPointer<LLViewerFetchedTexture> LLViewerFetchedTexture::sMissingAssetImagep = NULL;
|
||||||
LLPointer<LLViewerFetchedTexture> LLViewerFetchedTexture::sWhiteImagep = NULL;
|
LLPointer<LLViewerFetchedTexture> LLViewerFetchedTexture::sWhiteImagep = NULL;
|
||||||
LLPointer<LLViewerFetchedTexture> LLViewerFetchedTexture::sDefaultImagep = NULL;
|
LLPointer<LLViewerFetchedTexture> LLViewerFetchedTexture::sDefaultImagep = NULL;
|
||||||
@@ -314,17 +315,23 @@ LLViewerFetchedTexture* LLViewerTextureManager::getFetchedTextureFromHost(const
|
|||||||
|
|
||||||
void LLViewerTextureManager::init()
|
void LLViewerTextureManager::init()
|
||||||
{
|
{
|
||||||
LLPointer<LLImageRaw> raw = new LLImageRaw(1,1,3);
|
{
|
||||||
raw->clear(0x77, 0x77, 0x77, 0xFF);
|
LLPointer<LLImageRaw> raw = new LLImageRaw(1,1,3);
|
||||||
LLViewerTexture::sNullImagep = LLViewerTextureManager::getLocalTexture(raw.get(), TRUE) ;
|
raw->clear(0x77, 0x77, 0x77, 0xFF);
|
||||||
|
LLViewerTexture::sNullImagep = LLViewerTextureManager::getLocalTexture(raw.get(), TRUE) ;
|
||||||
|
}
|
||||||
|
|
||||||
|
const S32 dim = 128;
|
||||||
|
LLPointer<LLImageRaw> image_raw = new LLImageRaw(dim,dim,3);
|
||||||
|
U8* data = image_raw->getData();
|
||||||
|
|
||||||
|
memset(data, 0, dim * dim * 3) ;
|
||||||
|
LLViewerTexture::sBlackImagep = LLViewerTextureManager::getLocalTexture(image_raw.get(), TRUE) ;
|
||||||
|
|
||||||
#if 1
|
#if 1
|
||||||
LLPointer<LLViewerFetchedTexture> imagep = LLViewerTextureManager::getFetchedTexture(IMG_DEFAULT);
|
LLPointer<LLViewerFetchedTexture> imagep = LLViewerTextureManager::getFetchedTexture(IMG_DEFAULT);
|
||||||
LLViewerFetchedTexture::sDefaultImagep = imagep;
|
LLViewerFetchedTexture::sDefaultImagep = imagep;
|
||||||
|
|
||||||
const S32 dim = 128;
|
|
||||||
LLPointer<LLImageRaw> image_raw = new LLImageRaw(dim,dim,3);
|
|
||||||
U8* data = image_raw->getData();
|
|
||||||
for (S32 i = 0; i<dim; i++)
|
for (S32 i = 0; i<dim; i++)
|
||||||
{
|
{
|
||||||
for (S32 j = 0; j<dim; j++)
|
for (S32 j = 0; j<dim; j++)
|
||||||
@@ -380,6 +387,7 @@ void LLViewerTextureManager::cleanup()
|
|||||||
|
|
||||||
LLImageGL::sDefaultGLTexture = NULL ;
|
LLImageGL::sDefaultGLTexture = NULL ;
|
||||||
LLViewerTexture::sNullImagep = NULL;
|
LLViewerTexture::sNullImagep = NULL;
|
||||||
|
LLViewerTexture::sBlackImagep = NULL;
|
||||||
LLViewerFetchedTexture::sDefaultImagep = NULL;
|
LLViewerFetchedTexture::sDefaultImagep = NULL;
|
||||||
LLViewerFetchedTexture::sSmokeImagep = NULL;
|
LLViewerFetchedTexture::sSmokeImagep = NULL;
|
||||||
LLViewerFetchedTexture::sMissingAssetImagep = NULL;
|
LLViewerFetchedTexture::sMissingAssetImagep = NULL;
|
||||||
@@ -432,6 +440,48 @@ const S32 min_non_tex_system_mem = (128<<20); // 128 MB
|
|||||||
F32 texmem_lower_bound_scale = 0.85f;
|
F32 texmem_lower_bound_scale = 0.85f;
|
||||||
F32 texmem_middle_bound_scale = 0.925f;
|
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
|
//static
|
||||||
void LLViewerTexture::updateClass(const F32 velocity, const F32 angular_velocity)
|
void LLViewerTexture::updateClass(const F32 velocity, const F32 angular_velocity)
|
||||||
{
|
{
|
||||||
@@ -468,6 +518,11 @@ void LLViewerTexture::updateClass(const F32 velocity, const F32 angular_velocity
|
|||||||
sEvaluationTimer.reset();
|
sEvaluationTimer.reset();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else if(sEvaluationTimer.getElapsedTimeF32() > discard_delta_time && isMemoryForTextureLow())
|
||||||
|
{
|
||||||
|
sDesiredDiscardBias += discard_bias_delta;
|
||||||
|
sEvaluationTimer.reset();
|
||||||
|
}
|
||||||
else if (sDesiredDiscardBias > 0.0f &&
|
else if (sDesiredDiscardBias > 0.0f &&
|
||||||
BYTES_TO_MEGA_BYTES(sBoundTextureMemoryInBytes) < sMaxBoundTextureMemInMegaBytes * texmem_lower_bound_scale &&
|
BYTES_TO_MEGA_BYTES(sBoundTextureMemoryInBytes) < sMaxBoundTextureMemInMegaBytes * texmem_lower_bound_scale &&
|
||||||
BYTES_TO_MEGA_BYTES(sTotalTextureMemoryInBytes) < sMaxTotalTextureMemInMegaBytes * texmem_lower_bound_scale)
|
BYTES_TO_MEGA_BYTES(sTotalTextureMemoryInBytes) < sMaxTotalTextureMemInMegaBytes * texmem_lower_bound_scale)
|
||||||
@@ -2259,6 +2314,7 @@ void LLViewerFetchedTexture::unpauseLoadedCallbacks(const LLLoadedCallbackEntry:
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
mPauseLoadedCallBacks = FALSE ;
|
mPauseLoadedCallBacks = FALSE ;
|
||||||
|
mLastCallBackActiveTime = sCurrentTime ;
|
||||||
if(need_raw)
|
if(need_raw)
|
||||||
{
|
{
|
||||||
mSaveRawImage = TRUE ;
|
mSaveRawImage = TRUE ;
|
||||||
@@ -2304,7 +2360,12 @@ bool LLViewerFetchedTexture::doLoadedCallbacks()
|
|||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if(sCurrentTime - mLastCallBackActiveTime > MAX_INACTIVE_TIME)
|
if(mPauseLoadedCallBacks)
|
||||||
|
{
|
||||||
|
destroyRawImage();
|
||||||
|
return false; //paused
|
||||||
|
}
|
||||||
|
if(sCurrentTime - mLastCallBackActiveTime > MAX_INACTIVE_TIME && !mIsFetching)
|
||||||
{
|
{
|
||||||
clearCallbackEntryList() ; //remove all callbacks.
|
clearCallbackEntryList() ; //remove all callbacks.
|
||||||
return false ;
|
return false ;
|
||||||
@@ -2327,11 +2388,7 @@ bool LLViewerFetchedTexture::doLoadedCallbacks()
|
|||||||
|
|
||||||
// Remove ourself from the global list of textures with callbacks
|
// Remove ourself from the global list of textures with callbacks
|
||||||
gTextureList.mCallbackList.erase(this);
|
gTextureList.mCallbackList.erase(this);
|
||||||
}
|
return false ;
|
||||||
if(mPauseLoadedCallBacks)
|
|
||||||
{
|
|
||||||
destroyRawImage();
|
|
||||||
return res; //paused
|
|
||||||
}
|
}
|
||||||
|
|
||||||
S32 gl_discard = getDiscardLevel();
|
S32 gl_discard = getDiscardLevel();
|
||||||
@@ -2594,7 +2651,11 @@ bool LLViewerFetchedTexture::needsToSaveRawImage()
|
|||||||
|
|
||||||
void LLViewerFetchedTexture::destroyRawImage()
|
void LLViewerFetchedTexture::destroyRawImage()
|
||||||
{
|
{
|
||||||
if (mAuxRawImage.notNull()) sAuxCount--;
|
if (mAuxRawImage.notNull())
|
||||||
|
{
|
||||||
|
sAuxCount--;
|
||||||
|
mAuxRawImage = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
if (mRawImage.notNull())
|
if (mRawImage.notNull())
|
||||||
{
|
{
|
||||||
@@ -2608,12 +2669,12 @@ void LLViewerFetchedTexture::destroyRawImage()
|
|||||||
}
|
}
|
||||||
setCachedRawImage() ;
|
setCachedRawImage() ;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
mRawImage = NULL;
|
mRawImage = NULL;
|
||||||
mAuxRawImage = NULL;
|
|
||||||
mIsRawImageValid = FALSE;
|
mIsRawImageValid = FALSE;
|
||||||
mRawDiscardLevel = INVALID_DISCARD_LEVEL;
|
mRawDiscardLevel = INVALID_DISCARD_LEVEL;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//use the mCachedRawImage to (re)generate the gl texture.
|
//use the mCachedRawImage to (re)generate the gl texture.
|
||||||
|
|||||||
@@ -277,6 +277,7 @@ private:
|
|||||||
/*virtual*/ LLImageGL* getGLTexture() const ;
|
/*virtual*/ LLImageGL* getGLTexture() const ;
|
||||||
virtual void switchToCachedImage();
|
virtual void switchToCachedImage();
|
||||||
|
|
||||||
|
static bool isMemoryForTextureLow() ;
|
||||||
protected:
|
protected:
|
||||||
LLUUID mID;
|
LLUUID mID;
|
||||||
S32 mBoostLevel; // enum describing priority level
|
S32 mBoostLevel; // enum describing priority level
|
||||||
@@ -340,6 +341,7 @@ public:
|
|||||||
//static BOOL sUseTextureAtlas ;
|
//static BOOL sUseTextureAtlas ;
|
||||||
|
|
||||||
static LLPointer<LLViewerTexture> sNullImagep; // Null texture for non-textured objects.
|
static LLPointer<LLViewerTexture> sNullImagep; // Null texture for non-textured objects.
|
||||||
|
static LLPointer<LLViewerTexture> sBlackImagep; // Texture to show NOTHING (pure black)
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -543,9 +543,11 @@ void LLViewerTextureList::removeImageFromList(LLViewerFetchedTexture *image)
|
|||||||
}
|
}
|
||||||
llerrs << "LLViewerTextureList::removeImageFromList - Image not in list" << llendl;
|
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) ;
|
image->setInImageList(FALSE) ;
|
||||||
|
|||||||
Reference in New Issue
Block a user