summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrey Kleshchev <andreykproductengine@lindenlab.com>2024-02-14 02:46:24 +0200
committerAndrey Kleshchev <117672381+akleshchev@users.noreply.github.com>2024-02-15 19:31:41 +0200
commita2971d84d5aba0c2dcda9ec8274a5c5b72ccd67c (patch)
tree0d1f164e96fdd9aecee9bf6ae103fe561629ffd3
parent17b5bc9403da9608a9ddff3f989644c98bf936a7 (diff)
Viewer#779 Make RenderMaxVRAMBudget more consistent
-rw-r--r--indra/llwindow/llwindow.cpp2
-rw-r--r--indra/llwindow/llwindow.h1
-rw-r--r--indra/llwindow/llwindowheadless.h1
-rw-r--r--indra/llwindow/llwindowmacosx.cpp11
-rw-r--r--indra/llwindow/llwindowmacosx.h5
-rw-r--r--indra/llwindow/llwindowwin32.cpp8
-rw-r--r--indra/llwindow/llwindowwin32.h1
-rw-r--r--indra/newview/app_settings/settings.xml2
-rw-r--r--indra/newview/llviewerwindow.cpp12
-rw-r--r--indra/newview/llviewerwindow.h2
10 files changed, 39 insertions, 6 deletions
diff --git a/indra/llwindow/llwindow.cpp b/indra/llwindow/llwindow.cpp
index 9e281dfc99..6cfa9cd16d 100644
--- a/indra/llwindow/llwindow.cpp
+++ b/indra/llwindow/llwindow.cpp
@@ -431,7 +431,7 @@ LLWindow* LLWindowManager::createWindow(
#elif LL_DARWIN
new_window = new LLWindowMacOSX(callbacks,
title, name, x, y, width, height, flags,
- fullscreen, clearBg, enable_vsync, use_gl, ignore_pixel_depth, fsaa_samples);
+ fullscreen, clearBg, enable_vsync, use_gl, ignore_pixel_depth, fsaa_samples, max_vram);
#endif
}
else
diff --git a/indra/llwindow/llwindow.h b/indra/llwindow/llwindow.h
index f435d46584..b53cda6150 100644
--- a/indra/llwindow/llwindow.h
+++ b/indra/llwindow/llwindow.h
@@ -166,6 +166,7 @@ public:
// query VRAM usage
virtual U32 getAvailableVRAMMegabytes() = 0;
+ virtual void setMaxVRAMMegabytes(U32 max_vram) = 0;
virtual void beforeDialog() {}; // prepare to put up an OS dialog (if special measures are required, such as in fullscreen mode)
virtual void afterDialog() {}; // undo whatever was done in beforeDialog()
diff --git a/indra/llwindow/llwindowheadless.h b/indra/llwindow/llwindowheadless.h
index 2f2c0de5bd..10b3c66f93 100644
--- a/indra/llwindow/llwindowheadless.h
+++ b/indra/llwindow/llwindowheadless.h
@@ -102,6 +102,7 @@ public:
/*virtual*/ void setNativeAspectRatio(F32 ratio) override {}
U32 getAvailableVRAMMegabytes() override { return 4096; }
+ void setMaxVRAMMegabytes(U32 max_vram) override {}
/*virtual*/ void *getPlatformWindow() override { return 0; }
/*virtual*/ void bringToFront() override {}
diff --git a/indra/llwindow/llwindowmacosx.cpp b/indra/llwindow/llwindowmacosx.cpp
index b317f00ae7..9f71b80e74 100644
--- a/indra/llwindow/llwindowmacosx.cpp
+++ b/indra/llwindow/llwindowmacosx.cpp
@@ -115,8 +115,10 @@ LLWindowMacOSX::LLWindowMacOSX(LLWindowCallbacks* callbacks,
BOOL fullscreen, BOOL clearBg,
BOOL enable_vsync, BOOL use_gl,
BOOL ignore_pixel_depth,
- U32 fsaa_samples)
+ U32 fsaa_samples,
+ U32 max_vram)
: LLWindow(NULL, fullscreen, flags)
+ , mMaxVRAM(max_vram)
{
// *HACK: During window construction we get lots of OS events for window
// reshape, activate, etc. that the viewer isn't ready to handle.
@@ -1260,7 +1262,12 @@ U32 LLWindowMacOSX::getAvailableVRAMMegabytes() {
static const U32 mb = 1024*1024;
// We're asked for total available gpu memory, but we only have allocation info on texture usage. So estimate by doubling that.
static const U32 total_factor = 2; // estimated total/textures
- return gGLManager.mVRAM - (LLImageGL::getTextureBytesAllocated() * total_factor/mb);
+ U32 total_vram = gGLManager.mVRAM;
+ if (mMaxVRAM)
+ {
+ total_vram = llmin(mMaxVRAM, total_vram);
+ }
+ return total_vram - (LLImageGL::getTextureBytesAllocated() * total_factor/mb);
}
//static SInt32 oldWindowLevel;
diff --git a/indra/llwindow/llwindowmacosx.h b/indra/llwindow/llwindowmacosx.h
index 7614167213..3b13f60f77 100644
--- a/indra/llwindow/llwindowmacosx.h
+++ b/indra/llwindow/llwindowmacosx.h
@@ -102,6 +102,7 @@ public:
// query VRAM usage
/*virtual*/ U32 getAvailableVRAMMegabytes() override;
+ virtual void setMaxVRAMMegabytes(U32 max_vram) override { mMaxVRAM = max_vram; }
void beforeDialog() override;
void afterDialog() override;
@@ -150,7 +151,8 @@ protected:
const std::string& title, const std::string& name, int x, int y, int width, int height, U32 flags,
BOOL fullscreen, BOOL clearBg, BOOL enable_vsync, BOOL use_gl,
BOOL ignore_pixel_depth,
- U32 fsaa_samples);
+ U32 fsaa_samples,
+ U32 max_vram);
~LLWindowMacOSX();
void initCursors();
@@ -224,6 +226,7 @@ protected:
BOOL mMinimized;
U32 mFSAASamples;
BOOL mForceRebuild;
+ U32 mMaxVRAM;
S32 mDragOverrideCursor;
diff --git a/indra/llwindow/llwindowwin32.cpp b/indra/llwindow/llwindowwin32.cpp
index 057d7a700e..0dbb5b64c1 100644
--- a/indra/llwindow/llwindowwin32.cpp
+++ b/indra/llwindow/llwindowwin32.cpp
@@ -4586,6 +4586,14 @@ U32 LLWindowWin32::getAvailableVRAMMegabytes()
return mWindowThread ? mWindowThread->getAvailableVRAMMegabytes() : 0;
}
+void LLWindowWin32::setMaxVRAMMegabytes(U32 max_vram)
+{
+ if (mWindowThread)
+ {
+ mWindowThread->mMaxVRAM = max_vram;
+ }
+}
+
#endif // LL_WINDOWS
inline LLWindowWin32::LLWindowWin32Thread::LLWindowWin32Thread()
diff --git a/indra/llwindow/llwindowwin32.h b/indra/llwindow/llwindowwin32.h
index ff287a140e..c8ce507c8b 100644
--- a/indra/llwindow/llwindowwin32.h
+++ b/indra/llwindow/llwindowwin32.h
@@ -109,6 +109,7 @@ public:
/*virtual*/ void setNativeAspectRatio(F32 ratio) { mOverrideAspectRatio = ratio; }
U32 getAvailableVRAMMegabytes() override;
+ /*virtual*/ void setMaxVRAMMegabytes(U32 max_vram) override;
/*virtual*/ BOOL dialogColorPicker(F32 *r, F32 *g, F32 *b );
diff --git a/indra/newview/app_settings/settings.xml b/indra/newview/app_settings/settings.xml
index 4fd422e59a..a9b4ebcc04 100644
--- a/indra/newview/app_settings/settings.xml
+++ b/indra/newview/app_settings/settings.xml
@@ -9376,7 +9376,7 @@
<key>RenderMaxVRAMBudget</key>
<map>
<key>Comment</key>
- <string>Maximum amount of texture memory to budget for (in MB), or 0 for autodetect. Requires restart.</string>
+ <string>Maximum amount of texture memory to budget for (in MB), or 0 for autodetect.</string>
<key>Persist</key>
<integer>1</integer>
<key>Type</key>
diff --git a/indra/newview/llviewerwindow.cpp b/indra/newview/llviewerwindow.cpp
index 349847c57a..a218079fb5 100644
--- a/indra/newview/llviewerwindow.cpp
+++ b/indra/newview/llviewerwindow.cpp
@@ -1864,8 +1864,16 @@ LLViewerWindow::LLViewerWindow(const Params& p)
// create window
U32 max_core_count = gSavedSettings.getU32("EmulateCoreCount");
- U32 max_vram = gSavedSettings.getU32("RenderMaxVRAMBudget");
F32 max_gl_version = gSavedSettings.getF32("RenderMaxOpenGLVersion");
+
+ LLControlVariable* vram_control = gSavedSettings.getControl("RenderMaxVRAMBudget");
+ U32 max_vram = vram_control->getValue().asInteger();
+ mMaxVRAMControlConnection = vram_control->getSignal()->connect(
+ [this](LLControlVariable* control, const LLSD& new_val, const LLSD& old_val)
+ {
+ if (mWindow) mWindow->setMaxVRAMMegabytes(new_val.asInteger());
+ });
+
mWindow = LLWindowManager::createWindow(this,
p.title, p.name, p.x, p.y, p.width, p.height, 0,
@@ -2421,6 +2429,8 @@ LLViewerWindow::~LLViewerWindow()
LLViewerShaderMgr::releaseInstance();
LLViewerShaderMgr::sInitialized = FALSE;
}
+
+ mMaxVRAMControlConnection.disconnect();
}
diff --git a/indra/newview/llviewerwindow.h b/indra/newview/llviewerwindow.h
index 96c5c3115a..3355c0cf6d 100644
--- a/indra/newview/llviewerwindow.h
+++ b/indra/newview/llviewerwindow.h
@@ -545,6 +545,8 @@ private:
// Object temporarily hovered over while dragging
LLPointer<LLViewerObject> mDragHoveredObject;
+ boost::signals2::connection mMaxVRAMControlConnection;
+
static LLTrace::SampleStatHandle<> sMouseVelocityStat;
};