summaryrefslogtreecommitdiff
path: root/indra/llwindow
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 /indra/llwindow
parent17b5bc9403da9608a9ddff3f989644c98bf936a7 (diff)
Viewer#779 Make RenderMaxVRAMBudget more consistent
Diffstat (limited to 'indra/llwindow')
-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
7 files changed, 25 insertions, 4 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 );