diff --git a/include/osg/GLDefines b/include/osg/GLDefines index fa6f82e5f..51b9e6134 100644 --- a/include/osg/GLDefines +++ b/include/osg/GLDefines @@ -556,6 +556,53 @@ typedef char GLchar; #define GL_MAP_UNSYNCHRONIZED_BIT 0x0020 #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 #define GL_MAX_SERVER_WAIT_TIMEOUT 0x9111 #define GL_OBJECT_TYPE 0x9112 diff --git a/include/osg/GLExtensions b/include/osg/GLExtensions index faaf790da..d4c46c093 100644 --- a/include/osg/GLExtensions +++ b/include/osg/GLExtensions @@ -699,6 +699,11 @@ class OSG_EXPORT GLExtensions : public osg::Referenced GLint glMaxTextureCoords; 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()); } }; diff --git a/src/osg/GLExtensions.cpp b/src/osg/GLExtensions.cpp index 40d658e41..a9bec1e8a 100644 --- a/src/osg/GLExtensions.cpp +++ b/src/osg/GLExtensions.cpp @@ -1182,6 +1182,8 @@ GLExtensions::GLExtensions(unsigned int in_contextID): glMaxTextureUnits = 0; glMaxTextureCoords = 0; } + + osg::setGLExtensionFuncPtr(glObjectLabel, "glObjectLabel", validContext); } diff --git a/src/osg/Program.cpp b/src/osg/Program.cpp index 61a9be767..fca3db308 100644 --- a/src/osg/Program.cpp +++ b/src/osg/Program.cpp @@ -824,6 +824,8 @@ void Program::PerContextProgram::linkProgram(osg::State& state) OSG_INFO << "Program \""<< _program->getName() << "\" "<< "link succeeded, infolog:\n" << infoLog << std::endl; } + + _extensions->debugObjectLabel(GL_PROGRAM, _glProgramHandle, _program->getName()); } if (_extensions->isUniformBufferObjectSupported) diff --git a/src/osg/Shader.cpp b/src/osg/Shader.cpp index 4d3485565..2712e2a7b 100644 --- a/src/osg/Shader.cpp +++ b/src/osg/Shader.cpp @@ -716,6 +716,8 @@ void Shader::PerContextShader::compileShader(osg::State& state) OSG_INFO << _shader->getTypename() << " Shader \"" << _shader->getName() << "\" infolog:\n" << infoLog << std::endl; } + + _extensions->debugObjectLabel(GL_SHADER, _glShaderHandle, _shader->getName()); } } diff --git a/src/osg/Texture.cpp b/src/osg/Texture.cpp index e44e06736..443f991d9 100644 --- a/src/osg/Texture.cpp +++ b/src/osg/Texture.cpp @@ -715,7 +715,7 @@ osg::ref_ptr TextureObjectSet::takeFromOrphans(Texture* osg::ref_ptr 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 lock(_mutex); if (!_pendingOrphanedTextureObjects.empty()) @@ -1864,6 +1864,13 @@ void Texture::applyTexParameters(GLenum target, State& state) const const unsigned int contextID = state.getContextID(); const GLExtensions* extensions = state.get(); + TextureObject* to = getTextureObject(contextID); + if (to) + { + extensions->debugObjectLabel(GL_TEXTURE, to->id(), getName()); + } + + WrapMode ws = _wrap_s, wt = _wrap_t, wr = _wrap_r; // GL_IBM_texture_mirrored_repeat, fall-back REPEAT