Skip to content

Commit 6dc819e

Browse files
committed
#3364 Fix update rate being stuck high due to bias
if bias stays unchanged at 4.f, there is no reason to keep refreshing at high rate.
1 parent c2d4919 commit 6dc819e

File tree

3 files changed

+18
-2
lines changed

3 files changed

+18
-2
lines changed

indra/newview/llviewertexture.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,7 @@ S32 LLViewerTexture::sRawCount = 0;
8787
S32 LLViewerTexture::sAuxCount = 0;
8888
LLFrameTimer LLViewerTexture::sEvaluationTimer;
8989
F32 LLViewerTexture::sDesiredDiscardBias = 0.f;
90+
U32 LLViewerTexture::sBiasTexturesUpdated = 0;
9091

9192
S32 LLViewerTexture::sMaxSculptRez = 128; //max sculpt image size
9293
constexpr S32 MAX_CACHED_RAW_IMAGE_AREA = 64 * 64;
@@ -518,6 +519,7 @@ void LLViewerTexture::updateClass()
518519

519520
bool is_sys_low = isSystemMemoryLow();
520521
bool is_low = is_sys_low || over_pct > 0.f;
522+
F32 discard_bias = sDesiredDiscardBias;
521523

522524
static bool was_low = false;
523525
static bool was_sys_low = false;
@@ -604,6 +606,12 @@ void LLViewerTexture::updateClass()
604606
}
605607

606608
sDesiredDiscardBias = llclamp(sDesiredDiscardBias, 1.f, 4.f);
609+
if (discard_bias != sDesiredDiscardBias)
610+
{
611+
// bias changed, reset texture update counter to
612+
// let updates happen at an increased rate.
613+
sBiasTexturesUpdated = 0;
614+
}
607615

608616
LLViewerTexture::sFreezeImageUpdates = false;
609617
}

indra/newview/llviewertexture.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -220,6 +220,7 @@ class LLViewerTexture : public LLGLTexture
220220
static S32 sAuxCount;
221221
static LLFrameTimer sEvaluationTimer;
222222
static F32 sDesiredDiscardBias;
223+
static U32 sBiasTexturesUpdated;
223224
static S32 sMaxSculptRez ;
224225
static U32 sMinLargeImageSize ;
225226
static U32 sMaxSmallImageSize ;

indra/newview/llviewertexturelist.cpp

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1198,10 +1198,17 @@ F32 LLViewerTextureList::updateImagesFetchTextures(F32 max_time)
11981198

11991199
//update MIN_UPDATE_COUNT or 5% of other textures, whichever is greater
12001200
update_count = llmax((U32) MIN_UPDATE_COUNT, (U32) mUUIDMap.size()/20);
1201-
if (LLViewerTexture::sDesiredDiscardBias > 1.f)
1201+
if (LLViewerTexture::sDesiredDiscardBias > 1.f
1202+
&& LLViewerTexture::sBiasTexturesUpdated < (U32)mUUIDMap.size())
12021203
{
1203-
// we are over memory target, update more agresively
1204+
// We are over memory target. Bias affects discard rates, so update
1205+
// existing textures agresively to free memory faster.
12041206
update_count = (S32)(update_count * LLViewerTexture::sDesiredDiscardBias);
1207+
1208+
// This isn't particularly precise and can overshoot, but it doesn't need
1209+
// to be, just making sure it did a full circle and doesn't get stuck updating
1210+
// at bias = 4 with 4 times the rate permanently.
1211+
LLViewerTexture::sBiasTexturesUpdated += update_count;
12051212
}
12061213
update_count = llmin(update_count, (U32) mUUIDMap.size());
12071214

0 commit comments

Comments
 (0)