summaryrefslogtreecommitdiff
path: root/indra/newview/llviewertexture.cpp
diff options
context:
space:
mode:
authorRye <rye@lindenlab.com>2024-10-29 02:30:52 -0700
committerRye <rye@lindenlab.com>2024-10-29 02:30:52 -0700
commit7827f66caefe358f050caf4d1215d5e956192114 (patch)
tree70a19ad8193851c873330c7189cd4a58c8a5f7d5 /indra/newview/llviewertexture.cpp
parent32d766cb3af0b79a722b838dcebffef29a755cfe (diff)
Add handling for downrezzing textures when viewer is minimized, fix downrezzing textures when minimized due to texture system not processesing
Diffstat (limited to 'indra/newview/llviewertexture.cpp')
-rw-r--r--indra/newview/llviewertexture.cpp52
1 files changed, 32 insertions, 20 deletions
diff --git a/indra/newview/llviewertexture.cpp b/indra/newview/llviewertexture.cpp
index ab0ea1ec93..a4b76d0ae9 100644
--- a/indra/newview/llviewertexture.cpp
+++ b/indra/newview/llviewertexture.cpp
@@ -112,18 +112,6 @@ const U32 DESIRED_NORMAL_TEXTURE_SIZE = (U32)LLViewerFetchedTexture::MAX_IMAGE_S
const U32 DESIRED_NORMAL_TEXTURE_SIZE = (U32)LLViewerFetchedTexture::MAX_IMAGE_SIZE_DEFAULT;
#endif
-namespace
-{
-void onClickDisableDiscard(const LLSD& notification, const LLSD& response)
-{
- if (response["Cancel_okcancelignore"].asBoolean())
- {
- LL_INFOS() << "User chose to disable texture discard on backgrounding." << LL_ENDL;
- gSavedSettings.setF32("TextureDiscardBackgroundedTime", -1.f);
- }
-}
-} // namespace
-
//----------------------------------------------------------------------------------------------
//namespace: LLViewerTextureAccess
//----------------------------------------------------------------------------------------------
@@ -571,25 +559,49 @@ void LLViewerTexture::updateClass()
}
// set to max discard bias if the window has been backgrounded for a while
+ static F32 last_desired_discard_bias = 1.f;
static bool was_backgrounded = false;
static LLFrameTimer backgrounded_timer;
- static F32 last_desired_discard_bias = 1.f;
+ static LLCachedControl<F32> minimized_discard_time(gSavedSettings, "TextureDiscardMinimizedTime", 1.f);
static LLCachedControl<F32> backgrounded_discard_time(gSavedSettings, "TextureDiscardBackgroundedTime", 60.f);
bool in_background = (gViewerWindow && !gViewerWindow->getWindow()->getVisible()) || !gFocusMgr.getAppHasFocus();
-
+ bool is_minimized = gViewerWindow && gViewerWindow->getWindow()->getMinimized() && in_background;
if (in_background)
{
- F32 background_elapsed = backgrounded_timer.getElapsedTimeF32();
- if (backgrounded_discard_time > 0.f && background_elapsed > backgrounded_discard_time)
+ F32 discard_time = is_minimized ? minimized_discard_time : backgrounded_discard_time;
+ if (discard_time > 0.f && backgrounded_timer.getElapsedTimeF32() > discard_time)
{
if (!was_backgrounded)
{
- LL_INFOS() << "Viewer is backgrounded for " << backgrounded_discard_time << "s, freeing up video memory." << LL_ENDL;
- LLNotificationsUtil::add("TextureDiscardBackgrounded", llsd::map("DELAY", backgrounded_discard_time), LLSD(), &onClickDisableDiscard);
+ std::string notification_name;
+ std::string setting;
+ if (is_minimized)
+ {
+ notification_name = "TextureDiscardMinimized";
+ setting = "TextureDiscardMinimizedTime";
+ }
+ else
+ {
+ notification_name = "TextureDiscardBackgrounded";
+ setting = "TextureDiscardBackgroundedTime";
+ }
+
+ LL_INFOS() << "Viewer was " << (is_minimized ? "minimized" : "backgrounded") << " for " << discard_time
+ << "s, freeing up video memory." << LL_ENDL;
+
+ LLNotificationsUtil::add(notification_name, llsd::map("DELAY", discard_time), LLSD(),
+ [=](const LLSD& notification, const LLSD& response)
+ {
+ if (response["Cancel_okcancelignore"].asBoolean())
+ {
+ LL_INFOS() << "User chose to disable texture discard on " << (is_minimized ? "minimizing." : "backgrounding.") << LL_ENDL;
+ gSavedSettings.setF32(setting, -1.f);
+ }
+ });
last_desired_discard_bias = sDesiredDiscardBias;
+ was_backgrounded = true;
}
- was_backgrounded = true;
sDesiredDiscardBias = 4.f;
}
}
@@ -598,7 +610,7 @@ void LLViewerTexture::updateClass()
backgrounded_timer.reset();
if (was_backgrounded)
{ // if the viewer was backgrounded
- LL_INFOS() << "Viewer is no longer backgrounded, resuming normal texture usage." << LL_ENDL;
+ LL_INFOS() << "Viewer is no longer backgrounded or minimized, resuming normal texture usage." << LL_ENDL;
was_backgrounded = false;
sDesiredDiscardBias = last_desired_discard_bias;
}