summaryrefslogtreecommitdiff
path: root/indra
diff options
context:
space:
mode:
Diffstat (limited to 'indra')
-rw-r--r--indra/cmake/00-Common.cmake2
-rw-r--r--indra/llcommon/llmemory.cpp49
-rw-r--r--indra/llwindow/llopenglview-objc.mm7
-rw-r--r--indra/llwindow/llwindowmacosx.cpp10
-rw-r--r--indra/llwindow/llwindowmacosx.h3
-rw-r--r--indra/newview/llviewertexture.cpp2
-rw-r--r--indra/newview/llviewertexture.h2
7 files changed, 69 insertions, 6 deletions
diff --git a/indra/cmake/00-Common.cmake b/indra/cmake/00-Common.cmake
index bb5dd8f847..3e672cb128 100644
--- a/indra/cmake/00-Common.cmake
+++ b/indra/cmake/00-Common.cmake
@@ -201,7 +201,7 @@ if (LINUX OR DARWIN)
endif()
if (NOT GCC_DISABLE_FATAL_WARNINGS)
- set(GCC_WARNINGS "${GCC_WARNINGS} -Werror")
+ set(GCC_WARNINGS "${GCC_WARNINGS} -Werror -Wno-error=unused-but-set-variable")
endif (NOT GCC_DISABLE_FATAL_WARNINGS)
set(GCC_CXX_WARNINGS "${GCC_WARNINGS} -Wno-reorder -Wno-non-virtual-dtor")
diff --git a/indra/llcommon/llmemory.cpp b/indra/llcommon/llmemory.cpp
index 849867586a..267159e7cc 100644
--- a/indra/llcommon/llmemory.cpp
+++ b/indra/llcommon/llmemory.cpp
@@ -35,6 +35,7 @@
# include <sys/types.h>
# include <mach/task.h>
# include <mach/mach_init.h>
+#include <mach/mach_host.h>
#elif LL_LINUX
# include <unistd.h>
#endif
@@ -46,6 +47,9 @@
#include "lltrace.h"
#include "llerror.h"
//----------------------------------------------------------------------------
+#if defined(LL_DARWIN)
+extern LLMemoryInfo gSysMemory;
+#endif
//static
U32Kilobytes LLMemory::sAvailPhysicalMemInKB(U32_MAX);
@@ -109,6 +113,51 @@ void LLMemory::updateMemoryInfo()
{
sAvailPhysicalMemInKB = U32Kilobytes(0);
}
+
+#elif defined(LL_DARWIN)
+ task_vm_info info;
+ mach_msg_type_number_t infoCount = TASK_VM_INFO_COUNT;
+ // MACH_TASK_BASIC_INFO reports the same resident_size, but does not tell us the reusable bytes or phys_footprint.
+ if (task_info(mach_task_self(), TASK_VM_INFO, reinterpret_cast<task_info_t>(&info), &infoCount) == KERN_SUCCESS)
+ {
+ // Our Windows definition of PagefileUsage is documented by Microsoft as "the total amount of
+ // memory that the memory manager has committed for a running process", which is rss.
+ sAllocatedPageSizeInKB = U32Bytes(info.resident_size);
+
+ // Activity Monitor => Inspect Process => Real Memory Size appears to report resident_size
+ // Activity monitor => main window memory column appears to report phys_footprint, which spot checks as at least 30% less.
+ // I think that is because of compression, which isn't going to give us a consistent measurement. We want uncompressed totals.
+ //
+ // In between is resident_size - reusable. This is what Chrome source code uses, with source comments saying it is 'the "Real Memory" value
+ // reported for the app by the Memory Monitor in Instruments.' It is still about 8% bigger than phys_footprint.
+ //
+ // (On Windows, we use WorkingSetSize.)
+ sAllocatedMemInKB = U32Bytes(info.resident_size - info.reusable);
+ }
+ else
+ {
+ LL_WARNS() << "task_info failed" << LL_ENDL;
+ }
+
+ // Total installed and available physical memory are properties of the host, not just our process.
+ vm_statistics64_data_t vmstat;
+ mach_msg_type_number_t count = HOST_VM_INFO64_COUNT;
+ mach_port_t host = mach_host_self();
+ vm_size_t page_size;
+ host_page_size(host, &page_size);
+ kern_return_t result = host_statistics64(host, HOST_VM_INFO64, reinterpret_cast<host_info_t>(&vmstat), &count);
+ if (result == KERN_SUCCESS) {
+ // This is what Chrome reports as 'the "Physical Memory Free" value reported by the Memory Monitor in Instruments.'
+ // Note though that inactive pages are not included here and not yet free, but could become so under memory pressure.
+ sAvailPhysicalMemInKB = U32Bytes(vmstat.free_count * page_size);
+
+ sMaxPhysicalMemInKB = gSysMemory.getPhysicalMemoryKB();
+ }
+ else
+ {
+ LL_WARNS() << "task_info failed" << LL_ENDL;
+ }
+
#else
//not valid for other systems for now.
sAllocatedMemInKB = U64Bytes(LLMemory::getCurrentRSS());
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;
diff --git a/indra/newview/llviewertexture.cpp b/indra/newview/llviewertexture.cpp
index e31bc5ec6e..3584fffd44 100644
--- a/indra/newview/llviewertexture.cpp
+++ b/indra/newview/llviewertexture.cpp
@@ -524,7 +524,7 @@ void LLViewerTexture::getGPUMemoryForTextures(S32Megabytes &gpu, S32Megabytes &p
{
gpu_res = (S32Megabytes)gViewerWindow->getWindow()->getAvailableVRAMMegabytes();
- //check main memory, only works for windows.
+ //check main memory, only works for windows and macos.
LLMemory::updateMemoryInfo();
physical_res = LLMemory::getAvailableMemKB();
diff --git a/indra/newview/llviewertexture.h b/indra/newview/llviewertexture.h
index 088d11538a..8c41c4a6bc 100644
--- a/indra/newview/llviewertexture.h
+++ b/indra/newview/llviewertexture.h
@@ -302,7 +302,7 @@ public:
};
public:
- /*virtual*/ S8 getType() const override ;
+ /*virtual*/ S8 getType() const override;
FTType getFTType() const;
/*virtual*/ void forceImmediateUpdate() override;
/*virtual*/ void dump() override;