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.cpp33
1 files changed, 32 insertions, 1 deletions
diff --git a/indra/newview/llviewertexture.cpp b/indra/newview/llviewertexture.cpp
index 4922df6738..bb16fec32a 100644
--- a/indra/newview/llviewertexture.cpp
+++ b/indra/newview/llviewertexture.cpp
@@ -70,6 +70,7 @@ LLPointer<LLViewerTexture> LLViewerTexture::sBlackImagep = nullptr;
LLPointer<LLViewerTexture> LLViewerTexture::sCheckerBoardImagep = nullptr;
LLPointer<LLViewerFetchedTexture> LLViewerFetchedTexture::sMissingAssetImagep = nullptr;
LLPointer<LLViewerFetchedTexture> LLViewerFetchedTexture::sWhiteImagep = nullptr;
+LLPointer<LLViewerFetchedTexture> LLViewerFetchedTexture::sDefaultParticleImagep = nullptr;
LLPointer<LLViewerFetchedTexture> LLViewerFetchedTexture::sDefaultImagep = nullptr;
LLPointer<LLViewerFetchedTexture> LLViewerFetchedTexture::sSmokeImagep = nullptr;
LLPointer<LLViewerFetchedTexture> LLViewerFetchedTexture::sFlatNormalImagep = nullptr;
@@ -547,7 +548,37 @@ void LLViewerTexture::updateClass()
was_low = is_low;
- sDesiredDiscardBias = llclamp(sDesiredDiscardBias, 1.f, 3.f);
+
+ // set to max discard bias if the window has been backgrounded for a while
+ static bool was_backgrounded = false;
+ static LLFrameTimer backgrounded_timer;
+
+ bool in_background = (gViewerWindow && !gViewerWindow->getWindow()->getVisible()) || !gFocusMgr.getAppHasFocus();
+
+ if (in_background)
+ {
+ if (backgrounded_timer.getElapsedTimeF32() > 10.f)
+ {
+ if (!was_backgrounded)
+ {
+ LL_INFOS() << "Viewer is backgrounded, freeing up video memory." << LL_ENDL;
+ }
+ was_backgrounded = true;
+ sDesiredDiscardBias = 4.f;
+ }
+ }
+ else
+ {
+ backgrounded_timer.reset();
+ if (was_backgrounded)
+ { // if the viewer was backgrounded
+ LL_INFOS() << "Viewer is no longer backgrounded, resuming normal texture usage." << LL_ENDL;
+ was_backgrounded = false;
+ sDesiredDiscardBias = 1.f;
+ }
+ }
+
+ sDesiredDiscardBias = llclamp(sDesiredDiscardBias, 1.f, 4.f);
LLViewerTexture::sFreezeImageUpdates = false;
}