summaryrefslogtreecommitdiff
path: root/indra
diff options
context:
space:
mode:
authorSteve Bennetts <steve@lindenlab.com>2009-11-06 16:16:01 -0800
committerSteve Bennetts <steve@lindenlab.com>2009-11-06 16:16:01 -0800
commit485dcd9a8f89e885ceb290e70749fcb48767fdc6 (patch)
treed22ce15c10221c3f71c52aa65151d1b648c599c6 /indra
parent0a5cbfd195c5c67f105e7ea05684c4e726e689f0 (diff)
Fixed textrue prioritization so that boosted textures are always highest priority.
Diffstat (limited to 'indra')
-rw-r--r--indra/newview/llpreviewtexture.cpp5
-rw-r--r--indra/newview/llviewertexture.cpp86
-rw-r--r--indra/newview/llviewertexture.h4
3 files changed, 35 insertions, 60 deletions
diff --git a/indra/newview/llpreviewtexture.cpp b/indra/newview/llpreviewtexture.cpp
index d2527065db..3eab13fc4a 100644
--- a/indra/newview/llpreviewtexture.cpp
+++ b/indra/newview/llpreviewtexture.cpp
@@ -204,11 +204,6 @@ void LLPreviewTexture::draw()
// Pump the texture priority
F32 pixel_area = mLoadingFullImage ? (F32)MAX_IMAGE_AREA : (F32)(interior.getWidth() * interior.getHeight() );
mImage->addTextureStats( pixel_area );
- if(pixel_area > 0.f)
- {
- //boost the previewed image priority to the highest to make it to get loaded first.
- mImage->setAdditionalDecodePriority(1.0f) ;
- }
// Don't bother decoding more than we can display, unless
// we're loading the full image.
diff --git a/indra/newview/llviewertexture.cpp b/indra/newview/llviewertexture.cpp
index b2d7d71b53..9923c9ac74 100644
--- a/indra/newview/llviewertexture.cpp
+++ b/indra/newview/llviewertexture.cpp
@@ -986,8 +986,6 @@ void LLViewerFetchedTexture::init(bool firstinit)
mFetchPriority = 0;
mDownloadProgress = 0.f;
mFetchDeltaTime = 999999.f;
- mDecodeFrame = 0;
- mVisibleFrame = 0;
mForSculpt = FALSE ;
mIsFetched = FALSE ;
@@ -1370,16 +1368,6 @@ void LLViewerFetchedTexture::processTextureStats()
}
}
-//texture does not have any data, so we don't know the size of the image, treat it like 32 * 32.
-F32 LLViewerFetchedTexture::calcDecodePriorityForUnknownTexture(F32 pixel_priority)
-{
- F32 desired = (F32)(log(32.0/pixel_priority) / log_2);
- S32 ddiscard = MAX_DISCARD_LEVEL - (S32)desired + 1;
- ddiscard = llclamp(ddiscard, 1, 9);
-
- return ddiscard*100000.f;
-}
-
F32 LLViewerFetchedTexture::calcDecodePriority()
{
#ifndef LL_RELEASE_FOR_DOWNLOAD
@@ -1406,12 +1394,6 @@ F32 LLViewerFetchedTexture::calcDecodePriority()
S32 cur_discard = getDiscardLevel();
bool have_all_data = (cur_discard >= 0 && (cur_discard <= mDesiredDiscardLevel));
F32 pixel_priority = fsqrtf(mMaxVirtualSize);
- const S32 MIN_NOT_VISIBLE_FRAMES = 30; // NOTE: this function is not called every frame
- mDecodeFrame++;
- if (pixel_priority > 0.f)
- {
- mVisibleFrame = mDecodeFrame;
- }
F32 priority;
if (mIsMissingAsset)
@@ -1422,10 +1404,6 @@ F32 LLViewerFetchedTexture::calcDecodePriority()
{
priority = -1.0f ;
}
- else if (!isJustBound() && mCachedRawImageReady && !mBoostLevel)
- {
- priority = -1.0f;
- }
else if(mCachedRawDiscardLevel > -1 && mDesiredDiscardLevel >= mCachedRawDiscardLevel)
{
priority = -1.0f;
@@ -1447,11 +1425,6 @@ F32 LLViewerFetchedTexture::calcDecodePriority()
// Always want high boosted images
priority = 1.f;
}
- else if (mVisibleFrame == 0 || (mDecodeFrame - mVisibleFrame > MIN_NOT_VISIBLE_FRAMES))
- {
- // Don't decode anything that isn't visible unless it's important
- priority = -2.0f;
- }
else
{
// Leave the priority as-is
@@ -1460,7 +1433,13 @@ F32 LLViewerFetchedTexture::calcDecodePriority()
}
else if (cur_discard < 0)
{
- priority = calcDecodePriorityForUnknownTexture(pixel_priority) ;
+ //texture does not have any data, so we don't know the size of the image, treat it like 32 * 32.
+ // priority range = 100,000 - 500,000
+ static const F64 log_2 = log(2.0);
+ F32 desired = (F32)(log(32.0/pixel_priority) / log_2);
+ S32 ddiscard = MAX_DISCARD_LEVEL - (S32)desired;
+ ddiscard = llclamp(ddiscard, 0, 4);
+ priority = (ddiscard+1)*100000.f;
}
else if ((mMinDiscardLevel > 0) && (cur_discard <= mMinDiscardLevel))
{
@@ -1473,38 +1452,47 @@ F32 LLViewerFetchedTexture::calcDecodePriority()
}
else
{
- // priority range = 100000-400000
- S32 ddiscard = cur_discard - mDesiredDiscardLevel;
+ // priority range = 100,000 - 500,000
+ S32 desired_discard = mDesiredDiscardLevel;
if (getDontDiscard())
{
- ddiscard+=2;
+ desired_discard -= 2;
}
- else if (ddiscard > 2 && mGLTexturep.notNull() && !mGLTexturep->getBoundRecently() && mBoostLevel == LLViewerTexture::BOOST_NONE)
+ else if (!isJustBound() && mCachedRawImageReady && !mBoostLevel)
{
- ddiscard-=2;
+ // We haven't rendered this in the last half second, and we have a cached raw image, leave the desired discard as-is
+ desired_discard = cur_discard;
}
+ else if (mGLTexturep.notNull() && !mGLTexturep->getBoundRecently() && mBoostLevel == LLViewerTexture::BOOST_NONE)
+ {
+ // We haven't rendered this in a while, de-prioritize it
+ desired_discard += 2;
+ }
+ S32 ddiscard = cur_discard - desired_discard;
ddiscard = llclamp(ddiscard, 0, 4);
- priority = ddiscard*100000.f;
+ priority = (ddiscard+1)*100000.f;
}
+
+ // Priority Formula:
+ // BOOST_HIGH + ADDITIONAL PRI + DELTA DISCARD + BOOST LEVEL + PIXELS
+ // [10,000,000] + [1-9,000,000] + [1-400,000] + [1-20,000] + [0-999]
if (priority > 0.0f)
{
- // priority range = 100000-900000
- pixel_priority = llclamp(pixel_priority, 0.0f, priority-1.f);
+ pixel_priority = llclamp(pixel_priority, 0.0f, 999.f);
+
+ priority = pixel_priority + 1000.f * mBoostLevel;
- // priority range = [100000.f, 2000000.f]
if ( mBoostLevel > BOOST_HIGH)
{
- priority = 1000000.f + pixel_priority + 1000.f * (mBoostLevel - LLViewerTexture::BOOST_NONE);
+ priority += 10000000.f;
}
- else
- {
- priority += 0.f + pixel_priority + 1000.f * (mBoostLevel - LLViewerTexture::BOOST_NONE);
- }
-
- // priority range = [2100000.f, 5000000.f] if mAdditionalDecodePriority > 1.0
- if(mAdditionalDecodePriority > 1.0f)
+
+ if(mAdditionalDecodePriority > 0.0f)
{
- priority += 2000000.f + mAdditionalDecodePriority ;
+ // 1-9
+ S32 additional_priority = (S32)(1.0f + mAdditionalDecodePriority*8.0f + .5f); // round
+ // priority range += 0-9,000,000
+ priority += 1000000.f * (F32)additional_priority;
}
}
return priority;
@@ -1517,13 +1505,9 @@ void LLViewerFetchedTexture::setDecodePriority(F32 priority)
mDecodePriority = priority;
}
-F32 LLViewerFetchedTexture::maxAdditionalDecodePriority()
-{
- return 2000000.f;
-}
void LLViewerFetchedTexture::setAdditionalDecodePriority(F32 priority)
{
- priority *= maxAdditionalDecodePriority();
+ priority = llclamp(priority, 0.f, 1.f);
if(mAdditionalDecodePriority < priority)
{
mAdditionalDecodePriority = priority;
diff --git a/indra/newview/llviewertexture.h b/indra/newview/llviewertexture.h
index 4da6620658..bde87d1dd5 100644
--- a/indra/newview/llviewertexture.h
+++ b/indra/newview/llviewertexture.h
@@ -383,7 +383,6 @@ public:
F32 getDecodePriority() const { return mDecodePriority; };
void setAdditionalDecodePriority(F32 priority) ;
- F32 maxAdditionalDecodePriority() ;
void updateVirtualSize() ;
@@ -454,7 +453,6 @@ private:
void init(bool firstinit) ;
void cleanup() ;
- F32 calcDecodePriorityForUnknownTexture(F32 pixel_priority) ;
void saveRawImage() ;
BOOL forceFetch() ;
void setCachedRawImage() ;
@@ -488,8 +486,6 @@ protected:
F32 mDownloadProgress;
F32 mFetchDeltaTime;
F32 mRequestDeltaTime;
- S32 mDecodeFrame;
- S32 mVisibleFrame; // decode frame where image was last visible
F32 mDecodePriority; // The priority for decoding this image.
S32 mMinDiscardLevel;
S8 mDesiredDiscardLevel; // The discard level we'd LIKE to have - if we have it and there's space