summaryrefslogtreecommitdiff
path: root/indra/newview
diff options
context:
space:
mode:
Diffstat (limited to 'indra/newview')
-rw-r--r--indra/newview/app_settings/settings.xml22
-rw-r--r--indra/newview/llappviewer.cpp8
-rw-r--r--indra/newview/llviewertexturelist.cpp108
-rw-r--r--indra/newview/llviewertexturelist.h11
4 files changed, 147 insertions, 2 deletions
diff --git a/indra/newview/app_settings/settings.xml b/indra/newview/app_settings/settings.xml
index 36abebc942..d58ff17aaa 100644
--- a/indra/newview/app_settings/settings.xml
+++ b/indra/newview/app_settings/settings.xml
@@ -8020,6 +8020,28 @@
<key>Value</key>
<integer>0</integer>
</map>
+ <key>RenderDebugTextureLabel</key>
+ <map>
+ <key>Comment</key>
+ <string>Enable texture labels via glObjectLabel.</string>
+ <key>Persist</key>
+ <integer>0</integer>
+ <key>Type</key>
+ <string>Boolean</string>
+ <key>Value</key>
+ <integer>0</integer>
+ </map>
+ <key>RenderDebugTextureLabelLocalFilesSession</key>
+ <map>
+ <key>Comment</key>
+ <string>Enumerate textures with local file names. Doesn't do anything until RenderDebugTextureLabel is set to true. Requires restart AND applies on the next session only.</string>
+ <key>Persist</key>
+ <integer>1</integer>
+ <key>Type</key>
+ <string>Boolean</string>
+ <key>Value</key>
+ <integer>0</integer>
+ </map>
<key>RenderDelayCreation</key>
<map>
<key>Comment</key>
diff --git a/indra/newview/llappviewer.cpp b/indra/newview/llappviewer.cpp
index 75cd189980..acc79ed994 100644
--- a/indra/newview/llappviewer.cpp
+++ b/indra/newview/llappviewer.cpp
@@ -2912,6 +2912,14 @@ bool LLAppViewer::initConfiguration()
gSavedSettings.setBOOL("RenderDebugGLSession", false);
}
+ if (gSavedSettings.getBOOL("RenderDebugTextureLabelLocalFilesSession"))
+ {
+ gDebugTextureLabelLocalFilesSession = true;
+ // Texture label accounting for local files takes up memory in the
+ // background, so don't persist.
+ gSavedSettings.setBOOL("RenderDebugTextureLabelLocalFilesSession", false);
+ }
+
const LLControlVariable* skinfolder = gSavedSettings.getControl("SkinCurrent");
if (skinfolder && LLStringUtil::null != skinfolder->getValue().asString())
{
diff --git a/indra/newview/llviewertexturelist.cpp b/indra/newview/llviewertexturelist.cpp
index 7b89ae4e44..752cfb3884 100644
--- a/indra/newview/llviewertexturelist.cpp
+++ b/indra/newview/llviewertexturelist.cpp
@@ -364,10 +364,31 @@ void LLViewerTextureList::shutdown()
mInitialized = false ; //prevent loading textures again.
}
+namespace
+{
+
+std::string tex_name_as_string(const LLViewerFetchedTexture* image)
+{
+ if (!image->getGLTexture()) { return std::string("N/A"); }
+ return std::to_string(image->getGLTexture()->getTexName());
+}
+
+const std::string& tex_label_as_string(const LLViewerFetchedTexture* image, std::string& label)
+{
+ bool error;
+ image->getGLObjectLabel(label, error);
+ if (error) { label.assign("N/A"); }
+ return label;
+}
+
+};
+
void LLViewerTextureList::dump()
{
LL_PROFILE_ZONE_SCOPED_CATEGORY_TEXTURE;
- LL_INFOS() << "LLViewerTextureList::dump()" << LL_ENDL;
+ LL_INFOS() << __FUNCTION__ << "()" << LL_ENDL;
+
+ std::string label;
for (image_list_t::iterator it = mImageList.begin(); it != mImageList.end(); ++it)
{
LLViewerFetchedTexture* image = *it;
@@ -378,6 +399,9 @@ void LLViewerTextureList::dump()
<< " discard " << image->getDiscardLevel()
<< " desired " << image->getDesiredDiscardLevel()
<< " http://asset.siva.lindenlab.com/" << image->getID() << ".texture"
+ << " faces " << image->getTotalNumFaces()
+ << " texname " << tex_name_as_string(image)
+ << " label \"" << tex_label_as_string(image, label) << "\""
<< LL_ENDL;
}
}
@@ -422,7 +446,12 @@ LLViewerFetchedTexture* LLViewerTextureList::getImageFromFile(const std::string&
std::string url = "file://" + full_path;
- return getImageFromUrl(url, f_type, usemipmaps, boost_priority, texture_type, internal_format, primary_format, force_id);
+ LLViewerFetchedTexture* tex = getImageFromUrl(url, f_type, usemipmaps, boost_priority, texture_type, internal_format, primary_format, force_id);
+ if (gDebugTextureLabelLocalFilesSession)
+ {
+ gTextureList.mNameTextureList.push_back(LLViewerTextureList::NameElement(tex, filename));
+ }
+ return tex;
}
LLViewerFetchedTexture* LLViewerTextureList::getImageFromUrl(const std::string& url,
@@ -844,6 +873,10 @@ void LLViewerTextureList::updateImages(F32 max_time)
//handle results from decode threads
updateImagesCreateTextures(remaining_time);
+ // Label all images (if enabled)
+ updateImagesNameTextures();
+ labelAll();
+
bool didone = false;
for (image_list_t::iterator iter = mCallbackList.begin();
iter != mCallbackList.end(); )
@@ -1113,6 +1146,73 @@ F32 LLViewerTextureList::updateImagesCreateTextures(F32 max_time)
return create_timer.getElapsedTimeF32();
}
+void LLViewerTextureList::updateImagesNameTextures()
+{
+ LL_PROFILE_ZONE_SCOPED_CATEGORY_TEXTURE;
+ if (gGLManager.mIsDisabled) { return; }
+ static LLCachedControl<bool> debug_texture_label(gSavedSettings, "RenderDebugTextureLabel", false);
+ if (!debug_texture_label()) { return; }
+
+ static GLsizei max_length = 0;
+ if (max_length == 0) { glGetIntegerv(GL_MAX_LABEL_LENGTH, &max_length); }
+
+ auto it = mNameTextureList.begin();
+ while (it != mNameTextureList.end()) // For ALL textures needing names
+ {
+ LLViewerFetchedTexture* tex = it->mTex;
+ // Check that the texture is in the list first (otherwise it may be a dead pointer)
+ // A raw pointer ensures textures are cleaned up when this code isn't running.
+ const bool alive = mImageList.find(tex) != mImageList.end();
+
+ if (alive)
+ {
+ if (tex->hasGLTexture())
+ {
+ if(tex->getTexName())
+ {
+ tex->setGLObjectLabel(it->mPrefix, true);
+ it = mNameTextureList.erase(it); // Assume no rename needed
+ }
+ else
+ {
+ ++it; // Not ready
+ }
+ }
+ else
+ {
+ ++it; // Not ready
+ }
+ }
+ else
+ {
+ it = mNameTextureList.erase(it); // Remove dead pointer
+ }
+ }
+}
+
+void LLViewerTextureList::labelAll()
+{
+ LL_PROFILE_ZONE_SCOPED_CATEGORY_TEXTURE;
+ static LLCachedControl<bool> debug_texture_label(gSavedSettings, "RenderDebugTextureLabel", false);
+ if (!debug_texture_label()) { return; }
+
+ static const std::string local_prefix = "lltexlocal";
+ static const std::string other_prefix = "lltexother";
+
+ std::string label;
+ bool error;
+ for (LLViewerFetchedTexture* image : mImageList)
+ {
+ image->getGLObjectLabel(label, error);
+ if (!error && label.empty())
+ {
+ const S32 category = image->getGLTexture()->getCategory();
+ const std::string& new_prefix = category == LLGLTexture::LOCAL ? local_prefix : other_prefix;
+ image->setGLObjectLabel(new_prefix, true);
+ }
+ }
+}
+
F32 LLViewerTextureList::updateImagesLoadingFastCache(F32 max_time)
{
LL_PROFILE_ZONE_SCOPED_CATEGORY_TEXTURE;
@@ -1295,6 +1395,10 @@ void LLViewerTextureList::decodeAllImages(F32 max_time)
max_time = llmax(max_time, .001f);
F32 create_time = updateImagesCreateTextures(max_time);
+ // Label all images (if enabled)
+ updateImagesNameTextures();
+ labelAll();
+
LL_DEBUGS("ViewerImages") << "decodeAllImages() took " << timer.getElapsedTimeF32() << " seconds. "
<< " fetch_pending " << fetch_pending
<< " create_time " << create_time
diff --git a/indra/newview/llviewertexturelist.h b/indra/newview/llviewertexturelist.h
index 7c7112f4cf..08dd2d0f7f 100644
--- a/indra/newview/llviewertexturelist.h
+++ b/indra/newview/llviewertexturelist.h
@@ -153,6 +153,9 @@ private:
void updateImagesUpdateStats();
F32 updateImagesLoadingFastCache(F32 max_time);
+ void updateImagesNameTextures();
+ void labelAll();
+
void addImage(LLViewerFetchedTexture *image, ETexListType tex_type);
void deleteImage(LLViewerFetchedTexture *image);
@@ -214,6 +217,14 @@ public:
// images that have been loaded but are waiting to be uploaded to GL
image_queue_t mCreateTextureList;
+ struct NameElement
+ {
+ NameElement(LLViewerFetchedTexture* tex, const std::string& prefix) : mTex(tex), mPrefix(prefix) {}
+ LLViewerFetchedTexture* mTex;
+ std::string mPrefix;
+ };
+ std::vector<NameElement> mNameTextureList;
+
// images that must be downscaled quickly so we don't run out of memory
image_queue_t mDownScaleQueue;