Update texturelist/volumetexture management with changes from upstream. Note: TEX_LIST_SCALE not utilized in singu... yet.

This commit is contained in:
Shyotl
2019-10-19 04:05:34 -05:00
parent 835083a741
commit 4043130f75
17 changed files with 379 additions and 187 deletions

View File

@@ -82,8 +82,25 @@ S32 LLViewerTextureList::sNumImages = 0;
LLViewerTextureList gTextureList;
static LLTrace::BlockTimerStatHandle FTM_PROCESS_IMAGES("Process Images");
ETexListType get_element_type(S32 priority)
{
return (priority == LLViewerFetchedTexture::BOOST_ICON) ? TEX_LIST_SCALE : TEX_LIST_STANDARD;
}
///////////////////////////////////////////////////////////////////////////////
LLTextureKey::LLTextureKey()
: textureId(LLUUID::null),
textureType(TEX_LIST_STANDARD)
{
}
LLTextureKey::LLTextureKey(LLUUID id, ETexListType tex_type)
: textureId(id), textureType(tex_type)
{
}
///////////////////////////////////////////////////////////////////////////////
LLViewerTextureList::LLViewerTextureList()
: mForceResetTextureStats(FALSE),
mUpdateStats(FALSE),
@@ -398,7 +415,8 @@ LLViewerFetchedTexture* LLViewerTextureList::getImageFromFile(const std::string&
if (full_path.empty() || (full && !gDirUtilp->fileExists(full_path)))
{
LL_WARNS() << "Failed to find local image file: " << filename << LL_ENDL;
return LLViewerTextureManager::getFetchedTexture(IMG_DEFAULT, FTT_DEFAULT, TRUE, LLGLTexture::BOOST_UI);
LLViewerTexture::EBoostLevel priority = LLGLTexture::BOOST_UI;
return LLViewerTextureManager::getFetchedTexture(IMG_DEFAULT, FTT_DEFAULT, TRUE, priority);
}
std::string url = "file://" + full_path;
@@ -438,16 +456,10 @@ LLViewerFetchedTexture* LLViewerTextureList::getImageFromUrl(const std::string&
new_id.generate(url);
}
LLPointer<LLViewerFetchedTexture> imagep = findImage(new_id);
LLPointer<LLViewerFetchedTexture> imagep = findImage(new_id, get_element_type(boost_priority));
if (!imagep.isNull())
{
if (boost_priority != LLViewerTexture::BOOST_ALM && imagep->getBoostLevel() == LLViewerTexture::BOOST_ALM)
{
// Workaround: we need BOOST_ALM texture for something, 'rise' to NONE
imagep->setBoostLevel(LLViewerTexture::BOOST_NONE);
}
LLViewerFetchedTexture *texture = imagep.get();
if (texture->getUrl().empty())
{
@@ -482,15 +494,21 @@ LLViewerFetchedTexture* LLViewerTextureList::getImageFromUrl(const std::string&
imagep->setExplicitFormat(internal_format, primary_format);
}
addImage(imagep);
addImage(imagep, get_element_type(boost_priority));
if (boost_priority != 0)
{
if (boost_priority == LLViewerFetchedTexture::BOOST_UI ||
boost_priority == LLViewerFetchedTexture::BOOST_ICON)
if (boost_priority == LLViewerFetchedTexture::BOOST_UI)
{
imagep->dontDiscard();
}
if (boost_priority == LLViewerFetchedTexture::BOOST_ICON)
{
// Agent and group Icons are downloadable content, nothing manages
// icon deletion yet, so they should not persist
imagep->dontDiscard();
imagep->forceActive();
}
imagep->setBoostLevel(boost_priority);
}
}
@@ -524,9 +542,15 @@ LLViewerFetchedTexture* LLViewerTextureList::getImage(const LLUUID &image_id,
return (LLViewerTextureManager::getFetchedTexture(IMG_DEFAULT, FTT_DEFAULT, TRUE, LLGLTexture::BOOST_UI));
}
LLPointer<LLViewerFetchedTexture> imagep = findImage(image_id);
LLPointer<LLViewerFetchedTexture> imagep = findImage(image_id, get_element_type(boost_priority));
if (!imagep.isNull())
{
if (boost_priority != LLViewerTexture::BOOST_ALM && imagep->getBoostLevel() == LLViewerTexture::BOOST_ALM)
{
// Workaround: we need BOOST_ALM texture for something, 'rise' to NONE
imagep->setBoostLevel(LLViewerTexture::BOOST_NONE);
}
LLViewerFetchedTexture *texture = imagep.get();
if (request_from_host.isOk() &&
!texture->getTargetHost().isOk())
@@ -583,16 +607,22 @@ LLViewerFetchedTexture* LLViewerTextureList::createImage(const LLUUID &image_id,
{
imagep->setExplicitFormat(internal_format, primary_format);
}
addImage(imagep);
addImage(imagep, get_element_type(boost_priority));
if (boost_priority != 0)
{
if (boost_priority == LLViewerFetchedTexture::BOOST_UI ||
boost_priority == LLViewerFetchedTexture::BOOST_ICON)
if (boost_priority == LLViewerFetchedTexture::BOOST_UI)
{
imagep->dontDiscard();
}
if (boost_priority == LLViewerFetchedTexture::BOOST_ICON)
{
// Agent and group Icons are downloadable content, nothing manages
// icon deletion yet, so they should not persist.
imagep->dontDiscard();
imagep->forceActive();
}
imagep->setBoostLevel(boost_priority);
}
else
@@ -606,13 +636,29 @@ LLViewerFetchedTexture* LLViewerTextureList::createImage(const LLUUID &image_id,
return imagep ;
}
LLViewerFetchedTexture *LLViewerTextureList::findImage(const LLUUID &image_id)
void LLViewerTextureList::findTexturesByID(const LLUUID &image_id, std::vector<LLViewerFetchedTexture*> &output)
{
LLTextureKey search_key(image_id, TEX_LIST_STANDARD);
uuid_map_t::iterator iter = mUUIDMap.lower_bound(search_key);
while (iter != mUUIDMap.end() && iter->first.textureId == image_id)
{
output.push_back(iter->second);
iter++;
}
}
LLViewerFetchedTexture *LLViewerTextureList::findImage(const LLTextureKey &search_key)
{
// Singu note: Reworked hotspot
const auto& iter = mUUIDDict.find(image_id);
const auto& iter = mUUIDDict.find(search_key);
if(iter == mUUIDDict.end())
return NULL;
return iter->second;
return iter->second;
}
LLViewerFetchedTexture *LLViewerTextureList::findImage(const LLUUID &image_id, ETexListType tex_type)
{
return findImage(LLTextureKey(image_id, tex_type));
}
void LLViewerTextureList::addImageToList(LLViewerFetchedTexture *image)
@@ -657,7 +703,7 @@ void LLViewerTextureList::removeImageFromList(LLViewerFetchedTexture *image)
<< " but doesn't have mInImageList set"
<< " ref count is " << image->getNumRefs()
<< LL_ENDL;
const auto& iter = mUUIDDict.find(image->getID());
const auto& iter = mUUIDDict.find(LLTextureKey(image->getID(), (ETexListType)image->getTextureListType()));
if(iter == mUUIDDict.end())
{
LL_INFOS() << "Image " << image->getID() << " is also not in mUUIDMap!" << LL_ENDL ;
@@ -682,7 +728,7 @@ void LLViewerTextureList::removeImageFromList(LLViewerFetchedTexture *image)
image->setInImageList(FALSE) ;
}
void LLViewerTextureList::addImage(LLViewerFetchedTexture *new_image)
void LLViewerTextureList::addImage(LLViewerFetchedTexture *new_image, ETexListType tex_type)
{
if (!new_image)
{
@@ -690,8 +736,9 @@ void LLViewerTextureList::addImage(LLViewerFetchedTexture *new_image)
return;
}
LLUUID image_id = new_image->getID();
LLTextureKey key(image_id, tex_type);
LLViewerFetchedTexture *image = findImage(image_id);
LLViewerFetchedTexture *image = findImage(key);
if (image)
{
LL_INFOS() << "Image with ID " << image_id << " already in list" << LL_ENDL;
@@ -699,12 +746,13 @@ void LLViewerTextureList::addImage(LLViewerFetchedTexture *new_image)
sNumImages++;
addImageToList(new_image);
auto ret_pair = mUUIDMap.emplace(image_id, new_image);
auto ret_pair = mUUIDMap.emplace(key, new_image);
if (!ret_pair.second)
{
ret_pair.first->second = new_image;
}
mUUIDDict.insert_or_assign(image_id, new_image);
mUUIDDict.insert_or_assign(key, new_image);
new_image->setTextureListType(tex_type);
}
@@ -717,9 +765,9 @@ void LLViewerTextureList::deleteImage(LLViewerFetchedTexture *image)
mCallbackList.erase(image);
}
const LLUUID& id = image->getID();
llverify(mUUIDMap.erase(id) == 1);
llverify(mUUIDDict.erase(id) == 1);
const LLTextureKey key(image->getID(), (ETexListType)image->getTextureListType());
llverify(mUUIDMap.erase(key) == 1);
llverify(mUUIDDict.erase(key) == 1);
sNumImages--;
removeImageFromList(image);
}
@@ -866,14 +914,14 @@ void LLViewerTextureList::updateImagesDecodePriorities()
static const S32 MAX_PRIO_UPDATES = gSavedSettings.getS32("TextureFetchUpdatePriorities"); // default: 32
const size_t max_update_count = llmin((S32) (MAX_PRIO_UPDATES*MAX_PRIO_UPDATES*gFrameIntervalSeconds) + 1, MAX_PRIO_UPDATES);
S32 update_counter = llmin(max_update_count, mUUIDMap.size());
uuid_map_t::iterator iter = mUUIDMap.upper_bound(mLastUpdateUUID);
uuid_map_t::iterator iter = mUUIDMap.upper_bound(mLastUpdateKey);
while ((update_counter-- > 0) && !mUUIDMap.empty())
{
if (iter == mUUIDMap.end())
{
iter = mUUIDMap.begin();
}
mLastUpdateUUID = iter->first;
mLastUpdateKey = iter->first;
LLPointer<LLViewerFetchedTexture> imagep = iter->second;
++iter; // safe to incrament now
@@ -1065,7 +1113,7 @@ F32 LLViewerTextureList::updateImagesFetchTextures(F32 max_time)
update_counter = max_update_count;
if(update_counter > 0)
{
uuid_map_t::iterator iter2 = mUUIDMap.upper_bound(mLastFetchUUID);
uuid_map_t::iterator iter2 = mUUIDMap.upper_bound(mLastFetchKey);
while ((update_counter > 0) && (total_update_count > 0))
{
if (iter2 == mUUIDMap.end())
@@ -1095,7 +1143,7 @@ F32 LLViewerTextureList::updateImagesFetchTextures(F32 max_time)
fetch_count += (imagep->updateFetch() ? 1 : 0);
if (min_count <= (S32)min_update_count)
{
mLastFetchUUID = imagep->getID();
mLastFetchKey = LLTextureKey(imagep->getID(), (ETexListType)imagep->getTextureListType());
}
if ((min_count-- <= 0) && (image_op_timer.getElapsedTimeF32() > max_time))
{
@@ -1556,14 +1604,22 @@ void LLViewerTextureList::processImageNotInDatabase(LLMessageSystem *msg,void **
LLUUID image_id;
msg->getUUIDFast(_PREHASH_ImageID, _PREHASH_ID, image_id);
LLViewerFetchedTexture* image = gTextureList.findImage( image_id );
LLViewerFetchedTexture* image = gTextureList.findImage( image_id, TEX_LIST_STANDARD);
if( image )
{
LL_WARNS() << "not in db" << LL_ENDL;
LL_WARNS() << "Image not in db" << LL_ENDL;
image->setIsMissingAsset();
}
image = gTextureList.findImage(image_id, TEX_LIST_SCALE);
if (image)
{
LL_WARNS() << "Icon not in db" << LL_ENDL;
image->setIsMissingAsset();
}
}
///////////////////////////////////////////////////////////////////////////////
// explicitly cleanup resources, as this is a singleton class with process
@@ -1642,13 +1698,18 @@ LLUIImagePtr LLUIImageList::loadUIImage(LLViewerFetchedTexture* imagep, const st
//don't compress UI images
imagep->getGLTexture()->setAllowCompression(false);
//all UI images are non-deletable
imagep->setNoDelete();
LLUIImagePtr new_imagep = new LLUIImage(name, imagep);
new_imagep->setScaleStyle(scale_style);
mUIImages.insert(std::make_pair(name, new_imagep));
mUITextureList.push_back(imagep);
if (imagep->getBoostLevel() != LLGLTexture::BOOST_ICON &&
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
imagep->setNoDelete();
mUIImages.insert(std::make_pair(name, new_imagep));
mUITextureList.push_back(imagep);
}
//Note:
//Some other textures such as ICON also through this flow to be fetched.