Added support for glObjectLabel debugging

This commit is contained in:
Robert Osfield 2016-11-15 14:35:47 +00:00
parent 4ecf541cb6
commit 1abd99f084
6 changed files with 66 additions and 1 deletions

View File

@ -556,6 +556,53 @@ typedef char GLchar;
#define GL_MAP_UNSYNCHRONIZED_BIT 0x0020 #define GL_MAP_UNSYNCHRONIZED_BIT 0x0020
#endif #endif
/* ------------------------------ GL_KHR_debug ----------------------------- */
#ifndef GL_KHR_debug
#define GL_KHR_debug 1
#define GL_CONTEXT_FLAG_DEBUG_BIT 0x00000002
#define GL_STACK_OVERFLOW 0x0503
#define GL_STACK_UNDERFLOW 0x0504
#define GL_DEBUG_OUTPUT_SYNCHRONOUS 0x8242
#define GL_DEBUG_NEXT_LOGGED_MESSAGE_LENGTH 0x8243
#define GL_DEBUG_CALLBACK_FUNCTION 0x8244
#define GL_DEBUG_CALLBACK_USER_PARAM 0x8245
#define GL_DEBUG_SOURCE_API 0x8246
#define GL_DEBUG_SOURCE_WINDOW_SYSTEM 0x8247
#define GL_DEBUG_SOURCE_SHADER_COMPILER 0x8248
#define GL_DEBUG_SOURCE_THIRD_PARTY 0x8249
#define GL_DEBUG_SOURCE_APPLICATION 0x824A
#define GL_DEBUG_SOURCE_OTHER 0x824B
#define GL_DEBUG_TYPE_ERROR 0x824C
#define GL_DEBUG_TYPE_DEPRECATED_BEHAVIOR 0x824D
#define GL_DEBUG_TYPE_UNDEFINED_BEHAVIOR 0x824E
#define GL_DEBUG_TYPE_PORTABILITY 0x824F
#define GL_DEBUG_TYPE_PERFORMANCE 0x8250
#define GL_DEBUG_TYPE_OTHER 0x8251
#define GL_DEBUG_TYPE_MARKER 0x8268
#define GL_DEBUG_TYPE_PUSH_GROUP 0x8269
#define GL_DEBUG_TYPE_POP_GROUP 0x826A
#define GL_DEBUG_SEVERITY_NOTIFICATION 0x826B
#define GL_MAX_DEBUG_GROUP_STACK_DEPTH 0x826C
#define GL_DEBUG_GROUP_STACK_DEPTH 0x826D
#define GL_BUFFER 0x82E0
#define GL_SHADER 0x82E1
#define GL_PROGRAM 0x82E2
#define GL_QUERY 0x82E3
#define GL_PROGRAM_PIPELINE 0x82E4
#define GL_SAMPLER 0x82E6
#define GL_DISPLAY_LIST 0x82E7
#define GL_MAX_LABEL_LENGTH 0x82E8
#define GL_MAX_DEBUG_MESSAGE_LENGTH 0x9143
#define GL_MAX_DEBUG_LOGGED_MESSAGES 0x9144
#define GL_DEBUG_LOGGED_MESSAGES 0x9145
#define GL_DEBUG_SEVERITY_HIGH 0x9146
#define GL_DEBUG_SEVERITY_MEDIUM 0x9147
#define GL_DEBUG_SEVERITY_LOW 0x9148
#define GL_DEBUG_OUTPUT 0x92E0
#endif /* GL_KHR_debug */
#ifndef GL_ARB_sync #ifndef GL_ARB_sync
#define GL_MAX_SERVER_WAIT_TIMEOUT 0x9111 #define GL_MAX_SERVER_WAIT_TIMEOUT 0x9111
#define GL_OBJECT_TYPE 0x9112 #define GL_OBJECT_TYPE 0x9112

View File

@ -699,6 +699,11 @@ class OSG_EXPORT GLExtensions : public osg::Referenced
GLint glMaxTextureCoords; GLint glMaxTextureCoords;
GLint glMaxTextureUnits; GLint glMaxTextureUnits;
// debug extensions
void (GL_APIENTRY * glObjectLabel) (GLenum identifier, GLuint name, GLsizei length, const GLchar* label);
/** convinience wrapper around glObjectLabel that calls glObjectLabel if it's supported and using std::string as a label parameter.*/
void debugObjectLabel(GLenum identifier, GLuint name, const std::string& label) const { if (glObjectLabel && !label.empty()) glObjectLabel(identifier, name, label.size(), label.c_str()); }
}; };

View File

@ -1182,6 +1182,8 @@ GLExtensions::GLExtensions(unsigned int in_contextID):
glMaxTextureUnits = 0; glMaxTextureUnits = 0;
glMaxTextureCoords = 0; glMaxTextureCoords = 0;
} }
osg::setGLExtensionFuncPtr(glObjectLabel, "glObjectLabel", validContext);
} }

View File

@ -824,6 +824,8 @@ void Program::PerContextProgram::linkProgram(osg::State& state)
OSG_INFO << "Program \""<< _program->getName() << "\" "<< OSG_INFO << "Program \""<< _program->getName() << "\" "<<
"link succeeded, infolog:\n" << infoLog << std::endl; "link succeeded, infolog:\n" << infoLog << std::endl;
} }
_extensions->debugObjectLabel(GL_PROGRAM, _glProgramHandle, _program->getName());
} }
if (_extensions->isUniformBufferObjectSupported) if (_extensions->isUniformBufferObjectSupported)

View File

@ -716,6 +716,8 @@ void Shader::PerContextShader::compileShader(osg::State& state)
OSG_INFO << _shader->getTypename() << " Shader \"" OSG_INFO << _shader->getTypename() << " Shader \""
<< _shader->getName() << "\" infolog:\n" << infoLog << std::endl; << _shader->getName() << "\" infolog:\n" << infoLog << std::endl;
} }
_extensions->debugObjectLabel(GL_SHADER, _glShaderHandle, _shader->getName());
} }
} }

View File

@ -715,7 +715,7 @@ osg::ref_ptr<Texture::TextureObject> TextureObjectSet::takeFromOrphans(Texture*
osg::ref_ptr<Texture::TextureObject> TextureObjectSet::takeOrGenerate(Texture* texture) osg::ref_ptr<Texture::TextureObject> TextureObjectSet::takeOrGenerate(Texture* texture)
{ {
// see if we can recyle TextureObject from the orphan list // see if we can recycle TextureObject from the orphan list
{ {
OpenThreads::ScopedLock<OpenThreads::Mutex> lock(_mutex); OpenThreads::ScopedLock<OpenThreads::Mutex> lock(_mutex);
if (!_pendingOrphanedTextureObjects.empty()) if (!_pendingOrphanedTextureObjects.empty())
@ -1864,6 +1864,13 @@ void Texture::applyTexParameters(GLenum target, State& state) const
const unsigned int contextID = state.getContextID(); const unsigned int contextID = state.getContextID();
const GLExtensions* extensions = state.get<GLExtensions>(); const GLExtensions* extensions = state.get<GLExtensions>();
TextureObject* to = getTextureObject(contextID);
if (to)
{
extensions->debugObjectLabel(GL_TEXTURE, to->id(), getName());
}
WrapMode ws = _wrap_s, wt = _wrap_t, wr = _wrap_r; WrapMode ws = _wrap_s, wt = _wrap_t, wr = _wrap_r;
// GL_IBM_texture_mirrored_repeat, fall-back REPEAT // GL_IBM_texture_mirrored_repeat, fall-back REPEAT