summaryrefslogtreecommitdiff
path: root/indra/llrender
diff options
context:
space:
mode:
Diffstat (limited to 'indra/llrender')
-rw-r--r--indra/llrender/llgl.cpp1
-rw-r--r--indra/llrender/llgl.h1
-rw-r--r--indra/llrender/llgltexture.cpp71
-rw-r--r--indra/llrender/llgltexture.h3
4 files changed, 76 insertions, 0 deletions
diff --git a/indra/llrender/llgl.cpp b/indra/llrender/llgl.cpp
index b4fe711859..798b605f08 100644
--- a/indra/llrender/llgl.cpp
+++ b/indra/llrender/llgl.cpp
@@ -65,6 +65,7 @@
bool gDebugSession = false;
bool gDebugGLSession = false;
+bool gDebugTextureLabelLocalFilesSession = false;
bool gClothRipple = false;
bool gHeadlessClient = false;
bool gNonInteractive = false;
diff --git a/indra/llrender/llgl.h b/indra/llrender/llgl.h
index 08cf662526..0e26961588 100644
--- a/indra/llrender/llgl.h
+++ b/indra/llrender/llgl.h
@@ -48,6 +48,7 @@
extern bool gDebugGL;
extern bool gDebugSession;
extern bool gDebugGLSession;
+extern bool gDebugTextureLabelLocalFilesSession;
extern llofstream gFailLog;
#define LL_GL_ERRS LL_ERRS("RenderState")
diff --git a/indra/llrender/llgltexture.cpp b/indra/llrender/llgltexture.cpp
index 4dcca5a726..bb4205b319 100644
--- a/indra/llrender/llgltexture.cpp
+++ b/indra/llrender/llgltexture.cpp
@@ -168,6 +168,77 @@ bool LLGLTexture::createGLTexture(S32 discard_level, const LLImageRaw* imageraw,
return ret ;
}
+void LLGLTexture::getGLObjectLabel(std::string& label, bool& error) const
+{
+ // GL_VERSION_4_3
+ if (gGLManager.mGLVersion < 4.29f)
+ {
+ error = true;
+ label.clear();
+ return;
+ }
+ if (!mGLTexturep)
+ {
+ error = true;
+ label.clear();
+ return;
+ }
+ LLGLuint texname = mGLTexturep->getTexName();
+ if (!texname)
+ {
+ error = true;
+ label.clear();
+ return;
+ }
+ static GLsizei max_length = 0;
+ if (max_length == 0) { glGetIntegerv(GL_MAX_LABEL_LENGTH, &max_length); }
+ static char * clabel = new char[max_length+1];
+ GLsizei length;
+ glGetObjectLabel(GL_TEXTURE, texname, max_length+1, &length, clabel);
+ error = false;
+ label.assign(clabel, length);
+}
+
+std::string LLGLTexture::setGLObjectLabel(const std::string& prefix, bool append_texname) const
+{
+ if (gGLManager.mGLVersion < 4.29f) { return ""; } // GL_VERSION_4_3
+
+ llassert(mGLTexturep);
+ if (mGLTexturep)
+ {
+ LLGLuint texname = mGLTexturep->getTexName();
+ llassert(texname);
+ if (texname)
+ {
+ static GLsizei max_length = 0;
+ if (max_length == 0) { glGetIntegerv(GL_MAX_LABEL_LENGTH, &max_length); }
+
+ if (append_texname)
+ {
+ std::string label_with_texname = prefix + "_" + std::to_string(texname);
+ label_with_texname.resize(std::min(size_t(max_length), label_with_texname.size()));
+ glObjectLabel(GL_TEXTURE, texname, (GLsizei)label_with_texname.size(), label_with_texname.c_str());
+ return label_with_texname;
+ }
+ else
+ {
+ if (prefix.size() <= max_length)
+ {
+ glObjectLabel(GL_TEXTURE, texname, (GLsizei)prefix.size(), prefix.c_str());
+ return prefix;
+ }
+ else
+ {
+ const std::string label(prefix.c_str(), max_length);
+ glObjectLabel(GL_TEXTURE, texname, (GLsizei)label.size(), label.c_str());
+ return label;
+ }
+ }
+ }
+ }
+ return "";
+}
+
void LLGLTexture::setExplicitFormat(LLGLint internal_format, LLGLenum primary_format, LLGLenum type_format, bool swap_bytes)
{
llassert(mGLTexturep.notNull()) ;
diff --git a/indra/llrender/llgltexture.h b/indra/llrender/llgltexture.h
index 122d2a7f9c..22f2ed5131 100644
--- a/indra/llrender/llgltexture.h
+++ b/indra/llrender/llgltexture.h
@@ -118,6 +118,9 @@ public:
LLGLuint getTexName() const ;
bool createGLTexture() ;
+ void getGLObjectLabel(std::string& label, bool& error) const;
+ std::string setGLObjectLabel(const std::string& prefix, bool append_texname = false) const;
+
// Create a GL Texture from an image raw
// discard_level - mip level, 0 for highest resultion mip
// imageraw - the image to copy from