Texture console now shows number of 'cached' raw images.
png loading now immediately dumps allocated data on failure
This commit is contained in:
@@ -248,16 +248,17 @@ U8* LLImageBase::allocateDataSize(S32 width, S32 height, S32 ncomponents, S32 si
|
|||||||
|
|
||||||
S32 LLImageRaw::sGlobalRawMemory = 0;
|
S32 LLImageRaw::sGlobalRawMemory = 0;
|
||||||
S32 LLImageRaw::sRawImageCount = 0;
|
S32 LLImageRaw::sRawImageCount = 0;
|
||||||
|
S32 LLImageRaw::sRawImageCachedCount = 0;
|
||||||
|
|
||||||
LLImageRaw::LLImageRaw()
|
LLImageRaw::LLImageRaw()
|
||||||
: LLImageBase()
|
: LLImageBase(), mCacheEntries(0)
|
||||||
{
|
{
|
||||||
mMemType = LLMemType::MTYPE_IMAGERAW;
|
mMemType = LLMemType::MTYPE_IMAGERAW;
|
||||||
++sRawImageCount;
|
++sRawImageCount;
|
||||||
}
|
}
|
||||||
|
|
||||||
LLImageRaw::LLImageRaw(U16 width, U16 height, S8 components)
|
LLImageRaw::LLImageRaw(U16 width, U16 height, S8 components)
|
||||||
: LLImageBase()
|
: LLImageBase(), mCacheEntries(0)
|
||||||
{
|
{
|
||||||
mMemType = LLMemType::MTYPE_IMAGERAW;
|
mMemType = LLMemType::MTYPE_IMAGERAW;
|
||||||
llassert( S32(width) * S32(height) * S32(components) <= MAX_IMAGE_DATA_SIZE );
|
llassert( S32(width) * S32(height) * S32(components) <= MAX_IMAGE_DATA_SIZE );
|
||||||
@@ -266,7 +267,7 @@ LLImageRaw::LLImageRaw(U16 width, U16 height, S8 components)
|
|||||||
}
|
}
|
||||||
|
|
||||||
LLImageRaw::LLImageRaw(U8 *data, U16 width, U16 height, S8 components)
|
LLImageRaw::LLImageRaw(U8 *data, U16 width, U16 height, S8 components)
|
||||||
: LLImageBase()
|
: LLImageBase(), mCacheEntries(0)
|
||||||
{
|
{
|
||||||
mMemType = LLMemType::MTYPE_IMAGERAW;
|
mMemType = LLMemType::MTYPE_IMAGERAW;
|
||||||
if(allocateDataSize(width, height, components) && data)
|
if(allocateDataSize(width, height, components) && data)
|
||||||
@@ -277,7 +278,7 @@ LLImageRaw::LLImageRaw(U8 *data, U16 width, U16 height, S8 components)
|
|||||||
}
|
}
|
||||||
|
|
||||||
LLImageRaw::LLImageRaw(const std::string& filename, bool j2c_lowest_mip_only)
|
LLImageRaw::LLImageRaw(const std::string& filename, bool j2c_lowest_mip_only)
|
||||||
: LLImageBase()
|
: LLImageBase(), mCacheEntries(0)
|
||||||
{
|
{
|
||||||
createFromFile(filename, j2c_lowest_mip_only);
|
createFromFile(filename, j2c_lowest_mip_only);
|
||||||
}
|
}
|
||||||
@@ -288,6 +289,7 @@ LLImageRaw::~LLImageRaw()
|
|||||||
// NOT LLImageRaw::deleteData()
|
// NOT LLImageRaw::deleteData()
|
||||||
deleteData();
|
deleteData();
|
||||||
--sRawImageCount;
|
--sRawImageCount;
|
||||||
|
setInCache(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
// virtual
|
// virtual
|
||||||
|
|||||||
@@ -243,6 +243,24 @@ protected:
|
|||||||
public:
|
public:
|
||||||
static S32 sGlobalRawMemory;
|
static S32 sGlobalRawMemory;
|
||||||
static S32 sRawImageCount;
|
static S32 sRawImageCount;
|
||||||
|
|
||||||
|
static S32 sRawImageCachedCount;
|
||||||
|
S32 mCacheEntries;
|
||||||
|
void setInCache(bool in_cache)
|
||||||
|
{
|
||||||
|
if(in_cache)
|
||||||
|
{
|
||||||
|
if(!mCacheEntries)
|
||||||
|
sRawImageCachedCount++;
|
||||||
|
mCacheEntries++;
|
||||||
|
}
|
||||||
|
else if(mCacheEntries)
|
||||||
|
{
|
||||||
|
mCacheEntries--;
|
||||||
|
if(!mCacheEntries)
|
||||||
|
sRawImageCachedCount--;
|
||||||
|
}
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
// Compressed representation of image.
|
// Compressed representation of image.
|
||||||
|
|||||||
@@ -131,6 +131,7 @@ BOOL LLImagePNG::encode(const LLImageRaw* raw_image, F32 encode_time)
|
|||||||
if (! pngWrapper.writePng(raw_image, getData()))
|
if (! pngWrapper.writePng(raw_image, getData()))
|
||||||
{
|
{
|
||||||
setLastError(pngWrapper.getErrorMessage());
|
setLastError(pngWrapper.getErrorMessage());
|
||||||
|
deleteData();
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -138,6 +139,7 @@ BOOL LLImagePNG::encode(const LLImageRaw* raw_image, F32 encode_time)
|
|||||||
if(!reallocateData(pngWrapper.getFinalSize())) //Shrink. Returns NULL on failure.
|
if(!reallocateData(pngWrapper.getFinalSize())) //Shrink. Returns NULL on failure.
|
||||||
{
|
{
|
||||||
setLastError("LLImagePNG::encode failed reallocateData");
|
setLastError("LLImagePNG::encode failed reallocateData");
|
||||||
|
deleteData();
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
return TRUE;
|
return TRUE;
|
||||||
|
|||||||
@@ -496,14 +496,14 @@ void LLGLTexMemBar::draw()
|
|||||||
#endif
|
#endif
|
||||||
//----------------------------------------------------------------------------
|
//----------------------------------------------------------------------------
|
||||||
|
|
||||||
text = llformat("Textures: %d Fetch: %d(%d) Pkts:%d(%d) Cache R/W: %d/%d LFS:%d IW:%d RAW:%d HTP:%d DEC:%d CRE:%d",
|
text = llformat("Textures: %d Fetch: %d(%d) Pkts:%d(%d) Cache R/W: %d/%d LFS:%d IW:%d RAW:%d(%d) HTP:%d DEC:%d CRE:%d ",
|
||||||
gTextureList.getNumImages(),
|
gTextureList.getNumImages(),
|
||||||
LLAppViewer::getTextureFetch()->getNumRequests(), LLAppViewer::getTextureFetch()->getNumDeletes(),
|
LLAppViewer::getTextureFetch()->getNumRequests(), LLAppViewer::getTextureFetch()->getNumDeletes(),
|
||||||
LLAppViewer::getTextureFetch()->mPacketCount, LLAppViewer::getTextureFetch()->mBadPacketCount,
|
LLAppViewer::getTextureFetch()->mPacketCount, LLAppViewer::getTextureFetch()->mBadPacketCount,
|
||||||
LLAppViewer::getTextureCache()->getNumReads(), LLAppViewer::getTextureCache()->getNumWrites(),
|
LLAppViewer::getTextureCache()->getNumReads(), LLAppViewer::getTextureCache()->getNumWrites(),
|
||||||
LLLFSThread::sLocal->getPending(),
|
LLLFSThread::sLocal->getPending(),
|
||||||
LLAppViewer::getImageDecodeThread()->getPending(),
|
LLAppViewer::getImageDecodeThread()->getPending(),
|
||||||
LLImageRaw::sRawImageCount,
|
LLImageRaw::sRawImageCount, LLImageRaw::sRawImageCachedCount,
|
||||||
LLAppViewer::getTextureFetch()->getNumHTTPRequests(),
|
LLAppViewer::getTextureFetch()->getNumHTTPRequests(),
|
||||||
LLAppViewer::getImageDecodeThread()->getPending(),
|
LLAppViewer::getImageDecodeThread()->getPending(),
|
||||||
gTextureList.mCreateTextureList.size());
|
gTextureList.mCreateTextureList.size());
|
||||||
@@ -511,7 +511,7 @@ void LLGLTexMemBar::draw()
|
|||||||
LLFontGL::getFontMonospace()->renderUTF8(text, 0, 0, line_height*2,
|
LLFontGL::getFontMonospace()->renderUTF8(text, 0, 0, line_height*2,
|
||||||
text_color, LLFontGL::LEFT, LLFontGL::TOP);
|
text_color, LLFontGL::LEFT, LLFontGL::TOP);
|
||||||
|
|
||||||
left = 650;
|
left += LLFontGL::getFontMonospace()->getWidth(text);
|
||||||
F32 bandwidth = LLAppViewer::getTextureFetch()->getTextureBandwidth();
|
F32 bandwidth = LLAppViewer::getTextureFetch()->getTextureBandwidth();
|
||||||
F32 max_bandwidth = gSavedSettings.getF32("ThrottleBandwidthKBPS");
|
F32 max_bandwidth = gSavedSettings.getF32("ThrottleBandwidthKBPS");
|
||||||
color = bandwidth > max_bandwidth ? LLColor4::red : bandwidth > max_bandwidth*.75f ? LLColor4::yellow : text_color;
|
color = bandwidth > max_bandwidth ? LLColor4::red : bandwidth > max_bandwidth*.75f ? LLColor4::yellow : text_color;
|
||||||
|
|||||||
@@ -1180,6 +1180,8 @@ void LLViewerFetchedTexture::init(bool firstinit)
|
|||||||
mForSculpt = FALSE ;
|
mForSculpt = FALSE ;
|
||||||
mIsFetched = FALSE ;
|
mIsFetched = FALSE ;
|
||||||
|
|
||||||
|
if(!firstinit && mCachedRawImage.notNull())
|
||||||
|
mCachedRawImage->setInCache(false);
|
||||||
mCachedRawImage = NULL ;
|
mCachedRawImage = NULL ;
|
||||||
mCachedRawDiscardLevel = -1 ;
|
mCachedRawDiscardLevel = -1 ;
|
||||||
mCachedRawImageReady = FALSE ;
|
mCachedRawImageReady = FALSE ;
|
||||||
@@ -1228,6 +1230,8 @@ void LLViewerFetchedTexture::cleanup()
|
|||||||
|
|
||||||
// Clean up image data
|
// Clean up image data
|
||||||
destroyRawImage();
|
destroyRawImage();
|
||||||
|
if(mCachedRawImage.notNull())
|
||||||
|
mCachedRawImage->setInCache(false);
|
||||||
mCachedRawImage = NULL ;
|
mCachedRawImage = NULL ;
|
||||||
mCachedRawDiscardLevel = -1 ;
|
mCachedRawDiscardLevel = -1 ;
|
||||||
mCachedRawImageReady = FALSE ;
|
mCachedRawImageReady = FALSE ;
|
||||||
@@ -1354,6 +1358,8 @@ void LLViewerFetchedTexture::addToCreateTexture()
|
|||||||
//discard the cached raw image and the saved raw image
|
//discard the cached raw image and the saved raw image
|
||||||
mCachedRawImageReady = FALSE ;
|
mCachedRawImageReady = FALSE ;
|
||||||
mCachedRawDiscardLevel = -1 ;
|
mCachedRawDiscardLevel = -1 ;
|
||||||
|
if(mCachedRawImage.notNull())
|
||||||
|
mCachedRawImage->setInCache(false);
|
||||||
mCachedRawImage = NULL ;
|
mCachedRawImage = NULL ;
|
||||||
mSavedRawDiscardLevel = -1 ;
|
mSavedRawDiscardLevel = -1 ;
|
||||||
mSavedRawImage = NULL ;
|
mSavedRawImage = NULL ;
|
||||||
@@ -2617,7 +2623,11 @@ void LLViewerFetchedTexture::setCachedRawImage(S32 discard_level, LLImageRaw* im
|
|||||||
{
|
{
|
||||||
if(imageraw != mRawImage.get())
|
if(imageraw != mRawImage.get())
|
||||||
{
|
{
|
||||||
|
if(mCachedRawImage.notNull())
|
||||||
|
mCachedRawImage->setInCache(false);
|
||||||
mCachedRawImage = imageraw ;
|
mCachedRawImage = imageraw ;
|
||||||
|
if(mCachedRawImage.notNull())
|
||||||
|
mCachedRawImage->setInCache(true);
|
||||||
mCachedRawDiscardLevel = discard_level ;
|
mCachedRawDiscardLevel = discard_level ;
|
||||||
mCachedRawImageReady = TRUE ;
|
mCachedRawImageReady = TRUE ;
|
||||||
}
|
}
|
||||||
@@ -2674,7 +2684,11 @@ void LLViewerFetchedTexture::setCachedRawImage()
|
|||||||
|
|
||||||
mRawImage->scale(w >> i, h >> i) ;
|
mRawImage->scale(w >> i, h >> i) ;
|
||||||
}
|
}
|
||||||
|
if(mCachedRawImage.notNull())
|
||||||
|
mCachedRawImage->setInCache(false);
|
||||||
mCachedRawImage = mRawImage ;
|
mCachedRawImage = mRawImage ;
|
||||||
|
if(mCachedRawImage.notNull())
|
||||||
|
mCachedRawImage->setInCache(true);
|
||||||
mRawDiscardLevel += i ;
|
mRawDiscardLevel += i ;
|
||||||
mCachedRawDiscardLevel = mRawDiscardLevel ;
|
mCachedRawDiscardLevel = mRawDiscardLevel ;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -495,6 +495,7 @@ private:
|
|||||||
|
|
||||||
void saveRawImage() ;
|
void saveRawImage() ;
|
||||||
void setCachedRawImage() ;
|
void setCachedRawImage() ;
|
||||||
|
void setCachedRawImagePtr(LLImageRaw *pRawImage) ;
|
||||||
|
|
||||||
//for atlas
|
//for atlas
|
||||||
/*void resetFaceAtlas() ;
|
/*void resetFaceAtlas() ;
|
||||||
|
|||||||
Reference in New Issue
Block a user