Wrap sGlobalRawMemory in AIThreadSafe.

This is accessed by different threads.
Other globals like it might also be
accessed by different threads, this has
to be investigated.
This commit is contained in:
Aleric Inglewood
2011-08-05 00:05:08 +02:00
committed by Siana Gearz
parent a43f1ee299
commit 3bde58d970
5 changed files with 25 additions and 10 deletions

View File

@@ -245,7 +245,7 @@ U8* LLImageBase::allocateDataSize(S32 width, S32 height, S32 ncomponents, S32 si
// LLImageRaw
//---------------------------------------------------------------------------
S32 LLImageRaw::sGlobalRawMemory = 0;
AITHREADSAFESIMPLE(S32, LLImageRaw::sGlobalRawMemory, );
S32 LLImageRaw::sRawImageCount = 0;
S32 LLImageRaw::sRawImageCachedCount = 0;
@@ -295,23 +295,25 @@ LLImageRaw::~LLImageRaw()
U8* LLImageRaw::allocateData(S32 size)
{
U8* res = LLImageBase::allocateData(size);
sGlobalRawMemory += getDataSize();
*AIAccess<S32>(sGlobalRawMemory) += getDataSize();
return res;
}
// virtual
U8* LLImageRaw::reallocateData(S32 size)
{
sGlobalRawMemory -= getDataSize();
S32 old_data_size = getDataSize();
U8* res = LLImageBase::reallocateData(size);
sGlobalRawMemory += getDataSize();
*AIAccess<S32>(sGlobalRawMemory) += getDataSize() - old_data_size;
return res;
}
// virtual
void LLImageRaw::deleteData()
{
sGlobalRawMemory -= getDataSize();
{
*AIAccess<S32>(sGlobalRawMemory) -= getDataSize();
}
LLImageBase::deleteData();
}
@@ -327,7 +329,7 @@ void LLImageRaw::setDataAndSize(U8 *data, S32 width, S32 height, S8 components)
LLImageBase::setSize(width, height, components) ;
LLImageBase::setDataAndSize(data, width * height * components) ;
sGlobalRawMemory += getDataSize();
*AIAccess<S32>(sGlobalRawMemory) += getDataSize();
}
BOOL LLImageRaw::resize(U16 width, U16 height, S8 components)

View File

@@ -37,6 +37,7 @@
#include "llstring.h"
#include "llmemory.h"
#include "llthread.h"
#include "aithreadsafe.h"
const S32 MIN_IMAGE_MIP = 2; // 4x4, only used for expand/contract power of 2
const S32 MAX_IMAGE_MIP = 11; // 2048x2048
@@ -241,7 +242,7 @@ protected:
void setDataAndSize(U8 *data, S32 width, S32 height, S8 components) ;
public:
static S32 sGlobalRawMemory;
static AIThreadSafeSimple<S32> sGlobalRawMemory;
static S32 sRawImageCount;
static S32 sRawImageCachedCount;

View File

@@ -421,12 +421,16 @@ void LLGLTexMemBar::draw()
std::string text;
S32 global_raw_memory;
{
global_raw_memory = *AIAccess<S32>(LLImageRaw::sGlobalRawMemory);
}
text = llformat("GL Tot: %d/%d MB Bound: %d/%d MB Raw Tot: %d MB Bias: %.2f Cache: %.1f/%.1f MB Net Tot Tex: %.1f MB Tot Obj: %.1f MB",
total_mem,
max_total_mem,
bound_mem,
max_bound_mem,
LLImageRaw::sGlobalRawMemory >> 20, discard_bias,
global_raw_memory >> 20, discard_bias,
cache_usage, cache_max_usage, total_texture_downloaded, total_object_downloaded);
//, cache_entries, cache_max_entries

View File

@@ -362,12 +362,16 @@ void reset_statistics()
void output_statistics(void*)
{
S32 global_raw_memory;
{
global_raw_memory = *AIAccess<S32>(LLImageRaw::sGlobalRawMemory);
}
llinfos << "Number of orphans: " << gObjectList.getOrphanCount() << llendl;
llinfos << "Number of dead objects: " << gObjectList.mNumDeadObjects << llendl;
llinfos << "Num images: " << gTextureList.getNumImages() << llendl;
llinfos << "Texture usage: " << LLImageGL::sGlobalTextureMemoryInBytes << llendl;
llinfos << "Texture working set: " << LLImageGL::sBoundTextureMemoryInBytes << llendl;
llinfos << "Raw usage: " << LLImageRaw::sGlobalRawMemory << llendl;
llinfos << "Raw usage: " << global_raw_memory << llendl;
llinfos << "Formatted usage: " << LLImageFormatted::sGlobalFormattedMemory << llendl;
llinfos << "Zombie Viewer Objects: " << LLViewerObject::getNumZombieObjects() << llendl;
llinfos << "Number of lights: " << gPipeline.getLightCount() << llendl;

View File

@@ -608,11 +608,15 @@ void LLViewerTextureList::updateImages(F32 max_time)
{
LLAppViewer::getTextureFetch()->setTextureBandwidth(LLViewerStats::getInstance()->mTextureKBitStat.getMeanPerSec());
S32 global_raw_memory;
{
global_raw_memory = *AIAccess<S32>(LLImageRaw::sGlobalRawMemory);
}
sNumImagesStat.addValue(sNumImages);
sNumRawImagesStat.addValue(LLImageRaw::sRawImageCount);
sGLTexMemStat.addValue((F32)BYTES_TO_MEGA_BYTES(LLImageGL::sGlobalTextureMemoryInBytes));
sGLBoundMemStat.addValue((F32)BYTES_TO_MEGA_BYTES(LLImageGL::sBoundTextureMemoryInBytes));
sRawMemStat.addValue((F32)BYTES_TO_MEGA_BYTES(LLImageRaw::sGlobalRawMemory));
sRawMemStat.addValue((F32)BYTES_TO_MEGA_BYTES(global_raw_memory));
sFormattedMemStat.addValue((F32)BYTES_TO_MEGA_BYTES(LLImageFormatted::sGlobalFormattedMemory));
updateImagesDecodePriorities();