Skip to content

Commit 124f071

Browse files
committed
Merge remote-tracking branch 'origin/release/2024.08-DeltaFPS' into develop
2 parents 39c7f14 + 50dc4cb commit 124f071

File tree

7 files changed

+84
-31
lines changed

7 files changed

+84
-31
lines changed

indra/llcommon/llmemory.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ void LLMemory::updateMemoryInfo()
129129
{
130130
// Our Windows definition of PagefileUsage is documented by Microsoft as "the total amount of
131131
// memory that the memory manager has committed for a running process", which is rss.
132-
sAllocatedPageSizeInKB = U32Bytes(info.resident_size);
132+
sAllocatedPageSizeInKB = U32Kilobytes::convert(U64Bytes(info.resident_size));
133133

134134
// Activity Monitor => Inspect Process => Real Memory Size appears to report resident_size
135135
// Activity monitor => main window memory column appears to report phys_footprint, which spot checks as at least 30% less.
@@ -139,7 +139,7 @@ void LLMemory::updateMemoryInfo()
139139
// reported for the app by the Memory Monitor in Instruments.' It is still about 8% bigger than phys_footprint.
140140
//
141141
// (On Windows, we use WorkingSetSize.)
142-
sAllocatedMemInKB = U32Bytes(info.resident_size - info.reusable);
142+
sAllocatedMemInKB = U32Kilobytes::convert(U64Bytes(info.resident_size - info.reusable));
143143
}
144144
else
145145
{

indra/newview/llface.cpp

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2200,13 +2200,6 @@ bool LLFace::calcPixelArea(F32& cos_angle_to_view_dir, F32& radius)
22002200

22012201
F32 dist = lookAt.getLength3().getF32();
22022202
dist = llmax(dist-size.getLength3().getF32(), 0.001f);
2203-
//ramp down distance for nearby objects
2204-
if (dist < 16.f)
2205-
{
2206-
dist /= 16.f;
2207-
dist *= dist;
2208-
dist *= 16.f;
2209-
}
22102203

22112204
lookAt.normalize3fast() ;
22122205

indra/newview/lllogininstance.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -602,13 +602,14 @@ std::string construct_start_string()
602602
{
603603
// a startup URL was specified
604604
LLVector3 position = start_slurl.getPosition();
605-
std::string unescaped_start =
605+
// NOTE - do not xml escape here, will get escaped properly later by LLSD::asXMLRPCValue()
606+
// see secondlife/viewer#2395
607+
start =
606608
STRINGIZE( "uri:"
607609
<< start_slurl.getRegion() << "&"
608610
<< position[VX] << "&"
609611
<< position[VY] << "&"
610612
<< position[VZ]);
611-
start = LLStringFn::xml_encode(unescaped_start, true);
612613
break;
613614
}
614615
case LLSLURL::HOME_LOCATION:

indra/newview/llviewertexture.cpp

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -547,7 +547,37 @@ void LLViewerTexture::updateClass()
547547

548548
was_low = is_low;
549549

550-
sDesiredDiscardBias = llclamp(sDesiredDiscardBias, 1.f, 3.f);
550+
551+
// set to max discard bias if the window has been backgrounded for a while
552+
static bool was_backgrounded = false;
553+
static LLFrameTimer backgrounded_timer;
554+
555+
bool in_background = (gViewerWindow && !gViewerWindow->getWindow()->getVisible()) || !gFocusMgr.getAppHasFocus();
556+
557+
if (in_background)
558+
{
559+
if (backgrounded_timer.getElapsedTimeF32() > 10.f)
560+
{
561+
if (!was_backgrounded)
562+
{
563+
LL_INFOS() << "Viewer is backgrounded, freeing up video memory." << LL_ENDL;
564+
}
565+
was_backgrounded = true;
566+
sDesiredDiscardBias = 4.f;
567+
}
568+
}
569+
else
570+
{
571+
backgrounded_timer.reset();
572+
if (was_backgrounded)
573+
{ // if the viewer was backgrounded
574+
LL_INFOS() << "Viewer is no longer backgrounded, resuming normal texture usage." << LL_ENDL;
575+
was_backgrounded = false;
576+
sDesiredDiscardBias = 1.f;
577+
}
578+
}
579+
580+
sDesiredDiscardBias = llclamp(sDesiredDiscardBias, 1.f, 4.f);
551581

552582
LLViewerTexture::sFreezeImageUpdates = false;
553583
}

