diff options
author | Howard Stearns <aech@lindenlab.com> | 2022-06-17 15:17:54 +0000 |
---|---|---|
committer | Howard Stearns <aech@lindenlab.com> | 2022-06-17 15:17:54 +0000 |
commit | a42a89001d545548eaf1684e73a918badce2837d (patch) | |
tree | 2650993a565233f5995e6abe44f14d48d48619ac /indra/llwindow | |
parent | c9a48a1cdd23a592eb25454d5e2d6c316ec93445 (diff) | |
parent | 9d9c2037e10966bdf4b07ef3fed081c04a4ed30a (diff) |
Merged in SL-17485 (pull request #1016)
SL-17485 - MacOS memory accounting
Approved-by: Dave Parks
Diffstat (limited to 'indra/llwindow')
-rw-r--r-- | indra/llwindow/llopenglview-objc.mm | 7 | ||||
-rw-r--r-- | indra/llwindow/llwindowmacosx.cpp | 10 | ||||
-rw-r--r-- | indra/llwindow/llwindowmacosx.h | 3 |
3 files changed, 17 insertions, 3 deletions
diff --git a/indra/llwindow/llopenglview-objc.mm b/indra/llwindow/llopenglview-objc.mm index fd20f2ad15..8d064ec86c 100644 --- a/indra/llwindow/llopenglview-objc.mm +++ b/indra/llwindow/llopenglview-objc.mm @@ -141,7 +141,12 @@ attributedStringInfo getSegments(NSAttributedString *str) CGLError the_err = CGLQueryRendererInfo (CGDisplayIDToOpenGLDisplayMask(kCGDirectMainDisplay), &info, &num_renderers); if(0 == the_err) { - CGLDescribeRenderer (info, 0, kCGLRPTextureMemoryMegabytes, &vram_megabytes); + // The name, uses, and other platform definitions of gGLManager.mVRAM suggest that this is supposed to be total vram in MB, + // rather than, say, just the texture memory. The two exceptions are: + // 1. LLAppViewer::getViewerInfo() puts the value in a field labeled "TEXTURE_MEMORY" + // 2. For years, this present function used kCGLRPTextureMemoryMegabytes + // Now we use kCGLRPVideoMemoryMegabytes to bring it in line with everything else (except thatone label). + CGLDescribeRenderer (info, 0, kCGLRPVideoMemoryMegabytes, &vram_megabytes); CGLDestroyRendererInfo (info); } else diff --git a/indra/llwindow/llwindowmacosx.cpp b/indra/llwindow/llwindowmacosx.cpp index bc4f07941b..4bcb9b3aef 100644 --- a/indra/llwindow/llwindowmacosx.cpp +++ b/indra/llwindow/llwindowmacosx.cpp @@ -1222,6 +1222,16 @@ F32 LLWindowMacOSX::getPixelAspectRatio() return 1.f; } +U32 LLWindowMacOSX::getAvailableVRAMMegabytes() { + // MTL (and MoltenVK) has some additional gpu data, such as recommendedMaxWorkingSetSize and currentAllocatedSize. + // But these are not available for OpenGL and/or our current mimimum OS version. + // So we will estimate. + 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); +} + //static SInt32 oldWindowLevel; // MBW -- XXX -- There's got to be a better way than this. Find it, please... diff --git a/indra/llwindow/llwindowmacosx.h b/indra/llwindow/llwindowmacosx.h index 309d1377ea..0f316f1ddf 100644 --- a/indra/llwindow/llwindowmacosx.h +++ b/indra/llwindow/llwindowmacosx.h @@ -101,8 +101,7 @@ public: void setNativeAspectRatio(F32 ratio) override { mOverrideAspectRatio = ratio; } // query VRAM usage - // FIXME FIXME - virtual U32 getAvailableVRAMMegabytes() override { return 0; } + /*virtual*/ U32 getAvailableVRAMMegabytes() override; void beforeDialog() override; void afterDialog() override; |