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.cpp126
1 files changed, 77 insertions, 49 deletions
diff --git a/indra/newview/llviewertexture.cpp b/indra/newview/llviewertexture.cpp
index 2929dce898..75bb9f84e2 100644
--- a/indra/newview/llviewertexture.cpp
+++ b/indra/newview/llviewertexture.cpp
@@ -114,6 +114,7 @@ LLLoadedCallbackEntry::LLLoadedCallbackEntry(loaded_callback_func cb,
BOOL need_imageraw, // Needs image raw for the callback
void* userdata,
LLLoadedCallbackEntry::source_callback_list_t* src_callback_list,
+ void* source,
LLViewerFetchedTexture* target,
BOOL pause)
: mCallback(cb),
@@ -122,6 +123,7 @@ LLLoadedCallbackEntry::LLLoadedCallbackEntry(loaded_callback_func cb,
mNeedsImageRaw(need_imageraw),
mUserData(userdata),
mSourceCallbackList(src_callback_list),
+ mSource(source),
mPaused(pause)
{
if(mSourceCallbackList)
@@ -143,10 +145,10 @@ void LLLoadedCallbackEntry::removeTexture(LLViewerFetchedTexture* tex)
}
//static
-void LLLoadedCallbackEntry::cleanUpCallbackList(LLLoadedCallbackEntry::source_callback_list_t* callback_list)
+void LLLoadedCallbackEntry::cleanUpCallbackList(LLLoadedCallbackEntry::source_callback_list_t* callback_list, void* src)
{
//clear texture callbacks.
- if(callback_list && !callback_list->empty())
+ if(!callback_list->empty())
{
for(LLLoadedCallbackEntry::source_callback_list_t::iterator iter = callback_list->begin();
iter != callback_list->end(); ++iter)
@@ -154,7 +156,7 @@ void LLLoadedCallbackEntry::cleanUpCallbackList(LLLoadedCallbackEntry::source_ca
LLViewerFetchedTexture* tex = gTextureList.findImage(*iter) ;
if(tex)
{
- tex->deleteCallbackEntry(callback_list) ;
+ tex->deleteCallbackEntry(src) ;
}
}
callback_list->clear() ;
@@ -493,6 +495,7 @@ LLViewerTexture::LLViewerTexture(const U32 width, const U32 height, const U8 com
mFullHeight = height ;
mUseMipMaps = usemipmaps ;
mComponents = components ;
+ setTexelsPerImage();
mID.generate();
sImageCount++;
@@ -511,7 +514,6 @@ LLViewerTexture::LLViewerTexture(const LLImageRaw* raw, BOOL usemipmaps)
LLViewerTexture::~LLViewerTexture()
{
- cleanup();
sImageCount--;
}
@@ -521,6 +523,7 @@ void LLViewerTexture::init(bool firstinit)
mFullWidth = 0;
mFullHeight = 0;
+ mTexelsPerImage = 0 ;
mUseMipMaps = FALSE ;
mComponents = 0 ;
@@ -529,7 +532,7 @@ void LLViewerTexture::init(bool firstinit)
mMaxVirtualSize = 0.f;
mNeedsGLTexture = FALSE ;
mMaxVirtualSizeResetInterval = 1;
- mMaxVirtualSizeResetCounter = 1 ;
+ mMaxVirtualSizeResetCounter = mMaxVirtualSizeResetInterval ;
mAdditionalDecodePriority = 0.f ;
mParcelMedia = NULL ;
mNumFaces = 0 ;
@@ -544,6 +547,7 @@ S8 LLViewerTexture::getType() const
return LLViewerTexture::LOCAL_TEXTURE ;
}
+//virtual
void LLViewerTexture::cleanup()
{
mFaceList.clear() ;
@@ -836,7 +840,8 @@ BOOL LLViewerTexture::createGLTexture(S32 discard_level, const LLImageRaw* image
{
mFullWidth = mGLTexturep->getCurrentWidth() ;
mFullHeight = mGLTexturep->getCurrentHeight() ;
- mComponents = mGLTexturep->getComponents() ;
+ mComponents = mGLTexturep->getComponents() ;
+ setTexelsPerImage();
}
return ret ;
@@ -1054,9 +1059,16 @@ void LLViewerTexture::destroyGLTexture()
}
}
+void LLViewerTexture::setTexelsPerImage()
+{
+ S32 fullwidth = llmin(mFullWidth,(S32)MAX_IMAGE_SIZE_DEFAULT);
+ S32 fullheight = llmin(mFullHeight,(S32)MAX_IMAGE_SIZE_DEFAULT);
+ mTexelsPerImage = (F32)fullwidth * fullheight;
+}
+
BOOL LLViewerTexture::isLargeImage()
{
- return mFullWidth * mFullHeight > LLViewerTexture::sMinLargeImageSize ;
+ return (S32)mTexelsPerImage > LLViewerTexture::sMinLargeImageSize ;
}
//virtual
@@ -1174,6 +1186,7 @@ S8 LLViewerFetchedTexture::getType() const
return LLViewerTexture::FETCHED_TEXTURE ;
}
+//virtual
void LLViewerFetchedTexture::cleanup()
{
for(callback_list_t::iterator iter = mLoadedCallbackList.begin();
@@ -1195,6 +1208,8 @@ void LLViewerFetchedTexture::cleanup()
mCachedRawDiscardLevel = -1 ;
mCachedRawImageReady = FALSE ;
mSavedRawImage = NULL ;
+
+ LLViewerTexture::cleanup();
}
void LLViewerFetchedTexture::setForSculpt()
@@ -1410,6 +1425,7 @@ BOOL LLViewerFetchedTexture::createTexture(S32 usename/*= 0*/)
mFullWidth = mRawImage->getWidth();
mFullHeight = mRawImage->getHeight();
+ setTexelsPerImage();
}
else
{
@@ -1604,7 +1620,6 @@ 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.
}
else if ((mMinDiscardLevel > 0) && (cur_discard <= mMinDiscardLevel))
{
@@ -1615,11 +1630,7 @@ F32 LLViewerFetchedTexture::calcDecodePriority()
{
// priority range = 100,000 - 500,000
S32 desired_discard = mDesiredDiscardLevel;
- if (getDontDiscard())
- {
- desired_discard -= 2;
- }
- else if (!isJustBound() && mCachedRawImageReady)
+ if (!isJustBound() && mCachedRawImageReady)
{
if(mBoostLevel < BOOST_HIGH)
{
@@ -1635,7 +1646,7 @@ F32 LLViewerFetchedTexture::calcDecodePriority()
S32 ddiscard = cur_discard - desired_discard;
ddiscard = llclamp(ddiscard, -1, MAX_DELTA_DISCARD_LEVEL_FOR_PRIORITY);
- priority = (ddiscard + 1) * PRIORITY_DELTA_DISCARD_LEVEL_FACTOR;
+ priority = (ddiscard + 1) * PRIORITY_DELTA_DISCARD_LEVEL_FACTOR;
}
// Priority Formula:
@@ -1643,19 +1654,51 @@ F32 LLViewerFetchedTexture::calcDecodePriority()
// [10,000,000] + [1,000,000-9,000,000] + [100,000-500,000] + [1-20,000] + [0-999]
if (priority > 0.0f)
{
+ bool large_enough = mCachedRawImageReady && ((S32)mTexelsPerImage > sMinLargeImageSize) ;
+ if(large_enough)
+ {
+ //Note:
+ //to give small, low-priority textures some chance to be fetched,
+ //cut the priority in half if the texture size is larger than 256 * 256 and has a 64*64 ready.
+ priority *= 0.5f ;
+ }
+
pixel_priority = llclamp(pixel_priority, 0.0f, MAX_PRIORITY_PIXEL);
priority += pixel_priority + PRIORITY_BOOST_LEVEL_FACTOR * mBoostLevel;
if ( mBoostLevel > BOOST_HIGH)
{
- priority += PRIORITY_BOOST_HIGH_FACTOR;
+ if(mBoostLevel > BOOST_SUPER_HIGH)
+ {
+ //for very important textures, always grant the highest priority.
+ priority += PRIORITY_BOOST_HIGH_FACTOR;
+ }
+ else if(mCachedRawImageReady)
+ {
+ //Note:
+ //to give small, low-priority textures some chance to be fetched,
+ //if high priority texture has a 64*64 ready, lower its fetching priority.
+ setAdditionalDecodePriority(0.5f) ;
+ }
+ else
+ {
+ priority += PRIORITY_BOOST_HIGH_FACTOR;
+ }
}
if(mAdditionalDecodePriority > 0.0f)
{
// priority range += 1,000,000.f-9,000,000.f
- priority += PRIORITY_ADDITIONAL_FACTOR * (1.0 + mAdditionalDecodePriority * MAX_ADDITIONAL_LEVEL_FOR_PRIORITY);
+ F32 additional = PRIORITY_ADDITIONAL_FACTOR * (1.0 + mAdditionalDecodePriority * MAX_ADDITIONAL_LEVEL_FOR_PRIORITY);
+ if(large_enough)
+ {
+ //Note:
+ //to give small, low-priority textures some chance to be fetched,
+ //cut the additional priority to a quarter if the texture size is larger than 256 * 256 and has a 64*64 ready.
+ additional *= 0.25f ;
+ }
+ priority += additional;
}
}
return priority;
@@ -1698,11 +1741,6 @@ void LLViewerFetchedTexture::updateVirtualSize()
addTextureStats(0.f, FALSE) ;//reset
}
- if(mForceToSaveRawImage)
- {
- setAdditionalDecodePriority(0.75f) ; //boost the fetching priority
- }
-
for(U32 i = 0 ; i < mNumFaces ; i++)
{
LLFace* facep = mFaceList[i] ;
@@ -1815,6 +1853,7 @@ bool LLViewerFetchedTexture::updateFetch()
{
mFullWidth = mRawImage->getWidth() << mRawDiscardLevel;
mFullHeight = mRawImage->getHeight() << mRawDiscardLevel;
+ setTexelsPerImage();
if(mFullWidth > MAX_IMAGE_SIZE || mFullHeight > MAX_IMAGE_SIZE)
{
@@ -1999,7 +2038,7 @@ void LLViewerFetchedTexture::setIsMissingAsset()
}
void LLViewerFetchedTexture::setLoadedCallback( loaded_callback_func loaded_callback,
- S32 discard_level, BOOL keep_imageraw, BOOL needs_aux, void* userdata,
+ S32 discard_level, BOOL keep_imageraw, BOOL needs_aux, void* userdata, void* src,
LLLoadedCallbackEntry::source_callback_list_t* src_callback_list, BOOL pause)
{
//
@@ -2018,9 +2057,9 @@ void LLViewerFetchedTexture::setLoadedCallback( loaded_callback_func loaded_call
if(mPauseLoadedCallBacks && !pause)
{
- unpauseLoadedCallbacks(src_callback_list) ;
+ unpauseLoadedCallbacks(src) ;
}
- LLLoadedCallbackEntry* entryp = new LLLoadedCallbackEntry(loaded_callback, discard_level, keep_imageraw, userdata, src_callback_list, this, pause);
+ LLLoadedCallbackEntry* entryp = new LLLoadedCallbackEntry(loaded_callback, discard_level, keep_imageraw, userdata, src_callback_list, src, this, pause);
mLoadedCallbackList.push_back(entryp);
mNeedsAux |= needs_aux;
@@ -2035,9 +2074,9 @@ void LLViewerFetchedTexture::setLoadedCallback( loaded_callback_func loaded_call
}
}
-void LLViewerFetchedTexture::deleteCallbackEntry(const LLLoadedCallbackEntry::source_callback_list_t* callback_list)
+void LLViewerFetchedTexture::deleteCallbackEntry(void* src)
{
- if(mLoadedCallbackList.empty() || !callback_list)
+ if(mLoadedCallbackList.empty())
{
return ;
}
@@ -2048,13 +2087,13 @@ void LLViewerFetchedTexture::deleteCallbackEntry(const LLLoadedCallbackEntry::so
iter != mLoadedCallbackList.end(); )
{
LLLoadedCallbackEntry *entryp = *iter;
- if(entryp->mSourceCallbackList == callback_list)
+ if(entryp->mSource == src)
{
// We never finished loading the image. Indicate failure.
// Note: this allows mLoadedCallbackUserData to be cleaned up.
entryp->mCallback(FALSE, this, NULL, NULL, 0, TRUE, entryp->mUserData);
- iter = mLoadedCallbackList.erase(iter) ;
delete entryp;
+ iter = mLoadedCallbackList.erase(iter) ;
}
else
{
@@ -2093,20 +2132,14 @@ void LLViewerFetchedTexture::deleteCallbackEntry(const LLLoadedCallbackEntry::so
}
}
-void LLViewerFetchedTexture::unpauseLoadedCallbacks(const LLLoadedCallbackEntry::source_callback_list_t* callback_list)
+void LLViewerFetchedTexture::unpauseLoadedCallbacks(void* src)
{
- if(!callback_list)
- {
- mPauseLoadedCallBacks = FALSE ;
- return ;
- }
-
BOOL need_raw = FALSE ;
for(callback_list_t::iterator iter = mLoadedCallbackList.begin();
iter != mLoadedCallbackList.end(); )
{
LLLoadedCallbackEntry *entryp = *iter++;
- if(entryp->mSourceCallbackList == callback_list)
+ if(entryp->mSource == src)
{
entryp->mPaused = FALSE ;
if(entryp->mNeedsImageRaw)
@@ -2122,20 +2155,15 @@ void LLViewerFetchedTexture::unpauseLoadedCallbacks(const LLLoadedCallbackEntry:
}
}
-void LLViewerFetchedTexture::pauseLoadedCallbacks(const LLLoadedCallbackEntry::source_callback_list_t* callback_list)
+void LLViewerFetchedTexture::pauseLoadedCallbacks(void* src)
{
- if(!callback_list)
- {
- return ;
- }
-
bool paused = true ;
for(callback_list_t::iterator iter = mLoadedCallbackList.begin();
iter != mLoadedCallbackList.end(); )
{
LLLoadedCallbackEntry *entryp = *iter++;
- if(entryp->mSourceCallbackList == callback_list)
+ if(entryp->mSource == src)
{
entryp->mPaused = TRUE ;
}
@@ -2312,6 +2340,10 @@ bool LLViewerFetchedTexture::doLoadedCallbacks()
BOOL final = mRawDiscardLevel <= entryp->mDesiredDiscard ? TRUE : FALSE;
//llinfos << "Running callback for " << getID() << llendl;
//llinfos << mRawImage->getWidth() << "x" << mRawImage->getHeight() << llendl;
+ if (final)
+ {
+ //llinfos << "Final!" << llendl;
+ }
entryp->mLastUsedDiscard = mRawDiscardLevel;
entryp->mCallback(TRUE, this, mRawImage, mAuxRawImage, mRawDiscardLevel, final, entryp->mUserData);
if (final)
@@ -2890,10 +2922,6 @@ void LLViewerLODTexture::processTextureStats()
//static const F64 log_2 = log(2.0);
static const F64 log_4 = log(4.0);
- S32 fullwidth = llmin(mFullWidth,(S32)MAX_IMAGE_SIZE_DEFAULT);
- S32 fullheight = llmin(mFullHeight,(S32)MAX_IMAGE_SIZE_DEFAULT);
- mTexelsPerImage = (F32)fullwidth * fullheight;
-
F32 discard_level = 0.f;
// If we know the output width and height, we can force the discard
@@ -3668,7 +3696,7 @@ void LLTexturePipelineTester::updateStablizingTime()
{
F32 t = mEndStablizingTime - mStartStablizingTime ;
- if(t > F_ALMOST_ZERO && (t - mTotalStablizingTime) < F_ALMOST_ZERO)
+ if(t > 0.0001f && (t - mTotalStablizingTime) < 0.0001f)
{
//already stablized
mTotalStablizingTime = LLImageGL::sLastFrameTime - mStartStablizingTime ;
@@ -3793,7 +3821,7 @@ LLMetricPerformanceTester::LLTestSession* LLTexturePipelineTester::loadTestSessi
//time
F32 start_time = (*log)[label]["StartFetchingTime"].asReal() ;
F32 cur_time = (*log)[label]["Time"].asReal() ;
- if(start_time - start_fetching_time > F_ALMOST_ZERO) //fetching has paused for a while
+ if(start_time - start_fetching_time > 0.0001f) //fetching has paused for a while
{
sessionp->mTotalFetchingTime += total_fetching_time ;
sessionp->mTotalGrayTime += total_gray_time ;