Memory tracking system updated.

This commit is contained in:
Shyotl
2012-01-29 01:33:14 -06:00
parent 32c6365bf9
commit 9453c2c2e9
25 changed files with 1248 additions and 486 deletions

View File

@@ -17,7 +17,9 @@ include_directories(
set(llcommon_SOURCE_FILES set(llcommon_SOURCE_FILES
aiframetimer.cpp aiframetimer.cpp
imageids.cpp imageids.cpp
indra_constants.cpp indra_constants.cpp
llallocator.cpp
llallocator_heap_profile.cpp
llapp.cpp llapp.cpp
llapr.cpp llapr.cpp
llaprpool.cpp llaprpool.cpp
@@ -52,6 +54,7 @@ set(llcommon_SOURCE_FILES
llmd5.cpp llmd5.cpp
llmemory.cpp llmemory.cpp
llmemorystream.cpp llmemorystream.cpp
llmemtype.cpp
llmetrics.cpp llmetrics.cpp
llmortician.cpp llmortician.cpp
lloptioninterface.cpp lloptioninterface.cpp
@@ -101,6 +104,8 @@ set(llcommon_HEADER_FILES
linden_common.h linden_common.h
linked_lists.h linked_lists.h
llaccountingcost.h llaccountingcost.h
llallocator.h
llallocator_heap_profile.h
llagentconstants.h llagentconstants.h
llavatarname.h llavatarname.h
llapp.h llapp.h

View File

@@ -0,0 +1,134 @@
/**
* @file llallocator.cpp
* @brief Implementation of the LLAllocator class.
*
* $LicenseInfo:firstyear=2009&license=viewerlgpl$
* Second Life Viewer Source Code
* Copyright (C) 2010, Linden Research, Inc.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation;
* version 2.1 of the License only.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*
* Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA
* $/LicenseInfo$
*/
#include "linden_common.h"
#include "llallocator.h"
#if LL_USE_TCMALLOC
#include "google/heap-profiler.h"
#include "google/commandlineflags_public.h"
DECLARE_bool(heap_profile_use_stack_trace);
//DECLARE_double(tcmalloc_release_rate);
// static
void LLAllocator::pushMemType(S32 type)
{
if(isProfiling())
{
PushMemType(type);
}
}
// static
S32 LLAllocator::popMemType()
{
if (isProfiling())
{
return PopMemType();
}
else
{
return -1;
}
}
void LLAllocator::setProfilingEnabled(bool should_enable)
{
// NULL disables dumping to disk
static char const * const PREFIX = NULL;
if(should_enable)
{
HeapProfilerSetUseStackTrace(false);
HeapProfilerStart(PREFIX);
}
else
{
HeapProfilerStop();
}
}
// static
bool LLAllocator::isProfiling()
{
return IsHeapProfilerRunning();
}
std::string LLAllocator::getRawProfile()
{
// *TODO - fix google-perftools to accept an buffer to avoid this
// malloc-copy-free cycle.
char * buffer = GetHeapProfile();
std::string ret = buffer;
free(buffer);
return ret;
}
#else // LL_USE_TCMALLOC
//
// stub implementations for when tcmalloc is disabled
//
// static
void LLAllocator::pushMemType(S32 type)
{
}
// static
S32 LLAllocator::popMemType()
{
return -1;
}
void LLAllocator::setProfilingEnabled(bool should_enable)
{
}
// static
bool LLAllocator::isProfiling()
{
return false;
}
std::string LLAllocator::getRawProfile()
{
return std::string();
}
#endif // LL_USE_TCMALLOC
LLAllocatorHeapProfile const & LLAllocator::getProfile()
{
mProf.mLines.clear();
// *TODO - avoid making all these extra copies of things...
std::string prof_text = getRawProfile();
//std::cout << prof_text << std::endl;
mProf.parse(prof_text);
return mProf;
}

View File

@@ -0,0 +1,57 @@
/**
* @file llallocator.h
* @brief Declaration of the LLAllocator class.
*
* $LicenseInfo:firstyear=2009&license=viewerlgpl$
* Second Life Viewer Source Code
* Copyright (C) 2010, Linden Research, Inc.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation;
* version 2.1 of the License only.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*
* Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA
* $/LicenseInfo$
*/
#ifndef LL_LLALLOCATOR_H
#define LL_LLALLOCATOR_H
#include <string>
#include "llmemtype.h"
#include "llallocator_heap_profile.h"
class LL_COMMON_API LLAllocator {
friend class LLMemoryView;
friend class LLMemType;
private:
static void pushMemType(S32 type);
static S32 popMemType();
public:
void setProfilingEnabled(bool should_enable);
static bool isProfiling();
LLAllocatorHeapProfile const & getProfile();
private:
std::string getRawProfile();
private:
LLAllocatorHeapProfile mProf;
};
#endif // LL_LLALLOCATOR_H

View File

@@ -0,0 +1,147 @@
/**
* @file llallocator_heap_profile.cpp
* @brief Implementation of the parser for tcmalloc heap profile data.
* @author Brad Kittenbrink
*
* $LicenseInfo:firstyear=2009&license=viewerlgpl$
* Second Life Viewer Source Code
* Copyright (C) 2010, Linden Research, Inc.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation;
* version 2.1 of the License only.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*
* Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA
* $/LicenseInfo$
*/
#include "linden_common.h"
#include "llallocator_heap_profile.h"
#if LL_MSVC
// disable warning about boost::lexical_cast returning uninitialized data
// when it fails to parse the string
#pragma warning (disable:4701)
#pragma warning (disable:4702)
#endif
#include <boost/algorithm/string/split.hpp>
#include <boost/bind.hpp>
#include <boost/lexical_cast.hpp>
#include <boost/range/iterator_range.hpp>
static const std::string HEAP_PROFILE_MAGIC_STR = "heap profile:";
static bool is_separator(char c)
{
return isspace(c) || c == '[' || c == ']' || c == ':';
}
void LLAllocatorHeapProfile::parse(std::string const & prof_text)
{
// a typedef for handling a token in the string buffer
// it's a begin/end pair of string::const_iterators
typedef boost::iterator_range<std::string::const_iterator> range_t;
mLines.clear();
if(prof_text.compare(0, HEAP_PROFILE_MAGIC_STR.length(), HEAP_PROFILE_MAGIC_STR) != 0)
{
// *TODO - determine if there should be some better error state than
// mLines being empty. -brad
llwarns << "invalid heap profile data passed into parser." << llendl;
return;
}
std::vector< range_t > prof_lines;
std::string::const_iterator prof_begin = prof_text.begin() + HEAP_PROFILE_MAGIC_STR.length();
range_t prof_range(prof_begin, prof_text.end());
boost::algorithm::split(prof_lines,
prof_range,
boost::bind(std::equal_to<llwchar>(), '\n', _1));
std::vector< range_t >::const_iterator i;
for(i = prof_lines.begin(); i != prof_lines.end() && !i->empty(); ++i)
{
range_t const & line_text = *i;
std::vector<range_t> line_elems;
boost::algorithm::split(line_elems,
line_text,
is_separator);
std::vector< range_t >::iterator j;
j = line_elems.begin();
while(j != line_elems.end() && j->empty()) { ++j; } // skip any separator tokens
llassert_always(j != line_elems.end());
U32 live_count = boost::lexical_cast<U32>(*j);
++j;
while(j != line_elems.end() && j->empty()) { ++j; } // skip any separator tokens
llassert_always(j != line_elems.end());
U64 live_size = boost::lexical_cast<U64>(*j);
++j;
while(j != line_elems.end() && j->empty()) { ++j; } // skip any separator tokens
llassert_always(j != line_elems.end());
U32 tot_count = boost::lexical_cast<U32>(*j);
++j;
while(j != line_elems.end() && j->empty()) { ++j; } // skip any separator tokens
llassert_always(j != line_elems.end());
U64 tot_size = boost::lexical_cast<U64>(*j);
++j;
while(j != line_elems.end() && j->empty()) { ++j; } // skip any separator tokens
llassert(j != line_elems.end());
if (j != line_elems.end())
{
++j; // skip the '@'
mLines.push_back(line(live_count, live_size, tot_count, tot_size));
line & current_line = mLines.back();
for(; j != line_elems.end(); ++j)
{
if(!j->empty())
{
U32 marker = boost::lexical_cast<U32>(*j);
current_line.mTrace.push_back(marker);
}
}
}
}
// *TODO - parse MAPPED_LIBRARIES section here if we're ever interested in it
}
void LLAllocatorHeapProfile::dump(std::ostream & out) const
{
lines_t::const_iterator i;
for(i = mLines.begin(); i != mLines.end(); ++i)
{
out << i->mLiveCount << ": " << i->mLiveSize << '[' << i->mTotalCount << ": " << i->mTotalSize << "] @";
stack_trace::const_iterator j;
for(j = i->mTrace.begin(); j != i->mTrace.end(); ++j)
{
out << ' ' << *j;
}
out << '\n';
}
out.flush();
}

View File

@@ -0,0 +1,71 @@
/**
* @file llallocator_heap_profile.h
* @brief Declaration of the parser for tcmalloc heap profile data.
* @author Brad Kittenbrink
*
* $LicenseInfo:firstyear=2009&license=viewerlgpl$
* Second Life Viewer Source Code
* Copyright (C) 2010, Linden Research, Inc.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation;
* version 2.1 of the License only.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*
* Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA
* $/LicenseInfo$
*/
#ifndef LL_LLALLOCATOR_HEAP_PROFILE_H
#define LL_LLALLOCATOR_HEAP_PROFILE_H
#include "stdtypes.h"
#include <map>
#include <vector>
class LLAllocatorHeapProfile
{
public:
typedef int stack_marker;
typedef std::vector<stack_marker> stack_trace;
struct line {
line(U32 live_count, U64 live_size, U32 tot_count, U64 tot_size) :
mLiveSize(live_size),
mTotalSize(tot_size),
mLiveCount(live_count),
mTotalCount(tot_count)
{
}
U64 mLiveSize, mTotalSize;
U32 mLiveCount, mTotalCount;
stack_trace mTrace;
};
typedef std::vector<line> lines_t;
LLAllocatorHeapProfile()
{
}
void parse(std::string const & prof_text);
void dump(std::ostream & out) const;
public:
lines_t mLines;
};
#endif // LL_LLALLOCATOR_HEAP_PROFILE_H

View File

@@ -248,6 +248,7 @@ public:
struct CurTimerData struct CurTimerData
{ {
CurTimerData() : mCurTimer(NULL),mFrameState(NULL),mChildTime(0) {}
LLFastTimer* mCurTimer; LLFastTimer* mCurTimer;
FrameState* mFrameState; FrameState* mFrameState;
U32 mChildTime; U32 mChildTime;

View File

@@ -32,9 +32,13 @@
#include "linden_common.h" #include "linden_common.h"
//#if MEM_TRACK_MEM
#include "llthread.h"
//#endif
#if defined(LL_WINDOWS) #if defined(LL_WINDOWS)
#define _WINSOCKAPI_ //# include <windows.h>
# include <windows.h>
# include <psapi.h> # include <psapi.h>
#elif defined(LL_DARWIN) #elif defined(LL_DARWIN)
# include <sys/types.h> # include <sys/types.h>
@@ -45,10 +49,9 @@
#endif #endif
#include "llmemory.h" #include "llmemory.h"
#include "llmemtype.h"
#include "llsys.h"
#include "llthread.h"
#include "llsys.h"
#include "llframetimer.h"
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
//static //static
@@ -162,6 +165,7 @@ void LLMemory::logMemoryInfo(BOOL update)
if(update) if(update)
{ {
updateMemoryInfo() ; updateMemoryInfo() ;
LLPrivateMemoryPoolManager::getInstance()->updateStatistics() ;
} }
llinfos << "Current allocated physical memory(KB): " << sAllocatedMemInKB << llendl ; llinfos << "Current allocated physical memory(KB): " << sAllocatedMemInKB << llendl ;
@@ -242,161 +246,6 @@ U32 LLMemory::getAllocatedMemKB()
return sAllocatedMemInKB ; return sAllocatedMemInKB ;
} }
//----------------------------------------------------------------------------
//static
#if MEM_TRACK_TYPE
S32 LLMemType::sCurDepth = 0;
S32 LLMemType::sCurType = LLMemType::MTYPE_INIT;
S32 LLMemType::sType[LLMemType::MTYPE_MAX_DEPTH];
S32 LLMemType::sMemCount[LLMemType::MTYPE_NUM_TYPES] = { 0 };
S32 LLMemType::sMaxMemCount[LLMemType::MTYPE_NUM_TYPES] = { 0 };
S32 LLMemType::sNewCount[LLMemType::MTYPE_NUM_TYPES] = { 0 };
S32 LLMemType::sOverheadMem = 0;
const char* LLMemType::sTypeDesc[LLMemType::MTYPE_NUM_TYPES] =
{
"INIT",
"STARTUP",
"MAIN",
"IMAGEBASE",
"IMAGERAW",
"IMAGEFORMATTED",
"APPFMTIMAGE",
"APPRAWIMAGE",
"APPAUXRAWIMAGE",
"DRAWABLE",
"OBJECT",
"PIPELINE",
"AVATAR",
"PARTICLES",
"REGIONS",
"INVENTORY",
"ANIMATION",
"NETWORK",
"PHYSICS",
"INTERESTLIST",
"SCRIPT",
"SCRIPT_RUN",
"SCRIPT_BYTECODE",
"IO_PUMP",
"IO_TCP",
"IO_BUFFER",
"IO_HTTP_SERVER"
"IO_SD_SERVER",
"IO_SD_CLIENT",
"IO_URL_REQUEST",
"TEMP1",
"TEMP2",
"TEMP3",
"TEMP4",
"TEMP5",
"TEMP6",
"TEMP7",
"TEMP8",
"TEMP9"
};
#endif
S32 LLMemType::sTotalMem = 0;
S32 LLMemType::sMaxTotalMem = 0;
//static
void LLMemType::printMem()
{
S32 misc_mem = sTotalMem;
#if MEM_TRACK_TYPE
for (S32 i=0; i<MTYPE_NUM_TYPES; i++)
{
if (sMemCount[i])
{
llinfos << llformat("MEM: % 20s %03d MB (%03d MB) in %06d News",sTypeDesc[i],sMemCount[i]>>20,sMaxMemCount[i]>>20, sNewCount[i]) << llendl;
}
misc_mem -= sMemCount[i];
}
#endif
llinfos << llformat("MEM: % 20s %03d MB","MISC",misc_mem>>20) << llendl;
llinfos << llformat("MEM: % 20s %03d MB (Max=%d MB)","TOTAL",sTotalMem>>20,sMaxTotalMem>>20) << llendl;
}
#if MEM_TRACK_MEM
void* ll_allocate (size_t size)
{
if (size == 0)
{
llwarns << "Null allocation" << llendl;
}
size = (size+3)&~3;
S32 alloc_size = size + 4;
#if MEM_TRACK_TYPE
alloc_size += 4;
#endif
char* p = (char*)malloc(alloc_size);
if (p == NULL)
{
LLMemory::freeReserve();
llerrs << "Out of memory Error" << llendl;
}
LLMemType::sTotalMem += size;
LLMemType::sMaxTotalMem = llmax(LLMemType::sTotalMem, LLMemType::sMaxTotalMem);
LLMemType::sOverheadMem += 4;
*(size_t*)p = size;
p += 4;
#if MEM_TRACK_TYPE
if (LLMemType::sCurType < 0 || LLMemType::sCurType >= LLMemType::MTYPE_NUM_TYPES)
{
llerrs << "Memory Type Error: new" << llendl;
}
LLMemType::sOverheadMem += 4;
*(S32*)p = LLMemType::sCurType;
p += 4;
LLMemType::sMemCount[LLMemType::sCurType] += size;
if (LLMemType::sMemCount[LLMemType::sCurType] > LLMemType::sMaxMemCount[LLMemType::sCurType])
{
LLMemType::sMaxMemCount[LLMemType::sCurType] = LLMemType::sMemCount[LLMemType::sCurType];
}
LLMemType::sNewCount[LLMemType::sCurType]++;
#endif
return (void*)p;
}
void ll_release (void *pin)
{
if (!pin)
{
return;
}
char* p = (char*)pin;
#if MEM_TRACK_TYPE
p -= 4;
S32 type = *(S32*)p;
if (type < 0 || type >= LLMemType::MTYPE_NUM_TYPES)
{
llerrs << "Memory Type Error: delete" << llendl;
}
#endif
p -= 4;
S32 size = *(size_t*)p;
LLMemType::sOverheadMem -= 4;
#if MEM_TRACK_TYPE
LLMemType::sMemCount[type] -= size;
LLMemType::sOverheadMem -= 4;
LLMemType::sNewCount[type]--;
#endif
LLMemType::sTotalMem -= size;
free(p);
}
#else
void* ll_allocate (size_t size) void* ll_allocate (size_t size)
{ {
if (size == 0) if (size == 0)
@@ -412,38 +261,6 @@ void* ll_allocate (size_t size)
return p; return p;
} }
void ll_release (void *p)
{
free(p);
}
#endif
#if MEM_TRACK_MEM
void* operator new (size_t size)
{
return ll_allocate(size);
}
void* operator new[] (size_t size)
{
return ll_allocate(size);
}
void operator delete (void *p)
{
ll_release(p);
}
void operator delete[] (void *p)
{
ll_release(p);
}
#endif
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
#if defined(LL_WINDOWS) #if defined(LL_WINDOWS)
@@ -613,6 +430,141 @@ U32 LLMemory::getWorkingSetSize()
#endif #endif
//--------------------------------------------------------------------------------------------------
#if MEM_TRACK_MEM
#include "llframetimer.h"
//static
LLMemTracker* LLMemTracker::sInstance = NULL ;
LLMemTracker::LLMemTracker()
{
mLastAllocatedMem = LLMemory::getWorkingSetSize() ;
mCapacity = 128 ;
mCurIndex = 0 ;
mCounter = 0 ;
mDrawnIndex = 0 ;
mPaused = FALSE ;
mMutexp = new LLMutex() ;
mStringBuffer = new char*[128] ;
mStringBuffer[0] = new char[mCapacity * 128] ;
for(S32 i = 1 ; i < mCapacity ; i++)
{
mStringBuffer[i] = mStringBuffer[i-1] + 128 ;
}
}
LLMemTracker::~LLMemTracker()
{
delete[] mStringBuffer[0] ;
delete[] mStringBuffer;
delete mMutexp ;
}
//static
LLMemTracker* LLMemTracker::getInstance()
{
if(!sInstance)
{
sInstance = new LLMemTracker() ;
}
return sInstance ;
}
//static
void LLMemTracker::release()
{
if(sInstance)
{
delete sInstance ;
sInstance = NULL ;
}
}
//static
void LLMemTracker::track(const char* function, const int line)
{
static const S32 MIN_ALLOCATION = 0 ; //1KB
if(mPaused)
{
return ;
}
U32 allocated_mem = LLMemory::getWorkingSetSize() ;
LLMutexLock lock(mMutexp) ;
S32 delta_mem = allocated_mem - mLastAllocatedMem ;
mLastAllocatedMem = allocated_mem ;
if(delta_mem <= 0)
{
return ; //occupied memory does not grow
}
if(delta_mem < MIN_ALLOCATION)
{
return ;
}
char* buffer = mStringBuffer[mCurIndex++] ;
F32 time = (F32)LLFrameTimer::getElapsedSeconds() ;
S32 hours = (S32)(time / (60*60));
S32 mins = (S32)((time - hours*(60*60)) / 60);
S32 secs = (S32)((time - hours*(60*60) - mins*60));
strcpy(buffer, function) ;
sprintf(buffer + strlen(function), " line: %d DeltaMem: %d (bytes) Time: %d:%02d:%02d", line, delta_mem, hours,mins,secs) ;
if(mCounter < mCapacity)
{
mCounter++ ;
}
if(mCurIndex >= mCapacity)
{
mCurIndex = 0 ;
}
}
//static
void LLMemTracker::preDraw(BOOL pause)
{
mMutexp->lock() ;
mPaused = pause ;
mDrawnIndex = mCurIndex - 1;
mNumOfDrawn = 0 ;
}
//static
void LLMemTracker::postDraw()
{
mMutexp->unlock() ;
}
//static
const char* LLMemTracker::getNextLine()
{
if(mNumOfDrawn >= mCounter)
{
return NULL ;
}
mNumOfDrawn++;
if(mDrawnIndex < 0)
{
mDrawnIndex = mCapacity - 1 ;
}
return mStringBuffer[mDrawnIndex--] ;
}
#endif //MEM_TRACK_MEM
//--------------------------------------------------------------------------------------------------
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
//minimum slot size and minimal slot size interval //minimum slot size and minimal slot size interval

View File

@@ -40,6 +40,7 @@
#endif #endif
#include "llerror.h" #include "llerror.h"
#include "llmemtype.h"
#if LL_DEBUG #if LL_DEBUG
inline void* ll_aligned_malloc( size_t size, int align ) inline void* ll_aligned_malloc( size_t size, int align )
{ {

View File

@@ -0,0 +1,232 @@
/**
* @file llmemtype.cpp
* @brief Simple memory allocation/deallocation tracking stuff here
*
* $LicenseInfo:firstyear=2002&license=viewerlgpl$
* Second Life Viewer Source Code
* Copyright (C) 2010, Linden Research, Inc.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation;
* version 2.1 of the License only.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*
* Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA
* $/LicenseInfo$
*/
#include "llmemtype.h"
#include "llallocator.h"
std::vector<char const *> LLMemType::DeclareMemType::mNameList;
LLMemType::DeclareMemType LLMemType::MTYPE_INIT("Init");
LLMemType::DeclareMemType LLMemType::MTYPE_STARTUP("Startup");
LLMemType::DeclareMemType LLMemType::MTYPE_MAIN("Main");
LLMemType::DeclareMemType LLMemType::MTYPE_FRAME("Frame");
LLMemType::DeclareMemType LLMemType::MTYPE_GATHER_INPUT("GatherInput");
LLMemType::DeclareMemType LLMemType::MTYPE_JOY_KEY("JoyKey");
LLMemType::DeclareMemType LLMemType::MTYPE_IDLE("Idle");
LLMemType::DeclareMemType LLMemType::MTYPE_IDLE_PUMP("IdlePump");
LLMemType::DeclareMemType LLMemType::MTYPE_IDLE_NETWORK("IdleNetwork");
LLMemType::DeclareMemType LLMemType::MTYPE_IDLE_UPDATE_REGIONS("IdleUpdateRegions");
LLMemType::DeclareMemType LLMemType::MTYPE_IDLE_UPDATE_VIEWER_REGION("IdleUpdateViewerRegion");
LLMemType::DeclareMemType LLMemType::MTYPE_IDLE_UPDATE_SURFACE("IdleUpdateSurface");
LLMemType::DeclareMemType LLMemType::MTYPE_IDLE_UPDATE_PARCEL_OVERLAY("IdleUpdateParcelOverlay");
LLMemType::DeclareMemType LLMemType::MTYPE_IDLE_AUDIO("IdleAudio");
LLMemType::DeclareMemType LLMemType::MTYPE_CACHE_PROCESS_PENDING("CacheProcessPending");
LLMemType::DeclareMemType LLMemType::MTYPE_CACHE_PROCESS_PENDING_ASKS("CacheProcessPendingAsks");
LLMemType::DeclareMemType LLMemType::MTYPE_CACHE_PROCESS_PENDING_REPLIES("CacheProcessPendingReplies");
LLMemType::DeclareMemType LLMemType::MTYPE_MESSAGE_CHECK_ALL("MessageCheckAll");
LLMemType::DeclareMemType LLMemType::MTYPE_MESSAGE_PROCESS_ACKS("MessageProcessAcks");
LLMemType::DeclareMemType LLMemType::MTYPE_RENDER("Render");
LLMemType::DeclareMemType LLMemType::MTYPE_SLEEP("Sleep");
LLMemType::DeclareMemType LLMemType::MTYPE_NETWORK("Network");
LLMemType::DeclareMemType LLMemType::MTYPE_PHYSICS("Physics");
LLMemType::DeclareMemType LLMemType::MTYPE_INTERESTLIST("InterestList");
LLMemType::DeclareMemType LLMemType::MTYPE_IMAGEBASE("ImageBase");
LLMemType::DeclareMemType LLMemType::MTYPE_IMAGERAW("ImageRaw");
LLMemType::DeclareMemType LLMemType::MTYPE_IMAGEFORMATTED("ImageFormatted");
LLMemType::DeclareMemType LLMemType::MTYPE_APPFMTIMAGE("AppFmtImage");
LLMemType::DeclareMemType LLMemType::MTYPE_APPRAWIMAGE("AppRawImage");
LLMemType::DeclareMemType LLMemType::MTYPE_APPAUXRAWIMAGE("AppAuxRawImage");
LLMemType::DeclareMemType LLMemType::MTYPE_DRAWABLE("Drawable");
LLMemType::DeclareMemType LLMemType::MTYPE_OBJECT("Object");
LLMemType::DeclareMemType LLMemType::MTYPE_OBJECT_PROCESS_UPDATE("ObjectProcessUpdate");
LLMemType::DeclareMemType LLMemType::MTYPE_OBJECT_PROCESS_UPDATE_CORE("ObjectProcessUpdateCore");
LLMemType::DeclareMemType LLMemType::MTYPE_DISPLAY("Display");
LLMemType::DeclareMemType LLMemType::MTYPE_DISPLAY_UPDATE("DisplayUpdate");
LLMemType::DeclareMemType LLMemType::MTYPE_DISPLAY_UPDATE_CAMERA("DisplayUpdateCam");
LLMemType::DeclareMemType LLMemType::MTYPE_DISPLAY_UPDATE_GEOM("DisplayUpdateGeom");
LLMemType::DeclareMemType LLMemType::MTYPE_DISPLAY_SWAP("DisplaySwap");
LLMemType::DeclareMemType LLMemType::MTYPE_DISPLAY_UPDATE_HUD("DisplayUpdateHud");
LLMemType::DeclareMemType LLMemType::MTYPE_DISPLAY_GEN_REFLECTION("DisplayGenRefl");
LLMemType::DeclareMemType LLMemType::MTYPE_DISPLAY_IMAGE_UPDATE("DisplayImageUpdate");
LLMemType::DeclareMemType LLMemType::MTYPE_DISPLAY_STATE_SORT("DisplayStateSort");
LLMemType::DeclareMemType LLMemType::MTYPE_DISPLAY_SKY("DisplaySky");
LLMemType::DeclareMemType LLMemType::MTYPE_DISPLAY_RENDER_GEOM("DisplayRenderGeom");
LLMemType::DeclareMemType LLMemType::MTYPE_DISPLAY_RENDER_FLUSH("DisplayRenderFlush");
LLMemType::DeclareMemType LLMemType::MTYPE_DISPLAY_RENDER_UI("DisplayRenderUI");
LLMemType::DeclareMemType LLMemType::MTYPE_DISPLAY_RENDER_ATTACHMENTS("DisplayRenderAttach");
LLMemType::DeclareMemType LLMemType::MTYPE_VERTEX_DATA("VertexData");
LLMemType::DeclareMemType LLMemType::MTYPE_VERTEX_CONSTRUCTOR("VertexConstr");
LLMemType::DeclareMemType LLMemType::MTYPE_VERTEX_DESTRUCTOR("VertexDestr");
LLMemType::DeclareMemType LLMemType::MTYPE_VERTEX_CREATE_VERTICES("VertexCreateVerts");
LLMemType::DeclareMemType LLMemType::MTYPE_VERTEX_CREATE_INDICES("VertexCreateIndices");
LLMemType::DeclareMemType LLMemType::MTYPE_VERTEX_DESTROY_BUFFER("VertexDestroyBuff");
LLMemType::DeclareMemType LLMemType::MTYPE_VERTEX_DESTROY_INDICES("VertexDestroyIndices");
LLMemType::DeclareMemType LLMemType::MTYPE_VERTEX_UPDATE_VERTS("VertexUpdateVerts");
LLMemType::DeclareMemType LLMemType::MTYPE_VERTEX_UPDATE_INDICES("VertexUpdateIndices");
LLMemType::DeclareMemType LLMemType::MTYPE_VERTEX_ALLOCATE_BUFFER("VertexAllocateBuffer");
LLMemType::DeclareMemType LLMemType::MTYPE_VERTEX_RESIZE_BUFFER("VertexResizeBuffer");
LLMemType::DeclareMemType LLMemType::MTYPE_VERTEX_MAP_BUFFER("VertexMapBuffer");
LLMemType::DeclareMemType LLMemType::MTYPE_VERTEX_MAP_BUFFER_VERTICES("VertexMapBufferVerts");
LLMemType::DeclareMemType LLMemType::MTYPE_VERTEX_MAP_BUFFER_INDICES("VertexMapBufferIndices");
LLMemType::DeclareMemType LLMemType::MTYPE_VERTEX_UNMAP_BUFFER("VertexUnmapBuffer");
LLMemType::DeclareMemType LLMemType::MTYPE_VERTEX_SET_STRIDE("VertexSetStride");
LLMemType::DeclareMemType LLMemType::MTYPE_VERTEX_SET_BUFFER("VertexSetBuffer");
LLMemType::DeclareMemType LLMemType::MTYPE_VERTEX_SETUP_VERTEX_BUFFER("VertexSetupVertBuff");
LLMemType::DeclareMemType LLMemType::MTYPE_VERTEX_CLEANUP_CLASS("VertexCleanupClass");
LLMemType::DeclareMemType LLMemType::MTYPE_SPACE_PARTITION("SpacePartition");
LLMemType::DeclareMemType LLMemType::MTYPE_PIPELINE("Pipeline");
LLMemType::DeclareMemType LLMemType::MTYPE_PIPELINE_INIT("PipelineInit");
LLMemType::DeclareMemType LLMemType::MTYPE_PIPELINE_CREATE_BUFFERS("PipelineCreateBuffs");
LLMemType::DeclareMemType LLMemType::MTYPE_PIPELINE_RESTORE_GL("PipelineRestroGL");
LLMemType::DeclareMemType LLMemType::MTYPE_PIPELINE_UNLOAD_SHADERS("PipelineUnloadShaders");
LLMemType::DeclareMemType LLMemType::MTYPE_PIPELINE_LIGHTING_DETAIL("PipelineLightingDetail");
LLMemType::DeclareMemType LLMemType::MTYPE_PIPELINE_GET_POOL_TYPE("PipelineGetPoolType");
LLMemType::DeclareMemType LLMemType::MTYPE_PIPELINE_ADD_POOL("PipelineAddPool");
LLMemType::DeclareMemType LLMemType::MTYPE_PIPELINE_ALLOCATE_DRAWABLE("PipelineAllocDrawable");
LLMemType::DeclareMemType LLMemType::MTYPE_PIPELINE_ADD_OBJECT("PipelineAddObj");
LLMemType::DeclareMemType LLMemType::MTYPE_PIPELINE_CREATE_OBJECTS("PipelineCreateObjs");
LLMemType::DeclareMemType LLMemType::MTYPE_PIPELINE_UPDATE_MOVE("PipelineUpdateMove");
LLMemType::DeclareMemType LLMemType::MTYPE_PIPELINE_UPDATE_GEOM("PipelineUpdateGeom");
LLMemType::DeclareMemType LLMemType::MTYPE_PIPELINE_MARK_VISIBLE("PipelineMarkVisible");
LLMemType::DeclareMemType LLMemType::MTYPE_PIPELINE_MARK_MOVED("PipelineMarkMoved");
LLMemType::DeclareMemType LLMemType::MTYPE_PIPELINE_MARK_SHIFT("PipelineMarkShift");
LLMemType::DeclareMemType LLMemType::MTYPE_PIPELINE_SHIFT_OBJECTS("PipelineShiftObjs");
LLMemType::DeclareMemType LLMemType::MTYPE_PIPELINE_MARK_TEXTURED("PipelineMarkTextured");
LLMemType::DeclareMemType LLMemType::MTYPE_PIPELINE_MARK_REBUILD("PipelineMarkRebuild");
LLMemType::DeclareMemType LLMemType::MTYPE_PIPELINE_UPDATE_CULL("PipelineUpdateCull");
LLMemType::DeclareMemType LLMemType::MTYPE_PIPELINE_STATE_SORT("PipelineStateSort");
LLMemType::DeclareMemType LLMemType::MTYPE_PIPELINE_POST_SORT("PipelinePostSort");
LLMemType::DeclareMemType LLMemType::MTYPE_PIPELINE_RENDER_HUD_ELS("PipelineHudEls");
LLMemType::DeclareMemType LLMemType::MTYPE_PIPELINE_RENDER_HL("PipelineRenderHL");
LLMemType::DeclareMemType LLMemType::MTYPE_PIPELINE_RENDER_GEOM("PipelineRenderGeom");
LLMemType::DeclareMemType LLMemType::MTYPE_PIPELINE_RENDER_GEOM_DEFFERRED("PipelineRenderGeomDef");
LLMemType::DeclareMemType LLMemType::MTYPE_PIPELINE_RENDER_GEOM_POST_DEF("PipelineRenderGeomPostDef");
LLMemType::DeclareMemType LLMemType::MTYPE_PIPELINE_RENDER_GEOM_SHADOW("PipelineRenderGeomShadow");
LLMemType::DeclareMemType LLMemType::MTYPE_PIPELINE_RENDER_SELECT("PipelineRenderSelect");
LLMemType::DeclareMemType LLMemType::MTYPE_PIPELINE_REBUILD_POOLS("PipelineRebuildPools");
LLMemType::DeclareMemType LLMemType::MTYPE_PIPELINE_QUICK_LOOKUP("PipelineQuickLookup");
LLMemType::DeclareMemType LLMemType::MTYPE_PIPELINE_RENDER_OBJECTS("PipelineRenderObjs");
LLMemType::DeclareMemType LLMemType::MTYPE_PIPELINE_GENERATE_IMPOSTOR("PipelineGenImpostors");
LLMemType::DeclareMemType LLMemType::MTYPE_PIPELINE_RENDER_BLOOM("PipelineRenderBloom");
LLMemType::DeclareMemType LLMemType::MTYPE_UPKEEP_POOLS("UpkeepPools");
LLMemType::DeclareMemType LLMemType::MTYPE_AVATAR("Avatar");
LLMemType::DeclareMemType LLMemType::MTYPE_AVATAR_MESH("AvatarMesh");
LLMemType::DeclareMemType LLMemType::MTYPE_PARTICLES("Particles");
LLMemType::DeclareMemType LLMemType::MTYPE_REGIONS("Regions");
LLMemType::DeclareMemType LLMemType::MTYPE_INVENTORY("Inventory");
LLMemType::DeclareMemType LLMemType::MTYPE_INVENTORY_DRAW("InventoryDraw");
LLMemType::DeclareMemType LLMemType::MTYPE_INVENTORY_BUILD_NEW_VIEWS("InventoryBuildNewViews");
LLMemType::DeclareMemType LLMemType::MTYPE_INVENTORY_DO_FOLDER("InventoryDoFolder");
LLMemType::DeclareMemType LLMemType::MTYPE_INVENTORY_POST_BUILD("InventoryPostBuild");
LLMemType::DeclareMemType LLMemType::MTYPE_INVENTORY_FROM_XML("InventoryFromXML");
LLMemType::DeclareMemType LLMemType::MTYPE_INVENTORY_CREATE_NEW_ITEM("InventoryCreateNewItem");
LLMemType::DeclareMemType LLMemType::MTYPE_INVENTORY_VIEW_INIT("InventoryViewInit");
LLMemType::DeclareMemType LLMemType::MTYPE_INVENTORY_VIEW_SHOW("InventoryViewShow");
LLMemType::DeclareMemType LLMemType::MTYPE_INVENTORY_VIEW_TOGGLE("InventoryViewToggle");
LLMemType::DeclareMemType LLMemType::MTYPE_ANIMATION("Animation");
LLMemType::DeclareMemType LLMemType::MTYPE_VOLUME("Volume");
LLMemType::DeclareMemType LLMemType::MTYPE_PRIMITIVE("Primitive");
LLMemType::DeclareMemType LLMemType::MTYPE_SCRIPT("Script");
LLMemType::DeclareMemType LLMemType::MTYPE_SCRIPT_RUN("ScriptRun");
LLMemType::DeclareMemType LLMemType::MTYPE_SCRIPT_BYTECODE("ScriptByteCode");
LLMemType::DeclareMemType LLMemType::MTYPE_IO_PUMP("IoPump");
LLMemType::DeclareMemType LLMemType::MTYPE_IO_TCP("IoTCP");
LLMemType::DeclareMemType LLMemType::MTYPE_IO_BUFFER("IoBuffer");
LLMemType::DeclareMemType LLMemType::MTYPE_IO_HTTP_SERVER("IoHttpServer");
LLMemType::DeclareMemType LLMemType::MTYPE_IO_SD_SERVER("IoSDServer");
LLMemType::DeclareMemType LLMemType::MTYPE_IO_SD_CLIENT("IoSDClient");
LLMemType::DeclareMemType LLMemType::MTYPE_IO_URL_REQUEST("IOUrlRequest");
LLMemType::DeclareMemType LLMemType::MTYPE_DIRECTX_INIT("DirectXInit");
LLMemType::DeclareMemType LLMemType::MTYPE_TEMP1("Temp1");
LLMemType::DeclareMemType LLMemType::MTYPE_TEMP2("Temp2");
LLMemType::DeclareMemType LLMemType::MTYPE_TEMP3("Temp3");
LLMemType::DeclareMemType LLMemType::MTYPE_TEMP4("Temp4");
LLMemType::DeclareMemType LLMemType::MTYPE_TEMP5("Temp5");
LLMemType::DeclareMemType LLMemType::MTYPE_TEMP6("Temp6");
LLMemType::DeclareMemType LLMemType::MTYPE_TEMP7("Temp7");
LLMemType::DeclareMemType LLMemType::MTYPE_TEMP8("Temp8");
LLMemType::DeclareMemType LLMemType::MTYPE_TEMP9("Temp9");
LLMemType::DeclareMemType LLMemType::MTYPE_OTHER("Other");
LLMemType::DeclareMemType::DeclareMemType(char const * st)
{
mID = (S32)mNameList.size();
mName = st;
mNameList.push_back(mName);
}
LLMemType::DeclareMemType::~DeclareMemType()
{
}
LLMemType::LLMemType(LLMemType::DeclareMemType& dt)
{
mTypeIndex = dt.mID;
LLAllocator::pushMemType(dt.mID);
}
LLMemType::~LLMemType()
{
LLAllocator::popMemType();
}
char const * LLMemType::getNameFromID(S32 id)
{
if (id < 0 || id >= (S32)DeclareMemType::mNameList.size())
{
return "INVALID";
}
return DeclareMemType::mNameList[id];
}
//--------------------------------------------------------------------------------------------------

View File

@@ -36,128 +36,210 @@
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
class LLMemType;
extern void* ll_allocate (size_t size);
extern void ll_release (void *p);
#define MEM_TRACK_MEM 0
#define MEM_TRACK_TYPE (1 && MEM_TRACK_MEM)
#if MEM_TRACK_TYPE
#define MEM_DUMP_DATA 1
#define MEM_TYPE_NEW(T) \
static void* operator new(size_t s) { LLMemType mt(T); return ll_allocate(s); } \
static void operator delete(void* p) { ll_release(p); }
#else
#define MEM_TYPE_NEW(T)
#endif // MEM_TRACK_TYPE
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
#include "linden_common.h"
//!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
// WARNING: Never commit with MEM_TRACK_MEM == 1
//!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
#define MEM_TRACK_MEM (0 && LL_WINDOWS)
#include <vector>
#define MEM_TYPE_NEW(T)
class LL_COMMON_API LLMemType class LL_COMMON_API LLMemType
{ {
public: public:
// Also update sTypeDesc in llmemory.cpp
enum EMemType // class we'll initialize all instances of as
// static members of MemType. Then use
// to construct any new mem type.
class LL_COMMON_API DeclareMemType
{ {
MTYPE_INIT, public:
MTYPE_STARTUP, DeclareMemType(char const * st);
MTYPE_MAIN, ~DeclareMemType();
MTYPE_IMAGEBASE, S32 mID;
MTYPE_IMAGERAW, char const * mName;
MTYPE_IMAGEFORMATTED,
MTYPE_APPFMTIMAGE, // array so we can map an index ID to Name
MTYPE_APPRAWIMAGE, static std::vector<char const *> mNameList;
MTYPE_APPAUXRAWIMAGE,
MTYPE_DRAWABLE,
MTYPE_OBJECT,
MTYPE_VERTEX_DATA,
MTYPE_SPACE_PARTITION,
MTYPE_PIPELINE,
MTYPE_AVATAR,
MTYPE_AVATAR_MESH,
MTYPE_PARTICLES,
MTYPE_REGIONS,
MTYPE_INVENTORY,
MTYPE_ANIMATION,
MTYPE_VOLUME,
MTYPE_PRIMITIVE,
MTYPE_NETWORK,
MTYPE_PHYSICS,
MTYPE_INTERESTLIST,
MTYPE_SCRIPT,
MTYPE_SCRIPT_RUN,
MTYPE_SCRIPT_BYTECODE,
MTYPE_IO_PUMP,
MTYPE_IO_TCP,
MTYPE_IO_BUFFER,
MTYPE_IO_HTTP_SERVER,
MTYPE_IO_SD_SERVER,
MTYPE_IO_SD_CLIENT,
MTYPE_IO_URL_REQUEST,
MTYPE_TEMP1,
MTYPE_TEMP2,
MTYPE_TEMP3,
MTYPE_TEMP4,
MTYPE_TEMP5,
MTYPE_TEMP6,
MTYPE_TEMP7,
MTYPE_TEMP8,
MTYPE_TEMP9,
MTYPE_OTHER, // Special, used by display code
MTYPE_NUM_TYPES
}; };
enum { MTYPE_MAX_DEPTH = 64 };
public:
LLMemType(EMemType type)
{
#if MEM_TRACK_TYPE
if (type < 0 || type >= MTYPE_NUM_TYPES)
llerrs << "LLMemType error" << llendl;
if (sCurDepth < 0 || sCurDepth >= MTYPE_MAX_DEPTH)
llerrs << "LLMemType error" << llendl;
sType[sCurDepth] = sCurType;
sCurDepth++;
sCurType = type;
#endif
}
~LLMemType()
{
#if MEM_TRACK_TYPE
sCurDepth--;
sCurType = sType[sCurDepth];
#endif
}
static void reset(); LLMemType(DeclareMemType& dt);
static void printMem(); ~LLMemType();
static char const * getNameFromID(S32 id);
static DeclareMemType MTYPE_INIT;
static DeclareMemType MTYPE_STARTUP;
static DeclareMemType MTYPE_MAIN;
static DeclareMemType MTYPE_FRAME;
static DeclareMemType MTYPE_GATHER_INPUT;
static DeclareMemType MTYPE_JOY_KEY;
static DeclareMemType MTYPE_IDLE;
static DeclareMemType MTYPE_IDLE_PUMP;
static DeclareMemType MTYPE_IDLE_NETWORK;
static DeclareMemType MTYPE_IDLE_UPDATE_REGIONS;
static DeclareMemType MTYPE_IDLE_UPDATE_VIEWER_REGION;
static DeclareMemType MTYPE_IDLE_UPDATE_SURFACE;
static DeclareMemType MTYPE_IDLE_UPDATE_PARCEL_OVERLAY;
static DeclareMemType MTYPE_IDLE_AUDIO;
static DeclareMemType MTYPE_CACHE_PROCESS_PENDING;
static DeclareMemType MTYPE_CACHE_PROCESS_PENDING_ASKS;
static DeclareMemType MTYPE_CACHE_PROCESS_PENDING_REPLIES;
static DeclareMemType MTYPE_MESSAGE_CHECK_ALL;
static DeclareMemType MTYPE_MESSAGE_PROCESS_ACKS;
static DeclareMemType MTYPE_RENDER;
static DeclareMemType MTYPE_SLEEP;
static DeclareMemType MTYPE_NETWORK;
static DeclareMemType MTYPE_PHYSICS;
static DeclareMemType MTYPE_INTERESTLIST;
static DeclareMemType MTYPE_IMAGEBASE;
static DeclareMemType MTYPE_IMAGERAW;
static DeclareMemType MTYPE_IMAGEFORMATTED;
public: static DeclareMemType MTYPE_APPFMTIMAGE;
#if MEM_TRACK_TYPE static DeclareMemType MTYPE_APPRAWIMAGE;
static S32 sCurDepth; static DeclareMemType MTYPE_APPAUXRAWIMAGE;
static S32 sCurType;
static S32 sType[MTYPE_MAX_DEPTH]; static DeclareMemType MTYPE_DRAWABLE;
static S32 sMemCount[MTYPE_NUM_TYPES];
static S32 sMaxMemCount[MTYPE_NUM_TYPES]; static DeclareMemType MTYPE_OBJECT;
static S32 sNewCount[MTYPE_NUM_TYPES]; static DeclareMemType MTYPE_OBJECT_PROCESS_UPDATE;
static S32 sOverheadMem; static DeclareMemType MTYPE_OBJECT_PROCESS_UPDATE_CORE;
static const char* sTypeDesc[MTYPE_NUM_TYPES];
#endif static DeclareMemType MTYPE_DISPLAY;
static S32 sTotalMem; static DeclareMemType MTYPE_DISPLAY_UPDATE;
static S32 sMaxTotalMem; static DeclareMemType MTYPE_DISPLAY_UPDATE_CAMERA;
static DeclareMemType MTYPE_DISPLAY_UPDATE_GEOM;
static DeclareMemType MTYPE_DISPLAY_SWAP;
static DeclareMemType MTYPE_DISPLAY_UPDATE_HUD;
static DeclareMemType MTYPE_DISPLAY_GEN_REFLECTION;
static DeclareMemType MTYPE_DISPLAY_IMAGE_UPDATE;
static DeclareMemType MTYPE_DISPLAY_STATE_SORT;
static DeclareMemType MTYPE_DISPLAY_SKY;
static DeclareMemType MTYPE_DISPLAY_RENDER_GEOM;
static DeclareMemType MTYPE_DISPLAY_RENDER_FLUSH;
static DeclareMemType MTYPE_DISPLAY_RENDER_UI;
static DeclareMemType MTYPE_DISPLAY_RENDER_ATTACHMENTS;
static DeclareMemType MTYPE_VERTEX_DATA;
static DeclareMemType MTYPE_VERTEX_CONSTRUCTOR;
static DeclareMemType MTYPE_VERTEX_DESTRUCTOR;
static DeclareMemType MTYPE_VERTEX_CREATE_VERTICES;
static DeclareMemType MTYPE_VERTEX_CREATE_INDICES;
static DeclareMemType MTYPE_VERTEX_DESTROY_BUFFER;
static DeclareMemType MTYPE_VERTEX_DESTROY_INDICES;
static DeclareMemType MTYPE_VERTEX_UPDATE_VERTS;
static DeclareMemType MTYPE_VERTEX_UPDATE_INDICES;
static DeclareMemType MTYPE_VERTEX_ALLOCATE_BUFFER;
static DeclareMemType MTYPE_VERTEX_RESIZE_BUFFER;
static DeclareMemType MTYPE_VERTEX_MAP_BUFFER;
static DeclareMemType MTYPE_VERTEX_MAP_BUFFER_VERTICES;
static DeclareMemType MTYPE_VERTEX_MAP_BUFFER_INDICES;
static DeclareMemType MTYPE_VERTEX_UNMAP_BUFFER;
static DeclareMemType MTYPE_VERTEX_SET_STRIDE;
static DeclareMemType MTYPE_VERTEX_SET_BUFFER;
static DeclareMemType MTYPE_VERTEX_SETUP_VERTEX_BUFFER;
static DeclareMemType MTYPE_VERTEX_CLEANUP_CLASS;
static DeclareMemType MTYPE_SPACE_PARTITION;
static DeclareMemType MTYPE_PIPELINE;
static DeclareMemType MTYPE_PIPELINE_INIT;
static DeclareMemType MTYPE_PIPELINE_CREATE_BUFFERS;
static DeclareMemType MTYPE_PIPELINE_RESTORE_GL;
static DeclareMemType MTYPE_PIPELINE_UNLOAD_SHADERS;
static DeclareMemType MTYPE_PIPELINE_LIGHTING_DETAIL;
static DeclareMemType MTYPE_PIPELINE_GET_POOL_TYPE;
static DeclareMemType MTYPE_PIPELINE_ADD_POOL;
static DeclareMemType MTYPE_PIPELINE_ALLOCATE_DRAWABLE;
static DeclareMemType MTYPE_PIPELINE_ADD_OBJECT;
static DeclareMemType MTYPE_PIPELINE_CREATE_OBJECTS;
static DeclareMemType MTYPE_PIPELINE_UPDATE_MOVE;
static DeclareMemType MTYPE_PIPELINE_UPDATE_GEOM;
static DeclareMemType MTYPE_PIPELINE_MARK_VISIBLE;
static DeclareMemType MTYPE_PIPELINE_MARK_MOVED;
static DeclareMemType MTYPE_PIPELINE_MARK_SHIFT;
static DeclareMemType MTYPE_PIPELINE_SHIFT_OBJECTS;
static DeclareMemType MTYPE_PIPELINE_MARK_TEXTURED;
static DeclareMemType MTYPE_PIPELINE_MARK_REBUILD;
static DeclareMemType MTYPE_PIPELINE_UPDATE_CULL;
static DeclareMemType MTYPE_PIPELINE_STATE_SORT;
static DeclareMemType MTYPE_PIPELINE_POST_SORT;
static DeclareMemType MTYPE_PIPELINE_RENDER_HUD_ELS;
static DeclareMemType MTYPE_PIPELINE_RENDER_HL;
static DeclareMemType MTYPE_PIPELINE_RENDER_GEOM;
static DeclareMemType MTYPE_PIPELINE_RENDER_GEOM_DEFFERRED;
static DeclareMemType MTYPE_PIPELINE_RENDER_GEOM_POST_DEF;
static DeclareMemType MTYPE_PIPELINE_RENDER_GEOM_SHADOW;
static DeclareMemType MTYPE_PIPELINE_RENDER_SELECT;
static DeclareMemType MTYPE_PIPELINE_REBUILD_POOLS;
static DeclareMemType MTYPE_PIPELINE_QUICK_LOOKUP;
static DeclareMemType MTYPE_PIPELINE_RENDER_OBJECTS;
static DeclareMemType MTYPE_PIPELINE_GENERATE_IMPOSTOR;
static DeclareMemType MTYPE_PIPELINE_RENDER_BLOOM;
static DeclareMemType MTYPE_UPKEEP_POOLS;
static DeclareMemType MTYPE_AVATAR;
static DeclareMemType MTYPE_AVATAR_MESH;
static DeclareMemType MTYPE_PARTICLES;
static DeclareMemType MTYPE_REGIONS;
static DeclareMemType MTYPE_INVENTORY;
static DeclareMemType MTYPE_INVENTORY_DRAW;
static DeclareMemType MTYPE_INVENTORY_BUILD_NEW_VIEWS;
static DeclareMemType MTYPE_INVENTORY_DO_FOLDER;
static DeclareMemType MTYPE_INVENTORY_POST_BUILD;
static DeclareMemType MTYPE_INVENTORY_FROM_XML;
static DeclareMemType MTYPE_INVENTORY_CREATE_NEW_ITEM;
static DeclareMemType MTYPE_INVENTORY_VIEW_INIT;
static DeclareMemType MTYPE_INVENTORY_VIEW_SHOW;
static DeclareMemType MTYPE_INVENTORY_VIEW_TOGGLE;
static DeclareMemType MTYPE_ANIMATION;
static DeclareMemType MTYPE_VOLUME;
static DeclareMemType MTYPE_PRIMITIVE;
static DeclareMemType MTYPE_SCRIPT;
static DeclareMemType MTYPE_SCRIPT_RUN;
static DeclareMemType MTYPE_SCRIPT_BYTECODE;
static DeclareMemType MTYPE_IO_PUMP;
static DeclareMemType MTYPE_IO_TCP;
static DeclareMemType MTYPE_IO_BUFFER;
static DeclareMemType MTYPE_IO_HTTP_SERVER;
static DeclareMemType MTYPE_IO_SD_SERVER;
static DeclareMemType MTYPE_IO_SD_CLIENT;
static DeclareMemType MTYPE_IO_URL_REQUEST;
static DeclareMemType MTYPE_DIRECTX_INIT;
static DeclareMemType MTYPE_TEMP1;
static DeclareMemType MTYPE_TEMP2;
static DeclareMemType MTYPE_TEMP3;
static DeclareMemType MTYPE_TEMP4;
static DeclareMemType MTYPE_TEMP5;
static DeclareMemType MTYPE_TEMP6;
static DeclareMemType MTYPE_TEMP7;
static DeclareMemType MTYPE_TEMP8;
static DeclareMemType MTYPE_TEMP9;
static DeclareMemType MTYPE_OTHER; // Special; used by display code
S32 mTypeIndex;
}; };
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------

View File

@@ -170,7 +170,7 @@ void LLImageBase::deleteData()
// virtual // virtual
U8* LLImageBase::allocateData(S32 size) U8* LLImageBase::allocateData(S32 size)
{ {
LLMemType mt1((LLMemType::EMemType)mMemType); LLMemType mt1(mMemType);
if (size < 0) if (size < 0)
{ {
@@ -209,7 +209,7 @@ U8* LLImageBase::reallocateData(S32 size)
if(mData && (mDataSize == size)) if(mData && (mDataSize == size))
return mData; return mData;
LLMemType mt1((LLMemType::EMemType)mMemType); LLMemType mt1(mMemType);
U8 *new_datap = (U8*)ALLOCATE_MEM(sPrivatePoolp, size); U8 *new_datap = (U8*)ALLOCATE_MEM(sPrivatePoolp, size);
if (!new_datap) if (!new_datap)
{ {
@@ -457,7 +457,7 @@ void LLImageRaw::clear(U8 r, U8 g, U8 b, U8 a)
// Reverses the order of the rows in the image // Reverses the order of the rows in the image
void LLImageRaw::verticalFlip() void LLImageRaw::verticalFlip()
{ {
LLMemType mt1((LLMemType::EMemType)mMemType); LLMemType mt1(mMemType);
S32 row_bytes = getWidth() * getComponents(); S32 row_bytes = getWidth() * getComponents();
U8* line_buffer = new (std::nothrow) U8[row_bytes]; U8* line_buffer = new (std::nothrow) U8[row_bytes];
if (!line_buffer ) if (!line_buffer )
@@ -595,7 +595,7 @@ void LLImageRaw::composite( LLImageRaw* src )
// Src and dst can be any size. Src has 4 components. Dst has 3 components. // Src and dst can be any size. Src has 4 components. Dst has 3 components.
void LLImageRaw::compositeScaled4onto3(LLImageRaw* src) void LLImageRaw::compositeScaled4onto3(LLImageRaw* src)
{ {
LLMemType mt1((LLMemType::EMemType)mMemType); LLMemType mt1(mMemType);
llinfos << "compositeScaled4onto3" << llendl; llinfos << "compositeScaled4onto3" << llendl;
LLImageRaw* dst = this; // Just for clarity. LLImageRaw* dst = this; // Just for clarity.
@@ -846,7 +846,7 @@ void LLImageRaw::copyUnscaled3onto4( LLImageRaw* src )
// Src and dst can be any size. Src and dst have same number of components. // Src and dst can be any size. Src and dst have same number of components.
void LLImageRaw::copyScaled( LLImageRaw* src ) void LLImageRaw::copyScaled( LLImageRaw* src )
{ {
LLMemType mt1((LLMemType::EMemType)mMemType); LLMemType mt1(mMemType);
LLImageRaw* dst = this; // Just for clarity. LLImageRaw* dst = this; // Just for clarity.
llassert_always( (1 == src->getComponents()) || (3 == src->getComponents()) || (4 == src->getComponents()) ); llassert_always( (1 == src->getComponents()) || (3 == src->getComponents()) || (4 == src->getComponents()) );
@@ -932,7 +932,7 @@ BOOL LLImageRaw::scaleDownWithoutBlending( S32 new_width, S32 new_height)
BOOL LLImageRaw::scale( S32 new_width, S32 new_height, BOOL scale_image_data ) BOOL LLImageRaw::scale( S32 new_width, S32 new_height, BOOL scale_image_data )
{ {
LLMemType mt1((LLMemType::EMemType)mMemType); LLMemType mt1(mMemType);
llassert((1 == getComponents()) || (3 == getComponents()) || (4 == getComponents()) ); llassert((1 == getComponents()) || (3 == getComponents()) || (4 == getComponents()) );
S32 old_width = getWidth(); S32 old_width = getWidth();

View File

@@ -35,7 +35,7 @@
#include "lluuid.h" #include "lluuid.h"
#include "llstring.h" #include "llstring.h"
#include "llmemory.h" #include "llmemtype.h"
#include "llthread.h" #include "llthread.h"
#include "aithreadsafe.h" #include "aithreadsafe.h"
@@ -162,7 +162,7 @@ private:
static LLPrivateMemoryPool* sPrivatePoolp ; static LLPrivateMemoryPool* sPrivatePoolp ;
public: public:
S16 mMemType; // debug LLMemType::DeclareMemType& mMemType; // debug
}; };
// Raw representation of an image (used for textures, and other uncompressed formats // Raw representation of an image (used for textures, and other uncompressed formats

View File

@@ -297,7 +297,7 @@ BOOL LLImageJ2C::decode(LLImageRaw *raw_imagep, F32 decode_time)
// Returns TRUE to mean done, whether successful or not. // Returns TRUE to mean done, whether successful or not.
BOOL LLImageJ2C::decodeChannels(LLImageRaw *raw_imagep, F32 decode_time, S32 first_channel, S32 max_channel_count ) BOOL LLImageJ2C::decodeChannels(LLImageRaw *raw_imagep, F32 decode_time, S32 first_channel, S32 max_channel_count )
{ {
LLMemType mt1((LLMemType::EMemType)mMemType); LLMemType mt1(mMemType);
BOOL res = TRUE; BOOL res = TRUE;
@@ -347,7 +347,7 @@ BOOL LLImageJ2C::encode(const LLImageRaw *raw_imagep, F32 encode_time)
BOOL LLImageJ2C::encode(const LLImageRaw *raw_imagep, const char* comment_text, F32 encode_time) BOOL LLImageJ2C::encode(const LLImageRaw *raw_imagep, const char* comment_text, F32 encode_time)
{ {
LLMemType mt1((LLMemType::EMemType)mMemType); LLMemType mt1(mMemType);
resetLastError(); resetLastError();
BOOL res = mImpl->encodeImpl(*this, *raw_imagep, comment_text, encode_time, mReversible); BOOL res = mImpl->encodeImpl(*this, *raw_imagep, comment_text, encode_time, mReversible);
if (!mLastError.empty()) if (!mLastError.empty())
@@ -529,7 +529,7 @@ BOOL LLImageJ2C::loadAndValidate(const std::string &filename)
BOOL LLImageJ2C::validate(U8 *data, U32 file_size) BOOL LLImageJ2C::validate(U8 *data, U32 file_size)
{ {
LLMemType mt1((LLMemType::EMemType)mMemType); LLMemType mt1(mMemType);
resetLastError(); resetLastError();

View File

@@ -42,6 +42,7 @@
#include "llsdserialize.h" #include "llsdserialize.h"
#include "lluuid.h" #include "lluuid.h"
#include "message.h" #include "message.h"
#include "llmemtype.h"
#include <boost/regex.hpp> #include <boost/regex.hpp>
@@ -771,6 +772,7 @@ bool LLCacheName::getIfThere(const LLUUID& id, std::string& fullname, BOOL& is_g
// </edit> // </edit>
void LLCacheName::processPending() void LLCacheName::processPending()
{ {
LLMemType mt_pp(LLMemType::MTYPE_CACHE_PROCESS_PENDING);
const F32 SECS_BETWEEN_PROCESS = 0.1f; const F32 SECS_BETWEEN_PROCESS = 0.1f;
if(!impl.mProcessTimer.checkExpirationAndReset(SECS_BETWEEN_PROCESS)) if(!impl.mProcessTimer.checkExpirationAndReset(SECS_BETWEEN_PROCESS))
{ {
@@ -873,8 +875,10 @@ std::string LLCacheName::getDefaultLastName()
{ {
return "Resident"; return "Resident";
} }
void LLCacheName::Impl::processPendingAsks() void LLCacheName::Impl::processPendingAsks()
{ {
LLMemType mt_ppa(LLMemType::MTYPE_CACHE_PROCESS_PENDING_ASKS);
sendRequest(_PREHASH_UUIDNameRequest, mAskNameQueue); sendRequest(_PREHASH_UUIDNameRequest, mAskNameQueue);
sendRequest(_PREHASH_UUIDGroupNameRequest, mAskGroupQueue); sendRequest(_PREHASH_UUIDGroupNameRequest, mAskGroupQueue);
mAskNameQueue.clear(); mAskNameQueue.clear();
@@ -883,6 +887,7 @@ void LLCacheName::Impl::processPendingAsks()
void LLCacheName::Impl::processPendingReplies() void LLCacheName::Impl::processPendingReplies()
{ {
LLMemType mt_ppr(LLMemType::MTYPE_CACHE_PROCESS_PENDING_REPLIES);
// First call all the callbacks, because they might send messages. // First call all the callbacks, because they might send messages.
for(ReplyQueue::iterator it = mReplyQueue.begin(); it != mReplyQueue.end(); ++it) for(ReplyQueue::iterator it = mReplyQueue.begin(); it != mReplyQueue.end(); ++it)
{ {

View File

@@ -244,6 +244,7 @@ LLSocket::LLSocket() :
mPool(LLThread::tldata().mRootPool), mPool(LLThread::tldata().mRootPool),
mPort(PORT_INVALID) mPort(PORT_INVALID)
{ {
LLMemType m1(LLMemType::MTYPE_IO_TCP);
} }
LLSocket::~LLSocket() LLSocket::~LLSocket()

View File

@@ -86,6 +86,7 @@
#include "v3math.h" #include "v3math.h"
#include "v4math.h" #include "v4math.h"
#include "lltransfertargetvfile.h" #include "lltransfertargetvfile.h"
#include "llmemtype.h"
// <edit> // <edit>
#include "llrand.h" #include "llrand.h"
@@ -811,6 +812,7 @@ S32 LLMessageSystem::getReceiveBytes() const
void LLMessageSystem::processAcks() void LLMessageSystem::processAcks()
{ {
LLMemType mt_pa(LLMemType::MTYPE_MESSAGE_PROCESS_ACKS);
F64 mt_sec = getMessageTimeSeconds(); F64 mt_sec = getMessageTimeSeconds();
{ {
gTransferManager.updateTransfers(); gTransferManager.updateTransfers();
@@ -4048,6 +4050,7 @@ void LLMessageSystem::setTimeDecodesSpamThreshold( F32 seconds )
// TODO: babbage: move gServicePump in to LLMessageSystem? // TODO: babbage: move gServicePump in to LLMessageSystem?
bool LLMessageSystem::checkAllMessages(S64 frame_count, LLPumpIO* http_pump) bool LLMessageSystem::checkAllMessages(S64 frame_count, LLPumpIO* http_pump)
{ {
LLMemType mt_cam(LLMemType::MTYPE_MESSAGE_CHECK_ALL);
if(checkMessages(frame_count)) if(checkMessages(frame_count))
{ {
return true; return true;

View File

@@ -50,6 +50,7 @@
#include "llmath.h" #include "llmath.h"
#include "m4math.h" #include "m4math.h"
#include "llstring.h" #include "llstring.h"
#include "llmemtype.h"
#include "llstacktrace.h" #include "llstacktrace.h"
#include "llglheaders.h" #include "llglheaders.h"
@@ -2203,6 +2204,7 @@ void LLGLNamePool::release(GLuint name)
//static //static
void LLGLNamePool::upkeepPools() void LLGLNamePool::upkeepPools()
{ {
LLMemType mt(LLMemType::MTYPE_UPKEEP_POOLS);
for (tracker_t::instance_iter iter = beginInstances(); iter != endInstances(); ++iter) for (tracker_t::instance_iter iter = beginInstances(); iter != endInstances(); ++iter)
{ {
LLGLNamePool & pool = *iter; LLGLNamePool & pool = *iter;

View File

@@ -731,7 +731,7 @@ void LLVertexBuffer::unbind()
//static //static
void LLVertexBuffer::cleanupClass() void LLVertexBuffer::cleanupClass()
{ {
LLMemType mt(LLMemType::MTYPE_VERTEX_DATA); LLMemType mt2(LLMemType::MTYPE_VERTEX_CLEANUP_CLASS);
unbind(); unbind();
sStreamIBOPool.cleanup(); sStreamIBOPool.cleanup();
@@ -812,7 +812,7 @@ LLVertexBuffer::LLVertexBuffer(U32 typemask, S32 usage) :
mMappable(false), mMappable(false),
mFence(NULL) mFence(NULL)
{ {
LLMemType mt(LLMemType::MTYPE_VERTEX_DATA); LLMemType mt2(LLMemType::MTYPE_VERTEX_CONSTRUCTOR);
if (mUsage == GL_DYNAMIC_DRAW_ARB && !sDisableVBOMapping) if (mUsage == GL_DYNAMIC_DRAW_ARB && !sDisableVBOMapping)
{ {
@@ -880,7 +880,7 @@ S32 LLVertexBuffer::getSize() const
//virtual //virtual
LLVertexBuffer::~LLVertexBuffer() LLVertexBuffer::~LLVertexBuffer()
{ {
LLMemType mt(LLMemType::MTYPE_VERTEX_DATA); LLMemType mt2(LLMemType::MTYPE_VERTEX_DESTRUCTOR);
destroyGLBuffer(); destroyGLBuffer();
destroyGLIndices(); destroyGLIndices();
@@ -997,7 +997,7 @@ void LLVertexBuffer::releaseIndices()
void LLVertexBuffer::createGLBuffer(U32 size) void LLVertexBuffer::createGLBuffer(U32 size)
{ {
LLMemType mt(LLMemType::MTYPE_VERTEX_DATA); LLMemType mt2(LLMemType::MTYPE_VERTEX_CREATE_VERTICES);
if (mGLBuffer) if (mGLBuffer)
{ {
@@ -1028,7 +1028,7 @@ void LLVertexBuffer::createGLBuffer(U32 size)
void LLVertexBuffer::createGLIndices(U32 size) void LLVertexBuffer::createGLIndices(U32 size)
{ {
LLMemType mt(LLMemType::MTYPE_VERTEX_DATA); LLMemType mt2(LLMemType::MTYPE_VERTEX_CREATE_INDICES);
if (mGLIndices) if (mGLIndices)
{ {
@@ -1064,7 +1064,7 @@ void LLVertexBuffer::createGLIndices(U32 size)
void LLVertexBuffer::destroyGLBuffer() void LLVertexBuffer::destroyGLBuffer()
{ {
LLMemType mt(LLMemType::MTYPE_VERTEX_DATA); LLMemType mt2(LLMemType::MTYPE_VERTEX_DESTROY_BUFFER);
if (mGLBuffer) if (mGLBuffer)
{ {
if (mMappedDataUsingVBOs) if (mMappedDataUsingVBOs)
@@ -1085,7 +1085,7 @@ void LLVertexBuffer::destroyGLBuffer()
void LLVertexBuffer::destroyGLIndices() void LLVertexBuffer::destroyGLIndices()
{ {
LLMemType mt(LLMemType::MTYPE_VERTEX_DATA); LLMemType mt2(LLMemType::MTYPE_VERTEX_DESTROY_INDICES);
if (mGLIndices) if (mGLIndices)
{ {
if (mMappedIndexDataUsingVBOs) if (mMappedIndexDataUsingVBOs)
@@ -1106,7 +1106,7 @@ void LLVertexBuffer::destroyGLIndices()
void LLVertexBuffer::updateNumVerts(S32 nverts) void LLVertexBuffer::updateNumVerts(S32 nverts)
{ {
LLMemType mt(LLMemType::MTYPE_VERTEX_DATA); LLMemType mt2(LLMemType::MTYPE_VERTEX_UPDATE_VERTS);
llassert(nverts >= 0); llassert(nverts >= 0);
@@ -1128,7 +1128,7 @@ void LLVertexBuffer::updateNumVerts(S32 nverts)
void LLVertexBuffer::updateNumIndices(S32 nindices) void LLVertexBuffer::updateNumIndices(S32 nindices)
{ {
LLMemType mt(LLMemType::MTYPE_VERTEX_DATA); LLMemType mt2(LLMemType::MTYPE_VERTEX_UPDATE_INDICES);
llassert(nindices >= 0); llassert(nindices >= 0);
@@ -1144,7 +1144,7 @@ void LLVertexBuffer::updateNumIndices(S32 nindices)
void LLVertexBuffer::allocateBuffer(S32 nverts, S32 nindices, bool create) void LLVertexBuffer::allocateBuffer(S32 nverts, S32 nindices, bool create)
{ {
LLMemType mt(LLMemType::MTYPE_VERTEX_DATA); LLMemType mt2(LLMemType::MTYPE_VERTEX_ALLOCATE_BUFFER);
stop_glerror(); stop_glerror();
@@ -1265,7 +1265,7 @@ void LLVertexBuffer::resizeBuffer(S32 newnverts, S32 newnindices)
llassert(newnverts >= 0); llassert(newnverts >= 0);
llassert(newnindices >= 0); llassert(newnindices >= 0);
LLMemType mt(LLMemType::MTYPE_VERTEX_DATA); LLMemType mt2(LLMemType::MTYPE_VERTEX_RESIZE_BUFFER);
updateNumVerts(newnverts); updateNumVerts(newnverts);
updateNumIndices(newnindices); updateNumIndices(newnindices);
@@ -1313,7 +1313,7 @@ static LLFastTimer::DeclareTimer FTM_VBO_MAP_BUFFER("VBO Map");
volatile U8* LLVertexBuffer::mapVertexBuffer(S32 type, S32 index, S32 count, bool map_range) volatile U8* LLVertexBuffer::mapVertexBuffer(S32 type, S32 index, S32 count, bool map_range)
{ {
bindGLBuffer(true); bindGLBuffer(true);
LLMemType mt(LLMemType::MTYPE_VERTEX_DATA); LLMemType mt2(LLMemType::MTYPE_VERTEX_MAP_BUFFER);
if (mFinal) if (mFinal)
{ {
llerrs << "LLVertexBuffer::mapVeretxBuffer() called on a finalized buffer." << llendl; llerrs << "LLVertexBuffer::mapVeretxBuffer() called on a finalized buffer." << llendl;
@@ -1362,6 +1362,7 @@ volatile U8* LLVertexBuffer::mapVertexBuffer(S32 type, S32 index, S32 count, boo
if (!mVertexLocked) if (!mVertexLocked)
{ {
LLMemType mt_v(LLMemType::MTYPE_VERTEX_MAP_BUFFER_VERTICES);
mVertexLocked = true; mVertexLocked = true;
sMappedCount++; sMappedCount++;
stop_glerror(); stop_glerror();
@@ -1492,7 +1493,7 @@ static LLFastTimer::DeclareTimer FTM_VBO_MAP_INDEX("IBO Map");
volatile U8* LLVertexBuffer::mapIndexBuffer(S32 index, S32 count, bool map_range) volatile U8* LLVertexBuffer::mapIndexBuffer(S32 index, S32 count, bool map_range)
{ {
LLMemType mt(LLMemType::MTYPE_VERTEX_DATA); LLMemType mt2(LLMemType::MTYPE_VERTEX_MAP_BUFFER);
bindGLIndices(true); bindGLIndices(true);
if (mFinal) if (mFinal)
{ {
@@ -1539,7 +1540,7 @@ volatile U8* LLVertexBuffer::mapIndexBuffer(S32 index, S32 count, bool map_range
if (!mIndexLocked) if (!mIndexLocked)
{ {
//LLMemType mt_v(LLMemType::MTYPE_VERTEX_MAP_BUFFER_INDICES); LLMemType mt_v(LLMemType::MTYPE_VERTEX_MAP_BUFFER_INDICES);
mIndexLocked = true; mIndexLocked = true;
sMappedCount++; sMappedCount++;
@@ -1663,7 +1664,7 @@ static LLFastTimer::DeclareTimer FTM_IBO_FLUSH_RANGE("Flush IBO Range");
void LLVertexBuffer::unmapBuffer() void LLVertexBuffer::unmapBuffer()
{ {
LLMemType mt(LLMemType::MTYPE_VERTEX_DATA); LLMemType mt2(LLMemType::MTYPE_VERTEX_UNMAP_BUFFER);
if (!useVBOs()) if (!useVBOs())
{ {
return ; //nothing to unmap return ; //nothing to unmap
@@ -2007,7 +2008,7 @@ void LLVertexBuffer::setBuffer(U32 data_mask)
{ {
flush(); flush();
LLMemType mt(LLMemType::MTYPE_VERTEX_DATA); LLMemType mt2(LLMemType::MTYPE_VERTEX_SET_BUFFER);
//set up pointers if the data mask is different ... //set up pointers if the data mask is different ...
bool setup = (sLastMask != data_mask); bool setup = (sLastMask != data_mask);
@@ -2149,7 +2150,7 @@ void LLVertexBuffer::setBuffer(U32 data_mask)
// virtual (default) // virtual (default)
void LLVertexBuffer::setupVertexBuffer(U32 data_mask) void LLVertexBuffer::setupVertexBuffer(U32 data_mask)
{ {
LLMemType mt(LLMemType::MTYPE_VERTEX_DATA); LLMemType mt2(LLMemType::MTYPE_VERTEX_SETUP_VERTEX_BUFFER);
stop_glerror(); stop_glerror();
volatile U8* base = useVBOs() ? (U8*) mAlignedOffset : mMappedData; volatile U8* base = useVBOs() ? (U8*) mAlignedOffset : mMappedData;

View File

@@ -8043,6 +8043,17 @@
<key>Value</key> <key>Value</key>
<integer>512</integer> <integer>512</integer>
</map> </map>
<key>MemProfiling</key>
<map>
<key>Comment</key>
<string>You want to use tcmalloc's memory profiling options.</string>
<key>Persist</key>
<integer>1</integer>
<key>Type</key>
<string>Boolean</string>
<key>Value</key>
<integer>0</integer>
</map>
<key>MenuAccessKeyTime</key> <key>MenuAccessKeyTime</key>
<map> <map>
<key>Comment</key> <key>Comment</key>

View File

@@ -630,6 +630,8 @@ bool LLAppViewer::init()
initMaxHeapSize() ; initMaxHeapSize() ;
LLPrivateMemoryPoolManager::initClass((BOOL)gSavedSettings.getBOOL("MemoryPrivatePoolEnabled"), (U32)gSavedSettings.getU32("MemoryPrivatePoolSize")) ; LLPrivateMemoryPoolManager::initClass((BOOL)gSavedSettings.getBOOL("MemoryPrivatePoolEnabled"), (U32)gSavedSettings.getU32("MemoryPrivatePoolSize")) ;
mAlloc.setProfilingEnabled(gSavedSettings.getBOOL("MemProfiling"));
// *NOTE:Mani - LLCurl::initClass is not thread safe. // *NOTE:Mani - LLCurl::initClass is not thread safe.
// Called before threads are created. // Called before threads are created.
LLCurl::initClass(gSavedSettings.getBOOL("CurlUseMultipleThreads")); LLCurl::initClass(gSavedSettings.getBOOL("CurlUseMultipleThreads"));
@@ -1023,8 +1025,10 @@ static LLFastTimer::DeclareTimer FTM_PUMP_SERVICE("Service");
static LLFastTimer::DeclareTimer FTM_SERVICE_CALLBACK("Callback"); static LLFastTimer::DeclareTimer FTM_SERVICE_CALLBACK("Callback");
static LLFastTimer::DeclareTimer FTM_AGENT_AUTOPILOT("Autopilot"); static LLFastTimer::DeclareTimer FTM_AGENT_AUTOPILOT("Autopilot");
static LLFastTimer::DeclareTimer FTM_AGENT_UPDATE("Update"); static LLFastTimer::DeclareTimer FTM_AGENT_UPDATE("Update");
bool LLAppViewer::mainLoop() bool LLAppViewer::mainLoop()
{ {
LLMemType mt1(LLMemType::MTYPE_MAIN);
mMainloopTimeout = new LLWatchdogTimeout(); mMainloopTimeout = new LLWatchdogTimeout();
// *FIX:Mani - Make this a setting, once new settings exist in this branch. // *FIX:Mani - Make this a setting, once new settings exist in this branch.
@@ -1042,7 +1046,6 @@ bool LLAppViewer::mainLoop()
LLVoiceChannel::initClass(); LLVoiceChannel::initClass();
LLVoiceClient::init(gServicePump); LLVoiceClient::init(gServicePump);
LLMemType mt1(LLMemType::MTYPE_MAIN);
LLTimer frameTimer,idleTimer; LLTimer frameTimer,idleTimer;
LLTimer debugTime; LLTimer debugTime;
LLFrameTimer memCheckTimer; LLFrameTimer memCheckTimer;
@@ -1115,6 +1118,7 @@ bool LLAppViewer::mainLoop()
&& !gViewerWindow->getShowProgress() && !gViewerWindow->getShowProgress()
&& !gFocusMgr.focusLocked()) && !gFocusMgr.focusLocked())
{ {
LLMemType mjk(LLMemType::MTYPE_JOY_KEY);
joystick->scanJoystick(); joystick->scanJoystick();
gKeyboard->scanKeyboard(); gKeyboard->scanKeyboard();
if(isCrouch) if(isCrouch)
@@ -1134,6 +1138,7 @@ bool LLAppViewer::mainLoop()
if (gAres != NULL && gAres->isInitialized()) if (gAres != NULL && gAres->isInitialized())
{ {
LLMemType mt_ip(LLMemType::MTYPE_IDLE_PUMP);
pingMainloopTimeout("Main:ServicePump"); pingMainloopTimeout("Main:ServicePump");
LLFastTimer t4(FTM_PUMP); LLFastTimer t4(FTM_PUMP);
{ {
@@ -1188,6 +1193,7 @@ bool LLAppViewer::mainLoop()
// Sleep and run background threads // Sleep and run background threads
{ {
LLMemType mt_sleep(LLMemType::MTYPE_SLEEP);
LLFastTimer t2(FTM_SLEEP); LLFastTimer t2(FTM_SLEEP);
static const LLCachedControl<bool> run_multiple_threads("RunMultipleThreads",false); static const LLCachedControl<bool> run_multiple_threads("RunMultipleThreads",false);
@@ -3707,6 +3713,7 @@ static LLFastTimer::DeclareTimer FTM_VLMANAGER("VL Manager");
/////////////////////////////////////////////////////// ///////////////////////////////////////////////////////
void LLAppViewer::idle() void LLAppViewer::idle()
{ {
LLMemType mt_idle(LLMemType::MTYPE_IDLE);
pingMainloopTimeout("Main:Idle"); pingMainloopTimeout("Main:Idle");
// Update frame timers // Update frame timers
@@ -4287,6 +4294,7 @@ static LLFastTimer::DeclareTimer FTM_DYNAMIC_THROTTLE("Dynamic Throttle");
static LLFastTimer::DeclareTimer FTM_CHECK_REGION_CIRCUIT("Check Region Circuit"); static LLFastTimer::DeclareTimer FTM_CHECK_REGION_CIRCUIT("Check Region Circuit");
void LLAppViewer::idleNetwork() void LLAppViewer::idleNetwork()
{ {
LLMemType mt_in(LLMemType::MTYPE_IDLE_NETWORK);
pingMainloopTimeout("idleNetwork"); pingMainloopTimeout("idleNetwork");
gObjectList.mNumNewObjects = 0; gObjectList.mNumNewObjects = 0;

View File

@@ -33,7 +33,8 @@
#ifndef LL_LLAPPVIEWER_H #ifndef LL_LLAPPVIEWER_H
#define LL_LLAPPVIEWER_H #define LL_LLAPPVIEWER_H
#include "llsys.h" // LLOSInfo #include "llallocator.h"
#include "llsys.h" // for LLOSInfo
#include "llviewercontrol.h" // settings_map_type #include "llviewercontrol.h" // settings_map_type
class LLTextureCache; class LLTextureCache;
@@ -158,6 +159,7 @@ public:
// *NOTE:Mani Fix this for login abstraction!! // *NOTE:Mani Fix this for login abstraction!!
void handleLoginComplete(); void handleLoginComplete();
LLAllocator & getAllocator() { return mAlloc; }
void addOnIdleCallback(const boost::function<void()>& cb); // add a callback to fire (once) when idle void addOnIdleCallback(const boost::function<void()>& cb); // add a callback to fire (once) when idle
void purgeCache(); // Clear the local cache. void purgeCache(); // Clear the local cache.
@@ -245,6 +247,7 @@ private:
bool mAgentRegionLastAlive; bool mAgentRegionLastAlive;
LLUUID mAgentRegionLastID; LLUUID mAgentRegionLastID;
LLAllocator mAlloc;
LLFrameTimer mMemCheckTimer; LLFrameTimer mMemCheckTimer;

View File

@@ -32,37 +32,28 @@
#include "llviewerprecompiledheaders.h" #include "llviewerprecompiledheaders.h"
#include "indra_constants.h"
#include "llmemoryview.h" #include "llmemoryview.h"
#include "llrect.h" #include "llappviewer.h"
#include "llerror.h" #include "llallocator_heap_profile.h"
#include "llgl.h" #include "llgl.h" // LLGLSUIDefault
#include "llmath.h" #include "llviewerwindow.h"
#include "llfontgl.h"
#include "llmemtype.h"
#include "llcharacter.h"
#include "llui.h"
#include "llviewercontrol.h" #include "llviewercontrol.h"
#include "llstat.h"
#include "llfasttimer.h" #include <sstream>
#include <boost/algorithm/string/split.hpp>
#include "llmemory.h"
LLMemoryView::LLMemoryView(const std::string& name, const LLRect& rect) LLMemoryView::LLMemoryView(const std::string& name, const LLRect& rect)
: LLView(name, rect, TRUE), : LLView(name, rect, TRUE),
mDelay(120) mPaused(FALSE),
//mDelay(120),
mAlloc(NULL)
{ {
setVisible(FALSE); setVisible(FALSE);
mDumpTimer.reset();
#ifdef MEM_DUMP_DATA
// clear out file.
LLFILE *dump = LLFile::fopen("memusagedump.txt", "w");
fclose(dump);
#endif
} }
LLMemoryView::~LLMemoryView() LLMemoryView::~LLMemoryView()
@@ -79,6 +70,7 @@ BOOL LLMemoryView::handleMouseDown(S32 x, S32 y, MASK mask)
} }
else else
{ {
mPaused = !mPaused;
} }
return TRUE; return TRUE;
} }
@@ -94,62 +86,143 @@ BOOL LLMemoryView::handleHover(S32 x, S32 y, MASK mask)
return FALSE; return FALSE;
} }
////////////////////////////////////////////////////////////////////////////// void LLMemoryView::refreshProfile()
struct mtv_display_info {
S32 memtype;
const char *desc;
const LLColor4 *color;
};
static const LLColor4 red0(0.5f, 0.0f, 0.0f, 1.0f);
static const struct mtv_display_info mtv_display_table[] =
{ {
{ LLMemType::MTYPE_INIT, "Init", &LLColor4::white }, /*
{ LLMemType::MTYPE_STARTUP, "Startup", &LLColor4::cyan1 }, LLAllocator & alloc = LLAppViewer::instance()->getAllocator();
{ LLMemType::MTYPE_MAIN, "Main", &LLColor4::cyan2 }, if(alloc.isProfiling()) {
{ LLMemType::MTYPE_IMAGEBASE, "ImageBase", &LLColor4::yellow1 }, std::string profile_text = alloc.getRawProfile();
{ LLMemType::MTYPE_IMAGERAW, "ImageRaw", &LLColor4::yellow2 },
{ LLMemType::MTYPE_IMAGEFORMATTED, "ImageFmtd", &LLColor4::yellow3 },
{ LLMemType::MTYPE_APPFMTIMAGE, "ViewerImageFmt", &LLColor4::orange1 },
{ LLMemType::MTYPE_APPRAWIMAGE, "ViewerImageRaw", &LLColor4::orange2 },
{ LLMemType::MTYPE_APPAUXRAWIMAGE, "ViewerImageAux", &LLColor4::orange3 },
{ LLMemType::MTYPE_DRAWABLE, "Drawable", &LLColor4::green1 },
{ LLMemType::MTYPE_OBJECT, "ViewerObject", &LLColor4::green2 },
{ LLMemType::MTYPE_PIPELINE, "Pipeline", &LLColor4::green3 },
{ LLMemType::MTYPE_PARTICLES, "Particles", &LLColor4::green4 },
{ LLMemType::MTYPE_SPACE_PARTITION, "Space Partition", &LLColor4::blue2 },
{ LLMemType::MTYPE_VERTEX_DATA, "Vertex Buffer", &LLColor4::blue3 },
{ LLMemType::MTYPE_AVATAR, "Avatar", &LLColor4::purple1 },
{ LLMemType::MTYPE_AVATAR_MESH, "Avatar Mesh", &LLColor4::purple2 },
{ LLMemType::MTYPE_ANIMATION, "Animation", &LLColor4::purple3 },
{ LLMemType::MTYPE_REGIONS, "Regions", &LLColor4::blue1 },
{ LLMemType::MTYPE_VOLUME, "Volume", &LLColor4::pink1 },
{ LLMemType::MTYPE_PRIMITIVE, "Profile", &LLColor4::pink2 },
{ LLMemType::MTYPE_TEMP1, "Temp1", &LLColor4::red1 },
{ LLMemType::MTYPE_TEMP2, "Temp2", &LLColor4::magenta1 },
{ LLMemType::MTYPE_TEMP3, "Temp3", &LLColor4::red2 },
{ LLMemType::MTYPE_TEMP4, "Temp4", &LLColor4::magenta2 },
{ LLMemType::MTYPE_TEMP5, "Temp5", &LLColor4::red3 },
{ LLMemType::MTYPE_TEMP6, "Temp6", &LLColor4::magenta3 },
{ LLMemType::MTYPE_TEMP7, "Temp7", &LLColor4::red4 },
{ LLMemType::MTYPE_TEMP8, "Temp8", &LLColor4::magenta4 },
{ LLMemType::MTYPE_OTHER, "Other", &red0 }, boost::algorithm::split(mLines, profile_text, boost::bind(std::equal_to<llwchar>(), '\n', _1));
}; } else {
static const int MTV_DISPLAY_NUM = LL_ARRAY_SIZE(mtv_display_table); mLines.clear();
}
*/
if (mAlloc == NULL) {
mAlloc = &LLAppViewer::instance()->getAllocator();
}
mLines.clear();
if(mAlloc->isProfiling())
{
const LLAllocatorHeapProfile &prof = mAlloc->getProfile();
for(size_t i = 0; i < prof.mLines.size(); ++i)
{
std::stringstream ss;
ss << "Unfreed Mem: " << (prof.mLines[i].mLiveSize >> 20) << " M Trace: ";
for(size_t k = 0; k < prof.mLines[i].mTrace.size(); ++k)
{
ss << LLMemType::getNameFromID(prof.mLines[i].mTrace[k]) << " ";
}
mLines.push_back(utf8string_to_wstring(ss.str()));
}
}
}
void LLMemoryView::draw() void LLMemoryView::draw()
{ {
std::string tdesc; const S32 UPDATE_INTERVAL = 60;
S32 width = getRect().getWidth(); const S32 MARGIN_AMT = 10;
S32 height = getRect().getHeight(); static S32 curUpdate = UPDATE_INTERVAL;
static LLColor4 s_console_color = gColors.getColor("ConsoleBackground");
// setup update interval
if (curUpdate >= UPDATE_INTERVAL)
{
refreshProfile();
curUpdate = 0;
}
curUpdate++;
// setup window properly
S32 height = (S32) (gViewerWindow->getWindowRectScaled().getHeight()*0.75f);
S32 width = (S32) (gViewerWindow->getWindowRectScaled().getWidth() * 0.9f);
setRect(LLRect().setLeftTopAndSize(getRect().mLeft, getRect().mTop, width, height));
// setup window color
F32 console_opacity = llclamp(gSavedSettings.getF32("ConsoleBackgroundOpacity"), 0.f, 1.f);
LLColor4 color = s_console_color;
color.mV[VALPHA] *= console_opacity;
LLGLSUIDefault gls_ui; LLGLSUIDefault gls_ui;
gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE); gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE);
gl_rect_2d(0, height, width, 0, LLColor4(0.f, 0.f, 0.f, 0.25f)); gl_rect_2d(0, height, width, 0, color);
LLFontGL * font = LLFontGL::getFontSansSerifSmall();
// draw remaining lines
F32 y_pos = 0.f;
F32 y_off = 0.f;
F32 line_height = font->getLineHeight();
S32 target_width = width - 2 * MARGIN_AMT;
// cut off lines on bottom
U32 max_lines = U32((height - 2 * line_height) / line_height);
y_pos = height - MARGIN_AMT - line_height;
y_off = 0.f;
#if !MEM_TRACK_MEM
std::vector<LLWString>::const_iterator end = mLines.end();
if(mLines.size() > max_lines) {
end = mLines.begin() + max_lines;
}
for (std::vector<LLWString>::const_iterator i = mLines.begin(); i != end; ++i)
{
font->render(*i, 0, MARGIN_AMT, y_pos - y_off,
LLColor4::white,
LLFontGL::LEFT,
LLFontGL::BASELINE,
LLFontGL::NORMAL,
LLFontGL::DROP_SHADOW,
S32_MAX,
target_width
);
y_off += line_height;
}
#else
LLMemTracker::getInstance()->preDraw(mPaused) ;
{
F32 x_pos = MARGIN_AMT ;
U32 lines = 0 ;
const char* str = LLMemTracker::getInstance()->getNextLine() ;
while(str != NULL)
{
lines++ ;
font->renderUTF8(str, 0, x_pos, y_pos - y_off,
LLColor4::white,
LLFontGL::LEFT,
LLFontGL::BASELINE,
LLFontGL::NORMAL,
LLFontGL::DROP_SHADOW,
S32_MAX,
target_width,
NULL, FALSE);
str = LLMemTracker::getInstance()->getNextLine() ;
y_off += line_height;
if(lines >= max_lines)
{
lines = 0 ;
x_pos += 512.f ;
if(x_pos + 512.f > target_width)
{
break ;
}
y_pos = height - MARGIN_AMT - line_height;
y_off = 0.f;
}
}
}
LLMemTracker::getInstance()->postDraw() ;
#endif
#if MEM_TRACK_TYPE #if MEM_TRACK_TYPE
S32 left, top, right, bottom; S32 left, top, right, bottom;
@@ -267,40 +340,3 @@ void LLMemoryView::draw()
LLView::draw(); LLView::draw();
} }
void LLMemoryView::setDataDumpInterval(float delay)
{
mDelay = delay;
}
void LLMemoryView::dumpData()
{
#if MEM_TRACK_TYPE && MEM_DUMP_DATA
if (mDelay && (mDumpTimer.getElapsedTimeF32() > mDelay ))
{
// reset timer
mDumpTimer.reset();
// append dump info to text file
LLFILE *dump = LLFile::fopen("memusagedump.txt", "a");
if (dump)
{
// write out total memory usage
fprintf (dump, "Total memory in use = %09d (%03d MB)\n", LLMemType::sTotalMem, LLMemType::sTotalMem>>20);
fprintf (dump, "High Water Mark = %09d (%03d MB)\n\n", LLMemType::sMaxTotalMem, LLMemType::sMaxTotalMem>>20);
// dump out usage of 'new' for each memory type
for (S32 i=0; i<LLMemType::MTYPE_NUM_TYPES; i++)
{
if (LLMemType::sMemCount[i])
{
std::string outData = llformat("MEM: % 20s %09d %03d MB (%09d %03d MB) in %06d News", LLMemType::sTypeDesc[i], LLMemType::sMemCount[i], LLMemType::sMemCount[i]>>20, LLMemType::sMaxMemCount[i], LLMemType::sMaxMemCount[i]>>20, LLMemType::sNewCount[i]);
fprintf (dump, "%s\n", outData.c_str());
}
}
fprintf (dump, "\n\n");
fclose(dump);
}
}
#endif
}

View File

@@ -35,6 +35,8 @@
#include "llview.h" #include "llview.h"
class LLAllocator;
class LLMemoryView : public LLView class LLMemoryView : public LLView
{ {
public: public:
@@ -46,14 +48,13 @@ public:
virtual BOOL handleHover(S32 x, S32 y, MASK mask); virtual BOOL handleHover(S32 x, S32 y, MASK mask);
virtual void draw(); virtual void draw();
private: void refreshProfile();
void setDataDumpInterval(float delay);
void dumpData();
float mDelay;
LLFrameTimer mDumpTimer;
private: private:
std::vector<LLWString> mLines;
LLAllocator* mAlloc;
BOOL mPaused ;
}; };
#endif #endif

View File

@@ -946,14 +946,14 @@ void init_client_menu(LLMenuGL* menu)
&get_visibility, &get_visibility,
(void*)gDebugView->mFastTimerView, (void*)gDebugView->mFastTimerView,
'9', MASK_CONTROL|MASK_SHIFT ) ); '9', MASK_CONTROL|MASK_SHIFT ) );
#if MEM_TRACK_MEM //#if MEM_TRACK_MEM
sub->append(new LLMenuItemCheckGL("Memory", sub->append(new LLMenuItemCheckGL("Memory",
&toggle_visibility, &toggle_visibility,
NULL, NULL,
&get_visibility, &get_visibility,
(void*)gDebugView->mMemoryView, (void*)gDebugView->mMemoryView,
'0', MASK_CONTROL|MASK_SHIFT ) ); '0', MASK_CONTROL|MASK_SHIFT ) );
#endif //#endif
sub->appendSeparator(); sub->appendSeparator();

View File

@@ -388,7 +388,7 @@ LLPipeline::LLPipeline() :
void LLPipeline::init() void LLPipeline::init()
{ {
LLMemType mt(LLMemType::MTYPE_PIPELINE); LLMemType mt(LLMemType::MTYPE_PIPELINE_INIT);
refreshCachedSettings(); refreshCachedSettings();
@@ -868,6 +868,7 @@ void LLPipeline::releaseScreenBuffers()
void LLPipeline::createGLBuffers() void LLPipeline::createGLBuffers()
{ {
stop_glerror(); stop_glerror();
LLMemType mt_cb(LLMemType::MTYPE_PIPELINE_CREATE_BUFFERS);
assertInitialized(); assertInitialized();
updateRenderDeferred(); updateRenderDeferred();
@@ -982,6 +983,7 @@ void LLPipeline::createGLBuffers()
void LLPipeline::restoreGL() void LLPipeline::restoreGL()
{ {
LLMemType mt_cb(LLMemType::MTYPE_PIPELINE_RESTORE_GL);
assertInitialized(); assertInitialized();
if (mVertexShadersEnabled) if (mVertexShadersEnabled)
@@ -1043,6 +1045,7 @@ BOOL LLPipeline::canUseAntiAliasing() const
void LLPipeline::unloadShaders() void LLPipeline::unloadShaders()
{ {
LLMemType mt_us(LLMemType::MTYPE_PIPELINE_UNLOAD_SHADERS);
LLViewerShaderMgr::instance()->unloadShaders(); LLViewerShaderMgr::instance()->unloadShaders();
mVertexShadersLoaded = 0; mVertexShadersLoaded = 0;
@@ -1074,6 +1077,7 @@ S32 LLPipeline::getMaxLightingDetail() const
S32 LLPipeline::setLightingDetail(S32 level) S32 LLPipeline::setLightingDetail(S32 level)
{ {
LLMemType mt_ld(LLMemType::MTYPE_PIPELINE_LIGHTING_DETAIL);
refreshCachedSettings(); refreshCachedSettings();
if (level < 0) if (level < 0)
@@ -1264,7 +1268,7 @@ LLDrawPool* LLPipeline::getPoolFromTE(const LLTextureEntry* te, LLViewerTexture*
//static //static
U32 LLPipeline::getPoolTypeFromTE(const LLTextureEntry* te, LLViewerTexture* imagep) U32 LLPipeline::getPoolTypeFromTE(const LLTextureEntry* te, LLViewerTexture* imagep)
{ {
LLMemType mt(LLMemType::MTYPE_PIPELINE); LLMemType mt_gpt(LLMemType::MTYPE_PIPELINE_GET_POOL_TYPE);
if (!te || !imagep) if (!te || !imagep)
{ {
@@ -1294,7 +1298,7 @@ U32 LLPipeline::getPoolTypeFromTE(const LLTextureEntry* te, LLViewerTexture* ima
void LLPipeline::addPool(LLDrawPool *new_poolp) void LLPipeline::addPool(LLDrawPool *new_poolp)
{ {
LLMemType mt(LLMemType::MTYPE_PIPELINE); LLMemType mt_a(LLMemType::MTYPE_PIPELINE_ADD_POOL);
assertInitialized(); assertInitialized();
mPools.insert(new_poolp); mPools.insert(new_poolp);
addToQuickLookup( new_poolp ); addToQuickLookup( new_poolp );
@@ -1306,7 +1310,7 @@ void LLPipeline::allocDrawable(LLViewerObject *vobj)
{ {
llerrs << "Null object passed to allocDrawable!" << llendl; llerrs << "Null object passed to allocDrawable!" << llendl;
} }
LLMemType mt(LLMemType::MTYPE_DRAWABLE); LLMemType mt_ad(LLMemType::MTYPE_PIPELINE_ALLOCATE_DRAWABLE);
LLDrawable *drawable = new LLDrawable(); LLDrawable *drawable = new LLDrawable();
vobj->mDrawable = drawable; vobj->mDrawable = drawable;
@@ -1399,7 +1403,7 @@ U32 LLPipeline::addObject(LLViewerObject *vobj)
{ {
return 0; return 0;
} }
LLMemType mt_ao(LLMemType::MTYPE_PIPELINE_ADD_OBJECT);
static const LLCachedControl<bool> render_delay_creation("RenderDelayCreation",false); static const LLCachedControl<bool> render_delay_creation("RenderDelayCreation",false);
if (!vobj->isAvatar() && render_delay_creation) if (!vobj->isAvatar() && render_delay_creation)
{ {
@@ -1416,7 +1420,7 @@ U32 LLPipeline::addObject(LLViewerObject *vobj)
void LLPipeline::createObjects(F32 max_dtime) void LLPipeline::createObjects(F32 max_dtime)
{ {
LLFastTimer ftm(FTM_GEO_UPDATE); LLFastTimer ftm(FTM_GEO_UPDATE);
LLMemType mt(LLMemType::MTYPE_DRAWABLE); LLMemType mt(LLMemType::MTYPE_PIPELINE_CREATE_OBJECTS);
LLTimer update_timer; LLTimer update_timer;
@@ -1591,7 +1595,7 @@ static LLFastTimer::DeclareTimer FTM_UPDATE_MOVE("Update Move");
void LLPipeline::updateMove() void LLPipeline::updateMove()
{ {
LLFastTimer t(FTM_UPDATE_MOVE); LLFastTimer t(FTM_UPDATE_MOVE);
LLMemType mt(LLMemType::MTYPE_PIPELINE); LLMemType mt_um(LLMemType::MTYPE_PIPELINE_UPDATE_MOVE);
static const LLCachedControl<bool> freeze_time("FreezeTime",false); static const LLCachedControl<bool> freeze_time("FreezeTime",false);
if (freeze_time) if (freeze_time)
@@ -1945,7 +1949,7 @@ static LLFastTimer::DeclareTimer FTM_CULL("Object Culling");
void LLPipeline::updateCull(LLCamera& camera, LLCullResult& result, S32 water_clip, LLPlane* planep) void LLPipeline::updateCull(LLCamera& camera, LLCullResult& result, S32 water_clip, LLPlane* planep)
{ {
LLFastTimer t(FTM_CULL); LLFastTimer t(FTM_CULL);
LLMemType mt_uc(LLMemType::MTYPE_PIPELINE); LLMemType mt_uc(LLMemType::MTYPE_PIPELINE_UPDATE_CULL);
grabReferences(result); grabReferences(result);
@@ -2314,7 +2318,7 @@ void LLPipeline::rebuildGroups()
void LLPipeline::updateGeom(F32 max_dtime) void LLPipeline::updateGeom(F32 max_dtime)
{ {
LLTimer update_timer; LLTimer update_timer;
LLMemType mt(LLMemType::MTYPE_PIPELINE); LLMemType mt(LLMemType::MTYPE_PIPELINE_UPDATE_GEOM);
LLPointer<LLDrawable> drawablep; LLPointer<LLDrawable> drawablep;
LLFastTimer t(FTM_GEO_UPDATE); LLFastTimer t(FTM_GEO_UPDATE);
@@ -2417,7 +2421,7 @@ void LLPipeline::updateGeom(F32 max_dtime)
void LLPipeline::markVisible(LLDrawable *drawablep, LLCamera& camera) void LLPipeline::markVisible(LLDrawable *drawablep, LLCamera& camera)
{ {
LLMemType mt(LLMemType::MTYPE_PIPELINE); LLMemType mt(LLMemType::MTYPE_PIPELINE_MARK_VISIBLE);
if(drawablep && !drawablep->isDead()) if(drawablep && !drawablep->isDead())
{ {
@@ -2462,7 +2466,7 @@ void LLPipeline::markVisible(LLDrawable *drawablep, LLCamera& camera)
void LLPipeline::markMoved(LLDrawable *drawablep, BOOL damped_motion) void LLPipeline::markMoved(LLDrawable *drawablep, BOOL damped_motion)
{ {
LLMemType mt(LLMemType::MTYPE_PIPELINE); LLMemType mt_mm(LLMemType::MTYPE_PIPELINE_MARK_MOVED);
if (!drawablep) if (!drawablep)
{ {
@@ -2508,7 +2512,7 @@ void LLPipeline::markMoved(LLDrawable *drawablep, BOOL damped_motion)
void LLPipeline::markShift(LLDrawable *drawablep) void LLPipeline::markShift(LLDrawable *drawablep)
{ {
LLMemType mt(LLMemType::MTYPE_PIPELINE); LLMemType mt(LLMemType::MTYPE_PIPELINE_MARK_SHIFT);
if (!drawablep || drawablep->isDead()) if (!drawablep || drawablep->isDead())
{ {
@@ -2531,7 +2535,7 @@ void LLPipeline::markShift(LLDrawable *drawablep)
void LLPipeline::shiftObjects(const LLVector3 &offset) void LLPipeline::shiftObjects(const LLVector3 &offset)
{ {
LLMemType mt(LLMemType::MTYPE_PIPELINE); LLMemType mt(LLMemType::MTYPE_PIPELINE_SHIFT_OBJECTS);
assertInitialized(); assertInitialized();
@@ -2575,7 +2579,7 @@ void LLPipeline::shiftObjects(const LLVector3 &offset)
void LLPipeline::markTextured(LLDrawable *drawablep) void LLPipeline::markTextured(LLDrawable *drawablep)
{ {
LLMemType mt(LLMemType::MTYPE_PIPELINE); LLMemType mt(LLMemType::MTYPE_PIPELINE_MARK_TEXTURED);
if (drawablep && !drawablep->isDead() && assertInitialized()) if (drawablep && !drawablep->isDead() && assertInitialized())
{ {
@@ -2666,7 +2670,7 @@ void LLPipeline::markRebuild(LLSpatialGroup* group, BOOL priority)
void LLPipeline::markRebuild(LLDrawable *drawablep, LLDrawable::EDrawableFlags flag, BOOL priority) void LLPipeline::markRebuild(LLDrawable *drawablep, LLDrawable::EDrawableFlags flag, BOOL priority)
{ {
LLMemType mt(LLMemType::MTYPE_PIPELINE); LLMemType mt(LLMemType::MTYPE_PIPELINE_MARK_REBUILD);
if (drawablep && !drawablep->isDead() && assertInitialized()) if (drawablep && !drawablep->isDead() && assertInitialized())
{ {
@@ -2714,7 +2718,7 @@ void LLPipeline::stateSort(LLCamera& camera, LLCullResult &result)
} }
LLFastTimer ftm(FTM_STATESORT); LLFastTimer ftm(FTM_STATESORT);
LLMemType mt(LLMemType::MTYPE_PIPELINE); LLMemType mt(LLMemType::MTYPE_PIPELINE_STATE_SORT);
//LLVertexBuffer::unbind(); //LLVertexBuffer::unbind();
@@ -2815,7 +2819,7 @@ void LLPipeline::stateSort(LLCamera& camera, LLCullResult &result)
void LLPipeline::stateSort(LLSpatialGroup* group, LLCamera& camera) void LLPipeline::stateSort(LLSpatialGroup* group, LLCamera& camera)
{ {
LLMemType mt(LLMemType::MTYPE_PIPELINE); LLMemType mt(LLMemType::MTYPE_PIPELINE_STATE_SORT);
if (!sSkipUpdate && group->changeLOD()) if (!sSkipUpdate && group->changeLOD())
{ {
for (LLSpatialGroup::element_iter i = group->getData().begin(); i != group->getData().end(); ++i) for (LLSpatialGroup::element_iter i = group->getData().begin(); i != group->getData().end(); ++i)
@@ -2834,7 +2838,7 @@ void LLPipeline::stateSort(LLSpatialGroup* group, LLCamera& camera)
void LLPipeline::stateSort(LLSpatialBridge* bridge, LLCamera& camera) void LLPipeline::stateSort(LLSpatialBridge* bridge, LLCamera& camera)
{ {
LLMemType mt(LLMemType::MTYPE_PIPELINE); LLMemType mt(LLMemType::MTYPE_PIPELINE_STATE_SORT);
if (/*!sShadowRender && */!sSkipUpdate && bridge->getSpatialGroup()->changeLOD()) if (/*!sShadowRender && */!sSkipUpdate && bridge->getSpatialGroup()->changeLOD())
{ {
bool force_update = false; bool force_update = false;
@@ -2844,7 +2848,7 @@ void LLPipeline::stateSort(LLSpatialBridge* bridge, LLCamera& camera)
void LLPipeline::stateSort(LLDrawable* drawablep, LLCamera& camera) void LLPipeline::stateSort(LLDrawable* drawablep, LLCamera& camera)
{ {
LLMemType mt(LLMemType::MTYPE_PIPELINE); LLMemType mt(LLMemType::MTYPE_PIPELINE_STATE_SORT);
if (!drawablep if (!drawablep
|| drawablep->isDead() || drawablep->isDead()
@@ -3093,7 +3097,7 @@ void renderSoundHighlights(LLDrawable* drawablep)
void LLPipeline::postSort(LLCamera& camera) void LLPipeline::postSort(LLCamera& camera)
{ {
LLMemType mt(LLMemType::MTYPE_PIPELINE); LLMemType mt(LLMemType::MTYPE_PIPELINE_POST_SORT);
LLFastTimer ftm(FTM_STATESORT_POSTSORT); LLFastTimer ftm(FTM_STATESORT_POSTSORT);
assertInitialized(); assertInitialized();
@@ -3333,6 +3337,7 @@ void LLPipeline::postSort(LLCamera& camera)
void render_hud_elements() void render_hud_elements()
{ {
LLMemType mt_rhe(LLMemType::MTYPE_PIPELINE_RENDER_HUD_ELS);
LLFastTimer t(FTM_RENDER_UI); LLFastTimer t(FTM_RENDER_UI);
gPipeline.disableLights(); gPipeline.disableLights();
@@ -3352,25 +3357,22 @@ void render_hud_elements()
} }
LLGLDepthTest depth(GL_TRUE, GL_FALSE); LLGLDepthTest depth(GL_TRUE, GL_FALSE);
if (gPipeline.hasRenderDebugFeatureMask(LLPipeline::RENDER_DEBUG_FEATURE_UI)) if (!LLPipeline::sReflectionRender && gPipeline.hasRenderDebugFeatureMask(LLPipeline::RENDER_DEBUG_FEATURE_UI))
{ {
if(!LLPipeline::sReflectionRender) static const LLCachedControl<U32> RenderFSAASamples("RenderFSAASamples",0);
{ LLGLEnable multisample(RenderFSAASamples > 0 ? GL_MULTISAMPLE_ARB : 0);
static const LLCachedControl<U32> RenderFSAASamples("RenderFSAASamples",0); gViewerWindow->renderSelections(FALSE, FALSE, FALSE); // For HUD version in render_ui_3d()
LLGLEnable multisample(RenderFSAASamples > 0 ? GL_MULTISAMPLE_ARB : 0);
gViewerWindow->renderSelections(FALSE, FALSE, FALSE); // For HUD version in render_ui_3d()
// Draw the tracking overlays // Draw the tracking overlays
LLTracker::render3D(); LLTracker::render3D();
// Show the property lines // Show the property lines
LLWorld::getInstance()->renderPropertyLines(); LLWorld::getInstance()->renderPropertyLines();
LLViewerParcelMgr::getInstance()->render(); LLViewerParcelMgr::getInstance()->render();
LLViewerParcelMgr::getInstance()->renderParcelCollision(); LLViewerParcelMgr::getInstance()->renderParcelCollision();
// Render name tags. // Render name tags.
LLHUDObject::renderAll(); LLHUDObject::renderAll();
}
} }
else if (gForceRenderLandFence) else if (gForceRenderLandFence)
{ {
@@ -3391,7 +3393,7 @@ void render_hud_elements()
void LLPipeline::renderHighlights() void LLPipeline::renderHighlights()
{ {
LLMemType mt(LLMemType::MTYPE_PIPELINE); LLMemType mt(LLMemType::MTYPE_PIPELINE_RENDER_HL);
assertInitialized(); assertInitialized();
@@ -3456,9 +3458,10 @@ void LLPipeline::renderHighlights()
//debug use //debug use
U32 LLPipeline::sCurRenderPoolType = 0 ; U32 LLPipeline::sCurRenderPoolType = 0 ;
void LLPipeline::renderGeom(LLCamera& camera, BOOL forceVBOUpdate) void LLPipeline::renderGeom(LLCamera& camera, BOOL forceVBOUpdate)
{ {
LLMemType mt(LLMemType::MTYPE_PIPELINE); LLMemType mt(LLMemType::MTYPE_PIPELINE_RENDER_GEOM);
LLFastTimer t(FTM_RENDER_GEOMETRY); LLFastTimer t(FTM_RENDER_GEOMETRY);
assertInitialized(); assertInitialized();
@@ -3723,6 +3726,7 @@ void LLPipeline::renderGeom(LLCamera& camera, BOOL forceVBOUpdate)
void LLPipeline::renderGeomDeferred(LLCamera& camera) void LLPipeline::renderGeomDeferred(LLCamera& camera)
{ {
LLAppViewer::instance()->pingMainloopTimeout("Pipeline:RenderGeomDeferred"); LLAppViewer::instance()->pingMainloopTimeout("Pipeline:RenderGeomDeferred");
LLMemType mt_rgd(LLMemType::MTYPE_PIPELINE_RENDER_GEOM_DEFFERRED);
LLFastTimer t(FTM_RENDER_GEOMETRY); LLFastTimer t(FTM_RENDER_GEOMETRY);
LLFastTimer t2(FTM_POOLS); LLFastTimer t2(FTM_POOLS);
@@ -3822,6 +3826,7 @@ void LLPipeline::renderGeomDeferred(LLCamera& camera)
void LLPipeline::renderGeomPostDeferred(LLCamera& camera) void LLPipeline::renderGeomPostDeferred(LLCamera& camera)
{ {
LLMemType mt_rgpd(LLMemType::MTYPE_PIPELINE_RENDER_GEOM_POST_DEF);
LLFastTimer t(FTM_POOLS); LLFastTimer t(FTM_POOLS);
U32 cur_type = 0; U32 cur_type = 0;
@@ -3918,6 +3923,7 @@ void LLPipeline::renderGeomPostDeferred(LLCamera& camera)
void LLPipeline::renderGeomShadow(LLCamera& camera) void LLPipeline::renderGeomShadow(LLCamera& camera)
{ {
LLMemType mt_rgs(LLMemType::MTYPE_PIPELINE_RENDER_GEOM_SHADOW);
U32 cur_type = 0; U32 cur_type = 0;
LLGLEnable cull(GL_CULL_FACE); LLGLEnable cull(GL_CULL_FACE);
@@ -4351,7 +4357,7 @@ void LLPipeline::renderDebug()
void LLPipeline::rebuildPools() void LLPipeline::rebuildPools()
{ {
LLMemType mt(LLMemType::MTYPE_PIPELINE); LLMemType mt(LLMemType::MTYPE_PIPELINE_REBUILD_POOLS);
assertInitialized(); assertInitialized();
@@ -4391,7 +4397,7 @@ void LLPipeline::rebuildPools()
void LLPipeline::addToQuickLookup( LLDrawPool* new_poolp ) void LLPipeline::addToQuickLookup( LLDrawPool* new_poolp )
{ {
LLMemType mt(LLMemType::MTYPE_PIPELINE); LLMemType mt(LLMemType::MTYPE_PIPELINE_QUICK_LOOKUP);
assertInitialized(); assertInitialized();
@@ -6000,6 +6006,7 @@ void LLPipeline::doResetVertexBuffers()
void LLPipeline::renderObjects(U32 type, U32 mask, BOOL texture, BOOL batch_texture) void LLPipeline::renderObjects(U32 type, U32 mask, BOOL texture, BOOL batch_texture)
{ {
LLMemType mt_ro(LLMemType::MTYPE_PIPELINE_RENDER_OBJECTS);
assertInitialized(); assertInitialized();
gGL.loadMatrix(gGLModelView); gGL.loadMatrix(gGLModelView);
gGLLastMatrix = NULL; gGLLastMatrix = NULL;
@@ -6075,6 +6082,7 @@ void LLPipeline::bindScreenToTexture()
static LLFastTimer::DeclareTimer FTM_RENDER_BLOOM("Bloom"); static LLFastTimer::DeclareTimer FTM_RENDER_BLOOM("Bloom");
void LLPipeline::renderBloom(BOOL for_snapshot, F32 zoom_factor, int subfield, bool tiling) void LLPipeline::renderBloom(BOOL for_snapshot, F32 zoom_factor, int subfield, bool tiling)
{ {
LLMemType mt_ru(LLMemType::MTYPE_PIPELINE_RENDER_BLOOM);
if (!(gPipeline.canUseVertexShaders() && if (!(gPipeline.canUseVertexShaders() &&
sRenderGlow)) sRenderGlow))
{ {
@@ -9201,6 +9209,7 @@ void LLPipeline::renderGroups(LLRenderPass* pass, U32 type, U32 mask, BOOL textu
void LLPipeline::generateImpostor(LLVOAvatar* avatar) void LLPipeline::generateImpostor(LLVOAvatar* avatar)
{ {
LLMemType mt_gi(LLMemType::MTYPE_PIPELINE_GENERATE_IMPOSTOR);
LLGLState::checkStates(); LLGLState::checkStates();
LLGLState::checkTextureChannels(); LLGLState::checkTextureChannels();
LLGLState::checkClientArrays(); LLGLState::checkClientArrays();