llcommon merge. Added LLUnits.

This commit is contained in:
Shyotl
2016-04-06 01:31:20 -05:00
parent 0fa7848b19
commit 0841479ccc
66 changed files with 1895 additions and 621 deletions

View File

@@ -298,7 +298,7 @@ LLTexUnit::eTextureAddressMode LLGLTexture::getAddressMode(void) const
return mGLTexturep->getAddressMode() ;
}
S32 LLGLTexture::getTextureMemory() const
S32Bytes LLGLTexture::getTextureMemory() const
{
llassert(mGLTexturep.notNull()) ;

View File

@@ -138,7 +138,7 @@ public:
S32 getDiscardLevel() const;
S8 getComponents() const;
BOOL getBoundRecently() const;
S32 getTextureMemory() const ;
S32Bytes getTextureMemory() const ;
LLGLenum getPrimaryFormat() const;
BOOL getIsAlphaMask(const F32 max_rmse) const ;
LLTexUnit::eTextureType getTarget(void) const ;

View File

@@ -50,9 +50,9 @@ U32 wpo2(U32 i);
U32 LLImageGL::sUniqueCount = 0;
U32 LLImageGL::sBindCount = 0;
S32 LLImageGL::sGlobalTextureMemoryInBytes = 0;
S32 LLImageGL::sBoundTextureMemoryInBytes = 0;
S32 LLImageGL::sCurBoundTextureMemory = 0;
S32Bytes LLImageGL::sGlobalTextureMemory(0);
S32Bytes LLImageGL::sBoundTextureMemory(0);
S32Bytes LLImageGL::sCurBoundTextureMemory(0);
S32 LLImageGL::sCount = 0;
BOOL LLImageGL::sGlobalUseAnisotropic = FALSE;
@@ -78,9 +78,9 @@ S32 LLImageGL::sCurTexPickSize = -1 ;
LLPointer<LLImageGL> LLImageGL::sHighlightTexturep = NULL;
S32 LLImageGL::sMaxCategories = 1 ;
std::vector<S32> LLImageGL::sTextureMemByCategory;
std::vector<S32> LLImageGL::sTextureMemByCategoryBound ;
std::vector<S32> LLImageGL::sTextureCurMemByCategoryBound ;
std::vector<S32Bytes> LLImageGL::sTextureMemByCategory;
std::vector<S32Bytes> LLImageGL::sTextureMemByCategoryBound ;
std::vector<S32Bytes> LLImageGL::sTextureCurMemByCategoryBound ;
//------------------------
// ****************************************************************************************************
//End for texture auditing use only
@@ -292,8 +292,8 @@ void LLImageGL::updateStats(F32 current_time)
{
LLFastTimer t(FTM_IMAGE_UPDATE_STATS);
sLastFrameTime = current_time;
sBoundTextureMemoryInBytes = sCurBoundTextureMemory;
sCurBoundTextureMemory = 0;
sBoundTextureMemory = sCurBoundTextureMemory;
sCurBoundTextureMemory = S32Bytes(0);
if(gAuditTexture)
{
@@ -305,22 +305,22 @@ void LLImageGL::updateStats(F32 current_time)
for(U32 i = 0 ; i < sTextureCurMemByCategoryBound.size() ; i++)
{
sTextureMemByCategoryBound[i] = sTextureCurMemByCategoryBound[i] ;
sTextureCurMemByCategoryBound[i] = 0 ;
sTextureCurMemByCategoryBound[i] = (S32Bytes)0 ;
}
}
}
//static
S32 LLImageGL::updateBoundTexMem(const S32 mem, const S32 ncomponents, S32 category)
S32 LLImageGL::updateBoundTexMem(const S32Bytes mem, const S32 ncomponents, S32 category)
{
if(gAuditTexture && ncomponents > 0 && category > -1)
{
sTextureCurBoundCounter[getTextureCounterIndex(mem / ncomponents)]++ ;
sTextureCurBoundCounter[getTextureCounterIndex(mem.value() / ncomponents)]++ ;
sTextureCurMemByCategoryBound[category] += mem ;
}
LLImageGL::sCurBoundTextureMemory += mem ;
return LLImageGL::sCurBoundTextureMemory;
return LLImageGL::sCurBoundTextureMemory.value();
}
//----------------------------------------------------------------------------
@@ -480,7 +480,7 @@ void LLImageGL::init(BOOL usemipmaps)
// so that it is obvious by visual inspection if we forgot to
// init a field.
mTextureMemory = 0;
mTextureMemory = (S32Bytes)0;
mLastBindTime = 0.f;
mPickMask = NULL;
@@ -644,7 +644,7 @@ void LLImageGL::forceUpdateBindStats(void) const
mLastBindTime = sLastFrameTime;
}
BOOL LLImageGL::updateBindStats(S32 tex_mem) const
BOOL LLImageGL::updateBindStats(S32Bytes tex_mem) const
{
if (mTexName != 0)
{
@@ -1677,7 +1677,7 @@ BOOL LLImageGL::createGLTexture(S32 discard_level, const U8* data_in, BOOL data_
if (old_name != 0)
{
sGlobalTextureMemoryInBytes -= mTextureMemory;
sGlobalTextureMemory -= mTextureMemory;
if(gAuditTexture)
{
@@ -1689,8 +1689,8 @@ BOOL LLImageGL::createGLTexture(S32 discard_level, const U8* data_in, BOOL data_
stop_glerror();
}
mTextureMemory = getMipBytes(discard_level);
sGlobalTextureMemoryInBytes += mTextureMemory;
mTextureMemory = (S32Bytes)getMipBytes(discard_level);
sGlobalTextureMemory += mTextureMemory;
if(gAuditTexture)
{
@@ -1829,14 +1829,14 @@ void LLImageGL::destroyGLTexture()
{
if (mTexName != 0)
{
if(mTextureMemory)
if(mTextureMemory != S32Bytes(0))
{
if(gAuditTexture)
{
decTextureCounter(mTextureMemory, mComponents, mCategory) ;
}
sGlobalTextureMemoryInBytes -= mTextureMemory;
mTextureMemory = 0;
sGlobalTextureMemory -= mTextureMemory;
mTextureMemory = (S32Bytes)0;
}
LLImageGL::deleteTextures(1, &mTexName);
@@ -2356,19 +2356,19 @@ S32 LLImageGL::getTextureCounterIndex(U32 val)
}
//static
void LLImageGL::incTextureCounter(U32 val, S32 ncomponents, S32 category)
void LLImageGL::incTextureCounter(S32Bytes val, S32 ncomponents, S32 category)
{
sTextureLoadedCounter[getTextureCounterIndex(val)]++ ;
sTextureLoadedCounter[getTextureCounterIndex(val.value())]++ ;
if(category > -1)
sTextureMemByCategory[category] += (S32)val * ncomponents ;
sTextureMemByCategory[category] += (S32Bytes)val * ncomponents ;
}
//static
void LLImageGL::decTextureCounter(U32 val, S32 ncomponents, S32 category)
void LLImageGL::decTextureCounter(S32Bytes val, S32 ncomponents, S32 category)
{
sTextureLoadedCounter[getTextureCounterIndex(val)]-- ;
sTextureLoadedCounter[getTextureCounterIndex(val.value())]-- ;
if(category > -1)
sTextureMemByCategory[category] -= (S32)val * ncomponents ;
sTextureMemByCategory[category] -= (S32Bytes)val * ncomponents ;
}
void LLImageGL::setCurTexSizebar(S32 index, BOOL set_pick_size)

View File

@@ -34,6 +34,7 @@
#include "llpointer.h"
#include "llrefcount.h"
#include "v2math.h"
#include "llunits.h"
#include "llrender.h"
@@ -55,7 +56,7 @@ public:
static S32 dataFormatBytes(S32 dataformat, S32 width, S32 height);
static S32 dataFormatComponents(S32 dataformat);
BOOL updateBindStats(S32 tex_mem) const ;
BOOL updateBindStats(S32Bytes tex_mem) const ;
F32 getTimePassedSinceLastBound();
void forceUpdateBindStats(void) const;
@@ -68,7 +69,7 @@ public:
static void dirtyTexOptions();
// Sometimes called externally for textures not using LLImageGL (should go away...)
static S32 updateBoundTexMem(const S32 mem, const S32 ncomponents, S32 category) ;
static S32 updateBoundTexMem(const S32Bytes mem, const S32 ncomponents, S32 category) ;
static bool checkSize(S32 width, S32 height);
@@ -172,7 +173,7 @@ public:
void setNeedsAlphaAndPickMask(BOOL need_mask);
public:
// Various GL/Rendering options
S32 mTextureMemory;
S32Bytes mTextureMemory;
mutable F32 mLastBindTime; // last time this was bound, by discard level
private:
@@ -228,9 +229,9 @@ public:
static F32 sLastFrameTime;
// Global memory statistics
static S32 sGlobalTextureMemoryInBytes; // Tracks main memory texmem
static S32 sBoundTextureMemoryInBytes; // Tracks bound texmem for last completed frame
static S32 sCurBoundTextureMemory; // Tracks bound texmem for current frame
static S32Bytes sGlobalTextureMemory; // Tracks main memory texmem
static S32Bytes sBoundTextureMemory; // Tracks bound texmem for last completed frame
static S32Bytes sCurBoundTextureMemory; // Tracks bound texmem for current frame
static U32 sBindCount; // Tracks number of texture binds for current frame
static U32 sUniqueCount; // Tracks number of unique texture binds for current frame
static BOOL sGlobalUseAnisotropic;
@@ -274,8 +275,8 @@ public:
static void setHighlightTexture(S32 category) ;
static S32 getTextureCounterIndex(U32 val) ;
static void incTextureCounter(U32 val, S32 ncomponents, S32 category) ;
static void decTextureCounter(U32 val, S32 ncomponents, S32 category) ;
static void incTextureCounter(S32Bytes val, S32 ncomponents, S32 category) ;
static void decTextureCounter(S32Bytes val, S32 ncomponents, S32 category) ;
static void setCurTexSizebar(S32 index, BOOL set_pick_size = TRUE) ;
static void resetCurTexSizebar();
//----------------------------------------
@@ -283,9 +284,9 @@ public:
//for debug use: show texture category distribution
//----------------------------------------
static std::vector<S32> sTextureMemByCategory;
static std::vector<S32> sTextureMemByCategoryBound ;
static std::vector<S32> sTextureCurMemByCategoryBound ;
static std::vector<S32Bytes> sTextureMemByCategory;
static std::vector<S32Bytes> sTextureMemByCategoryBound ;
static std::vector<S32Bytes> sTextureCurMemByCategoryBound ;
//----------------------------------------
// ****************************************************************************************************
//End of definitions for texture auditing use only

View File

@@ -187,7 +187,7 @@ volatile U8* LLVBOPool::allocate(U32& name, U32 size, bool for_seed)
if (LLVertexBuffer::sDisableVBOMapping || mUsage != GL_DYNAMIC_DRAW_ARB)
{
glBufferDataARB(mType, size, 0, mUsage);
ret = (U8*) ll_aligned_malloc(size, 64);
ret = (U8*) ll_aligned_malloc<64>(size);
}
else
{ //always use a true hint of static draw when allocating non-client-backed buffers
@@ -240,7 +240,7 @@ void LLVBOPool::release(U32 name, volatile U8* buffer, U32 size)
llassert(vbo_block_size(size) == size);
deleteBuffer(name);
ll_aligned_free((U8*) buffer);
ll_aligned_free<64>((U8*) buffer);
if (mType == GL_ARRAY_BUFFER_ARB)
{
@@ -294,7 +294,7 @@ void LLVBOPool::cleanup()
if (r.mClientData)
{
ll_aligned_free((void*) r.mClientData);
ll_aligned_free<64>((void*) r.mClientData);
}
l.pop_front();