Skip to content

Commit

Permalink
SL-20411 Thumbnail textures should have less of an impact on performa…
Browse files Browse the repository at this point in the history
…nce #1

scale thumbnail textures down to 256 when needed. As we do to chat icons.
  • Loading branch information
akleshchev committed Oct 9, 2023
1 parent 683e96e commit c1c5275
Show file tree
Hide file tree
Showing 6 changed files with 83 additions and 23 deletions.
3 changes: 2 additions & 1 deletion indra/llrender/llgltexture.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,8 @@ void LLGLTexture::setBoostLevel(S32 level)
{
mBoostLevel = level ;
if(mBoostLevel != LLGLTexture::BOOST_NONE
&& mBoostLevel != LLGLTexture::BOOST_ICON)
&& mBoostLevel != LLGLTexture::BOOST_ICON
&& mBoostLevel != LLGLTexture::BOOST_THUMBNAIL)
{
setNoDelete() ;
}
Expand Down
1 change: 1 addition & 0 deletions indra/llrender/llgltexture.h
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ class LLGLTexture : public LLTexture
BOOST_SUPER_HIGH , //textures higher than this need to be downloaded at the required resolution without delay.
BOOST_HUD ,
BOOST_ICON ,
BOOST_THUMBNAIL ,
BOOST_UI ,
BOOST_PREVIEW ,
BOOST_MAP ,
Expand Down
4 changes: 1 addition & 3 deletions indra/newview/llthumbnailctrl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,6 @@ LLThumbnailCtrl::LLThumbnailCtrl(const LLThumbnailCtrl::Params& p)
, mFallbackImagep(p.fallback_image)
, mInteractable(p.interactable())
, mShowLoadingPlaceholder(p.show_loading())
, mPriority(LLGLTexture::BOOST_PREVIEW)
{
mLoadingPlaceholderString = LLTrans::getString("texture_loading");

Expand Down Expand Up @@ -201,9 +200,8 @@ void LLThumbnailCtrl::setValue(const LLSD& value)
if (mImageAssetID.notNull())
{
// Should it support baked textures?
mTexturep = LLViewerTextureManager::getFetchedTexture(mImageAssetID, FTT_DEFAULT, MIPMAP_YES, LLGLTexture::BOOST_NONE, LLViewerTexture::LOD_TEXTURE);
mTexturep = LLViewerTextureManager::getFetchedTexture(mImageAssetID, FTT_DEFAULT, MIPMAP_YES, LLGLTexture::BOOST_THUMBNAIL);

mTexturep->setBoostLevel(mPriority);
mTexturep->forceToSaveRawImage(0);

S32 desired_draw_width = mTexturep->getWidth();
Expand Down
1 change: 0 additions & 1 deletion indra/newview/llthumbnailctrl.h
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,6 @@ class LLThumbnailCtrl
virtual BOOL handleHover(S32 x, S32 y, MASK mask) override;

private:
S32 mPriority;
bool mBorderVisible;
bool mInteractable;
bool mShowLoadingPlaceholder;
Expand Down
84 changes: 71 additions & 13 deletions indra/newview/llviewertexture.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,8 @@ S32 LLViewerTexture::sMaxSculptRez = 128; //max sculpt image size
const S32 MAX_CACHED_RAW_IMAGE_AREA = 64 * 64;
const S32 MAX_CACHED_RAW_SCULPT_IMAGE_AREA = LLViewerTexture::sMaxSculptRez * LLViewerTexture::sMaxSculptRez;
const S32 MAX_CACHED_RAW_TERRAIN_IMAGE_AREA = 128 * 128;
const S32 DEFAULT_ICON_DIMENTIONS = 32;
const S32 DEFAULT_ICON_DIMENSIONS = 32;
const S32 DEFAULT_THUMBNAIL_DIMENSIONS = 256;
U32 LLViewerTexture::sMinLargeImageSize = 65536; //256 * 256.
U32 LLViewerTexture::sMaxSmallImageSize = MAX_CACHED_RAW_IMAGE_AREA;
bool LLViewerTexture::sFreezeImageUpdates = false;
Expand Down Expand Up @@ -729,7 +730,8 @@ void LLViewerTexture::setBoostLevel(S32 level)
if(mBoostLevel != LLViewerTexture::BOOST_NONE &&
mBoostLevel != LLViewerTexture::BOOST_ALM &&
mBoostLevel != LLViewerTexture::BOOST_SELECTED &&
mBoostLevel != LLViewerTexture::BOOST_ICON)
mBoostLevel != LLViewerTexture::BOOST_ICON &&
mBoostLevel != LLViewerTexture::BOOST_THUMBNAIL)
{
setNoDelete();
}
Expand Down Expand Up @@ -1239,8 +1241,19 @@ void LLViewerFetchedTexture::loadFromFastCache()
{
// Shouldn't do anything usefull since texures in fast cache are 16x16,
// it is here in case fast cache changes.
S32 expected_width = mKnownDrawWidth > 0 ? mKnownDrawWidth : DEFAULT_ICON_DIMENTIONS;
S32 expected_height = mKnownDrawHeight > 0 ? mKnownDrawHeight : DEFAULT_ICON_DIMENTIONS;
S32 expected_width = mKnownDrawWidth > 0 ? mKnownDrawWidth : DEFAULT_ICON_DIMENSIONS;
S32 expected_height = mKnownDrawHeight > 0 ? mKnownDrawHeight : DEFAULT_ICON_DIMENSIONS;
if (mRawImage && (mRawImage->getWidth() > expected_width || mRawImage->getHeight() > expected_height))
{
// scale oversized icon, no need to give more work to gl
mRawImage->scale(expected_width, expected_height);
}
}

if (mBoostLevel == LLGLTexture::BOOST_THUMBNAIL)
{
S32 expected_width = mKnownDrawWidth > 0 ? mKnownDrawWidth : DEFAULT_THUMBNAIL_DIMENSIONS;
S32 expected_height = mKnownDrawHeight > 0 ? mKnownDrawHeight : DEFAULT_THUMBNAIL_DIMENSIONS;
if (mRawImage && (mRawImage->getWidth() > expected_width || mRawImage->getHeight() > expected_height))
{
// scale oversized icon, no need to give more work to gl
Expand Down Expand Up @@ -1723,7 +1736,7 @@ void LLViewerFetchedTexture::processTextureStats()
{
mDesiredDiscardLevel = MAX_DISCARD_LEVEL + 1;
}
else if (mDontDiscard && mBoostLevel == LLGLTexture::BOOST_ICON)
else if (mDontDiscard && (mBoostLevel == LLGLTexture::BOOST_ICON || mBoostLevel == LLGLTexture::BOOST_THUMBNAIL))
{
if (mFullWidth > MAX_IMAGE_SIZE_DEFAULT || mFullHeight > MAX_IMAGE_SIZE_DEFAULT)
{
Expand Down Expand Up @@ -1826,7 +1839,10 @@ F32 LLViewerFetchedTexture::calcDecodePriority()
// Don't decode anything we don't need
priority = -4.0f;
}
else if ((mBoostLevel == LLGLTexture::BOOST_UI || mBoostLevel == LLGLTexture::BOOST_ICON) && !have_all_data)
else if ((mBoostLevel == LLGLTexture::BOOST_UI
|| mBoostLevel == LLGLTexture::BOOST_ICON
|| mBoostLevel == LLGLTexture::BOOST_THUMBNAIL)
&& !have_all_data)
{
priority = 1.f;
}
Expand Down Expand Up @@ -2173,8 +2189,20 @@ bool LLViewerFetchedTexture::updateFetch()

if (mBoostLevel == LLGLTexture::BOOST_ICON)
{
S32 expected_width = mKnownDrawWidth > 0 ? mKnownDrawWidth : DEFAULT_ICON_DIMENTIONS;
S32 expected_height = mKnownDrawHeight > 0 ? mKnownDrawHeight : DEFAULT_ICON_DIMENTIONS;
S32 expected_width = mKnownDrawWidth > 0 ? mKnownDrawWidth : DEFAULT_ICON_DIMENSIONS;
S32 expected_height = mKnownDrawHeight > 0 ? mKnownDrawHeight : DEFAULT_ICON_DIMENSIONS;
if (mRawImage && (mRawImage->getWidth() > expected_width || mRawImage->getHeight() > expected_height))
{
// scale oversized icon, no need to give more work to gl
// since we got mRawImage from thread worker and image may be in use (ex: writing cache), make a copy
mRawImage = mRawImage->scaled(expected_width, expected_height);
}
}

if (mBoostLevel == LLGLTexture::BOOST_THUMBNAIL)
{
S32 expected_width = mKnownDrawWidth > 0 ? mKnownDrawWidth : DEFAULT_THUMBNAIL_DIMENSIONS;
S32 expected_height = mKnownDrawHeight > 0 ? mKnownDrawHeight : DEFAULT_THUMBNAIL_DIMENSIONS;
if (mRawImage && (mRawImage->getWidth() > expected_width || mRawImage->getHeight() > expected_height))
{
// scale oversized icon, no need to give more work to gl
Expand Down Expand Up @@ -2920,7 +2948,9 @@ LLImageRaw* LLViewerFetchedTexture::reloadRawImage(S8 discard_level)

if(mSavedRawDiscardLevel >= 0 && mSavedRawDiscardLevel <= discard_level)
{
if (mSavedRawDiscardLevel != discard_level && mBoostLevel != BOOST_ICON)
if (mSavedRawDiscardLevel != discard_level
&& mBoostLevel != BOOST_ICON
&& mBoostLevel != BOOST_THUMBNAIL)
{
mRawImage = new LLImageRaw(getWidth(discard_level), getHeight(discard_level), getComponents());
mRawImage->copy(getSavedRawImage());
Expand Down Expand Up @@ -3026,8 +3056,22 @@ void LLViewerFetchedTexture::setCachedRawImage(S32 discard_level, LLImageRaw* im
{
if (mBoostLevel == LLGLTexture::BOOST_ICON)
{
S32 expected_width = mKnownDrawWidth > 0 ? mKnownDrawWidth : DEFAULT_ICON_DIMENTIONS;
S32 expected_height = mKnownDrawHeight > 0 ? mKnownDrawHeight : DEFAULT_ICON_DIMENTIONS;
S32 expected_width = mKnownDrawWidth > 0 ? mKnownDrawWidth : DEFAULT_ICON_DIMENSIONS;
S32 expected_height = mKnownDrawHeight > 0 ? mKnownDrawHeight : DEFAULT_ICON_DIMENSIONS;
if (mRawImage->getWidth() > expected_width || mRawImage->getHeight() > expected_height)
{
mCachedRawImage = new LLImageRaw(expected_width, expected_height, imageraw->getComponents());
mCachedRawImage->copyScaled(imageraw);
}
else
{
mCachedRawImage = imageraw;
}
}
else if (mBoostLevel == LLGLTexture::BOOST_THUMBNAIL)
{
S32 expected_width = mKnownDrawWidth > 0 ? mKnownDrawWidth : DEFAULT_THUMBNAIL_DIMENSIONS;
S32 expected_height = mKnownDrawHeight > 0 ? mKnownDrawHeight : DEFAULT_THUMBNAIL_DIMENSIONS;
if (mRawImage->getWidth() > expected_width || mRawImage->getHeight() > expected_height)
{
mCachedRawImage = new LLImageRaw(expected_width, expected_height, imageraw->getComponents());
Expand Down Expand Up @@ -3132,8 +3176,22 @@ void LLViewerFetchedTexture::saveRawImage()
mSavedRawDiscardLevel = mRawDiscardLevel;
if (mBoostLevel == LLGLTexture::BOOST_ICON)
{
S32 expected_width = mKnownDrawWidth > 0 ? mKnownDrawWidth : DEFAULT_ICON_DIMENTIONS;
S32 expected_height = mKnownDrawHeight > 0 ? mKnownDrawHeight : DEFAULT_ICON_DIMENTIONS;
S32 expected_width = mKnownDrawWidth > 0 ? mKnownDrawWidth : DEFAULT_ICON_DIMENSIONS;
S32 expected_height = mKnownDrawHeight > 0 ? mKnownDrawHeight : DEFAULT_ICON_DIMENSIONS;
if (mRawImage->getWidth() > expected_width || mRawImage->getHeight() > expected_height)
{
mSavedRawImage = new LLImageRaw(expected_width, expected_height, mRawImage->getComponents());
mSavedRawImage->copyScaled(mRawImage);
}
else
{
mSavedRawImage = new LLImageRaw(mRawImage->getData(), mRawImage->getWidth(), mRawImage->getHeight(), mRawImage->getComponents());
}
}
else if (mBoostLevel == LLGLTexture::BOOST_THUMBNAIL)
{
S32 expected_width = mKnownDrawWidth > 0 ? mKnownDrawWidth : DEFAULT_THUMBNAIL_DIMENSIONS;
S32 expected_height = mKnownDrawHeight > 0 ? mKnownDrawHeight : DEFAULT_THUMBNAIL_DIMENSIONS;
if (mRawImage->getWidth() > expected_width || mRawImage->getHeight() > expected_height)
{
mSavedRawImage = new LLImageRaw(expected_width, expected_height, mRawImage->getComponents());
Expand Down
13 changes: 8 additions & 5 deletions indra/newview/llviewertexturelist.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ LLViewerTextureList gTextureList;

ETexListType get_element_type(S32 priority)
{
return (priority == LLViewerFetchedTexture::BOOST_ICON) ? TEX_LIST_SCALE : TEX_LIST_STANDARD;
return (priority == LLViewerFetchedTexture::BOOST_ICON || priority == LLViewerFetchedTexture::BOOST_THUMBNAIL) ? TEX_LIST_SCALE : TEX_LIST_STANDARD;
}

///////////////////////////////////////////////////////////////////////////////
Expand Down Expand Up @@ -498,7 +498,8 @@ LLViewerFetchedTexture* LLViewerTextureList::getImageFromUrl(const std::string&
{
imagep->dontDiscard();
}
if (boost_priority == LLViewerFetchedTexture::BOOST_ICON)
if (boost_priority == LLViewerFetchedTexture::BOOST_ICON
|| boost_priority == LLViewerFetchedTexture::BOOST_THUMBNAIL)
{
// Agent and group Icons are downloadable content, nothing manages
// icon deletion yet, so they should not persist
Expand Down Expand Up @@ -615,7 +616,8 @@ LLViewerFetchedTexture* LLViewerTextureList::createImage(const LLUUID &image_id,
{
imagep->dontDiscard();
}
if (boost_priority == LLViewerFetchedTexture::BOOST_ICON)
if (boost_priority == LLViewerFetchedTexture::BOOST_ICON
|| boost_priority == LLViewerFetchedTexture::BOOST_THUMBNAIL)
{
// Agent and group Icons are downloadable content, nothing manages
// icon deletion yet, so they should not persist.
Expand Down Expand Up @@ -1696,8 +1698,9 @@ LLUIImagePtr LLUIImageList::loadUIImage(LLViewerFetchedTexture* imagep, const st
LLUIImagePtr new_imagep = new LLUIImage(name, imagep);
new_imagep->setScaleStyle(scale_style);

if (imagep->getBoostLevel() != LLGLTexture::BOOST_ICON &&
imagep->getBoostLevel() != LLGLTexture::BOOST_PREVIEW)
if (imagep->getBoostLevel() != LLGLTexture::BOOST_ICON
&& imagep->getBoostLevel() != LLGLTexture::BOOST_THUMBNAIL
&& imagep->getBoostLevel() != LLGLTexture::BOOST_PREVIEW)
{
// Don't add downloadable content into this list
// all UI images are non-deletable and list does not support deletion
Expand Down

0 comments on commit c1c5275

Please sign in to comment.