Skip to content

Commit

Permalink
GLObjWrapper: do not allow debug label length exceed the GL_MAX_LABEL…
Browse files Browse the repository at this point in the history
…_LENGTH
  • Loading branch information
TheMostDiligent committed Nov 28, 2024
1 parent 37bc6cd commit 8d2e896
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 1 deletion.
24 changes: 23 additions & 1 deletion Graphics/GraphicsEngineOpenGL/include/GLObjectWrapper.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,29 @@ class GLObjWrapper
VERIFY_EXPR(Name != nullptr);
if (glObjectLabel && m_uiHandle)
{
glObjectLabel(m_CreateReleaseHelper.Type, m_uiHandle, -1, Name);
static GLint MaxLabelLen = 0;
if (MaxLabelLen == 0)
{
glGetIntegerv(GL_MAX_LABEL_LENGTH, &MaxLabelLen);
# ifdef DILIGENT_DEVELOPMENT
glGetError(); // Ignore GL error
# endif
if (MaxLabelLen <= 0)
{
// Minimum required value by the spec
MaxLabelLen = 256;
}

// The spec requires that the number of characters in <label>,
// excluding the null terminator, is less than the value of MAX_LABEL_LENGTH.
// In other words, the maximum length of the label is one less than the value of MAX_LABEL_LENGTH.
--MaxLabelLen;
}
GLsizei Length = static_cast<GLsizei>(strlen(Name));
if (Length > MaxLabelLen)
Length = MaxLabelLen;

glObjectLabel(m_CreateReleaseHelper.Type, m_uiHandle, Length, Name);
# ifdef DILIGENT_DEVELOPMENT
glGetError(); // Ignore GL error
# endif
Expand Down
5 changes: 5 additions & 0 deletions Graphics/GraphicsEngineOpenGL/include/GLStubsAndroid.h
Original file line number Diff line number Diff line change
Expand Up @@ -1037,6 +1037,11 @@
#endif


#ifndef GL_MAX_LABEL_LENGTH
# define GL_MAX_LABEL_LENGTH 0x82E8
#endif


/* ------------------------------ GL_EXT_disjoint_timer_query ----------------------------- */
#ifndef GL_TIMESTAMP
# define GL_TIMESTAMP 0x8E28
Expand Down

0 comments on commit 8d2e896

Please sign in to comment.