summaryrefslogtreecommitdiff
path: root/indra/newview/llviewertexture.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'indra/newview/llviewertexture.cpp')
-rw-r--r--indra/newview/llviewertexture.cpp315
1 files changed, 256 insertions, 59 deletions
diff --git a/indra/newview/llviewertexture.cpp b/indra/newview/llviewertexture.cpp
index 786e2b73b1..08fcb60d03 100644
--- a/indra/newview/llviewertexture.cpp
+++ b/indra/newview/llviewertexture.cpp
@@ -39,7 +39,6 @@
#include "llimagebmp.h"
#include "llimagej2c.h"
#include "llimagetga.h"
-#include "llmemtype.h"
#include "llstl.h"
#include "llvfile.h"
#include "llvfs.h"
@@ -62,11 +61,13 @@
#include "llmediaentry.h"
#include "llvovolume.h"
#include "llviewermedia.h"
+#include "lltexturecache.h"
///////////////////////////////////////////////////////////////////////////////
// statics
LLPointer<LLViewerTexture> LLViewerTexture::sNullImagep = NULL;
LLPointer<LLViewerTexture> LLViewerTexture::sBlackImagep = NULL;
+LLPointer<LLViewerTexture> LLViewerTexture::sCheckerBoardImagep = NULL;
LLPointer<LLViewerFetchedTexture> LLViewerFetchedTexture::sMissingAssetImagep = NULL;
LLPointer<LLViewerFetchedTexture> LLViewerFetchedTexture::sWhiteImagep = NULL;
LLPointer<LLViewerFetchedTexture> LLViewerFetchedTexture::sDefaultImagep = NULL;
@@ -87,6 +88,7 @@ S32 LLViewerTexture::sMaxBoundTextureMemInMegaBytes = 0;
S32 LLViewerTexture::sMaxTotalTextureMemInMegaBytes = 0;
S32 LLViewerTexture::sMaxDesiredTextureMemInBytes = 0 ;
S8 LLViewerTexture::sCameraMovingDiscardBias = 0 ;
+F32 LLViewerTexture::sCameraMovingBias = 0.0f ;
S32 LLViewerTexture::sMaxSculptRez = 128 ; //max sculpt image size
const S32 MAX_CACHED_RAW_IMAGE_AREA = 64 * 64 ;
const S32 MAX_CACHED_RAW_SCULPT_IMAGE_AREA = LLViewerTexture::sMaxSculptRez * LLViewerTexture::sMaxSculptRez ;
@@ -96,6 +98,9 @@ S32 LLViewerTexture::sMaxSmallImageSize = MAX_CACHED_RAW_IMAGE_AREA ;
BOOL LLViewerTexture::sFreezeImageScalingDown = FALSE ;
F32 LLViewerTexture::sCurrentTime = 0.0f ;
BOOL LLViewerTexture::sUseTextureAtlas = FALSE ;
+F32 LLViewerTexture::sTexelPixelRatio = 1.0f;
+
+LLViewerTexture::EDebugTexels LLViewerTexture::sDebugTexelsMode = LLViewerTexture::DEBUG_TEXELS_OFF;
const F32 desired_discard_bias_min = -2.0f; // -max number of levels to improve image quality by
const F32 desired_discard_bias_max = (F32)MAX_DISCARD_LEVEL; // max number of levels to reduce image quality by
@@ -175,7 +180,12 @@ LLViewerTexture* LLViewerTextureManager::findTexture(const LLUUID& id)
}
return tex ;
}
-
+
+LLViewerFetchedTexture* LLViewerTextureManager::findFetchedTexture(const LLUUID& id)
+{
+ return gTextureList.findImage(id);
+}
+
LLViewerMediaTexture* LLViewerTextureManager::findMediaTexture(const LLUUID &media_id)
{
return LLViewerMediaTexture::findMediaTexture(media_id) ;
@@ -347,6 +357,21 @@ void LLViewerTextureManager::init()
LLViewerFetchedTexture::sSmokeImagep = LLViewerTextureManager::getFetchedTexture(IMG_SMOKE, TRUE, LLViewerTexture::BOOST_UI);
LLViewerFetchedTexture::sSmokeImagep->setNoDelete() ;
+ image_raw = new LLImageRaw(32,32,3);
+ data = image_raw->getData();
+
+ for (S32 i = 0; i < (32*32*3); i+=3)
+ {
+ S32 x = (i % (32*3)) / (3*16);
+ S32 y = i / (32*3*16);
+ U8 color = ((x + y) % 2) * 255;
+ data[i] = color;
+ data[i+1] = color;
+ data[i+2] = color;
+ }
+
+ LLViewerTexture::sCheckerBoardImagep = LLViewerTextureManager::getLocalTexture(image_raw.get(), TRUE);
+
LLViewerTexture::initClass() ;
if (LLMetricPerformanceTesterBasic::isMetricLogRequested(sTesterName) && !LLMetricPerformanceTesterBasic::getTester(sTesterName))
@@ -367,6 +392,7 @@ void LLViewerTextureManager::cleanup()
LLImageGL::sDefaultGLTexture = NULL ;
LLViewerTexture::sNullImagep = NULL;
LLViewerTexture::sBlackImagep = NULL;
+ LLViewerTexture::sCheckerBoardImagep = NULL;
LLViewerFetchedTexture::sDefaultImagep = NULL;
LLViewerFetchedTexture::sSmokeImagep = NULL;
LLViewerFetchedTexture::sMissingAssetImagep = NULL;
@@ -383,10 +409,10 @@ void LLViewerTextureManager::cleanup()
void LLViewerTexture::initClass()
{
LLImageGL::sDefaultGLTexture = LLViewerFetchedTexture::sDefaultImagep->getGLTexture() ;
-
- if(gAuditTexture)
+
+ if(gSavedSettings.getBOOL("TextureFetchDebuggerEnabled"))
{
- LLImageGL::setHighlightTexture(LLViewerTexture::OTHER) ;
+ sTexelPixelRatio = gSavedSettings.getF32("TexelPixelRatio");
}
}
@@ -417,11 +443,24 @@ 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 LLFastTimer::DeclareTimer FTM_TEXTURE_MEMORY_CHECK("Memory Check");
+
//static
bool LLViewerTexture::isMemoryForTextureLow()
{
- const static S32 MIN_FREE_TEXTURE_MEMORY = 5 ; //MB
- const static S32 MIN_FREE_MAIN_MEMORy = 100 ; //MB
+ const F32 WAIT_TIME = 1.0f ; //second
+ static LLFrameTimer timer ;
+
+ if(timer.getElapsedTimeF32() < WAIT_TIME) //call this once per second.
+ {
+ return false;
+ }
+ timer.reset() ;
+
+ LLFastTimer t(FTM_TEXTURE_MEMORY_CHECK);
+
+ const S32 MIN_FREE_TEXTURE_MEMORY = 5 ; //MB
+ const S32 MIN_FREE_MAIN_MEMORy = 100 ; //MB
bool low_mem = false ;
if (gGLManager.mHasATIMemInfo)
@@ -433,6 +472,15 @@ bool LLViewerTexture::isMemoryForTextureLow()
{
low_mem = true ;
}
+
+ if(!low_mem) //check main memory, only works for windows.
+ {
+ LLMemory::updateMemoryInfo() ;
+ if(LLMemory::getAvailableMemKB() / 1024 < MIN_FREE_MAIN_MEMORy)
+ {
+ low_mem = true ;
+ }
+ }
}
#if 0 //ignore nVidia cards
else if (gGLManager.mHasNVXMemInfo)
@@ -445,20 +493,14 @@ bool LLViewerTexture::isMemoryForTextureLow()
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 ;
- }
- }
+#endif
return low_mem ;
}
+static LLFastTimer::DeclareTimer FTM_TEXTURE_UPDATE_MEDIA("Media");
+static LLFastTimer::DeclareTimer FTM_TEXTURE_UPDATE_TEST("Test");
+
//static
void LLViewerTexture::updateClass(const F32 velocity, const F32 angular_velocity)
{
@@ -467,9 +509,14 @@ void LLViewerTexture::updateClass(const F32 velocity, const F32 angular_velocity
LLTexturePipelineTester* tester = (LLTexturePipelineTester*)LLMetricPerformanceTesterBasic::getTester(sTesterName);
if (tester)
{
+ LLFastTimer t(FTM_TEXTURE_UPDATE_TEST);
tester->update() ;
}
- LLViewerMediaTexture::updateClass() ;
+
+ {
+ LLFastTimer t(FTM_TEXTURE_UPDATE_MEDIA);
+ LLViewerMediaTexture::updateClass() ;
+ }
sBoundTextureMemoryInBytes = LLImageGL::sBoundTextureMemoryInBytes;//in bytes
sTotalTextureMemoryInBytes = LLImageGL::sGlobalTextureMemoryInBytes;//in bytes
@@ -513,7 +560,8 @@ void LLViewerTexture::updateClass(const F32 velocity, const F32 angular_velocity
F32 camera_moving_speed = LLViewerCamera::getInstance()->getAverageSpeed() ;
F32 camera_angular_speed = LLViewerCamera::getInstance()->getAverageAngularSpeed();
- sCameraMovingDiscardBias = (S8)llmax(0.2f * camera_moving_speed, 2.0f * camera_angular_speed - 1) ;
+ sCameraMovingBias = llmax(0.2f * camera_moving_speed, 2.0f * camera_angular_speed - 1);
+ sCameraMovingDiscardBias = (S8)(sCameraMovingBias);
LLViewerTexture::sFreezeImageScalingDown = (BYTES_TO_MEGA_BYTES(sBoundTextureMemoryInBytes) < 0.75f * sMaxBoundTextureMemInMegaBytes * texmem_middle_bound_scale) &&
(BYTES_TO_MEGA_BYTES(sTotalTextureMemoryInBytes) < 0.75f * sMaxTotalTextureMemInMegaBytes * texmem_middle_bound_scale) ;
@@ -575,6 +623,7 @@ LLViewerTexture::~LLViewerTexture()
void LLViewerTexture::init(bool firstinit)
{
mBoostLevel = LLViewerTexture::BOOST_NONE;
+ mSelectedTime = 0.f;
mFullWidth = 0;
mFullHeight = 0;
@@ -630,15 +679,18 @@ void LLViewerTexture::setBoostLevel(S32 level)
if(mBoostLevel != level)
{
mBoostLevel = level ;
- if(mBoostLevel != LLViewerTexture::BOOST_NONE)
+ if(mBoostLevel != LLViewerTexture::BOOST_NONE &&
+ mBoostLevel != LLViewerTexture::BOOST_SELECTED)
{
setNoDelete() ;
}
- if(gAuditTexture)
- {
- setCategory(mBoostLevel);
- }
}
+
+ if (mBoostLevel == LLViewerTexture::BOOST_SELECTED)
+ {
+ mSelectedTime = gFrameTimeSeconds;
+ }
+
}
@@ -691,6 +743,7 @@ void LLViewerTexture::addTextureStats(F32 virtual_size, BOOL needs_gltexture) co
mNeedsGLTexture = TRUE ;
}
+ virtual_size *= sTexelPixelRatio;
if(!mMaxVirtualSizeResetCounter)
{
//flag to reset the values because the old values are used.
@@ -1195,7 +1248,7 @@ void LLViewerFetchedTexture::init(bool firstinit)
mIsMissingAsset = FALSE;
mLoadedCallbackDesiredDiscardLevel = S8_MAX;
- mPauseLoadedCallBacks = TRUE ;
+ mPauseLoadedCallBacks = FALSE ;
mNeedsCreateTexture = FALSE;
@@ -1212,6 +1265,7 @@ void LLViewerFetchedTexture::init(bool firstinit)
mRequestDeltaTime = 0.f;
mForSculpt = FALSE ;
mIsFetched = FALSE ;
+ mInFastCacheList = FALSE;
mCachedRawImage = NULL ;
mCachedRawDiscardLevel = -1 ;
@@ -1225,6 +1279,8 @@ void LLViewerFetchedTexture::init(bool firstinit)
mLastReferencedSavedRawImageTime = 0.0f ;
mKeptSavedRawImageTime = 0.f ;
mLastCallBackActiveTime = 0.f;
+
+ mInDebug = FALSE;
}
LLViewerFetchedTexture::~LLViewerFetchedTexture()
@@ -1266,6 +1322,39 @@ void LLViewerFetchedTexture::cleanup()
mCachedRawDiscardLevel = -1 ;
mCachedRawImageReady = FALSE ;
mSavedRawImage = NULL ;
+ mSavedRawDiscardLevel = -1;
+}
+
+//access the fast cache
+void LLViewerFetchedTexture::loadFromFastCache()
+{
+ if(!mInFastCacheList)
+ {
+ return; //no need to access the fast cache.
+ }
+ mInFastCacheList = FALSE;
+
+ mRawImage = LLAppViewer::getTextureCache()->readFromFastCache(getID(), mRawDiscardLevel) ;
+ if(mRawImage.notNull())
+ {
+ mFullWidth = mRawImage->getWidth() << mRawDiscardLevel;
+ mFullHeight = mRawImage->getHeight() << mRawDiscardLevel;
+ setTexelsPerImage();
+
+ if(mFullWidth > MAX_IMAGE_SIZE || mFullHeight > MAX_IMAGE_SIZE)
+ {
+ //discard all oversized textures.
+ destroyRawImage();
+ setIsMissingAsset();
+ mRawDiscardLevel = INVALID_DISCARD_LEVEL ;
+ }
+ else
+ {
+ mRequestedDiscardLevel = mDesiredDiscardLevel + 1;
+ mIsRawImageValid = TRUE;
+ addToCreateTexture() ;
+ }
+ }
}
void LLViewerFetchedTexture::setForSculpt()
@@ -1273,9 +1362,10 @@ void LLViewerFetchedTexture::setForSculpt()
static const S32 MAX_INTERVAL = 8 ; //frames
mForSculpt = TRUE ;
- if(isForSculptOnly() && !getBoundRecently())
+ if(isForSculptOnly() && hasGLTexture() && !getBoundRecently())
{
destroyGLTexture() ; //sculpt image does not need gl texture.
+ mTextureState = ACTIVE;
}
checkCachedRawSculptImage() ;
setMaxVirtualSizeResetInterval(MAX_INTERVAL) ;
@@ -1356,10 +1446,10 @@ void LLViewerFetchedTexture::dump()
// ONLY called from LLViewerFetchedTextureList
void LLViewerFetchedTexture::destroyTexture()
{
- if(LLImageGL::sGlobalTextureMemoryInBytes < sMaxDesiredTextureMemInBytes)//not ready to release unused memory.
- {
- return ;
- }
+ //if(LLImageGL::sGlobalTextureMemoryInBytes < sMaxDesiredTextureMemInBytes)//not ready to release unused memory.
+ //{
+ // return ;
+ //}
if (mNeedsCreateTexture)//return if in the process of generating a new texture.
{
return ;
@@ -1693,7 +1783,7 @@ F32 LLViewerFetchedTexture::calcDecodePriority()
S32 ddiscard = MAX_DISCARD_LEVEL - (S32)desired;
ddiscard = llclamp(ddiscard, 0, MAX_DELTA_DISCARD_LEVEL_FOR_PRIORITY);
priority = (ddiscard + 1) * PRIORITY_DELTA_DISCARD_LEVEL_FACTOR;
- setAdditionalDecodePriority(1.0f) ;//boost the textures without any data so far.
+ setAdditionalDecodePriority(0.1f) ;//boost the textures without any data so far.
}
else if ((mMinDiscardLevel > 0) && (cur_discard <= mMinDiscardLevel))
{
@@ -1794,8 +1884,6 @@ F32 LLViewerFetchedTexture::maxDecodePriority()
void LLViewerFetchedTexture::setDecodePriority(F32 priority)
{
- llassert(!mInImageList);
-
mDecodePriority = priority;
if(mDecodePriority < F_ALMOST_ZERO)
@@ -1823,13 +1911,34 @@ void LLViewerFetchedTexture::updateVirtualSize()
for(U32 i = 0 ; i < mNumFaces ; i++)
{
LLFace* facep = mFaceList[i] ;
- if(facep->getDrawable()->isRecentlyVisible())
+ if( facep )
{
- addTextureStats(facep->getVirtualSize()) ;
- setAdditionalDecodePriority(facep->getImportanceToCamera()) ;
+ LLDrawable* drawable = facep->getDrawable();
+ if (drawable)
+ {
+ if(drawable->isRecentlyVisible())
+ {
+ if (getBoostLevel() == LLViewerTexture::BOOST_NONE &&
+ drawable->getVObj() && drawable->getVObj()->isSelected())
+ {
+ setBoostLevel(LLViewerTexture::BOOST_SELECTED);
+ }
+ addTextureStats(facep->getVirtualSize()) ;
+ setAdditionalDecodePriority(facep->getImportanceToCamera()) ;
+ }
+ }
}
}
+ //reset whether or not a face was selected after 10 seconds
+ const F32 SELECTION_RESET_TIME = 10.f;
+
+ if (getBoostLevel() == LLViewerTexture::BOOST_SELECTED &&
+ gFrameTimeSeconds - mSelectedTime > SELECTION_RESET_TIME)
+ {
+ setBoostLevel(LLViewerTexture::BOOST_NONE);
+ }
+
if(mMaxVirtualSizeResetCounter > 0)
{
mMaxVirtualSizeResetCounter--;
@@ -1856,9 +1965,25 @@ S32 LLViewerFetchedTexture::getCurrentDiscardLevelForFetching()
return current_discard ;
}
+bool LLViewerFetchedTexture::setDebugFetching(S32 debug_level)
+{
+ if(debug_level < 0)
+ {
+ mInDebug = FALSE;
+ return false;
+ }
+ mInDebug = TRUE;
+
+ mDesiredDiscardLevel = debug_level;
+
+ return true;
+}
+
bool LLViewerFetchedTexture::updateFetch()
{
static LLCachedControl<bool> textures_decode_disabled(gSavedSettings,"TextureDecodeDisabled");
+ static LLCachedControl<F32> sCameraMotionThreshold(gSavedSettings,"TextureCameraMotionThreshold");
+ static LLCachedControl<S32> sCameraMotionBoost(gSavedSettings,"TextureCameraMotionBoost");
if(textures_decode_disabled)
{
return false ;
@@ -1891,6 +2016,10 @@ bool LLViewerFetchedTexture::updateFetch()
{
return false; // process any raw image data in callbacks before replacing
}
+ if(mInFastCacheList)
+ {
+ return false;
+ }
S32 current_discard = getCurrentDiscardLevelForFetching() ;
S32 desired_discard = getDesiredDiscardLevel();
@@ -2008,6 +2137,10 @@ bool LLViewerFetchedTexture::updateFetch()
{
make_request = false;
}
+ else if(mDesiredDiscardLevel > getMaxDiscardLevel())
+ {
+ make_request = false;
+ }
else if (mNeedsCreateTexture || mIsMissingAsset)
{
make_request = false;
@@ -2016,23 +2149,34 @@ bool LLViewerFetchedTexture::updateFetch()
{
make_request = false;
}
+ else if(mCachedRawImage.notNull() && (current_discard < 0 || current_discard > mCachedRawDiscardLevel))
+ {
+ make_request = false;
+ switchToCachedImage() ; //use the cached raw data first
+ }
//else if (!isJustBound() && mCachedRawImageReady)
//{
// make_request = false;
//}
- if(make_request)
+ if (make_request)
{
- //load the texture progressively.
+ // Load the texture progressively: we try not to rush to the desired discard too fast.
+ // If the camera is not moving, we do not tweak the discard level notch by notch but go to the desired discard with larger boosted steps
+ // This mitigates the "textures stay blurry" problem when loading while not killing the texture memory while moving around
S32 delta_level = (mBoostLevel > LLViewerTexture::BOOST_NONE) ? 2 : 1 ;
- if(current_discard < 0)
+ if (current_discard < 0)
{
desired_discard = llmax(desired_discard, getMaxDiscardLevel() - delta_level);
}
- else
+ else if (LLViewerTexture::sCameraMovingBias < sCameraMotionThreshold)
{
- desired_discard = llmax(desired_discard, current_discard - delta_level);
+ desired_discard = llmax(desired_discard, current_discard - sCameraMotionBoost);
}
+ else
+ {
+ desired_discard = llmax(desired_discard, current_discard - delta_level);
+ }
if (mIsFetching)
{
@@ -2100,6 +2244,35 @@ bool LLViewerFetchedTexture::updateFetch()
return mIsFetching ? true : false;
}
+void LLViewerFetchedTexture::clearFetchedResults()
+{
+ if(mNeedsCreateTexture || mIsFetching)
+ {
+ return ;
+ }
+
+ cleanup();
+ destroyGLTexture();
+
+ if(getDiscardLevel() >= 0) //sculpty texture, force to invalidate
+ {
+ mGLTexturep->forceToInvalidateGLTexture();
+ }
+}
+
+void LLViewerFetchedTexture::forceToDeleteRequest()
+{
+ if (mHasFetcher)
+ {
+ mHasFetcher = FALSE;
+ mIsFetching = FALSE ;
+ }
+
+ resetTextureStats();
+
+ mDesiredDiscardLevel = getMaxDiscardLevel() + 1;
+}
+
void LLViewerFetchedTexture::setIsMissingAsset()
{
if (mUrl.empty())
@@ -2108,7 +2281,8 @@ void LLViewerFetchedTexture::setIsMissingAsset()
}
else
{
- llwarns << mUrl << ": Marking image as missing" << llendl;
+ //it is normal no map tile on an empty region.
+ //llwarns << mUrl << ": Marking image as missing" << llendl;
}
if (mHasFetcher)
{
@@ -2140,10 +2314,18 @@ void LLViewerFetchedTexture::setLoadedCallback( loaded_callback_func loaded_call
mLoadedCallbackDesiredDiscardLevel = llmin(mLoadedCallbackDesiredDiscardLevel, (S8)discard_level) ;
}
- if(mPauseLoadedCallBacks && !pause)
+ if(mPauseLoadedCallBacks)
{
- unpauseLoadedCallbacks(src_callback_list) ;
+ if(!pause)
+ {
+ unpauseLoadedCallbacks(src_callback_list) ;
+ }
}
+ else if(pause)
+ {
+ pauseLoadedCallbacks(src_callback_list) ;
+ }
+
LLLoadedCallbackEntry* entryp = new LLLoadedCallbackEntry(loaded_callback, discard_level, keep_imageraw, userdata, src_callback_list, this, pause);
mLoadedCallbackList.push_back(entryp);
@@ -2269,6 +2451,7 @@ void LLViewerFetchedTexture::unpauseLoadedCallbacks(const LLLoadedCallbackEntry:
}
}
mPauseLoadedCallBacks = FALSE ;
+ mLastCallBackActiveTime = sCurrentTime ;
if(need_raw)
{
mSaveRawImage = TRUE ;
@@ -2308,13 +2491,18 @@ void LLViewerFetchedTexture::pauseLoadedCallbacks(const LLLoadedCallbackEntry::s
bool LLViewerFetchedTexture::doLoadedCallbacks()
{
- static const F32 MAX_INACTIVE_TIME = 120.f ; //seconds
+ static const F32 MAX_INACTIVE_TIME = 900.f ; //seconds
if (mNeedsCreateTexture)
{
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.
return false ;
@@ -2337,12 +2525,8 @@ bool LLViewerFetchedTexture::doLoadedCallbacks()
// Remove ourself from the global list of textures with callbacks
gTextureList.mCallbackList.erase(this);
- }
- if(mPauseLoadedCallBacks)
- {
- destroyRawImage();
- return res; //paused
- }
+ return false ;
+ }
S32 gl_discard = getDiscardLevel();
@@ -2604,7 +2788,11 @@ bool LLViewerFetchedTexture::needsToSaveRawImage()
void LLViewerFetchedTexture::destroyRawImage()
{
- if (mAuxRawImage.notNull()) sAuxCount--;
+ if (mAuxRawImage.notNull())
+ {
+ sAuxCount--;
+ mAuxRawImage = NULL;
+ }
if (mRawImage.notNull())
{
@@ -2618,12 +2806,12 @@ void LLViewerFetchedTexture::destroyRawImage()
}
setCachedRawImage() ;
}
+
+ mRawImage = NULL;
+
+ mIsRawImageValid = FALSE;
+ mRawDiscardLevel = INVALID_DISCARD_LEVEL;
}
-
- mRawImage = NULL;
- mAuxRawImage = NULL;
- mIsRawImageValid = FALSE;
- mRawDiscardLevel = INVALID_DISCARD_LEVEL;
}
//use the mCachedRawImage to (re)generate the gl texture.
@@ -3136,8 +3324,13 @@ void LLViewerLODTexture::processTextureStats()
S32 current_discard = getDiscardLevel();
if (sDesiredDiscardBias > 0.0f && mBoostLevel < LLViewerTexture::BOOST_SCULPTED && current_discard >= 0)
{
+ if(desired_discard_bias_max <= sDesiredDiscardBias && !mForceToSaveRawImage)
+ {
+ //needs to release texture memory urgently
+ scaleDown() ;
+ }
// Limit the amount of GL memory bound each frame
- if ( BYTES_TO_MEGA_BYTES(sBoundTextureMemoryInBytes) > sMaxBoundTextureMemInMegaBytes * texmem_middle_bound_scale &&
+ else if ( BYTES_TO_MEGA_BYTES(sBoundTextureMemoryInBytes) > sMaxBoundTextureMemInMegaBytes * texmem_middle_bound_scale &&
(!getBoundRecently() || mDesiredDiscardLevel >= mCachedRawDiscardLevel))
{
scaleDown() ;
@@ -3258,10 +3451,14 @@ LLViewerMediaTexture::LLViewerMediaTexture(const LLUUID& id, BOOL usemipmaps, LL
sMediaMap.insert(std::make_pair(id, this));
mGLTexturep = gl_image ;
+
if(mGLTexturep.isNull())
{
generateGLTexture() ;
}
+
+ mGLTexturep->setAllowCompression(false);
+
mGLTexturep->setNeedsAlphaAndPickMask(FALSE) ;
mIsPlaying = FALSE ;