Expose setting to limit VRAM usage for textures

master
Ansariel 2024-11-01 17:51:59 +01:00
parent 03ecb756de
commit c93fd14a14
7 changed files with 62 additions and 10 deletions

View File

@ -11177,13 +11177,13 @@ Change of this parameter will affect the layout of buttons in notification toast
<key>RenderMaxVRAMBudget</key>
<map>
<key>Comment</key>
<string>Maximum amount of texture memory to budget for (in MB), or 0 for autodetect.</string>
<string>Maximum amount of texture memory to budget for (in MB), or autodetect if FSLimitTextureVRAMUsage is disabled.</string>
<key>Persist</key>
<integer>1</integer>
<key>Type</key>
<string>U32</string>
<key>Value</key>
<integer>0</integer>
<integer>768</integer>
</map>
<key>RenderMinFreeMainMemoryThreshold</key>
<map>
@ -23923,7 +23923,7 @@ Change of this parameter will affect the layout of buttons in notification toast
<key>HideFromEditor</key>
<integer>1</integer>
<key>Type</key>
<string>S32</string>
<string>U32</string>
<key>Value</key>
<integer>0</integer>
</map>
@ -25975,5 +25975,16 @@ Change of this parameter will affect the layout of buttons in notification toast
<key>Value</key>
<integer>1</integer>
</map>
<key>FSLimitTextureVRAMUsage</key>
<map>
<key>Comment</key>
<string>If enabled, limits the amount of VRAM used for textures to the value of RenderMaxVRAMBudget.</string>
<key>Persist</key>
<integer>1</integer>
<key>Type</key>
<string>Boolean</string>
<key>Value</key>
<integer>0</integer>
</map>
</map>
</llsd>

View File

@ -1513,12 +1513,12 @@ bool LLAppViewer::init()
void LLAppViewer::overrideDetectedHardware()
{
// Override the VRAM Detection if FSOverrideVRAMDetection is set.
if ( gSavedSettings.getBOOL("FSOverrideVRAMDetection") )
if (gSavedSettings.getBOOL("FSOverrideVRAMDetection"))
{
S32 forced_video_memory = gSavedSettings.getS32("FSForcedVideoMemory");
U32 forced_video_memory = gSavedSettings.getU32("FSForcedVideoMemory");
// Note: 0 is allowed here, some systems detect VRAM as zero so override should support emulating them.
LL_INFOS("AppInit") << "Overriding VRAM to " << forced_video_memory*1024 << " MB" << LL_ENDL;
gGLManager.mVRAM = forced_video_memory*1024;
LL_INFOS("AppInit") << "Overriding VRAM to " << forced_video_memory * 1024U << " MB" << LL_ENDL;
gGLManager.mVRAM = forced_video_memory * 1024U;
}
}
// </FS:Beq>
@ -4169,8 +4169,9 @@ LLSD LLAppViewer::getViewerInfo() const
// </FS:PP>
// <FS:Ansariel> Include VRAM budget
if (auto budget = gSavedSettings.getU32("RenderMaxVRAMBudget"); budget > 0)
if (gSavedSettings.getBOOL("FSLimitTextureVRAMUsage"))
{
auto budget = gSavedSettings.getU32("RenderMaxVRAMBudget");
info["VRAM_BUDGET"] = std::to_string(budget) + " MB";
info["VRAM_BUDGET_ENGLISH"] = std::to_string(budget) + " MB";
}

View File

@ -2238,6 +2238,12 @@ void LLFloaterPreference::refreshEnabledState()
getChild<LLUICtrl>("do_not_disturb_response")->setEnabled(!RlvActions::hasBehaviour(RLV_BHVR_SENDIM));
}
// [/RLVa:KB]
// <FS:Ansariel> Expose max texture VRAM setting
auto max_texmem = getChild<LLSliderCtrl>("RenderMaxVRAMBudget");
max_texmem->setMinValue(MIN_VRAM_BUDGET);
max_texmem->setMaxValue((F32)gGLManager.mVRAM);
// </FS:Ansariel>
}
// <FS:Zi> Support preferences search SLURLs

View File