indra/newview/llviewertexture.h

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,8 @@ class LLViewerTexture : public LLGLTexture
146146

147147
virtual F32 getMaxVirtualSize() ;
148148

149+
LLFrameTimer* getLastReferencedTimer() { return &mLastReferencedTimer; }
150+
149151
S32 getFullWidth() const { return mFullWidth; }
150152
S32 getFullHeight() const { return mFullHeight; }
151153
/*virtual*/ void setKnownDrawSize(S32 width, S32 height);
@@ -195,6 +197,7 @@ class LLViewerTexture : public LLGLTexture
195197
mutable F32 mMaxVirtualSize = 0.f; // The largest virtual size of the image, in pixels - how much data to we need?
196198
mutable S32 mMaxVirtualSizeResetCounter;
197199
mutable S32 mMaxVirtualSizeResetInterval;
200+
LLFrameTimer mLastReferencedTimer;
198201

199202
ll_face_list_t mFaceList[LLRender::NUM_TEXTURE_CHANNELS]; //reverse pointer pointing to the faces using this image as texture
200203
U32 mNumFaces[LLRender::NUM_TEXTURE_CHANNELS];
@@ -571,10 +574,7 @@ class LLViewerMediaTexture : public LLViewerTexture
571574
/*virtual*/ void addFace(U32 ch, LLFace* facep) ;
572575
/*virtual*/ void removeFace(U32 ch, LLFace* facep) ;
573576

574-
/*virtual*/ F32 getMaxVirtualSize() ;
575-
576-
// get the timer that tracks the last time reinit was called
577-
LLFrameTimer* getLastReferencedTimer() { return &mLastReferencedTimer; }
577+
/*virtual*/ F32 getMaxVirtualSize();
578578

579579
private:
580580
void switchTexture(U32 ch, LLFace* facep) ;
@@ -596,9 +596,6 @@ class LLViewerMediaTexture : public LLViewerTexture
596596
bool mIsPlaying ;
597597
U32 mUpdateVirtualSizeTime ;
598598

599-
// tracks last time reinit was called
600-
LLFrameTimer mLastReferencedTimer;
601-
602599
public:
603600
static void updateClass() ;
604601
static void cleanUpClass() ;

indra/newview/llviewertexturelist.cpp

Lines changed: 43 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -889,12 +889,9 @@ void LLViewerTextureList::updateImageDecodePriority(LLViewerFetchedTexture* imag
889889
static LLCachedControl<F32> texture_scale_min(gSavedSettings, "TextureScaleMinAreaFactor", 0.04f);
890890
static LLCachedControl<F32> texture_scale_max(gSavedSettings, "TextureScaleMaxAreaFactor", 25.f);
891891

892-
if (imagep->getType() == LLViewerTexture::LOD_TEXTURE && imagep->getBoostLevel() == LLViewerTexture::BOOST_NONE)
893-
{ // reset max virtual size for unboosted LOD_TEXTURES
894-
// this is an alternative to decaying mMaxVirtualSize over time
895-
// that keeps textures from continously downrezzing and uprezzing in the background
896-
imagep->mMaxVirtualSize = 0.f;
897-
}
892+
893+
F32 max_vsize = 0.f;
894+
bool on_screen = false;
898895

899896
LL_PROFILE_ZONE_SCOPED_CATEGORY_TEXTURE;
900897
for (U32 i = 0; i < LLRender::NUM_TEXTURE_CHANNELS; ++i)
@@ -911,6 +908,8 @@ void LLViewerTextureList::updateImageDecodePriority(LLViewerFetchedTexture* imag
911908
F32 vsize = face->getPixelArea();
912909
bool in_frustum = face->calcPixelArea(cos_angle_to_view_dir, radius);
913910

911+
on_screen = in_frustum;
912+
914913
// Scale desired texture resolution higher or lower depending on texture scale
915914
//
916915
// Minimum usage examples: a 1024x1024 texture with aplhabet, runing string
@@ -936,15 +935,40 @@ void LLViewerTextureList::updateImageDecodePriority(LLViewerFetchedTexture* imag
936935
if (apply_bias)
937936
{
938937
F32 bias = powf(4, LLViewerTexture::sDesiredDiscardBias - 1.f);
939-
bias = (F32)llround(bias);
938+
bias = (F32) llround(bias);
940939
vsize /= bias;
941940
}
942941

943-
imagep->addTextureStats(vsize);
942+
max_vsize = llmax(max_vsize, vsize);
944943
}
945944
}
946945
}
947946

