From 0edf6e230e4580fc61917bc823f82d983d807ccf Mon Sep 17 00:00:00 2001 From: Dave Parks Date: Fri, 23 Aug 2024 16:35:52 -0500 Subject: #2388 Texture downrezzing tune up. (#2414) - Hold onto unreferenced textures for 30 seconds. - Don't downres unless memory is low - Downres when viewer is backgrounded. --- indra/newview/llviewertexture.cpp | 32 +++++++++++++++++++++++++++++++- 1 file changed, 31 insertions(+), 1 deletion(-) (limited to 'indra/newview/llviewertexture.cpp') diff --git a/indra/newview/llviewertexture.cpp b/indra/newview/llviewertexture.cpp index eab564a856..452d6f2c04 100644 --- a/indra/newview/llviewertexture.cpp +++ b/indra/newview/llviewertexture.cpp @@ -548,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; } -- cgit v1.2.3