diff options
author | Erik Kundiman <erik@megapahit.org> | 2025-09-15 06:54:46 +0800 |
---|---|---|
committer | Erik Kundiman <erik@megapahit.org> | 2025-09-15 09:54:39 +0800 |
commit | 4c74344f464928864ef7f70835628be1d92969c3 (patch) | |
tree | 72814839d439f6969593ffcd89d85d6ce74acbab /indra/newview/llviewertexture.cpp | |
parent | df871e95234b670012908d06a6ecc62418e18aa2 (diff) | |
parent | 175400230869963df7a3f126122ace14456c56cb (diff) |
Merge tag 'Second_Life_Release#17540023-2025.07' into 2025.07
Diffstat (limited to 'indra/newview/llviewertexture.cpp')
-rw-r--r-- | indra/newview/llviewertexture.cpp | 53 |
1 files changed, 41 insertions, 12 deletions
diff --git a/indra/newview/llviewertexture.cpp b/indra/newview/llviewertexture.cpp index 5ba0a86e68..7a25fb03a5 100644 --- a/indra/newview/llviewertexture.cpp +++ b/indra/newview/llviewertexture.cpp @@ -524,12 +524,19 @@ void LLViewerTexture::updateClass() bool is_low = is_sys_low || over_pct > 0.f; static bool was_low = false; - static bool was_sys_low = false; if (is_low && !was_low) { - // slam to 1.5 bias the moment we hit low memory (discards off screen textures immediately) - sDesiredDiscardBias = llmax(sDesiredDiscardBias, 1.5f); + if (is_sys_low) + { + // Not having system memory is more serious, so discard harder + sDesiredDiscardBias = llmax(sDesiredDiscardBias, 1.5f * getSystemMemoryBudgetFactor()); + } + else + { + // Slam to 1.5 bias the moment we hit low memory (discards off screen textures immediately) + sDesiredDiscardBias = llmax(sDesiredDiscardBias, 1.5f); + } if (is_sys_low || over_pct > 2.f) { // if we're low on system memory, emergency purge off screen textures to avoid a death spiral @@ -542,7 +549,6 @@ void LLViewerTexture::updateClass() } was_low = is_low; - was_sys_low = is_sys_low; if (is_low) { @@ -561,8 +567,13 @@ void LLViewerTexture::updateClass() sEvaluationTimer.reset(); // lower discard bias over time when at least 10% of budget is free - const F32 FREE_PERCENTAGE_TRESHOLD = -0.1f; - if (sDesiredDiscardBias > 1.f && over_pct < FREE_PERCENTAGE_TRESHOLD) + constexpr F32 FREE_PERCENTAGE_TRESHOLD = -0.1f; + constexpr U32 FREE_SYS_MEM_TRESHOLD = 100; + static LLCachedControl<U32> min_free_main_memory(gSavedSettings, "RenderMinFreeMainMemoryThreshold", 512); + const S32Megabytes MIN_FREE_MAIN_MEMORY(min_free_main_memory() + FREE_SYS_MEM_TRESHOLD); + if (sDesiredDiscardBias > 1.f + && over_pct < FREE_PERCENTAGE_TRESHOLD + && getFreeSystemMemory() > MIN_FREE_MAIN_MEMORY) { static LLCachedControl<F32> high_mem_discard_decrement(gSavedSettings, "RenderHighMemMinDiscardDecrement", .1f); @@ -629,24 +640,42 @@ void LLViewerTexture::updateClass() } //static -bool LLViewerTexture::isSystemMemoryLow() +U32Megabytes LLViewerTexture::getFreeSystemMemory() { static LLFrameTimer timer; static U32Megabytes physical_res = U32Megabytes(U32_MAX); - static LLCachedControl<U32> min_free_main_memory(gSavedSettings, "RenderMinFreeMainMemoryThreshold", 512); - const U32Megabytes MIN_FREE_MAIN_MEMORY(min_free_main_memory); - if (timer.getElapsedTimeF32() < MEMORY_CHECK_WAIT_TIME) //call this once per second. { - return physical_res < MIN_FREE_MAIN_MEMORY; + return physical_res; } timer.reset(); LLMemory::updateMemoryInfo(); physical_res = LLMemory::getAvailableMemKB(); - return physical_res < MIN_FREE_MAIN_MEMORY; + return physical_res; +} + +//static +bool LLViewerTexture::isSystemMemoryLow() +{ + static LLCachedControl<U32> min_free_main_memory(gSavedSettings, "RenderMinFreeMainMemoryThreshold", 512); + const U32Megabytes MIN_FREE_MAIN_MEMORY(min_free_main_memory); + return getFreeSystemMemory() < MIN_FREE_MAIN_MEMORY; +} + +F32 LLViewerTexture::getSystemMemoryBudgetFactor() +{ + static LLCachedControl<U32> min_free_main_memory(gSavedSettings, "RenderMinFreeMainMemoryThreshold", 512); + const S32Megabytes MIN_FREE_MAIN_MEMORY(min_free_main_memory); + S32 free_budget = (S32Megabytes)getFreeSystemMemory() - MIN_FREE_MAIN_MEMORY; + if (free_budget < 0) + { + // Result should range from 1 (0 free budget) to 2 (-512 free budget) + return 1.f - free_budget / MIN_FREE_MAIN_MEMORY; + } + return 1.f; } //end of static functions |