947+
if (imagep->getType() == LLViewerTexture::LOD_TEXTURE && imagep->getBoostLevel() == LLViewerTexture::BOOST_NONE)
948+
{ // conditionally reset max virtual size for unboosted LOD_TEXTURES
949+
// this is an alternative to decaying mMaxVirtualSize over time
950+
// that keeps textures from continously downrezzing and uprezzing in the background
951+
952+
if (LLViewerTexture::sDesiredDiscardBias > 2.f ||
953+
(!on_screen && LLViewerTexture::sDesiredDiscardBias > 1.f))
954+
{
955+
imagep->mMaxVirtualSize = 0.f;
956+
}
957+
}
958+
959+
960+
imagep->addTextureStats(max_vsize);
961+
962+
#if 0
963+
imagep->setDebugText(llformat("%d/%d - %d/%d -- %d/%d",
964+
(S32)sqrtf(max_vsize),
965+
(S32)sqrtf(imagep->mMaxVirtualSize),
966+
imagep->getDiscardLevel(),
967+
imagep->getDesiredDiscardLevel(),
968+
imagep->getWidth(),
969+
imagep->getFullWidth()));
970+
#endif
971+
948972
// make sure to addTextureStats for any spotlights that are using this texture
949973
for (S32 vi = 0; vi < imagep->getNumVolumes(LLRender::LIGHT_TEX); ++vi)
950974
{
@@ -955,18 +979,26 @@ void LLViewerTextureList::updateImageDecodePriority(LLViewerFetchedTexture* imag
955979
F32 max_inactive_time = 20.f; // inactive time before deleting saved raw image
956980
S32 min_refs = 3; // 1 for mImageList, 1 for mUUIDMap, and 1 for "entries" in updateImagesFetchTextures
957981

982+
F32 lazy_flush_timeout = 30.f; // delete unused images after 30 seconds
983+
958984
//
959985
// Flush formatted images using a lazy flush
960986
//
961987
S32 num_refs = imagep->getNumRefs();
962988
if (num_refs <= min_refs && flush_images)
963989
{
964-
// Remove the unused image from the image list
965-
deleteImage(imagep);
966-
return;
990+
if (imagep->getLastReferencedTimer()->getElapsedTimeF32() > lazy_flush_timeout)
991+
{
992+
// Remove the unused image from the image list
993+
deleteImage(imagep);
994+
return;
995+
}
967996
}
968997
else
969998
{
999+
// still referenced outside of image list, reset timer
1000+
imagep->getLastReferencedTimer()->reset();
1001+
9701002
if (imagep->hasSavedRawImage())
9711003
{
9721004
if (imagep->getElapsedLastReferencedSavedRawImageTime() > max_inactive_time)

indra/viewer_components/login/lllogin.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ void LLLogin::Impl::connect(const std::string& uri, const LLSD& login_params)
128128
// Launch a coroutine with our login_() method. Run the coroutine until
129129
// its first wait; at that point, return here.
130130
std::string coroname =
131-
LLCoros::instance().launch("LLLogin::Impl::login_", [&]() { loginCoro(uri, login_params); });
131+
LLCoros::instance().launch("LLLogin::Impl::login_", [=]() { loginCoro(uri, login_params); });
132132

133133
LL_DEBUGS("LLLogin") << " connected with uri '" << uri << "', login_params " << login_params << LL_ENDL;
134134
}

0 commit comments

Comments
 (0)