Merge branch 'master' of git://github.com/Shyotl/SingularityViewer

Conflicts:
	indra/newview/llvoavatar.cpp
This commit is contained in:
Lirusaito
2012-02-01 11:24:45 -05:00
9 changed files with 122 additions and 78 deletions

View File

@@ -57,7 +57,6 @@ S32 LLFastTimer::sLastFrameIndex = -1;
U64 LLFastTimer::sLastFrameTime = LLFastTimer::getCPUClockCount64(); U64 LLFastTimer::sLastFrameTime = LLFastTimer::getCPUClockCount64();
bool LLFastTimer::sPauseHistory = 0; bool LLFastTimer::sPauseHistory = 0;
bool LLFastTimer::sResetHistory = 0; bool LLFastTimer::sResetHistory = 0;
LLFastTimer::CurTimerData LLFastTimer::sCurTimerData;
BOOL LLFastTimer::sLog = FALSE; BOOL LLFastTimer::sLog = FALSE;
std::string LLFastTimer::sLogName = ""; std::string LLFastTimer::sLogName = "";
BOOL LLFastTimer::sMetricLog = FALSE; BOOL LLFastTimer::sMetricLog = FALSE;
@@ -72,7 +71,6 @@ U64 LLFastTimer::sClockResolution = 1000000000; // Nanosecond resolution
U64 LLFastTimer::sClockResolution = 1000000; // Microsecond resolution U64 LLFastTimer::sClockResolution = 1000000; // Microsecond resolution
#endif #endif
std::vector<LLFastTimer::FrameState>* LLFastTimer::sTimerInfos = NULL;
U64 LLFastTimer::sTimerCycles = 0; U64 LLFastTimer::sTimerCycles = 0;
U32 LLFastTimer::sTimerCalls = 0; U32 LLFastTimer::sTimerCalls = 0;
@@ -130,8 +128,16 @@ public:
mActiveTimerRoot->setCollapsed(false); mActiveTimerRoot->setCollapsed(false);
mRootFrameState = new LLFastTimer::FrameState(mActiveTimerRoot); mRootFrameState = new LLFastTimer::FrameState(mActiveTimerRoot);
mRootFrameState->mParent = &mTimerRoot->getFrameState(); // getFrameState and setParent recursively call this function,
mActiveTimerRoot->setParent(mTimerRoot); // so we have to work around that by using a specialized implementation
// for the special case were mTimerRoot != mActiveTimerRoot -- Aleric
mRootFrameState->mParent = &LLFastTimer::getFrameStateList()[0]; // &mTimerRoot->getFrameState()
// And the following four lines are mActiveTimerRoot->setParent(mTimerRoot);
llassert(!mActiveTimerRoot->mParent);
mActiveTimerRoot->mParent = mTimerRoot; // mParent = parent;
mRootFrameState->mParent = mRootFrameState->mParent; // getFrameState().mParent = &parent->getFrameState();
mTimerRoot->getChildren().push_back(mActiveTimerRoot); // parent->getChildren().push_back(this);
mTimerRoot->mNeedsSorting = true; // parent->mNeedsSorting = true;
mAppTimer = new LLFastTimer(mRootFrameState); mAppTimer = new LLFastTimer(mRootFrameState);
} }
@@ -227,7 +233,8 @@ void LLFastTimer::DeclareTimer::updateCachedPointers()
} }
// also update frame states of timers on stack // also update frame states of timers on stack
LLFastTimer* cur_timerp = LLFastTimer::sCurTimerData.mCurTimer; static LLFastTimer::CurTimerData& static_cur_data = LLFastTimer::CurTimerData::get();
LLFastTimer* cur_timerp = static_cur_data.mCurTimer;
while(cur_timerp->mLastTimerData.mCurTimer != cur_timerp) while(cur_timerp->mLastTimerData.mCurTimer != cur_timerp)
{ {
cur_timerp->mFrameState = &cur_timerp->mFrameState->mTimer->getFrameState(); cur_timerp->mFrameState = &cur_timerp->mFrameState->mTimer->getFrameState();
@@ -454,10 +461,12 @@ void LLFastTimer::NamedTimer::accumulateTimings()
{ {
U32 cur_time = getCPUClockCount32(); U32 cur_time = getCPUClockCount32();
static LLFastTimer::CurTimerData& static_cur_data = LLFastTimer::CurTimerData::get();
// walk up stack of active timers and accumulate current time while leaving timing structures active // walk up stack of active timers and accumulate current time while leaving timing structures active
LLFastTimer* cur_timer = sCurTimerData.mCurTimer; LLFastTimer* cur_timer = static_cur_data.mCurTimer;
// root defined by parent pointing to self // root defined by parent pointing to self
CurTimerData* cur_data = &sCurTimerData; CurTimerData* cur_data = &static_cur_data;
while(cur_timer->mLastTimerData.mCurTimer != cur_timer) while(cur_timer->mLastTimerData.mCurTimer != cur_timer)
{ {
U32 cumulative_time_delta = cur_time - cur_timer->mStartTime; U32 cumulative_time_delta = cur_time - cur_timer->mStartTime;
@@ -606,8 +615,10 @@ void LLFastTimer::NamedTimer::reset()
// effectively zeroing out any accumulated time // effectively zeroing out any accumulated time
U32 cur_time = getCPUClockCount32(); U32 cur_time = getCPUClockCount32();
static LLFastTimer::CurTimerData& static_cur_data = LLFastTimer::CurTimerData::get();
// root defined by parent pointing to self // root defined by parent pointing to self
CurTimerData* cur_data = &sCurTimerData; CurTimerData* cur_data = &static_cur_data;
LLFastTimer* cur_timer = cur_data->mCurTimer; LLFastTimer* cur_timer = cur_data->mCurTimer;
while(cur_timer->mLastTimerData.mCurTimer != cur_timer) while(cur_timer->mLastTimerData.mCurTimer != cur_timer)
{ {
@@ -642,11 +653,12 @@ void LLFastTimer::NamedTimer::reset()
//static //static
LLFastTimer::info_list_t& LLFastTimer::getFrameStateList() LLFastTimer::info_list_t& LLFastTimer::getFrameStateList()
{ {
if (!sTimerInfos) //Static local varaible to avoid static initialization order fiasco.
{ //NamedTimerFactory ctor uses this object, and is called during static initialization...
sTimerInfos = new info_list_t(); //often before llfasttimer_class.cpp's translation unit.
} //'leak' is harmless and intended to ensure it out-scopes NamedTimerFactory.
return *sTimerInfos; static info_list_t* timer_infos = new info_list_t();
return *timer_infos;
} }
@@ -779,10 +791,11 @@ LLFastTimer::LLFastTimer(LLFastTimer::FrameState* state)
U32 start_time = getCPUClockCount32(); U32 start_time = getCPUClockCount32();
mStartTime = start_time; mStartTime = start_time;
mFrameState->mActiveCount++; mFrameState->mActiveCount++;
LLFastTimer::sCurTimerData.mCurTimer = this; static LLFastTimer::CurTimerData& static_cur_data = LLFastTimer::CurTimerData::get();
LLFastTimer::sCurTimerData.mFrameState = mFrameState; static_cur_data.mCurTimer = this;
LLFastTimer::sCurTimerData.mChildTime = 0; static_cur_data.mFrameState = mFrameState;
mLastTimerData = LLFastTimer::sCurTimerData; static_cur_data.mChildTime = 0;
mLastTimerData = static_cur_data;
} }

View File

@@ -169,11 +169,11 @@ public:
// keep current parent as long as it is active when we are // keep current parent as long as it is active when we are
frame_state->mMoveUpTree |= (frame_state->mParent->mActiveCount == 0); frame_state->mMoveUpTree |= (frame_state->mParent->mActiveCount == 0);
LLFastTimer::CurTimerData* cur_timer_data = &LLFastTimer::sCurTimerData; static LLFastTimer::CurTimerData& static_cur_data = LLFastTimer::CurTimerData::get();
mLastTimerData = *cur_timer_data; mLastTimerData = static_cur_data;
cur_timer_data->mCurTimer = this; static_cur_data.mCurTimer = this;
cur_timer_data->mFrameState = frame_state; static_cur_data.mFrameState = frame_state;
cur_timer_data->mChildTime = 0; static_cur_data.mChildTime = 0;
#endif #endif
#if TIME_FAST_TIMERS #if TIME_FAST_TIMERS
U64 timer_end = getCPUClockCount64(); U64 timer_end = getCPUClockCount64();
@@ -195,7 +195,9 @@ public:
LLFastTimer::FrameState* frame_state = mFrameState; LLFastTimer::FrameState* frame_state = mFrameState;
U32 total_time = getCPUClockCount32() - mStartTime; U32 total_time = getCPUClockCount32() - mStartTime;
frame_state->mSelfTimeCounter += total_time - LLFastTimer::sCurTimerData.mChildTime; static LLFastTimer::CurTimerData& static_cur_data = LLFastTimer::CurTimerData::get();
frame_state->mSelfTimeCounter += total_time - static_cur_data.mChildTime;
frame_state->mActiveCount--; frame_state->mActiveCount--;
// store last caller to bootstrap tree creation // store last caller to bootstrap tree creation
@@ -205,7 +207,7 @@ public:
// we are only tracking self time, so subtract our total time delta from parents // we are only tracking self time, so subtract our total time delta from parents
mLastTimerData.mChildTime += total_time; mLastTimerData.mChildTime += total_time;
LLFastTimer::sCurTimerData = mLastTimerData; static_cur_data = mLastTimerData;
#endif #endif
#if TIME_FAST_TIMERS #if TIME_FAST_TIMERS
U64 timer_end = getCPUClockCount64(); U64 timer_end = getCPUClockCount64();
@@ -252,8 +254,16 @@ public:
LLFastTimer* mCurTimer; LLFastTimer* mCurTimer;
FrameState* mFrameState; FrameState* mFrameState;
U32 mChildTime; U32 mChildTime;
static CurTimerData& get()
{
//Static local varaible to avoid static initialization order fiasco.
//NamedTimerFactory ctor uses this object, and is called during static initialization...
//often before llfasttimer_class.cpp's translation unit.
//'leak' is harmless and intended to ensure it out-scopes NamedTimerFactory.
static CurTimerData* timer_data = new CurTimerData();
return *timer_data;
}
}; };
static CurTimerData sCurTimerData;
static std::string sClockType; static std::string sClockType;
public: public:
@@ -265,7 +275,6 @@ private:
static S32 sCurFrameIndex; static S32 sCurFrameIndex;
static S32 sLastFrameIndex; static S32 sLastFrameIndex;
static U64 sLastFrameTime; static U64 sLastFrameTime;
static info_list_t* sTimerInfos;
U32 mStartTime; U32 mStartTime;
LLFastTimer::FrameState* mFrameState; LLFastTimer::FrameState* mFrameState;

View File

@@ -151,9 +151,10 @@ public:
*/ */
static void deleteSingleton() static void deleteSingleton()
{ {
delete getData().mSingletonInstance; DERIVED_TYPE* instance = getData().mSingletonInstance;
getData().mSingletonInstance = NULL;
getData().mInitState = DELETED; getData().mInitState = DELETED;
getData().mSingletonInstance = NULL;
delete instance;
} }
static SingletonInstanceData& getData() static SingletonInstanceData& getData()
@@ -175,23 +176,9 @@ public:
{ {
SingletonInstanceData& data = getData(); SingletonInstanceData& data = getData();
if (data.mInitState == CONSTRUCTING) if (data.mInitState != INITIALIZED)
{ {
llerrs << "Tried to access singleton " << typeid(DERIVED_TYPE).name() << " from singleton constructor!" << llendl; createInstance(data);
}
if (data.mInitState == DELETED)
{
llwarns << "Trying to access deleted singleton " << typeid(DERIVED_TYPE).name() << " creating new instance" << llendl;
}
if (!data.mSingletonInstance)
{
data.mInitState = CONSTRUCTING;
data.mSingletonInstance = new DERIVED_TYPE();
data.mInitState = INITIALIZING;
data.mSingletonInstance->initSingleton();
data.mInitState = INITIALIZED;
} }
return data.mSingletonInstance; return data.mSingletonInstance;
@@ -219,7 +206,35 @@ public:
} }
private: private:
static void createInstance(SingletonInstanceData& data);
virtual void initSingleton() {} virtual void initSingleton() {}
}; };
// Moved this here cause it's too big to be inlined --Aleric.
template<typename DERIVED_TYPE>
void LLSingleton<DERIVED_TYPE>::createInstance(SingletonInstanceData& data)
{
if (data.mInitState == CONSTRUCTING)
{
llerrs << "Tried to access singleton " << typeid(DERIVED_TYPE).name() << " from singleton constructor!" << llendl;
}
if (data.mInitState == DELETED)
{
llwarns << "Trying to access deleted singleton " << typeid(DERIVED_TYPE).name() << " creating new instance" << llendl;
}
if (data.mInitState == INITIALIZING)
{
llwarns << "Tried to access singleton " << typeid(DERIVED_TYPE).name() << " from initSingleton(), using half-initialized object" << llendl;
return;
}
data.mInitState = CONSTRUCTING;
data.mSingletonInstance = new DERIVED_TYPE();
data.mInitState = INITIALIZING;
data.mSingletonInstance->initSingleton();
data.mInitState = INITIALIZED;
}
#endif #endif

View File

@@ -330,7 +330,7 @@ public:
virtual void setLastError(const std::string& message, const std::string& filename = std::string()); virtual void setLastError(const std::string& message, const std::string& filename = std::string());
protected: protected:
BOOL copyData(U8 *data, S32 size); // calls updateData() BOOL copyData(U8 *data, S32 size);
protected: protected:
S8 mCodec; S8 mCodec;

View File

@@ -130,7 +130,7 @@ BOOL LLVFile::read(U8 *buffer, S32 bytes, BOOL async, F32 priority)
} }
//static //static
U8* LLVFile::readFile(LLVFS *vfs, const LLUUID &uuid, LLAssetType::EType type, S32* bytes_read) U8* LLVFile::readFile(LLVFS *vfs, LLPrivateMemoryPool* poolp, const LLUUID &uuid, LLAssetType::EType type, S32* bytes_read)
{ {
U8 *data; U8 *data;
LLVFile file(vfs, uuid, type, LLVFile::READ); LLVFile file(vfs, uuid, type, LLVFile::READ);
@@ -142,12 +142,12 @@ U8* LLVFile::readFile(LLVFS *vfs, const LLUUID &uuid, LLAssetType::EType type, S
} }
else else
{ {
data = new U8[file_size]; data = (U8*)ALLOCATE_MEM(poolp, file_size);
file.read(data, file_size); /* Flawfinder: ignore */ file.read(data, file_size); /* Flawfinder: ignore */
if (file.getLastBytesRead() != (S32)file_size) if (file.getLastBytesRead() != (S32)file_size)
{ {
delete[] data; FREE_MEM(poolp, data);
data = NULL; data = NULL;
file_size = 0; file_size = 0;
} }

View File

@@ -38,6 +38,8 @@
#include "llvfs.h" #include "llvfs.h"
#include "llvfsthread.h" #include "llvfsthread.h"
class LLPrivateMemoryPool;
class LLVFile class LLVFile
{ {
public: public:
@@ -45,7 +47,7 @@ public:
~LLVFile(); ~LLVFile();
BOOL read(U8 *buffer, S32 bytes, BOOL async = FALSE, F32 priority = 128.f); /* Flawfinder: ignore */ BOOL read(U8 *buffer, S32 bytes, BOOL async = FALSE, F32 priority = 128.f); /* Flawfinder: ignore */
static U8* readFile(LLVFS *vfs, const LLUUID &uuid, LLAssetType::EType type, S32* bytes_read = 0); static U8* readFile(LLVFS *vfs, LLPrivateMemoryPool* poolp, const LLUUID &uuid, LLAssetType::EType type, S32* bytes_read = 0);
void setReadPriority(const F32 priority); void setReadPriority(const F32 priority);
BOOL isReadComplete(); BOOL isReadComplete();
S32 getLastBytesRead(); S32 getLastBytesRead();

View File

@@ -2766,6 +2766,11 @@ bool idle_startup()
LL_DEBUGS("AppInit") << "Initialization complete" << LL_ENDL; LL_DEBUGS("AppInit") << "Initialization complete" << LL_ENDL;
gRenderStartTime.reset(); gRenderStartTime.reset();
// We're not allowed to call reset() when paused, and we might or might not be paused depending on
// whether or not the main window lost focus before we get here (see LLViewerWindow::handleFocusLost).
// The simplest, legal way to make sure we're unpaused is to just pause/unpause here.
gForegroundTime.pause();
gForegroundTime.unpause();
gForegroundTime.reset(); gForegroundTime.reset();
if (gSavedSettings.getBOOL("FetchInventoryOnLogin") if (gSavedSettings.getBOOL("FetchInventoryOnLogin")

View File

@@ -402,7 +402,7 @@ void LLTexLayerSetBuffer::readBackAndUpload()
BOOL valid = FALSE; BOOL valid = FALSE;
LLPointer<LLImageJ2C> integrity_test = new LLImageJ2C; LLPointer<LLImageJ2C> integrity_test = new LLImageJ2C;
S32 file_size = 0; S32 file_size = 0;
U8* data = LLVFile::readFile(gVFS, asset_id, LLAssetType::AT_TEXTURE, &file_size); U8* data = LLVFile::readFile(gVFS, LLImageBase::getPrivatePool(), asset_id, LLAssetType::AT_TEXTURE, &file_size);
if (data) if (data)
{ {
valid = integrity_test->validate(data, file_size); // integrity_test will delete 'data' valid = integrity_test->validate(data, file_size); // integrity_test will delete 'data'

View File

@@ -3258,6 +3258,29 @@ void LLVOAvatar::getClientInfo(std::string& client, LLColor4& color, BOOL useCom
return; return;
std::string uuid_str = getTE(TEX_HEAD_BODYPAINT)->getID().asString(); //UUID of the head texture std::string uuid_str = getTE(TEX_HEAD_BODYPAINT)->getID().asString(); //UUID of the head texture
if(isFullyLoaded())
{
//Zwagoth's new client identification - HgB
// Overwrite the current tag/color settings if new method
// exists -- charbl.
const LLTextureEntry* texentry = getTE(0);
if(texentry->getGlow() > 0.0)
{
///llinfos << "Using new client identifier." << llendl;
U8 tag_buffer[UUID_BYTES+1];
memset(&tag_buffer, 0, UUID_BYTES);
memcpy(&tag_buffer[0], &texentry->getID().mData, UUID_BYTES);
tag_buffer[UUID_BYTES] = 0;
U32 tag_len = strlen((const char*)&tag_buffer[0]);
tag_len = (tag_len>UUID_BYTES) ? (UUID_BYTES) : tag_len;
client = std::string((char*)&tag_buffer[0], tag_len);
LLStringFn::replace_ascii_controlchars(mClientTag, LL_UNKNOWN_CHAR);
mNameString.clear();
color = texentry->getColor();
return;
}
}
static const LLCachedControl<LLColor4> avatar_name_color(gColors,"AvatarNameColor",LLColor4(LLColor4U(251, 175, 93, 255)) ); static const LLCachedControl<LLColor4> avatar_name_color(gColors,"AvatarNameColor",LLColor4(LLColor4U(251, 175, 93, 255)) );
if (isSelf()) if (isSelf())
{ {
@@ -3553,38 +3576,15 @@ void LLVOAvatar::idleUpdateNameTag(const LLVector3& root_pos_last)
static const LLCachedControl<LLColor4> avatar_name_color(gColors, "AvatarNameColor" ); static const LLCachedControl<LLColor4> avatar_name_color(gColors, "AvatarNameColor" );
//As pointed out by Zwagoth, we really shouldn't be doing this per-frame. Skip if we already have the data. -HgB //As pointed out by Zwagoth, we really shouldn't be doing this per-frame. Skip if we already have the data. -HgB
if (mClientTag == "") if (mClientTag == "")
{ {
mClientColor = avatar_name_color; mClientColor = avatar_name_color;
if(isFullyLoaded()) getClientInfo(mClientTag,mClientColor);
if(mClientTag == "")
{ {
//Zwagoth's new client identification - HgB client = "?"; //prevent console spam..
// Overwrite the current tag/color settings if new method
// exists -- charbl.
const LLTextureEntry* texentry = getTE(0);
if(texentry->getGlow() > 0.0)
{
llinfos << "Using new client identifier." << llendl;
U8 tag_buffer[UUID_BYTES+1];
memset(&tag_buffer, 0, UUID_BYTES);
memcpy(&tag_buffer[0], &texentry->getID().mData, UUID_BYTES);
tag_buffer[UUID_BYTES] = 0;
U32 tag_len = strlen((const char*)&tag_buffer[0]);
tag_len = (tag_len>UUID_BYTES) ? (UUID_BYTES) : tag_len;
mClientTag = std::string((char*)&tag_buffer[0], tag_len);
LLStringFn::replace_ascii_controlchars(mClientTag, LL_UNKNOWN_CHAR);
mNameString.clear();
mClientColor = texentry->getColor();
}
else
{
//llinfos << "Using Emerald-style client identifier." << llendl;
//The old client identification. Used only if the new method doesn't exist, so that it isn't automatically overwritten. -HgB
getClientInfo(mClientTag,mClientColor);
if(mClientTag == "")
client = "?"; //prevent console spam..
}
} }
// Overwrite the tag/color shit yet again if we want to see // Overwrite the tag/color shit yet again if we want to see