From e23aa060494ea1ae8f01033177ec10c333f01b30 Mon Sep 17 00:00:00 2001 From: Andrey Kleshchev Date: Fri, 29 Aug 2025 00:02:04 +0300 Subject: #4604 Reduce draw distance when low on RAM --- indra/newview/llvocache.cpp | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) (limited to 'indra/newview/llvocache.cpp') diff --git a/indra/newview/llvocache.cpp b/indra/newview/llvocache.cpp index 501828eee8..ac73c2def6 100644 --- a/indra/newview/llvocache.cpp +++ b/indra/newview/llvocache.cpp @@ -486,14 +486,23 @@ void LLVOCacheEntry::updateDebugSettings() //min radius: all objects within this radius remain loaded in memory static LLCachedControl min_radius(gSavedSettings,"SceneLoadMinRadius"); static const F32 MIN_RADIUS = 1.0f; - const F32 draw_radius = gAgentCamera.mDrawDistance; + + F32 draw_radius = gAgentCamera.mDrawDistance; + if (LLViewerTexture::sDesiredDiscardBias > 2.f && LLViewerTexture::isSystemMemoryLow()) + { + // Discard's bias maximum is 4 so we need to check 2 to 4 range + // Factor is intended to go from 1.0 to 2.0 + F32 factor = 1.f + (LLViewerTexture::sDesiredDiscardBias - 2.f) / 2.f; + // For safety cap reduction at 50%, we don't want to go below half of draw distance + draw_radius = llmax(draw_radius / factor, draw_radius / 2.f); + } const F32 clamped_min_radius = llclamp((F32) min_radius, MIN_RADIUS, draw_radius); // [1, mDrawDistance] sNearRadius = MIN_RADIUS + ((clamped_min_radius - MIN_RADIUS) * adjust_factor); // a percentage of draw distance beyond which all objects outside of view frustum will be unloaded, regardless of pixel threshold static LLCachedControl rear_max_radius_frac(gSavedSettings,"SceneLoadRearMaxRadiusFraction"); const F32 min_radius_plus_one = sNearRadius + 1.f; - const F32 max_radius = rear_max_radius_frac * gAgentCamera.mDrawDistance; + const F32 max_radius = rear_max_radius_frac * draw_radius; const F32 clamped_max_radius = llclamp(max_radius, min_radius_plus_one, draw_radius); // [sNearRadius, mDrawDistance] sRearFarRadius = min_radius_plus_one + ((clamped_max_radius - min_radius_plus_one) * adjust_factor); -- cgit v1.2.3 From 5c69ae1d66063ee683c5fda4da979f84bc0ce971 Mon Sep 17 00:00:00 2001 From: Andrey Kleshchev <117672381+akleshchev@users.noreply.github.com> Date: Fri, 12 Sep 2025 23:07:47 +0300 Subject: #4604 Tweak range decrease isSystemMemoryLow() and factor check were too agressive for draw range. --- indra/newview/llvocache.cpp | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) (limited to 'indra/newview/llvocache.cpp') diff --git a/indra/newview/llvocache.cpp b/indra/newview/llvocache.cpp index ac73c2def6..52a6afc2d0 100644 --- a/indra/newview/llvocache.cpp +++ b/indra/newview/llvocache.cpp @@ -488,13 +488,11 @@ void LLVOCacheEntry::updateDebugSettings() static const F32 MIN_RADIUS = 1.0f; F32 draw_radius = gAgentCamera.mDrawDistance; - if (LLViewerTexture::sDesiredDiscardBias > 2.f && LLViewerTexture::isSystemMemoryLow()) + if (LLViewerTexture::isSystemMemoryCritical()) { - // Discard's bias maximum is 4 so we need to check 2 to 4 range // Factor is intended to go from 1.0 to 2.0 - F32 factor = 1.f + (LLViewerTexture::sDesiredDiscardBias - 2.f) / 2.f; // For safety cap reduction at 50%, we don't want to go below half of draw distance - draw_radius = llmax(draw_radius / factor, draw_radius / 2.f); + draw_radius = llmax(draw_radius / LLViewerTexture::getSystemMemoryBudgetFactor(), draw_radius / 2.f); } const F32 clamped_min_radius = llclamp((F32) min_radius, MIN_RADIUS, draw_radius); // [1, mDrawDistance] sNearRadius = MIN_RADIUS + ((clamped_min_radius - MIN_RADIUS) * adjust_factor); -- cgit v1.2.3