summaryrefslogtreecommitdiff
path: root/indra/newview
diff options
context:
space:
mode:
authorDave Parks <davep@lindenlab.com>2023-03-10 10:52:35 -0600
committerDave Parks <davep@lindenlab.com>2023-03-10 10:52:35 -0600
commit25ede8638209fac8dde5b71bece4bc1dfa30ea16 (patch)
treece5deda0c12a9e157c07cb72001eda396b1a542e /indra/newview
parentcf72c8ec614fcfc2811f10dfacdc51ed3f477e31 (diff)
SL-19172 Texture streaming tune up. Incidental decruft.
Diffstat (limited to 'indra/newview')
-rw-r--r--indra/newview/app_settings/settings.xml17
-rw-r--r--indra/newview/lldrawable.cpp8
-rw-r--r--indra/newview/llface.cpp2
-rw-r--r--indra/newview/llface.h1
-rw-r--r--indra/newview/llspatialpartition.cpp62
-rw-r--r--indra/newview/lltextureview.cpp4
-rw-r--r--indra/newview/llviewerobject.cpp10
-rw-r--r--indra/newview/llviewerobjectlist.cpp20
-rw-r--r--indra/newview/llviewertexture.cpp211
-rw-r--r--indra/newview/llviewertexture.h3
-rw-r--r--indra/newview/llviewertexturelist.cpp36
-rw-r--r--indra/newview/llvovolume.cpp19
-rw-r--r--indra/newview/pipeline.cpp2
13 files changed, 203 insertions, 192 deletions
diff --git a/indra/newview/app_settings/settings.xml b/indra/newview/app_settings/settings.xml
index ffe2202a6d..a369b22ef1 100644
--- a/indra/newview/app_settings/settings.xml
+++ b/indra/newview/app_settings/settings.xml
@@ -12627,27 +12627,16 @@
<key>Value</key>
<real>20.0</real>
</map>
- <key>TextureCameraMotionThreshold</key>
+ <key>TextureBiasDistanceScale</key>
<map>
<key>Comment</key>
- <string>If the overall motion is lower than this value, textures will be loaded faster</string>
+ <string>When biasing textures to lower resolution due to lack of vram, weight to put on distance factor.</string>
<key>Persist</key>
<integer>1</integer>
<key>Type</key>
<string>F32</string>
<key>Value</key>
- <real>0.2</real>
- </map>
- <key>TextureCameraMotionBoost</key>
- <map>
- <key>Comment</key>
- <string>Progressive discard level decrement when the camera is still</string>
- <key>Persist</key>
- <integer>1</integer>
- <key>Type</key>
- <string>S32</string>
- <key>Value</key>
- <integer>3</integer>
+ <real>8.0</real>
</map>
<key>TextureDecodeDisabled</key>
<map>
diff --git a/indra/newview/lldrawable.cpp b/indra/newview/lldrawable.cpp
index 45df4d0eee..04b6ebd14c 100644
--- a/indra/newview/lldrawable.cpp
+++ b/indra/newview/lldrawable.cpp
@@ -1094,11 +1094,11 @@ void LLDrawable::updateUVMinMax()
bool LLDrawable::isVisible() const
{
if (LLViewerOctreeEntryData::isVisible())
-{
- return true;
-}
+ {
+ return true;
+ }
-{
+ {
LLViewerOctreeGroup* group = mEntry->getGroup();
if (group && group->isVisible())
{
diff --git a/indra/newview/llface.cpp b/indra/newview/llface.cpp
index 87abb06285..1ae13e06f5 100644
--- a/indra/newview/llface.cpp
+++ b/indra/newview/llface.cpp
@@ -357,8 +357,6 @@ void LLFace::switchTexture(U32 ch, LLViewerTexture* new_texture)
llassert(mTexture[ch].notNull());
- new_texture->addTextureStats(mTexture[ch]->getMaxVirtualSize()) ;
-
if (ch == LLRender::DIFFUSE_MAP)
{
getViewerObject()->changeTEImage(mTEOffset, new_texture) ;
diff --git a/indra/newview/llface.h b/indra/newview/llface.h
index ee8316018b..0a66dc6ba6 100644
--- a/indra/newview/llface.h
+++ b/indra/newview/llface.h
@@ -235,6 +235,7 @@ public: //aligned members
LLVector4a mExtents[2];
private:
+ friend class LLViewerTextureList;
F32 adjustPartialOverlapPixelArea(F32 cos_angle_to_view_dir, F32 radius );
BOOL calcPixelArea(F32& cos_angle_to_view_dir, F32& radius) ;
public:
diff --git a/indra/newview/llspatialpartition.cpp b/indra/newview/llspatialpartition.cpp
index 35e11b8991..d81d7ab674 100644
--- a/indra/newview/llspatialpartition.cpp
+++ b/indra/newview/llspatialpartition.cpp
@@ -3095,6 +3095,60 @@ void renderAgentTarget(LLVOAvatar* avatar)
}
}
+static void setTextureAreaDebugText(LLDrawable* drawablep)
+{
+ LLVOVolume* vobjp = drawablep->getVOVolume();
+
+ if (vobjp)
+ {
+ if (drawablep->mDistanceWRTCamera < 32.f)
+ {
+ std::ostringstream str;
+
+ for (S32 i = 0; i < vobjp->getNumTEs(); ++i)
+ {
+ if (i < drawablep->getNumFaces())
+ {
+ LLFace* facep = drawablep->getFace(i);
+
+ if (facep)
+ {
+ LLViewerTexture* imagep = facep->getTexture();
+
+ if (imagep)
+ {
+ str << llformat("D - %.2f", sqrtf(imagep->getMaxVirtualSize()));
+ }
+
+ imagep = vobjp->getTENormalMap(i);
+
+ if (imagep && imagep != LLViewerFetchedTexture::sDefaultImagep)
+ {
+ str << llformat("\nN - %.2f", sqrtf(imagep->getMaxVirtualSize()));
+ }
+
+ imagep = vobjp->getTESpecularMap(i);
+
+ if (imagep && imagep != LLViewerFetchedTexture::sDefaultImagep)
+ {
+ str << llformat("\nS - %.2f", sqrtf(imagep->getMaxVirtualSize()));
+ }
+
+ str << "\n\n";
+ }
+
+ vobjp->setDebugText(str.str());
+ }
+ break;
+ }
+ }
+ else
+ {
+ vobjp->setDebugText(".");
+ }
+ }
+}
+
class LLOctreeRenderNonOccluded : public OctreeTraveler
{
public:
@@ -3183,7 +3237,12 @@ public:
size.mul(0.5f);
drawBoxOutline(center, size);
}
- }
+ }
+
+ if (gPipeline.hasRenderDebugMask(LLPipeline::RENDER_DEBUG_TEXTURE_AREA))
+ {
+ setTextureAreaDebugText(drawable);
+ }
/*if (drawable->getVOVolume() && gPipeline.hasRenderDebugMask(LLPipeline::RENDER_DEBUG_TEXTURE_PRIORITY))
{
@@ -3514,6 +3573,7 @@ void LLSpatialPartition::renderDebug()
LLPipeline::RENDER_DEBUG_NORMALS |
LLPipeline::RENDER_DEBUG_POINTS |
//LLPipeline::RENDER_DEBUG_TEXTURE_PRIORITY |
+ LLPipeline::RENDER_DEBUG_TEXTURE_AREA |
LLPipeline::RENDER_DEBUG_TEXTURE_ANIM |
LLPipeline::RENDER_DEBUG_RAYCAST |
LLPipeline::RENDER_DEBUG_AVATAR_VOLUME |
diff --git a/indra/newview/lltextureview.cpp b/indra/newview/lltextureview.cpp
index 1f4f086352..ca93eb648b 100644
--- a/indra/newview/lltextureview.cpp
+++ b/indra/newview/lltextureview.cpp
@@ -175,10 +175,6 @@ void LLTextureBar::draw()
{
color = LLColor4::green4;
}
- else if (mImagep->getBoostLevel() > LLGLTexture::BOOST_ALM)
- {
- color = LLColor4::magenta; // except none and alm
- }
else if (mImagep->getMaxVirtualSize() <= 0.0f)
{
color = LLColor4::grey; color[VALPHA] = .7f;
diff --git a/indra/newview/llviewerobject.cpp b/indra/newview/llviewerobject.cpp
index e217ede067..fd3c8de3e9 100644
--- a/indra/newview/llviewerobject.cpp
+++ b/indra/newview/llviewerobject.cpp
@@ -4950,10 +4950,10 @@ void LLViewerObject::updateTEMaterialTextures(U8 te)
if (getTE(te)->getMaterialParams().notNull())
{
const LLUUID& norm_id = getTE(te)->getMaterialParams()->getNormalID();
- mTENormalMaps[te] = LLViewerTextureManager::getFetchedTexture(norm_id, FTT_DEFAULT, TRUE, LLGLTexture::BOOST_ALM, LLViewerTexture::LOD_TEXTURE);
+ mTENormalMaps[te] = LLViewerTextureManager::getFetchedTexture(norm_id, FTT_DEFAULT, TRUE, LLGLTexture::BOOST_NONE, LLViewerTexture::LOD_TEXTURE);
const LLUUID& spec_id = getTE(te)->getMaterialParams()->getSpecularID();
- mTESpecularMaps[te] = LLViewerTextureManager::getFetchedTexture(spec_id, FTT_DEFAULT, TRUE, LLGLTexture::BOOST_ALM, LLViewerTexture::LOD_TEXTURE);
+ mTESpecularMaps[te] = LLViewerTextureManager::getFetchedTexture(spec_id, FTT_DEFAULT, TRUE, LLGLTexture::BOOST_NONE, LLViewerTexture::LOD_TEXTURE);
}
LLFetchedGLTFMaterial* mat = (LLFetchedGLTFMaterial*) getTE(te)->getGLTFRenderMaterial();
@@ -4982,7 +4982,7 @@ void LLViewerObject::updateTEMaterialTextures(U8 te)
}
else
{
- img = LLViewerTextureManager::getFetchedTexture(id, FTT_DEFAULT, TRUE, LLGLTexture::BOOST_ALM, LLViewerTexture::LOD_TEXTURE);
+ img = LLViewerTextureManager::getFetchedTexture(id, FTT_DEFAULT, TRUE, LLGLTexture::BOOST_NONE, LLViewerTexture::LOD_TEXTURE);
img->addTextureStats(64.f * 64.f, TRUE);
}
}
@@ -5140,14 +5140,14 @@ S32 LLViewerObject::setTETexture(const U8 te, const LLUUID& uuid)
S32 LLViewerObject::setTENormalMap(const U8 te, const LLUUID& uuid)
{
LLViewerFetchedTexture *image = (uuid == LLUUID::null) ? NULL : LLViewerTextureManager::getFetchedTexture(
- uuid, FTT_DEFAULT, TRUE, LLGLTexture::BOOST_ALM, LLViewerTexture::LOD_TEXTURE, 0, 0, LLHost());
+ uuid, FTT_DEFAULT, TRUE, LLGLTexture::BOOST_NONE, LLViewerTexture::LOD_TEXTURE, 0, 0, LLHost());
return setTENormalMapCore(te, image);
}
S32 LLViewerObject::setTESpecularMap(const U8 te, const LLUUID& uuid)
{
LLViewerFetchedTexture *image = (uuid == LLUUID::null) ? NULL : LLViewerTextureManager::getFetchedTexture(
- uuid, FTT_DEFAULT, TRUE, LLGLTexture::BOOST_ALM, LLViewerTexture::LOD_TEXTURE, 0, 0, LLHost());
+ uuid, FTT_DEFAULT, TRUE, LLGLTexture::BOOST_NONE, LLViewerTexture::LOD_TEXTURE, 0, 0, LLHost());
return setTESpecularMapCore(te, image);
}
diff --git a/indra/newview/llviewerobjectlist.cpp b/indra/newview/llviewerobjectlist.cpp
index 816fa6607e..bb22d90cd9 100644
--- a/indra/newview/llviewerobjectlist.cpp
+++ b/indra/newview/llviewerobjectlist.cpp
@@ -815,19 +815,19 @@ void LLViewerObjectList::updateApparentAngles(LLAgent &agent)
mCurBin = (mCurBin + 1) % NUM_BINS;
}
-#if 1
+#if 0
// Slam priorities for textures that we care about (hovered, selected, and focused)
// Hovered
// Assumes only one level deep of parenting
LLSelectNode* nodep = LLSelectMgr::instance().getHoverNode();
- if (nodep)
- {
- objectp = nodep->getObject();
- if (objectp)
- {
- objectp->boostTexturePriority();
- }
- }
+ if (nodep)
+ {
+ objectp = nodep->getObject();
+ if (objectp)
+ {
+ objectp->boostTexturePriority();
+ }
+ }
// Focused
objectp = gAgentCamera.getFocusObject();
@@ -835,6 +835,7 @@ void LLViewerObjectList::updateApparentAngles(LLAgent &agent)
{
objectp->boostTexturePriority();
}
+#endif
// Selected
struct f : public LLSelectedObjectFunctor
@@ -846,7 +847,6 @@ void LLViewerObjectList::updateApparentAngles(LLAgent &agent)
}
} func;
LLSelectMgr::getInstance()->getSelection()->applyToRootObjects(&func);
-#endif
LLVOAvatar::cullAvatarsByPixelArea();
}
diff --git a/indra/newview/llviewertexture.cpp b/indra/newview/llviewertexture.cpp
index 578deb8b3f..f677a38f34 100644
--- a/indra/newview/llviewertexture.cpp
+++ b/indra/newview/llviewertexture.cpp
@@ -89,8 +89,6 @@ S32 LLViewerTexture::sAuxCount = 0;
LLFrameTimer LLViewerTexture::sEvaluationTimer;
F32 LLViewerTexture::sDesiredDiscardBias = 0.f;
F32 LLViewerTexture::sDesiredDiscardScale = 1.1f;
-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;
@@ -552,29 +550,26 @@ void LLViewerTexture::updateClass()
LLViewerMediaTexture::updateClass();
- if(isMemoryForTextureLow())
- {
- // Note: isMemoryForTextureLow() uses 1s delay, make sure we waited enough for it to recheck
- if (sEvaluationTimer.getElapsedTimeF32() > GPU_MEMORY_CHECK_WAIT_TIME)
- {
- sDesiredDiscardBias += discard_bias_delta;
- sEvaluationTimer.reset();
- }
- }
- else if (sDesiredDiscardBias > 0.0f
- && isMemoryForTextureSuficientlyFree())
- {
- // If we are using less texture memory than we should,
- // scale down the desired discard level
- if (sEvaluationTimer.getElapsedTimeF32() > discard_delta_time)
- {
- sDesiredDiscardBias -= discard_bias_delta;
- sEvaluationTimer.reset();
- }
- }
- sDesiredDiscardBias = llclamp(sDesiredDiscardBias, desired_discard_bias_min, desired_discard_bias_max);
+ static LLCachedControl<U32> max_vram_budget(gSavedSettings, "RenderMaxVRAMBudget", 0);
+
+ // get an estimate of how much video memory we're using
+ // NOTE: our metrics miss about half the vram we use, so this biases high but turns out to typically be within 5% of the real number
+ F32 used = (LLImageGL::getTextureBytesAllocated() + LLVertexBuffer::getBytesAllocated()) / 1024 / 512;
+
+ F32 budget = max_vram_budget == 0 ? gGLManager.mVRAM : max_vram_budget;
+
+ // try to leave half a GB for everyone else, but keep at least 768MB for ourselves
+ F32 target = llmax(budget - 512.f, 768.f);
+
+ F32 over_pct = llmax((used-target) / target, 0.f);
+ sDesiredDiscardBias = llmax(sDesiredDiscardBias, 1.f + over_pct);
- LLViewerTexture::sFreezeImageUpdates = sDesiredDiscardBias > (desired_discard_bias_max - 1.0f);
+ if (sDesiredDiscardBias > 1.f)
+ {
+ sDesiredDiscardBias -= gFrameIntervalSeconds * 0.01;
+ }
+
+ LLViewerTexture::sFreezeImageUpdates = false; // sDesiredDiscardBias > (desired_discard_bias_max - 1.0f);
}
//end of static functions
@@ -627,7 +622,6 @@ LLViewerTexture::~LLViewerTexture()
// virtual
void LLViewerTexture::init(bool firstinit)
{
- mSelectedTime = 0.f;
mMaxVirtualSize = 0.f;
mMaxVirtualSizeResetInterval = 1;
mMaxVirtualSizeResetCounter = mMaxVirtualSizeResetInterval;
@@ -685,7 +679,6 @@ void LLViewerTexture::setBoostLevel(S32 level)
{
mBoostLevel = level;
if(mBoostLevel != LLViewerTexture::BOOST_NONE &&
- mBoostLevel != LLViewerTexture::BOOST_ALM &&
mBoostLevel != LLViewerTexture::BOOST_SELECTED &&
mBoostLevel != LLViewerTexture::BOOST_ICON)
{
@@ -698,12 +691,6 @@ void LLViewerTexture::setBoostLevel(S32 level)
{
mMaxVirtualSize = 2048.f * 2048.f;
}
-
- if (mBoostLevel == LLViewerTexture::BOOST_SELECTED)
- {
- mSelectedTime = gFrameTimeSeconds;
- }
-
}
bool LLViewerTexture::isActiveFetching()
@@ -1710,10 +1697,6 @@ void LLViewerFetchedTexture::processTextureStats()
{
mDesiredDiscardLevel = 0;
}
- else if (!LLPipeline::sRenderDeferred && mBoostLevel == LLGLTexture::BOOST_ALM)
- { // ??? don't load spec and normal maps when alm is disabled ???
- mDesiredDiscardLevel = MAX_DISCARD_LEVEL + 1;
- }
else if (mDontDiscard && mBoostLevel == LLGLTexture::BOOST_ICON)
{
if (mFullWidth > MAX_IMAGE_SIZE_DEFAULT || mFullHeight > MAX_IMAGE_SIZE_DEFAULT)
@@ -1831,8 +1814,7 @@ bool LLViewerFetchedTexture::updateFetch()
{
LL_PROFILE_ZONE_SCOPED_CATEGORY_TEXTURE;
static LLCachedControl<bool> textures_decode_disabled(gSavedSettings,"TextureDecodeDisabled", false);
- static LLCachedControl<F32> sCameraMotionThreshold(gSavedSettings,"TextureCameraMotionThreshold", 0.2);
- static LLCachedControl<S32> sCameraMotionBoost(gSavedSettings,"TextureCameraMotionBoost", 3);
+
if(textures_decode_disabled) // don't fetch the surface textures in wireframe mode
{
return false;
@@ -2055,32 +2037,9 @@ bool LLViewerFetchedTexture::updateFetch()
make_request = false;
switchToCachedImage(); //use the cached raw data first
}
- //else if (!isJustBound() && mCachedRawImageReady)
- //{
- // make_request = false;
- //}
if (make_request)
{
-#if 0
- // 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 > LLGLTexture::BOOST_ALM) ? 2 : 1;
- if (current_discard < 0)
- {
- desired_discard = llmax(desired_discard, getMaxDiscardLevel() - delta_level);
- }
- else if (LLViewerTexture::sCameraMovingBias < sCameraMotionThreshold)
- {
- desired_discard = llmax(desired_discard, current_discard - sCameraMotionBoost);
- }
- else
- {
- desired_discard = llmax(desired_discard, current_discard - delta_level);
- }
-#endif
-
if (mIsFetching)
{
// already requested a higher resolution mip
@@ -3095,10 +3054,6 @@ void LLViewerLODTexture::processTextureStats()
if (mFullWidth > MAX_IMAGE_SIZE_DEFAULT || mFullHeight > MAX_IMAGE_SIZE_DEFAULT)
mDesiredDiscardLevel = 1; // MAX_IMAGE_SIZE_DEFAULT = 1024 and max size ever is 2048
}
- else if (!LLPipeline::sRenderDeferred && mBoostLevel == LLGLTexture::BOOST_ALM)
- {
- mDesiredDiscardLevel = MAX_DISCARD_LEVEL + 1;
- }
else if (mBoostLevel < LLGLTexture::BOOST_HIGH && mMaxVirtualSize <= 10.f)
{
// If the image has not been significantly visible in a while, we don't want it
@@ -3108,72 +3063,70 @@ void LLViewerLODTexture::processTextureStats()
{
mDesiredDiscardLevel = getMaxDiscardLevel();
}
- else
- {
- //static const F64 log_2 = log(2.0);
- static const F64 log_4 = log(4.0);
+ else
+ {
+ //static const F64 log_2 = log(2.0);
+ static const F64 log_4 = log(4.0);
- F32 discard_level = 0.f;
+ F32 discard_level = 0.f;
- // If we know the output width and height, we can force the discard
- // level to the correct value, and thus not decode more texture
- // data than we need to.
- if (mKnownDrawWidth && mKnownDrawHeight)
- {
- S32 draw_texels = mKnownDrawWidth * mKnownDrawHeight;
- draw_texels = llclamp(draw_texels, MIN_IMAGE_AREA, MAX_IMAGE_AREA);
+ // If we know the output width and height, we can force the discard
+ // level to the correct value, and thus not decode more texture
+ // data than we need to.
+ if (mKnownDrawWidth && mKnownDrawHeight)
+ {
+ S32 draw_texels = mKnownDrawWidth * mKnownDrawHeight;
+ draw_texels = llclamp(draw_texels, MIN_IMAGE_AREA, MAX_IMAGE_AREA);
- // Use log_4 because we're in square-pixel space, so an image
- // with twice the width and twice the height will have mTexelsPerImage
- // 4 * draw_size
- discard_level = (F32)(log(mTexelsPerImage/draw_texels) / log_4);
- }
- else
- {
- // Calculate the required scale factor of the image using pixels per texel
- discard_level = (F32)(log(mTexelsPerImage/mMaxVirtualSize) / log_4);
- mDiscardVirtualSize = mMaxVirtualSize;
- mCalculatedDiscardLevel = discard_level;
- }
- if (mBoostLevel < LLGLTexture::BOOST_SCULPTED)
- {
- discard_level += sDesiredDiscardBias;
- discard_level *= sDesiredDiscardScale; // scale
- discard_level += sCameraMovingDiscardBias;
- }
- discard_level = floorf(discard_level);
+ // Use log_4 because we're in square-pixel space, so an image
+ // with twice the width and twice the height will have mTexelsPerImage
+ // 4 * draw_size
+ discard_level = (F32)(log(mTexelsPerImage / draw_texels) / log_4);
+ }
+ else
+ {
+ // Calculate the required scale factor of the image using pixels per texel
+ discard_level = (F32)(log(mTexelsPerImage / mMaxVirtualSize) / log_4);
+ mDiscardVirtualSize = mMaxVirtualSize;
+ mCalculatedDiscardLevel = discard_level;
+ }
+ if (mBoostLevel < LLGLTexture::BOOST_SCULPTED)
+ {
+ //discard_level += sDesiredDiscardBias; // gradually increases to a maximum of 5 as vram runs low
+ discard_level *= sDesiredDiscardScale; // scale (default 1.1f)
+ }
+ discard_level = floorf(discard_level);
- F32 min_discard = 0.f;
- U32 desired_size = MAX_IMAGE_SIZE_DEFAULT; // MAX_IMAGE_SIZE_DEFAULT = 1024 and max size ever is 2048
- if (mBoostLevel <= LLGLTexture::BOOST_SCULPTED)
- {
- desired_size = DESIRED_NORMAL_TEXTURE_SIZE;
- }
- if (mFullWidth > desired_size || mFullHeight > desired_size)
- min_discard = 1.f;
+ F32 min_discard = 0.f;
+ U32 desired_size = MAX_IMAGE_SIZE_DEFAULT; // MAX_IMAGE_SIZE_DEFAULT = 1024 and max size ever is 2048
+ if (mBoostLevel <= LLGLTexture::BOOST_SCULPTED)
+ {
+ desired_size = DESIRED_NORMAL_TEXTURE_SIZE;
+ }
+ if (mFullWidth > desired_size || mFullHeight > desired_size)
+ min_discard = 1.f;
- discard_level = llclamp(discard_level, min_discard, (F32)MAX_DISCARD_LEVEL);
-
- // Can't go higher than the max discard level
- mDesiredDiscardLevel = llmin(getMaxDiscardLevel() + 1, (S32)discard_level);
- // Clamp to min desired discard
- mDesiredDiscardLevel = llmin(mMinDesiredDiscardLevel, mDesiredDiscardLevel);
+ discard_level = llclamp(discard_level, min_discard, (F32)MAX_DISCARD_LEVEL);
- //
- // At this point we've calculated the quality level that we want,
- // if possible. Now we check to see if we have it, and take the
- // proper action if we don't.
- //
+ // Can't go higher than the max discard level
+ mDesiredDiscardLevel = llmin(getMaxDiscardLevel() + 1, (S32)discard_level);
+ // Clamp to min desired discard
+ mDesiredDiscardLevel = llmin(mMinDesiredDiscardLevel, mDesiredDiscardLevel);
- S32 current_discard = getDiscardLevel();
- if (sDesiredDiscardBias > 0.0f && mBoostLevel < LLGLTexture::BOOST_SCULPTED && current_discard >= 0)
- {
- if(desired_discard_bias_max <= sDesiredDiscardBias && !mForceToSaveRawImage)
- {
- //needs to release texture memory urgently
- scaleDown();
- }
- }
+ //
+ // At this point we've calculated the quality level that we want,
+ // if possible. Now we check to see if we have it, and take the
+ // proper action if we don't.
+ //
+
+ S32 current_discard = getDiscardLevel();
+ if (mBoostLevel < LLGLTexture::BOOST_SCULPTED && current_discard >= 0)
+ {
+ if (current_discard < (mDesiredDiscardLevel-1) && !mForceToSaveRawImage)
+ { // should scale down
+ scaleDown();
+ }
+ }
if (isUpdateFrozen() // we are out of memory and nearing max allowed bias
&& mBoostLevel < LLGLTexture::BOOST_SCULPTED
@@ -3188,6 +3141,16 @@ void LLViewerLODTexture::processTextureStats()
{
mDesiredDiscardLevel = llmin(mDesiredDiscardLevel, (S8)mDesiredSavedRawDiscardLevel);
}
+
+ // decay max virtual size over time
+ mMaxVirtualSize *= 0.8f;
+
+ // selection manager will immediately reset BOOST_SELECTED but never unsets it
+ // unset it immediately after we consume it
+ if (getBoostLevel() == BOOST_SELECTED)
+ {
+ setBoostLevel(BOOST_NONE);
+ }
}
bool LLViewerLODTexture::scaleDown()
diff --git a/indra/newview/llviewertexture.h b/indra/newview/llviewertexture.h
index facf05e52f..1370f4debe 100644
--- a/indra/newview/llviewertexture.h
+++ b/indra/newview/llviewertexture.h
@@ -195,7 +195,6 @@ protected:
LLUUID mID;
S32 mTextureListType; // along with mID identifies where to search for this texture in TextureList
- F32 mSelectedTime; // time texture was last selected
mutable F32 mMaxVirtualSize = 0.f; // The largest virtual size of the image, in pixels - how much data to we need?
mutable S32 mMaxVirtualSizeResetCounter;
mutable S32 mMaxVirtualSizeResetInterval;
@@ -223,8 +222,6 @@ public:
static LLFrameTimer sEvaluationTimer;
static F32 sDesiredDiscardBias;
static F32 sDesiredDiscardScale;
- static S8 sCameraMovingDiscardBias;
- static F32 sCameraMovingBias;
static S32 sMaxSculptRez ;
static U32 sMinLargeImageSize ;
static U32 sMaxSmallImageSize ;
diff --git a/indra/newview/llviewertexturelist.cpp b/indra/newview/llviewertexturelist.cpp
index 611aace4b4..8db4db795e 100644
--- a/indra/newview/llviewertexturelist.cpp
+++ b/indra/newview/llviewertexturelist.cpp
@@ -61,6 +61,7 @@
#include "llviewerdisplay.h"
#include "llviewerwindow.h"
#include "llprogressview.h"
+
////////////////////////////////////////////////////////////////////////////
void (*LLViewerTextureList::sUUIDCallback)(void **, const LLUUID&) = NULL;
@@ -533,12 +534,6 @@ LLViewerFetchedTexture* LLViewerTextureList::getImage(const LLUUID &image_id,
LLPointer<LLViewerFetchedTexture> imagep = findImage(image_id, get_element_type(boost_priority));
if (!imagep.isNull())
{
- if (boost_priority != LLViewerTexture::BOOST_ALM && imagep->getBoostLevel() == LLViewerTexture::BOOST_ALM)
- {
- // Workaround: we need BOOST_ALM texture for something, 'rise' to NONE
- imagep->setBoostLevel(LLViewerTexture::BOOST_NONE);
- }
-
LLViewerFetchedTexture *texture = imagep.get();
if (request_from_host.isOk() &&
!texture->getTargetHost().isOk())
@@ -874,6 +869,8 @@ static void touch_texture(LLViewerFetchedTexture* tex, F32 vsize)
}
}
+extern BOOL gCubeSnapshot;
+
void LLViewerTextureList::updateImageDecodePriority(LLViewerFetchedTexture* imagep)
{
if (imagep->isInDebug() || imagep->isUnremovable())
@@ -882,18 +879,37 @@ void LLViewerTextureList::updateImageDecodePriority(LLViewerFetchedTexture* imag
return; //is in debug, ignore.
}
+ llassert(!gCubeSnapshot);
+
+ static LLCachedControl<F32> bias_distance_scale(gSavedSettings, "TextureBiasDistanceScale", 1.f);
+
LL_PROFILE_ZONE_SCOPED_CATEGORY_TEXTURE
{
for (U32 i = 0; i < LLRender::NUM_TEXTURE_CHANNELS; ++i)
{
for (U32 fi = 0; fi < imagep->getNumFaces(i); ++fi)
{
- const LLFace* face = (*(imagep->getFaceList(i)))[fi];
+ LLFace* face = (*(imagep->getFaceList(i)))[fi];
if (face && face->getViewerObject() && face->getTextureEntry())
{
- F32 vsize = face->getVirtualSize();
+ F32 radius;
+ F32 cos_angle_to_view_dir;
+ BOOL in_frustum = face->calcPixelArea(cos_angle_to_view_dir, radius);
+ F32 vsize = face->getPixelArea();
+
+#if LL_DARWIN
+ vsize /= 1.f + LLViewerTexture::sDesiredDiscardBias*(1.f+face->getDrawable()->mDistanceWRTCamera*bias_distance_scale);
+#else
+ vsize /= LLViewerTexture::sDesiredDiscardBias;
+ vsize /= llmax(1.f, (LLViewerTexture::sDesiredDiscardBias-1.f) * (1.f + face->getDrawable()->mDistanceWRTCamera * bias_distance_scale));
+
+ if (!in_frustum || !face->getDrawable()->isVisible())
+ { // further reduce by discard bias when off screen or occluded
+ vsize /= LLViewerTexture::sDesiredDiscardBias;
+ }
+#endif
// if a GLTF material is present, ignore that face
// as far as this texture stats go, but update the GLTF material
// stats
@@ -914,7 +930,9 @@ void LLViewerTextureList::updateImageDecodePriority(LLViewerFetchedTexture* imag
}
}
}
-
+
+ //imagep->setDebugText(llformat("%.3f - %d", sqrtf(imagep->getMaxVirtualSize()), imagep->getBoostLevel()));
+
F32 lazy_flush_timeout = 30.f; // stop decoding
F32 max_inactive_time = 20.f; // actually delete
S32 min_refs = 3; // 1 for mImageList, 1 for mUUIDMap, 1 for local reference
diff --git a/indra/newview/llvovolume.cpp b/indra/newview/llvovolume.cpp
index 853c580964..a96701003b 100644
--- a/indra/newview/llvovolume.cpp
+++ b/indra/newview/llvovolume.cpp
@@ -843,12 +843,6 @@ void LLVOVolume::updateTextureVirtualSize(bool forced)
continue;
}
- // clear out boost selected periodically
- if (imagep->getBoostLevel() == LLGLTexture::BOOST_SELECTED)
- {
- imagep->setBoostLevel(LLGLTexture::BOOST_NONE);
- }
-
F32 vsize;
F32 old_size = face->getVirtualSize();
@@ -863,7 +857,6 @@ void LLVOVolume::updateTextureVirtualSize(bool forced)
else
{
vsize = face->getTextureVirtualSize();
- imagep->addTextureStats(vsize);
}
mPixelArea = llmax(mPixelArea, face->getPixelArea());
@@ -880,12 +873,7 @@ void LLVOVolume::updateTextureVirtualSize(bool forced)
}
}
- if (gPipeline.hasRenderDebugMask(LLPipeline::RENDER_DEBUG_TEXTURE_AREA))
- {
- if (vsize < min_vsize) min_vsize = vsize;
- if (vsize > max_vsize) max_vsize = vsize;
- }
- else if (gPipeline.hasRenderDebugMask(LLPipeline::RENDER_DEBUG_TEXTURE_PRIORITY))
+ if (gPipeline.hasRenderDebugMask(LLPipeline::RENDER_DEBUG_TEXTURE_PRIORITY))
{
LLViewerFetchedTexture* img = LLViewerTextureManager::staticCastToFetchedTexture(imagep) ;
if(img)
@@ -950,7 +938,7 @@ void LLVOVolume::updateTextureVirtualSize(bool forced)
{
LLLightImageParams* params = (LLLightImageParams*) getParameterEntry(LLNetworkData::PARAMS_LIGHT_IMAGE);
LLUUID id = params->getLightTexture();
- mLightTexture = LLViewerTextureManager::getFetchedTexture(id, FTT_DEFAULT, TRUE, LLGLTexture::BOOST_ALM);
+ mLightTexture = LLViewerTextureManager::getFetchedTexture(id, FTT_DEFAULT, TRUE, LLGLTexture::BOOST_NONE);
if (mLightTexture.notNull())
{
F32 rad = getLightRadius();
@@ -3292,7 +3280,6 @@ void LLVOVolume::updateSpotLightPriority()
if (mLightTexture.notNull())
{
mLightTexture->addTextureStats(mSpotLightPriority);
- mLightTexture->setBoostLevel(LLGLTexture::BOOST_CLOUDS);
}
}
@@ -3316,7 +3303,7 @@ LLViewerTexture* LLVOVolume::getLightTexture()
{
if (mLightTexture.isNull() || id != mLightTexture->getID())
{
- mLightTexture = LLViewerTextureManager::getFetchedTexture(id, FTT_DEFAULT, TRUE, LLGLTexture::BOOST_ALM);
+ mLightTexture = LLViewerTextureManager::getFetchedTexture(id, FTT_DEFAULT, TRUE, LLGLTexture::BOOST_NONE);
}
}
else
diff --git a/indra/newview/pipeline.cpp b/indra/newview/pipeline.cpp
index deafa6900e..b053af3f96 100644
--- a/indra/newview/pipeline.cpp
+++ b/indra/newview/pipeline.cpp
@@ -4319,6 +4319,8 @@ extern std::set<LLSpatialGroup*> visible_selected_groups;
void LLPipeline::renderDebug()
{
+ LL_PROFILE_ZONE_SCOPED_CATEGORY_PIPELINE;
+
assertInitialized();
bool hud_only = hasRenderType(LLPipeline::RENDER_TYPE_HUD);