@ -103,7 +103,7 @@ bool LLViewerTexture::sFreezeImageUpdates = false;
F32 LLViewerTexture::sCurrentTime = 0.0f;
constexpr F32 MEMORY_CHECK_WAIT_TIME = 1.0f;
constexpr F32 MIN_VRAM_BUDGET = 768.f;
//constexpr F32 MIN_VRAM_BUDGET = 768.f; // <FS:Ansariel> Expose max texture VRAM setting
F32 LLViewerTexture::sFreeVRAMMegabytes = MIN_VRAM_BUDGET;
LLViewerTexture::EDebugTexels LLViewerTexture::sDebugTexelsMode = LLViewerTexture::DEBUG_TEXELS_OFF;
@ -510,6 +510,7 @@ void LLViewerTexture::updateClass()
LLViewerMediaTexture::updateClass();
static LLCachedControl<U32> max_vram_budget(gSavedSettings, "RenderMaxVRAMBudget", 0);
static LLCachedControl<bool> max_vram_budget_enabled(gSavedSettings, "FSLimitTextureVRAMUsage"); // <FS:Ansariel> Expose max texture VRAM setting
F64 texture_bytes_alloc = LLImageGL::getTextureBytesAllocated() / 1024.0 / 512.0;
F64 vertex_bytes_alloc = LLVertexBuffer::getBytesAllocated() / 1024.0 / 512.0;
@ -518,7 +519,9 @@ 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;
// <FS:Ansariel> Expose max texture VRAM setting
//F32 budget = max_vram_budget == 0 ? (F32)gGLManager.mVRAM : (F32)max_vram_budget;
F32 budget = !max_vram_budget_enabled ? (F32)gGLManager.mVRAM : (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

View File

@ -44,6 +44,7 @@
// <FS:Ansariel> Max texture resolution
extern U32 DESIRED_NORMAL_TEXTURE_SIZE;
constexpr F32 MIN_VRAM_BUDGET = 768.f; // <FS:Ansariel> Expose max texture VRAM setting
class LLFace;
class LLImageGL ;

View File

@ -165,6 +165,8 @@
<text name="advanced_settings">
Erweiterte Einstellungen (Neustart erforderlich):
</text>
<check_box label="VRAM-Speicher für Texturen begrenzen (MB)" name="FSLimitTextureVRAMUsage" tool_tip="Begrenzt die Nutzung von VRAM-Speicher für Texturen. Der gesamte Speicherverbrauch kann höher sein, da andere Elemente ebenfalls VRAM-Speicher nutzen."/>
<slider name="RenderMaxVRAMBudget" tool_tip="Maximaler VRAM-Speicher in Megabytes, der für Texturen verwendet wird."/>
<check_box label="VRAM-Erkennung übersteuern" name="FSOverrideVRAMDetection" tool_tip="Erlaubt die Übersteuerung der VRAM-Erkennung (mit extreme Vorsicht verwenden)" />
<slider label="Dedizierter GPU-VRAM(GB):" name="FSForcedVideoMemory" tool_tip="Wichtig: Mit extremer Vorsicht verwenden. Übersteuert den erkannten VRAM der GPU. Dieser Wert darf nicht den geteilten VRAM enthalten, der Teil des Systemspeichers ist. Falls Sie den Unterschied nicht kennen, verändern Sie diese Einstellung bitte nicht!" />
<text name="automatic_texture_downscale_settings">

View File

@ -1071,6 +1071,34 @@
value="2" />
</combo_box>
<check_box
control_name="FSLimitTextureVRAMUsage"
height="16"
label="Limit VRAM texture usage (MB)"
layout="topleft"
left="10"
top_pad="15"
name="FSLimitTextureVRAMUsage"
tool_tip="Limits the amount of VRAM used for textures. Overall usage may still be higher because other elements also use VRAM."
width="275"
/>
<slider
control_name="RenderMaxVRAMBudget"
enabled_control="FSLimitTextureVRAMUsage"
decimal_digits="0"
follows="left|top"
height="20"
increment="16"
layout="topleft"
left_pad="5"
min_val="0"
max_val="4096"
name="RenderMaxVRAMBudget"
tool_tip="The maximum amount of VRAM in Megabytes used for textures."
top_delta="0"
width="200"
/>
<text
type="string"
length="1"