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.cpp28
1 files changed, 23 insertions, 5 deletions
diff --git a/indra/newview/llviewertexture.cpp b/indra/newview/llviewertexture.cpp
index 609ad38e96..4a9dd1c1b6 100644
--- a/indra/newview/llviewertexture.cpp
+++ b/indra/newview/llviewertexture.cpp
@@ -489,7 +489,12 @@ void LLViewerTexture::updateClass()
}
LLViewerMediaTexture::updateClass();
-
+ // This is a divisor used to determine how much VRAM from our overall VRAM budget to use.
+ // This is **cumulative** on whatever the detected or manually set VRAM budget is.
+ // If we detect 2048MB of VRAM, this will, by default, only use 1024.
+ // If you set 1024MB of VRAM, this will, by default, use 512.
+ // -Geenz 2025-03-03
+ static LLCachedControl<U32> tex_vram_divisor(gSavedSettings, "RenderTextureVRAMDivisor", 2);
static LLCachedControl<U32> max_vram_budget(gSavedSettings, "RenderMaxVRAMBudget", 0);
F64 texture_bytes_alloc = LLImageGL::getTextureBytesAllocated() / 1024.0 / 512.0;
@@ -499,7 +504,11 @@ void LLViewerTexture::updateClass()
// NOTE: our metrics miss about half the vram we use, so this biases high but turns out to typically be within 5% of the real number
F32 used = (F32)ll_round(texture_bytes_alloc + vertex_bytes_alloc);
- F32 budget = max_vram_budget == 0 ? (F32)gGLManager.mVRAM : (F32)max_vram_budget;
+ // For debugging purposes, it's useful to be able to set the VRAM budget manually.
+ // But when manual control is not enabled, use the VRAM divisor.
+ // While we're at it, assume we have 1024 to play with at minimum when the divisor is in use. Works more elegantly with the logic below this.
+ // -Geenz 2025-03-21
+ F32 budget = max_vram_budget == 0 ? llmax(1024, (F32)gGLManager.mVRAM / tex_vram_divisor) : (F32)max_vram_budget;
// Try to leave at least half a GB for everyone else and for bias,
// but keep at least 768MB for ourselves
@@ -513,7 +522,6 @@ void LLViewerTexture::updateClass()
bool is_sys_low = isSystemMemoryLow();
bool is_low = is_sys_low || over_pct > 0.f;
- F32 discard_bias = sDesiredDiscardBias;
static bool was_low = false;
static bool was_sys_low = false;
@@ -565,6 +573,7 @@ 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 F32 last_texture_update_count_bias = 1.f;
static bool was_backgrounded = false;
static LLFrameTimer backgrounded_timer;
static LLCachedControl<F32> minimized_discard_time(gSavedSettings, "TextureDiscardMinimizedTime", 1.f);
@@ -600,12 +609,21 @@ void LLViewerTexture::updateClass()
}
sDesiredDiscardBias = llclamp(sDesiredDiscardBias, 1.f, 4.f);
- if (discard_bias != sDesiredDiscardBias)
+ if (last_texture_update_count_bias < sDesiredDiscardBias)
{
- // bias changed, reset texture update counter to
+ // bias increased, reset texture update counter to
// let updates happen at an increased rate.
+ last_texture_update_count_bias = sDesiredDiscardBias;
sBiasTexturesUpdated = 0;
}
+ else if (last_texture_update_count_bias > sDesiredDiscardBias + 0.1f)
+ {
+ // bias decreased, 0.1f is there to filter out small fluctuations
+ // and not reset sBiasTexturesUpdated too often.
+ // Bias jumps to 1.5 at low memory, so getting stuck at 1.1 is not
+ // a problem.
+ last_texture_update_count_bias = sDesiredDiscardBias;
+ }
LLViewerTexture::sFreezeImageUpdates = false;
}