40 #include <QtCore/private/qobject_p.h>
41 #include <QtCore/qglobal.h>
42 #include <QtCore/qvarlengtharray.h>
43 #include <QtGui/qopengl.h>
44 #include <QtGui/qopenglfunctions.h>
45 #include <QtGui/qoffscreensurface.h>
422 #if defined(GL_KHR_debug) && defined(GL_DEBUG_SOURCE_API_KHR)
423 #define USE_MANUAL_DEFS
432 #define GL_KHR_debug 1
433 #define USE_MANUAL_DEFS
436 #ifdef USE_MANUAL_DEFS
438 #ifndef GL_DEBUG_OUTPUT_SYNCHRONOUS
439 #define GL_DEBUG_OUTPUT_SYNCHRONOUS 0x8242
441 #ifndef GL_DEBUG_NEXT_LOGGED_MESSAGE_LENGTH
442 #define GL_DEBUG_NEXT_LOGGED_MESSAGE_LENGTH 0x8243
444 #ifndef GL_DEBUG_CALLBACK_FUNCTION
445 #define GL_DEBUG_CALLBACK_FUNCTION 0x8244
447 #ifndef GL_DEBUG_CALLBACK_USER_PARAM
448 #define GL_DEBUG_CALLBACK_USER_PARAM 0x8245
450 #ifndef GL_DEBUG_SOURCE_API
451 #define GL_DEBUG_SOURCE_API 0x8246
453 #ifndef GL_DEBUG_SOURCE_WINDOW_SYSTEM
454 #define GL_DEBUG_SOURCE_WINDOW_SYSTEM 0x8247
456 #ifndef GL_DEBUG_SOURCE_SHADER_COMPILER
457 #define GL_DEBUG_SOURCE_SHADER_COMPILER 0x8248
459 #ifndef GL_DEBUG_SOURCE_THIRD_PARTY
460 #define GL_DEBUG_SOURCE_THIRD_PARTY 0x8249
462 #ifndef GL_DEBUG_SOURCE_APPLICATION
463 #define GL_DEBUG_SOURCE_APPLICATION 0x824A
465 #ifndef GL_DEBUG_SOURCE_OTHER
466 #define GL_DEBUG_SOURCE_OTHER 0x824B
468 #ifndef GL_DEBUG_TYPE_ERROR
469 #define GL_DEBUG_TYPE_ERROR 0x824C
471 #ifndef GL_DEBUG_TYPE_DEPRECATED_BEHAVIOR
472 #define GL_DEBUG_TYPE_DEPRECATED_BEHAVIOR 0x824D
474 #ifndef GL_DEBUG_TYPE_UNDEFINED_BEHAVIOR
475 #define GL_DEBUG_TYPE_UNDEFINED_BEHAVIOR 0x824E
477 #ifndef GL_DEBUG_TYPE_PORTABILITY
478 #define GL_DEBUG_TYPE_PORTABILITY 0x824F
480 #ifndef GL_DEBUG_TYPE_PERFORMANCE
481 #define GL_DEBUG_TYPE_PERFORMANCE 0x8250
483 #ifndef GL_DEBUG_TYPE_OTHER
484 #define GL_DEBUG_TYPE_OTHER 0x8251
486 #ifndef GL_DEBUG_TYPE_MARKER
487 #define GL_DEBUG_TYPE_MARKER 0x8268
489 #ifndef GL_DEBUG_TYPE_PUSH_GROUP
490 #define GL_DEBUG_TYPE_PUSH_GROUP 0x8269
492 #ifndef GL_DEBUG_TYPE_POP_GROUP
493 #define GL_DEBUG_TYPE_POP_GROUP 0x826A
495 #ifndef GL_DEBUG_SEVERITY_NOTIFICATION
496 #define GL_DEBUG_SEVERITY_NOTIFICATION 0x826B
498 #ifndef GL_MAX_DEBUG_GROUP_STACK_DEPTH
499 #define GL_MAX_DEBUG_GROUP_STACK_DEPTH 0x826C
501 #ifndef GL_DEBUG_GROUP_STACK_DEPTH
502 #define GL_DEBUG_GROUP_STACK_DEPTH 0x826D
505 #define GL_BUFFER 0x82E0
508 #define GL_SHADER 0x82E1
511 #define GL_PROGRAM 0x82E2
514 #define GL_QUERY 0x82E3
516 #ifndef GL_PROGRAM_PIPELINE
517 #define GL_PROGRAM_PIPELINE 0x82E4
520 #define GL_SAMPLER 0x82E6
522 #ifndef GL_DISPLAY_LIST
523 #define GL_DISPLAY_LIST 0x82E7
525 #ifndef GL_MAX_LABEL_LENGTH
526 #define GL_MAX_LABEL_LENGTH 0x82E8
528 #ifndef GL_MAX_DEBUG_MESSAGE_LENGTH
529 #define GL_MAX_DEBUG_MESSAGE_LENGTH 0x9143
531 #ifndef GL_MAX_DEBUG_LOGGED_MESSAGES
532 #define GL_MAX_DEBUG_LOGGED_MESSAGES 0x9144
534 #ifndef GL_DEBUG_LOGGED_MESSAGES
535 #define GL_DEBUG_LOGGED_MESSAGES 0x9145
537 #ifndef GL_DEBUG_SEVERITY_HIGH
538 #define GL_DEBUG_SEVERITY_HIGH 0x9146
540 #ifndef GL_DEBUG_SEVERITY_MEDIUM
541 #define GL_DEBUG_SEVERITY_MEDIUM 0x9147
543 #ifndef GL_DEBUG_SEVERITY_LOW
544 #define GL_DEBUG_SEVERITY_LOW 0x9148
546 #ifndef GL_DEBUG_OUTPUT
547 #define GL_DEBUG_OUTPUT 0x92E0
549 #ifndef GL_CONTEXT_FLAG_DEBUG_BIT
550 #define GL_CONTEXT_FLAG_DEBUG_BIT 0x00000002
552 #ifndef GL_STACK_OVERFLOW
553 #define GL_STACK_OVERFLOW 0x0503
555 #ifndef GL_STACK_UNDERFLOW
556 #define GL_STACK_UNDERFLOW 0x0504
982 return (d == debugMessage.d)
983 || (d->
id == debugMessage.d->
id
999 #ifndef QT_NO_DEBUG_STREAM
1009 debug.nospace() <<
"QOpenGLDebugMessage::Source("
1010 << qt_messageSourceToString(
source)
1024 debug.nospace() <<
"QOpenGLDebugMessage::Type("
1025 << qt_messageTypeToString(
type)
1039 debug.nospace() <<
"QOpenGLDebugMessage::Severity("
1040 << qt_messageSeverityToString(
severity)
1054 debug.nospace() <<
"QOpenGLDebugMessage("
1055 << qt_messageSourceToString(
message.source()) <<
", "
1058 << qt_messageSeverityToString(
message.severity()) <<
", "
1059 << qt_messageTypeToString(
message.type()) <<
')';
1081 QOpenGLDebugMessage::Types
types,
1109 : glDebugMessageControl(
nullptr),
1110 glDebugMessageInsert(
nullptr),
1111 glDebugMessageCallback(
nullptr),
1112 glGetDebugMessageLog(
nullptr),
1115 oldDebugCallbackFunction(
nullptr),
1117 maxMessageLength(0),
1121 debugWasEnabled(
false),
1122 syncDebugWasEnabled(
false)
1134 const GLchar *rawMessage)
1142 messagePrivate->
source = qt_messageSourceFromGL(
source);
1143 messagePrivate->
type = qt_messageTypeFromGL(
type);
1144 messagePrivate->
id =
id;
1158 QOpenGLDebugMessage::Types
types,
1164 qWarning(
"QOpenGLDebugLogger::%s(): object must be initialized before enabling/disabling messages", callerName.
constData());
1168 qWarning(
"QOpenGLDebugLogger::%s(): invalid source specified", callerName.
constData());
1172 qWarning(
"QOpenGLDebugLogger::%s(): invalid type specified", callerName.
constData());
1176 qWarning(
"QOpenGLDebugLogger::%s(): invalid severity specified", callerName.
constData());
1184 if (
ids.count() > 0) {
1211 #define CONVERT_TO_GL_DEBUG_MESSAGE_CONTROL_PARAMETERS(type, source, target) \
1212 if (source == QOpenGLDebugMessage::Any ## type) { \
1213 target << GL_DONT_CARE; \
1215 for (uint i = 1; i <= QOpenGLDebugMessage::Last ## type; i = i << 1) \
1216 if (source.testFlag(QOpenGLDebugMessage:: type (i))) \
1217 target << qt_message ## type ## ToGL (QOpenGLDebugMessage:: type (i)); \
1223 #undef CONVERT_TO_GL_DEBUG_MESSAGE_CONTROL_PARAMETERS
1228 const GLuint *
const idPtr = idCount ?
ids.constData() :
nullptr;
1247 QSurface *currentSurface =
nullptr;
1251 if (
context != currentContext) {
1254 currentSurface = currentContext->
surface();
1258 offscreenSurface->
create();
1260 qWarning(
"QOpenGLDebugLoggerPrivate::_q_contextAboutToBeDestroyed(): could not make the owning GL context current for cleanup");
1266 if (offscreenSurface) {
1285 const GLchar *rawMessage,
1306 qRegisterMetaType<QOpenGLDebugMessage>();
1336 qWarning(
"QOpenGLDebugLogger::initialize(): no current OpenGL context found.");
1348 qWarning(
"QOpenGLDebugLogger::initialize(): cannot initialize the object while logging. Please stop the logging first.");
1355 d->initialized =
false;
1356 d->context =
nullptr;
1362 connect(
d->context,
SIGNAL(aboutToBeDestroyed()),
this,
SLOT(_q_contextAboutToBeDestroyed()));
1364 #define GET_DEBUG_PROC_ADDRESS(procName) \
1365 d->procName = reinterpret_cast< qt_ ## procName ## _t >( \
1366 d->context->getProcAddress(d->context->isOpenGLES() ? (#procName "KHR") : (#procName)) \
1377 #undef GET_DEBUG_PROC_ADDRESS
1383 qWarning(
"QOpenGLDebugLogger::initialize(): the current context is not a debug context:\n"
1384 " this means that the GL may not generate any debug output at all.\n"
1385 " To avoid this warning, try creating the context with the\n"
1386 " QSurfaceFormat::DebugContext surface format option.");
1390 d->initialized =
true;
1402 return d->isLogging;
1430 if (!
d->initialized) {
1431 qWarning(
"QOpenGLDebugLogger::startLogging(): object must be initialized before logging can start");
1435 qWarning(
"QOpenGLDebugLogger::startLogging(): this object is already logging");
1439 d->isLogging =
true;
1445 d->glDebugMessageCallback(&qt_opengl_debug_callback,
d);
1467 return d->loggingMode;
1482 if (!currentContext || currentContext !=
d->context) {
1483 qWarning(
"QOpenGLDebugLogger::stopLogging(): attempting to stop logging with the wrong OpenGL context current");
1487 d->isLogging =
false;
1489 d->glDebugMessageCallback(
d->oldDebugCallbackFunction,
d->oldDebugCallbackParameter);
1492 if (!
d->debugWasEnabled)
1495 if (
d->syncDebugWasEnabled)
1517 if (!
d->initialized) {
1518 qWarning(
"QOpenGLDebugLogger::logMessage(): object must be initialized before logging messages");
1523 qWarning(
"QOpenGLDebugLogger::logMessage(): using a message source different from ApplicationSource\n"
1524 " or ThirdPartySource is not supported by GL_KHR_debug. The message will not be logged.");
1531 qWarning(
"QOpenGLDebugLogger::logMessage(): the message has a non-valid type and/or severity. The message will not be logged.");
1541 if (rawMessage.
length() >
d->maxMessageLength) {
1542 qWarning(
"QOpenGLDebugLogger::logMessage(): message too long, truncating it\n"
1543 " (%d bytes long, but the GL accepts up to %d bytes)",
int(rawMessage.
length()),
d->maxMessageLength);
1544 rawMessage.
resize(
d->maxMessageLength - 1);
1551 d->glDebugMessageInsert(
source,
1580 if (!
d->initialized) {
1581 qWarning(
"QOpenGLDebugLogger::pushGroup(): object must be initialized before pushing a debug group");
1586 qWarning(
"QOpenGLDebugLogger::pushGroup(): using a source different from ApplicationSource\n"
1587 " or ThirdPartySource is not supported by GL_KHR_debug. The group will not be pushed.");
1593 if (rawName.
length() >
d->maxMessageLength) {
1594 qWarning(
"QOpenGLDebugLogger::pushGroup(): group name too long, truncating it\n"
1595 " (%d bytes long, but the GL accepts up to %d bytes)",
int(rawName.
length()),
d->maxMessageLength);
1596 rawName.
resize(
d->maxMessageLength - 1);
1603 d->glPushDebugGroup(qt_messageSourceToGL(
source),
id, -1, rawName.
constData());
1623 if (!
d->initialized) {
1624 qWarning(
"QOpenGLDebugLogger::pushGroup(): object must be initialized before popping a debug group");
1628 d->glPopDebugGroup();
1640 QOpenGLDebugMessage::Types
types,
1657 QOpenGLDebugMessage::Sources
sources,
1658 QOpenGLDebugMessage::Types
types)
1678 QOpenGLDebugMessage::Types
types,
1695 QOpenGLDebugMessage::Sources
sources,
1696 QOpenGLDebugMessage::Types
types)
1718 if (!
d->initialized) {
1719 qWarning(
"QOpenGLDebugLogger::loggedMessages(): object must be initialized before reading logged messages");
1723 static const GLuint maxMessageCount = 128;
1725 GLenum messageSources[maxMessageCount];
1726 GLenum messageTypes[maxMessageCount];
1727 GLuint messageIds[maxMessageCount];
1728 GLenum messageSeverities[maxMessageCount];
1729 GLsizei messageLengths[maxMessageCount];
1732 messagesBuffer.
resize(maxMessageCount *
d->maxMessageLength);
1736 messagesRead =
d->glGetDebugMessageLog(maxMessageCount,
1743 messagesBuffer.
data());
1745 const char *messagesBufferPtr = messagesBuffer.
constData();
1746 for (
GLuint i = 0;
i < messagesRead; ++
i) {
1750 messagePrivate->
source = qt_messageSourceFromGL(messageSources[
i]);
1751 messagePrivate->
type = qt_messageTypeFromGL(messageTypes[
i]);
1752 messagePrivate->
id = messageIds[
i];
1753 messagePrivate->
severity = qt_messageSeverityFromGL(messageSeverities[
i]);
1756 messagesBufferPtr += messageLengths[
i];
1759 }
while (messagesRead == maxMessageCount);
1805 if (!
d->initialized) {
1806 qWarning(
"QOpenGLDebugLogger::maximumMessageLength(): object must be initialized before reading the maximum message length");
1809 return d->maxMessageLength;
1815 #include "moc_qopengldebug.cpp"
small capitals from c petite p scientific i
[1]
The QByteArray class provides an array of bytes.
qsizetype size() const noexcept
const char * constData() const noexcept
qsizetype length() const noexcept
void resize(qsizetype size)
QByteArray & append(char c)
The QDebug class provides an output stream for debugging information.
Convenience class for custom QDebug operators.
The QObject class is the base class of all Qt objects.
static QMetaObject::Connection connect(const QObject *sender, const char *signal, const QObject *receiver, const char *member, Qt::ConnectionType=Qt::AutoConnection)
static bool disconnect(const QObject *sender, const char *signal, const QObject *receiver, const char *member)
The QOffscreenSurface class represents an offscreen surface in the underlying platform.
void setFormat(const QSurfaceFormat &format)
The QOpenGLContext class represents a native OpenGL context, enabling OpenGL rendering on a QSurface.
bool makeCurrent(QSurface *surface)
QSurfaceFormat format() const
static QOpenGLContext * currentContext()
QOpenGLFunctions * functions() const
QSurface * surface() const
The QOpenGLDebugLogger enables logging of OpenGL debugging messages. \inmodule QtOpenGL.
LoggingMode loggingMode
the logging mode passed to startLogging().
qint64 maximumMessageLength() const
QOpenGLDebugLogger(QObject *parent=nullptr)
void disableMessages(QOpenGLDebugMessage::Sources sources=QOpenGLDebugMessage::AnySource, QOpenGLDebugMessage::Types types=QOpenGLDebugMessage::AnyType, QOpenGLDebugMessage::Severities severities=QOpenGLDebugMessage::AnySeverity)
void logMessage(const QOpenGLDebugMessage &debugMessage)
void pushGroup(const QString &name, GLuint id=0, QOpenGLDebugMessage::Source source=QOpenGLDebugMessage::ApplicationSource)
void enableMessages(QOpenGLDebugMessage::Sources sources=QOpenGLDebugMessage::AnySource, QOpenGLDebugMessage::Types types=QOpenGLDebugMessage::AnyType, QOpenGLDebugMessage::Severities severities=QOpenGLDebugMessage::AnySeverity)
void startLogging(LoggingMode loggingMode=AsynchronousLogging)
QList< QOpenGLDebugMessage > loggedMessages() const
void _q_contextAboutToBeDestroyed()
qt_glDebugMessageCallback_t glDebugMessageCallback
qt_glPushDebugGroup_t glPushDebugGroup
void controlDebugMessages(QOpenGLDebugMessage::Sources sources, QOpenGLDebugMessage::Types types, QOpenGLDebugMessage::Severities severities, const QList< GLuint > &ids, const QByteArray &callerName, bool enable)
QOpenGLDebugLoggerPrivate()
qt_glDebugMessageInsert_t glDebugMessageInsert
void * oldDebugCallbackParameter
GLDEBUGPROC oldDebugCallbackFunction
qt_glGetPointerv_t glGetPointerv
QOpenGLDebugLogger::LoggingMode loggingMode
qt_glDebugMessageControl_t glDebugMessageControl
qt_glGetDebugMessageLog_t glGetDebugMessageLog
void handleMessage(GLenum source, GLenum type, GLuint id, GLenum severity, GLsizei length, const GLchar *rawMessage)
qt_glPopDebugGroup_t glPopDebugGroup
The QOpenGLDebugMessage class wraps an OpenGL debug message. \inmodule QtOpenGL \reentrant.
QOpenGLDebugMessage & operator=(const QOpenGLDebugMessage &debugMessage)
static QOpenGLDebugMessage createThirdPartyMessage(const QString &text, GLuint id=0, Severity severity=NotificationSeverity, Type type=OtherType)
QDebug operator<<(QDebug debug, const QOpenGLDebugMessage &message)
QDebug operator<<(QDebug debug, QOpenGLDebugMessage::Type type)
static QOpenGLDebugMessage createApplicationMessage(const QString &text, GLuint id=0, Severity severity=NotificationSeverity, Type type=OtherType)
Severity severity() const
QDebug operator<<(QDebug debug, QOpenGLDebugMessage::Source source)
bool operator==(const QOpenGLDebugMessage &debugMessage) const
QDebug operator<<(QDebug debug, QOpenGLDebugMessage::Severity severity)
QOpenGLDebugMessage::Source source
QOpenGLDebugMessage::Type type
QOpenGLDebugMessagePrivate()
QOpenGLDebugMessage::Severity severity
The QOpenGLFunctions class provides cross-platform access to the OpenGL ES 2.0 API.
GLboolean glIsEnabled(GLenum cap)
void glDisable(GLenum cap)
void glEnable(GLenum cap)
void glGetIntegerv(GLenum pname, GLint *params)
T * data() const noexcept
void reset(T *other=nullptr) noexcept(noexcept(Cleanup::cleanup(std::declval< T * >())))
The QSharedData class is a base class for shared data objects. \reentrant.
The QString class provides a Unicode character string.
static QString fromUtf8(QByteArrayView utf8)
QByteArray toUtf8() const &
The QSurface class is an abstraction of renderable surfaces in Qt.
#define QByteArrayLiteral(str)
#define QOPENGLF_APIENTRYP
GLenum GLuint GLenum GLsizei length
#define QOPENGLF_APIENTRY
GLenum GLuint GLenum GLsizei const GLchar const GLvoid * userParam
GLenum GLuint GLenum GLsizei const GLchar * message
GLenum GLuint GLenum severity
#define GL_DEBUG_TYPE_MARKER
#define GL_DEBUG_SEVERITY_LOW
GLsizei GLenum GLenum GLuint GLenum * severities
GLsizei GLenum GLenum GLuint GLenum GLsizei * lengths
#define GL_DEBUG_SOURCE_THIRD_PARTY
#define GL_DEBUG_TYPE_PORTABILITY
#define GL_DEBUG_TYPE_OTHER
GLsizei GLenum GLenum GLuint GLenum GLsizei GLchar * messageLog
#define GL_DEBUG_TYPE_DEPRECATED_BEHAVIOR
#define GL_MAX_DEBUG_MESSAGE_LENGTH
GLenum GLenum GLsizei const GLuint * ids
#define GL_DEBUG_TYPE_PUSH_GROUP
GLenum GLuint GLenum GLsizei length
#define GL_DEBUG_SOURCE_APPLICATION
#define GL_DEBUG_SOURCE_OTHER
GLenum GLenum GLsizei const GLuint GLboolean enabled
#define GL_DEBUG_SEVERITY_MEDIUM
#define GL_DEBUG_SOURCE_SHADER_COMPILER
typedef void(QOPENGLF_APIENTRYP qt_glDebugMessageControl_t)(GLenum source
#define GL_DEBUG_TYPE_UNDEFINED_BEHAVIOR
#define GL_DEBUG_SEVERITY_NOTIFICATION
#define GL_DEBUG_TYPE_POP_GROUP
GLenum GLenum GLsizei count
#define GL_DEBUG_SOURCE_WINDOW_SYSTEM
#define GL_DEBUG_SOURCE_API
void(QOPENGLF_APIENTRY * GLDEBUGPROC)(GLenum source, GLenum type, GLuint id, GLenum severity, GLsizei length, const GLchar *message, const GLvoid *userParam)
#define GL_DEBUG_CALLBACK_USER_PARAM
#define GL_DEBUG_TYPE_ERROR
#define CONVERT_TO_GL_DEBUG_MESSAGE_CONTROL_PARAMETERS(type, source, target)
#define GL_DEBUG_CALLBACK_FUNCTION
GLuint GLsizei const GLchar * message
#define GL_DEBUG_SEVERITY_HIGH
#define GL_DEBUG_OUTPUT_SYNCHRONOUS
#define GET_DEBUG_PROC_ADDRESS(procName)
typedef GLuint(QOPENGLF_APIENTRYP qt_glGetDebugMessageLog_t)(GLuint count
GLsizei GLenum GLenum * types
#define GL_DEBUG_TYPE_PERFORMANCE
GLenum GLuint GLenum GLsizei const GLchar * buf
typedef GLint(GL_APIENTRYP PFNGLGETPROGRAMRESOURCELOCATIONINDEXEXTPROC)(GLuint program
GLsizei GLenum GLenum GLuint GLenum * severities
GLenum GLenum GLsizei const GLuint * ids
GLsizei GLenum GLenum * types
typedef GLsizei(GL_APIENTRYP PFNGLGETFRAMEBUFFERPIXELLOCALSTORAGESIZEEXTPROC)(GLuint target)
typedef GLenum(GL_APIENTRYP PFNGLGETGRAPHICSRESETSTATUSKHRPROC)(void)
typedef GLboolean(GL_APIENTRYP PFNGLISENABLEDIOESPROC)(GLenum target
GLsizei GLsizei GLchar * source
GLdouble GLdouble GLdouble GLdouble q
#define Q_ASSERT_X(cond, x, msg)
#define QStringLiteral(str)
constexpr const auto messages
IUIAutomationTreeWalker __RPC__deref_out_opt IUIAutomationElement ** parent