diff options
author | Maxim Nikolenko <maximnproductengine@lindenlab.com> | 2024-10-08 17:06:20 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-10-08 17:06:20 +0300 |
commit | 6ccae2d0ae977965202ecb45de77e46f8d0312b3 (patch) | |
tree | 0819595c2a50aa7066b0c75b49d3b6c31f5636b9 /indra/llrender/llgltexture.cpp | |
parent | ccc7fffb22b347149bf807b9d92677e5616c5017 (diff) | |
parent | 3dca9fc377e855b74a78a5c30464b468dcc82644 (diff) |
Merge branch 'develop' into maxim/lua-nearby-avatars
Diffstat (limited to 'indra/llrender/llgltexture.cpp')
-rw-r--r-- | indra/llrender/llgltexture.cpp | 80 |
1 files changed, 80 insertions, 0 deletions
diff --git a/indra/llrender/llgltexture.cpp b/indra/llrender/llgltexture.cpp index 4dcca5a726..c2298d5377 100644 --- a/indra/llrender/llgltexture.cpp +++ b/indra/llrender/llgltexture.cpp @@ -168,6 +168,86 @@ 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; + } + +#if LL_DARWIN + // apple doesn't support GL after 4.1 so should have hit the above early out, but make the compiler happy here + error = true; + label.clear(); + return; +#else + 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); +#endif +} + +std::string LLGLTexture::setGLObjectLabel(const std::string& prefix, bool append_texname) const +{ +#ifndef LL_DARWIN // apple doesn't support GL > 4.1 + 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; + } + } + } + } +#endif + return ""; +} + void LLGLTexture::setExplicitFormat(LLGLint internal_format, LLGLenum primary_format, LLGLenum type_format, bool swap_bytes) { llassert(mGLTexturep.notNull()) ; |