diff --git a/src/Magnum/DebugMessage.cpp b/src/Magnum/DebugMessage.cpp index fd3a690e4..64438422e 100644 --- a/src/Magnum/DebugMessage.cpp +++ b/src/Magnum/DebugMessage.cpp @@ -98,10 +98,6 @@ Int DebugMessage::maxMessageLength() { return value; } -void DebugMessage::insert(const Source source, const Type type, const UnsignedInt id, const Severity severity, const std::string& string) { - Context::current()->state().debug->messageInsertImplementation(source, type, id, severity, string); -} - void DebugMessage::setCallback(const Callback callback, const void* userParam) { Context::current()->state().debug->messageCallbackImplementation(callback, userParam); } @@ -110,9 +106,13 @@ void DebugMessage::setDefaultCallback() { setCallback(defaultCallback, nullptr); } -void DebugMessage::insertImplementationNoOp(Source, Type, UnsignedInt, Severity, const std::string&) {} +void DebugMessage::insertInternal(const Source source, const Type type, const UnsignedInt id, const Severity severity, const Containers::ArrayReference string) { + Context::current()->state().debug->messageInsertImplementation(source, type, id, severity, string); +} + +void DebugMessage::insertImplementationNoOp(Source, Type, UnsignedInt, Severity, const Containers::ArrayReference) {} -void DebugMessage::insertImplementationKhr(const Source source, const Type type, const UnsignedInt id, const Severity severity, const std::string& string) { +void DebugMessage::insertImplementationKhr(const Source source, const Type type, const UnsignedInt id, const Severity severity, const Containers::ArrayReference string) { /** @todo Re-enable when extension wrangler is available for ES */ #ifndef MAGNUM_TARGET_GLES glDebugMessageInsert(GLenum(source), GLenum(type), id, GLenum(severity), string.size(), string.data()); @@ -127,7 +127,7 @@ void DebugMessage::insertImplementationKhr(const Source source, const Type type, #endif } -void DebugMessage::insertImplementationExt(Source, Type, UnsignedInt, Severity, const std::string& string) { +void DebugMessage::insertImplementationExt(Source, Type, UnsignedInt, Severity, const Containers::ArrayReference string) { /** @todo Re-enable when extension wrangler is available for ES */ #ifndef MAGNUM_TARGET_GLES glInsertEventMarkerEXT(string.size(), string.data()); @@ -138,8 +138,8 @@ void DebugMessage::insertImplementationExt(Source, Type, UnsignedInt, Severity, } #ifndef MAGNUM_TARGET_GLES -void DebugMessage::insertImplementationGremedy(Source, Type, UnsignedInt, Severity, const std::string& string) { - glStringMarkerGREMEDY(string.length(), string.data()); +void DebugMessage::insertImplementationGremedy(Source, Type, UnsignedInt, Severity, const Containers::ArrayReference string) { + glStringMarkerGREMEDY(string.size(), string.data()); } #endif diff --git a/src/Magnum/DebugMessage.h b/src/Magnum/DebugMessage.h index a213a1fb9..9fe752911 100644 --- a/src/Magnum/DebugMessage.h +++ b/src/Magnum/DebugMessage.h @@ -30,6 +30,7 @@ */ #include +#include #include "Magnum/Magnum.h" #include "Magnum/OpenGL.h" @@ -272,7 +273,14 @@ class MAGNUM_EXPORT DebugMessage { * @fn_gl_extension2{InsertEventMarker,EXT,debug_marker} or * @fn_gl_extension{StringMarker,GREMEDY,string_marker} */ - static void insert(Source source, Type type, UnsignedInt id, Severity severity, const std::string& string); + static void insert(Source source, Type type, UnsignedInt id, Severity severity, const std::string& string) { + insertInternal(source, type, id, severity, {string.data(), string.size()}); + } + + /** @overload */ + template static void insert(Source source, Type type, UnsignedInt id, Severity severity, const char(&string)[size]) { + insertInternal(source, type, id, severity, {string, size - 1}); + } /** * @brief Set debug message callback @@ -306,11 +314,12 @@ class MAGNUM_EXPORT DebugMessage { DebugMessage() = delete; private: - static MAGNUM_LOCAL void insertImplementationNoOp(Source, Type, UnsignedInt, Severity, const std::string&); - static MAGNUM_LOCAL void insertImplementationKhr(Source source, Type type, UnsignedInt id, Severity severity, const std::string& string); - static MAGNUM_LOCAL void insertImplementationExt(Source, Type, UnsignedInt, Severity, const std::string& string); + static void insertInternal(Source source, Type type, UnsignedInt id, Severity severity, Containers::ArrayReference string); + static MAGNUM_LOCAL void insertImplementationNoOp(Source, Type, UnsignedInt, Severity, Containers::ArrayReference); + static MAGNUM_LOCAL void insertImplementationKhr(Source source, Type type, UnsignedInt id, Severity severity, Containers::ArrayReference string); + static MAGNUM_LOCAL void insertImplementationExt(Source, Type, UnsignedInt, Severity, Containers::ArrayReference string); #ifndef MAGNUM_TARGET_GLES - static MAGNUM_LOCAL void insertImplementationGremedy(Source, Type, UnsignedInt, Severity, const std::string& string); + static MAGNUM_LOCAL void insertImplementationGremedy(Source, Type, UnsignedInt, Severity, Containers::ArrayReference string); #endif static MAGNUM_LOCAL void callbackImplementationNoOp(Callback, const void*); diff --git a/src/Magnum/Implementation/DebugState.h b/src/Magnum/Implementation/DebugState.h index dd90ec181..2db42423c 100644 --- a/src/Magnum/Implementation/DebugState.h +++ b/src/Magnum/Implementation/DebugState.h @@ -38,7 +38,7 @@ struct DebugState { std::string(*getLabelImplementation)(GLenum, GLuint); void(*labelImplementation)(GLenum, GLuint, Containers::ArrayReference); - void(*messageInsertImplementation)(DebugMessage::Source, DebugMessage::Type, UnsignedInt, DebugMessage::Severity, const std::string&); + void(*messageInsertImplementation)(DebugMessage::Source, DebugMessage::Type, UnsignedInt, DebugMessage::Severity, Containers::ArrayReference); void(*messageCallbackImplementation)(DebugMessage::Callback, const void*); GLint maxLabelLength, maxLoggedMessages, maxMessageLength;