SH-3344 WIP - keep avatar local textures flagged no-delete while in use

master
Brad Payne (Vir Linden) 2013-01-07 18:31:28 -05:00
parent 81e759dde0
commit 4e1eda1c3b
5 changed files with 127 additions and 37 deletions

View File

@ -616,7 +616,7 @@ LLViewerTexture::LLViewerTexture(const LLImageRaw* raw, BOOL usemipmaps) :
LLViewerTexture::~LLViewerTexture()
{
// LL_DEBUGS("Avatar") << mID << llendl;
LL_DEBUGS("Avatar") << mID << llendl;
cleanup();
sImageCount--;
}
@ -1160,7 +1160,8 @@ void LLViewerFetchedTexture::destroyTexture()
{
return ;
}
LL_DEBUGS("Avatar") << mID << llendl;
destroyGLTexture() ;
mFullyLoaded = FALSE ;
}

View File

@ -4004,8 +4004,81 @@ U32 LLVOAvatar::renderImpostor(LLColor4U color, S32 diffuse_channel)
//------------------------------------------------------------------------
// LLVOAvatar::updateTextures()
//------------------------------------------------------------------------
void LLVOAvatar::collectTextureUUIDs(std::set<LLUUID>& ids, S32& local_mem, S32& baked_mem)
{
for (U32 texture_index = 0; texture_index < getNumTEs(); texture_index++)
{
LLWearableType::EType wearable_type = LLAvatarAppearanceDictionary::getTEWearableType((ETextureIndex)texture_index);
U32 num_wearables = gAgentWearables.getWearableCount(wearable_type);
LLViewerFetchedTexture *imagep = NULL;
for (U32 wearable_index = 0; wearable_index < num_wearables; wearable_index++)
{
imagep = LLViewerTextureManager::staticCastToFetchedTexture(getImage(texture_index, wearable_index), TRUE);
if (imagep)
{
const LLAvatarAppearanceDictionary::TextureEntry *texture_dict = LLAvatarAppearanceDictionary::getInstance()->getTexture((ETextureIndex)texture_index);
if (texture_dict->mIsLocalTexture)
{
local_mem += imagep->getTextureMemory();
ids.insert(imagep->getID());
}
}
}
if (isIndexBakedTexture((ETextureIndex) texture_index))
{
imagep = LLViewerTextureManager::staticCastToFetchedTexture(getImage(texture_index,0), TRUE);
if (imagep)
{
baked_mem += imagep->getTextureMemory();
ids.insert(imagep->getID());
}
}
}
ids.erase(IMG_DEFAULT);
ids.erase(IMG_DEFAULT_AVATAR);
ids.erase(IMG_INVISIBLE);
}
void LLVOAvatar::releaseOldTextures()
{
S32 current_texture_mem = 0;
// Any textures that we used to be using but are no longer using should no longer be flagged as "NO_DELETE"
std::set<LLUUID> new_texture_ids;
S32 local_mem = 0, baked_mem = 0;
collectTextureUUIDs(new_texture_ids, local_mem, baked_mem);
LL_DEBUGS("Avatar") << getFullname() << " local_mem: " << local_mem << " baked_mem: " << baked_mem << llendl;
for (std::set<LLUUID>::iterator it = mTextureIDs.begin(); it != mTextureIDs.end(); ++it)
{
if (new_texture_ids.find(*it) == new_texture_ids.end())
{
LLViewerFetchedTexture *imagep = gTextureList.findImage(*it);
if (imagep)
{
current_texture_mem += imagep->getTextureMemory();
if (imagep->getTextureState() == LLGLTexture::NO_DELETE)
{
// This will allow the texture to be deleted if not in use.
imagep->forceActive();
// This resets the clock to being flagged as
// unused, preventing the texture from being
// deleted immediately. If other avatars or
// objects are using it, it can still be flagged
// no-delete by them.
imagep->forceUpdateBindStats();
}
}
}
}
mTextureIDs = new_texture_ids;
}
void LLVOAvatar::updateTextures()
{
releaseOldTextures();
BOOL render_avatar = TRUE;
if (mIsDummy)

View File

@ -134,6 +134,8 @@ public:
BOOL updateJointLODs();
void updateLODRiggedAttachments( void );
/*virtual*/ BOOL isActive() const; // Whether this object needs to do an idleUpdate.
void collectTextureUUIDs(std::set<LLUUID>& ids, S32& local_mem, S32& baked_mem);
void releaseOldTextures();
/*virtual*/ void updateTextures();
/*virtual*/ S32 setTETexture(const U8 te, const LLUUID& uuid); // If setting a baked texture, need to request it from a non-local sim.
/*virtual*/ void onShift(const LLVector4a& shift_vector);
@ -528,6 +530,7 @@ protected:
LLLoadedCallbackEntry::source_callback_list_t mCallbackTextureList ;
BOOL mLoadedCallbacksPaused;
std::set<LLUUID> mTextureIDs;
//--------------------------------------------------------------------
// Local Textures
//--------------------------------------------------------------------

View File

@ -177,7 +177,7 @@ LLVOAvatarSelf::LLVOAvatarSelf(const LLUUID& id,
}
// Called periodically for diagnostics, return true when done.
bool output_texture_diagnostics()
bool output_self_av_texture_diagnostics()
{
if (!isAgentAvatarValid())
return true; // done checking
@ -221,7 +221,7 @@ void LLVOAvatarSelf::initInstance()
return;
}
//doPeriodically(output_texture_diagnostics, 30.0);
doPeriodically(output_self_av_texture_diagnostics, 30.0);
}
// virtual
@ -2039,14 +2039,15 @@ const std::string LLVOAvatarSelf::verboseDebugDumpLocalTextureDataInfo(const LLV
++local_tex_iter)
{
const ETextureIndex tex_index = *local_tex_iter;
outbuf << " tex_index " << (S32) tex_index << "\n";
const std::string tex_name = LLAvatarAppearanceDictionary::getInstance()->getTexture(tex_index)->mName;
outbuf << " tex_index " << (S32) tex_index << " name " << tex_name << "\n";
const LLWearableType::EType wearable_type = LLAvatarAppearanceDictionary::getTEWearableType(tex_index);
const U32 wearable_count = gAgentWearables.getWearableCount(wearable_type);
if (wearable_count > 0)
{
for (U32 wearable_index = 0; wearable_index < wearable_count; wearable_index++)
{
outbuf << " " << LLWearableType::getTypeName(wearable_type) << " " << wearable_index << "\n";
outbuf << " " << LLWearableType::getTypeName(wearable_type) << " " << wearable_index << ":";
const LLLocalTextureObject *local_tex_obj = getLocalTextureObject(tex_index, wearable_index);
if (local_tex_obj)
{
@ -2055,7 +2056,7 @@ const std::string LLVOAvatarSelf::verboseDebugDumpLocalTextureDataInfo(const LLV
&& local_tex_obj->getID() != IMG_DEFAULT_AVATAR
&& !image->isMissingAsset())
{
outbuf << " id: " << image->getID()
outbuf << " id: " << image->getID()
<< " refs: " << image->getNumRefs()
<< " glocdisc: " << getLocalDiscardLevel(tex_index, wearable_index)
<< " discard: " << image->getDiscardLevel()
@ -2067,9 +2068,10 @@ const std::string LLVOAvatarSelf::verboseDebugDumpLocalTextureDataInfo(const LLV
<< " fl: " << image->isFullyLoaded() // this is not an accessor for mFullyLoaded - see comment there.
<< " mvs: " << image->getMaxVirtualSize()
<< " mvsc: " << image->getMaxVirtualSizeResetCounter()
<< "\n";
<< " mem: " << image->getTextureMemory();
}
}
outbuf << "\n";
}
}
}
@ -2079,6 +2081,23 @@ const std::string LLVOAvatarSelf::verboseDebugDumpLocalTextureDataInfo(const LLV
return outbuf.str();
}
void LLVOAvatarSelf::dumpAllTextures() const
{
std::string vd_text = "Local textures per baked index and wearable:\n";
for (LLAvatarAppearanceDefines::LLAvatarAppearanceDictionary::BakedTextures::const_iterator baked_iter = LLAvatarAppearanceDefines::LLAvatarAppearanceDictionary::getInstance()->getBakedTextures().begin();
baked_iter != LLAvatarAppearanceDefines::LLAvatarAppearanceDictionary::getInstance()->getBakedTextures().end();
++baked_iter)
{
const LLAvatarAppearanceDefines::EBakedTextureIndex baked_index = baked_iter->first;
const LLViewerTexLayerSet *layerset = debugGetLayerSet(baked_index);
if (!layerset) continue;
const LLViewerTexLayerSetBuffer *layerset_buffer = layerset->getViewerComposite();
if (!layerset_buffer) continue;
vd_text += verboseDebugDumpLocalTextureDataInfo(layerset);
}
LL_DEBUGS("Avatar") << vd_text << llendl;
}
const std::string LLVOAvatarSelf::debugDumpLocalTextureDataInfo(const LLViewerTexLayerSet* layerset) const
{
std::string text="";
@ -2348,24 +2367,28 @@ void LLVOAvatarSelf::addLocalTextureStats( ETextureIndex type, LLViewerFetchedTe
{
if (!isIndexLocalTexture(type)) return;
if (getLocalTextureID(type, index) != IMG_DEFAULT_AVATAR && imagep->getDiscardLevel() != 0)
if (getLocalTextureID(type, index) != IMG_DEFAULT_AVATAR)
{
F32 desired_pixels;
desired_pixels = llmin(mPixelArea, (F32)getTexImageArea());
imagep->setNoDelete();
if (imagep->getDiscardLevel() != 0)
{
F32 desired_pixels;
desired_pixels = llmin(mPixelArea, (F32)getTexImageArea());
// DRANO what priority should wearable-based textures have?
if (isUsingLocalAppearance())
{
imagep->setBoostLevel(getAvatarBoostLevel());
imagep->setAdditionalDecodePriority(SELF_ADDITIONAL_PRI) ;
}
imagep->resetTextureStats();
imagep->setMaxVirtualSizeResetInterval(MAX_TEXTURE_VIRTURE_SIZE_RESET_INTERVAL);
imagep->addTextureStats( desired_pixels / texel_area_ratio );
imagep->forceUpdateBindStats() ;
if (imagep->getDiscardLevel() < 0)
{
mHasGrey = TRUE; // for statistics gathering
// DRANO what priority should wearable-based textures have?
if (isUsingLocalAppearance())
{
imagep->setBoostLevel(getAvatarBoostLevel());
imagep->setAdditionalDecodePriority(SELF_ADDITIONAL_PRI) ;
}
imagep->resetTextureStats();
imagep->setMaxVirtualSizeResetInterval(MAX_TEXTURE_VIRTURE_SIZE_RESET_INTERVAL);
imagep->addTextureStats( desired_pixels / texel_area_ratio );
imagep->forceUpdateBindStats() ;
if (imagep->getDiscardLevel() < 0)
{
mHasGrey = TRUE; // for statistics gathering
}
}
}
else
@ -2538,19 +2561,8 @@ void LLVOAvatarSelf::outputRezDiagnostics() const
if (!layerset_buffer) continue;
LL_DEBUGS("Avatar") << layerset_buffer->dumpTextureInfo() << llendl;
}
std::string vd_text = "Local textures per baked index and wearable:\n";
for (LLAvatarAppearanceDefines::LLAvatarAppearanceDictionary::BakedTextures::const_iterator baked_iter = LLAvatarAppearanceDefines::LLAvatarAppearanceDictionary::getInstance()->getBakedTextures().begin();
baked_iter != LLAvatarAppearanceDefines::LLAvatarAppearanceDictionary::getInstance()->getBakedTextures().end();
++baked_iter)
{
const LLAvatarAppearanceDefines::EBakedTextureIndex baked_index = baked_iter->first;
const LLViewerTexLayerSet *layerset = debugGetLayerSet(baked_index);
if (!layerset) continue;
const LLViewerTexLayerSetBuffer *layerset_buffer = layerset->getViewerComposite();
if (!layerset_buffer) continue;
vd_text += verboseDebugDumpLocalTextureDataInfo(layerset);
}
LL_DEBUGS("Avatar") << vd_text << llendl;
dumpAllTextures();
}
void LLVOAvatarSelf::outputRezTiming(const std::string& msg) const

View File

@ -391,6 +391,7 @@ public:
const LLViewerTexLayerSet* debugGetLayerSet(LLAvatarAppearanceDefines::EBakedTextureIndex index) const { return (LLViewerTexLayerSet*)(mBakedTextureDatas[index].mTexLayerSet); }
const std::string verboseDebugDumpLocalTextureDataInfo(const LLViewerTexLayerSet* layerset) const; // Lists out state of this particular baked texture layer
void dumpAllTextures() const;
const std::string debugDumpLocalTextureDataInfo(const LLViewerTexLayerSet* layerset) const; // Lists out state of this particular baked texture layer
const std::string debugDumpAllLocalTextureDataInfo() const; // Lists out which baked textures are at highest LOD
LLSD metricsData();