qopengldebug.cpp

Absolute File Name:/home/qt/qt5_coco/qt5/qtbase/src/gui/opengl/qopengldebug.cpp
Source codeSwitch to Preprocessed file
LineSourceCount
1/****************************************************************************-
2**-
3** Copyright (C) 2013 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com, author Giuseppe D'Angelo <giuseppe.dangelo@kdab.com>-
4** Contact: http://www.qt.io/licensing/-
5**-
6** This file is part of the QtGui module of the Qt Toolkit.-
7**-
8** $QT_BEGIN_LICENSE:LGPL21$-
9** Commercial License Usage-
10** Licensees holding valid commercial Qt licenses may use this file in-
11** accordance with the commercial license agreement provided with the-
12** Software or, alternatively, in accordance with the terms contained in-
13** a written agreement between you and The Qt Company. For licensing terms-
14** and conditions see http://www.qt.io/terms-conditions. For further-
15** information use the contact form at http://www.qt.io/contact-us.-
16**-
17** GNU Lesser General Public License Usage-
18** Alternatively, this file may be used under the terms of the GNU Lesser-
19** General Public License version 2.1 or version 3 as published by the Free-
20** Software Foundation and appearing in the file LICENSE.LGPLv21 and-
21** LICENSE.LGPLv3 included in the packaging of this file. Please review the-
22** following information to ensure the GNU Lesser General Public License-
23** requirements will be met: https://www.gnu.org/licenses/lgpl.html and-
24** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.-
25**-
26** As a special exception, The Qt Company gives you certain additional-
27** rights. These rights are described in The Qt Company LGPL Exception-
28** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.-
29**-
30** $QT_END_LICENSE$-
31**-
32****************************************************************************/-
33-
34#include <QtCore/private/qobject_p.h>-
35#include <QtCore/qglobal.h>-
36#include <QtCore/qvarlengtharray.h>-
37#include <QtGui/qopengl.h>-
38#include <QtGui/qopenglfunctions.h>-
39#include <QtGui/qoffscreensurface.h>-
40-
41#include "qopengldebug.h"-
42-
43QT_BEGIN_NAMESPACE-
44-
45/*!-
46 \class QOpenGLDebugMessage-
47 \brief The QOpenGLDebugMessage class wraps an OpenGL debug message.-
48 \inmodule QtGui-
49 \reentrant-
50 \since 5.1-
51 \ingroup shared-
52 \ingroup painting-3D-
53-
54 Debug messages are usually created by the OpenGL server and then read by-
55 OpenGL clients (either from the OpenGL internal debug log, or logged in real-time).-
56 A debug message has a textual representation, a vendor-specific numeric id,-
57 a source, a type and a severity.-
58-
59 It's also possible for applications or third-party libraries and toolkits-
60 to create and insert messages in the debug log. In order to do so, you can use-
61 the createApplicationMessage() or the createThirdPartyMessage() static functions.-
62-
63 \sa QOpenGLDebugLogger-
64*/-
65-
66/*!-
67 \class QOpenGLDebugLogger-
68 \brief The QOpenGLDebugLogger enables logging of OpenGL debugging messages.-
69 \inmodule QtGui-
70 \since 5.1-
71 \ingroup painting-3D-
72-
73 \tableofcontents-
74-
75 \section1 Introduction-
76-
77 OpenGL programming can be very error prone. Most of the time, a single-
78 failing call to OpenGL can cause an entire portion of an application to-
79 stop working, with nothing being drawn on the screen.-
80-
81 The only way to be sure that no errors are being returned from the OpenGL-
82 implementation is checking with \c{glGetError} after each and every API-
83 call. Moreover, OpenGL errors stack up, therefore glGetError should always-
84 be used in a loop like this:-
85-
86 \code-
87-
88 GLenum error = GL_NO_ERROR;-
89 do {-
90 error = glGetError();-
91 if (error != GL_NO_ERROR)-
92 // handle the error-
93 } while (error != GL_NO_ERROR);-
94-
95 \endcode-
96-
97 There are also many other information we are interested in (as application-
98 developers), for instance performance issues, or warnings about using-
99 deprecated APIs. Those kind of messages are not reported through the-
100 ordinary OpenGL error reporting mechanisms.-
101-
102 QOpenGLDebugLogger aims at addressing these issues by providing access to-
103 the \e{OpenGL debug log}. If your OpenGL implementation supports it (by-
104 exposing the \c{GL_KHR_debug} extension), messages from the OpenGL server-
105 will be either logged in an internal OpenGL log, or passed in "real-time"-
106 to listeners as they're generated from OpenGL.-
107-
108 QOpenGLDebugLogger supports both these modes of operation. Refer to the-
109 following sections to find out the differences between them.-
110-
111 \section1 Creating an OpenGL Debug Context-
112-
113 For efficiency reasons, OpenGL implementations are allowed not to create-
114 any debug output at all, unless the OpenGL context is a debug context. In order-
115 to create a debug context from Qt, you must set the QSurfaceFormat::DebugContext-
116 format option on the QSurfaceFormat used to create the QOpenGLContext object:-
117-
118 \code-
119-
120 QSurfaceFormat format;-
121 // asks for a OpenGL 3.2 debug context using the Core profile-
122 format.setMajorVersion(3);-
123 format.setMinorVersion(2);-
124 format.setProfile(QSurfaceFormat::CoreProfile);-
125 format.setOption(QSurfaceFormat::DebugContext);-
126-
127 QOpenGLContext *context = new QOpenGLContext;-
128 context->setFormat(format);-
129 context->create();-
130-
131 \endcode-
132-
133 Note that requesting a 3.2 OpenGL Core Profile is just for the example's-
134 purposes; this class is not tied to any specific OpenGL or OpenGL ES-
135 version, as it relies on the availability of the \c{GL_KHR_debug} extension-
136 (see below).-
137-
138 \section1 Creating and Initializing a QOpenGLDebugLogger-
139-
140 QOpenGLDebugLogger is a simple QObject-derived class. Just like all QObject-
141 subclasses, you create an instance (and optionally specify a parent-
142 object), and like the other OpenGL functions in Qt you \e{must} initialize-
143 it before usage by calling initialize() whilst there is a current OpenGL context:-
144-
145 \code-
146-
147 QOpenGLContext *ctx = QOpenGLContext::currentContext();-
148 QOpenGLDebugLogger *logger = new QOpenGLDebugLogger(this);-
149-
150 logger->initialize(); // initializes in the current context, i.e. ctx-
151-
152 \endcode-
153-
154 Note that the \c{GL_KHR_debug} extension \e{must} be available in the context-
155 in order to access the messages logged by OpenGL. You can check the-
156 presence of this extension by calling:-
157-
158 \code-
159-
160 ctx->hasExtension(QByteArrayLiteral("GL_KHR_debug"))-
161-
162 \endcode-
163-
164 where \c{ctx} is a valid QOpenGLContext. If the extension is not available,-
165 initialize() will return false.-
166-
167 \section1 Reading the Internal OpenGL Debug Log-
168-
169 OpenGL implementations keep an internal log of debug messages. Messages-
170 stored in this log can be retrieved by using the loggedMessages() function:-
171-
172 \code-
173-
174 QList<QOpenGLDebugMessage> messages = logger->loggedMessages();-
175 foreach (const QOpenGLDebugMessage &message, messages)-
176 qDebug() << message;-
177-
178 \endcode-
179-
180 The internal log has a limited size; when it fills up, older messages will-
181 get discarded to make room for the new incoming messages. When you call-
182 loggedMessages(), the internal log will be emptied as well.-
183-
184 If you want to be sure not to lose any debug message, you must use real-time-
185 logging instead of calling this function. However, debug messages might-
186 still be generated in the timespan between context creation and activation-
187 of real-time logging (or, in general, when the real-time logging is disabled).-
188-
189 \section1 Real-time logging of messages-
190-
191 It is also possible to receive a stream of debug messages from the OpenGL-
192 server \e{as they are generated} by the implementation. In order to do so,-
193 you need to connect a suitable slot to the messageLogged() signal, and-
194 start logging by calling startLogging():-
195-
196 \code-
197-
198 connect(logger, &QOpenGLDebugLogger::messageLogged, receiver, &LogHandler::handleLoggedMessage);-
199 logger->startLogging();-
200-
201 \endcode-
202-
203 Similarly, logging can be disabled at any time by calling the stopLogging()-
204 function.-
205-
206 Real-time logging can be either asynchronous or synchronous, depending on-
207 the parameter passed to startLogging(). When logging in asynchronous mode-
208 (the default, as it has a very small overhead), the OpenGL implementation-
209 can generate messages at any time, and/or in an order which is different from the-
210 order of the OpenGL commands which caused those messages to be logged.-
211 The messages could also be generated from a thread that it's different from-
212 the thread the context is currently bound to. This is because OpenGL-
213 implementations are usually highly threaded and asynchronous, and therefore-
214 no warranties are made about the relative order and the timings of the-
215 debug messages.-
216-
217 On the other hand, logging in synchronous mode has a high overhead, but-
218 the OpenGL implementation guarantees that all the messages caused by a-
219 certain command are received in order, before the command returns,-
220 and from the same thread the OpenGL context is bound to.-
221-
222 This means that when logging in synchronous mode you will be able to run-
223 your OpenGL application in a debugger, put a breakpoint on a slot connected-
224 to the messageLogged() signal, and see in the backtrace the exact call-
225 that caused the logged message. This can be extremely useful to debug-
226 an OpenGL problem. Note that if OpenGL rendering is happening in another-
227 thread, you must force the signal/slot connection type to Qt::DirectConnection-
228 in order to be able to see the actual backtrace.-
229-
230 Refer to the LoggingMode enum documentation for more information about-
231 logging modes.-
232-
233 \note When real-time logging is enabled, debug messages will \e{not} be-
234 inserted in the internal OpenGL debug log any more; messages already-
235 present in the internal log will not be deleted, nor they will be emitted-
236 through the messageLogged() signal. Since some messages might be generated-
237 before real-time logging is started (and therefore be kept in the internal-
238 OpenGL log), it is important to always check if it contains any message-
239 after calling startLogging().-
240-
241 \section1 Inserting Messages in the Debug Log-
242-
243 It is possible for applications and libraries to insert custom messages in-
244 the debug log, for instance for marking a group of related OpenGL commands-
245 and therefore being then able to identify eventual messages coming from them.-
246-
247 In order to do so, you can create a QOpenGLDebugMessage object by calling-
248 \l{QOpenGLDebugMessage::}{createApplicationMessage()} or-
249 \l{QOpenGLDebugMessage::}{createThirdPartyMessage()}, and then inserting it-
250 into the log by calling logMessage():-
251-
252 \code-
253-
254 QOpenGLDebugMessage message =-
255 QOpenGLDebugMessage::createApplicationMessage(QStringLiteral("Custom message"));-
256-
257 logger->logMessage(message);-
258-
259 \endcode-
260-
261 Note that OpenGL implementations have a vendor-specific limit to the length-
262 of the messages that can be inserted in the debug log. You can retrieve-
263 this length by calling the maximumMessageLength() method; messages longer-
264 than the limit will automatically get truncated.-
265-
266 \section1 Controlling the Debug Output-
267-
268 QOpenGLDebugMessage is also able to apply filters to the debug messages, and-
269 therefore limit the amount of messages logged. You can enable or disable-
270 logging of messages by calling enableMessages() and disableMessages()-
271 respectively. By default, all messages are logged.-
272-
273 It is possible to enable or disable messages by selecting them by:-
274-
275 \list-
276 \li source, type and severity (and including all ids in the selection);-
277 \li id, source and type (and including all severities in the selection).-
278 \endlist-
279-
280 Note that the "enabled" status for a given message is a property of the-
281 (id, source, type, severity) tuple; the message attributes \e{do not} form-
282 a hierarchy of any kind. You should be careful about the order of the calls-
283 to enableMessages() and disableMessages(), as it will change which-
284 messages will are enabled / disabled.-
285-
286 It's not possible to filter by the message text itself; applications-
287 have to do that on their own (in slots connected to the messageLogged()-
288 signal, or after fetching the messages in the internal debug log-
289 through loggedMessages()).-
290-
291 In order to simplify the management of the enabled / disabled statuses,-
292 QOpenGLDebugMessage also supports the concept of \c{debug groups}. A debug-
293 group contains the group of enabled / disabled configurations of debug-
294 messages. Moreover, debug groups are organized in a stack: it is possible-
295 to push and pop groups by calling pushGroup() and popGroup() respectively.-
296 (When an OpenGL context is created, there is already a group in the stack).-
297-
298 The enableMessages() and disableMessages() functions will modify the-
299 configuration in the current debug group, that is, the one at the top of-
300 the debug groups stack.-
301-
302 When a new group is pushed onto the debug groups stack, it will inherit-
303 the configuration of the group that was previously on the top of the stack.-
304 Vice versa, popping a debug group will restore the configuration of-
305 the debug group that becomes the new top.-
306-
307 Pushing (respectively popping) debug groups will also automatically generate-
308 a debug message of type QOpenGLDebugMessage::GroupPushType (respectively-
309 \l{QOpenGLDebugMessage::}{GroupPopType}).-
310-
311 \sa QOpenGLDebugMessage-
312*/-
313-
314/*!-
315 \enum QOpenGLDebugMessage::Source-
316-
317 The Source enum defines the source of the debug message.-
318-
319 \value InvalidSource-
320 The source of the message is invalid; this is the source of a-
321 default-constructed QOpenGLDebugMessage object.-
322-
323 \value APISource-
324 The message was generated in response to OpenGL API calls.-
325-
326 \value WindowSystemSource-
327 The message was generated by the window system.-
328-
329 \value ShaderCompilerSource-
330 The message was generated by the shader compiler.-
331-
332 \value ThirdPartySource-
333 The message was generated by a third party, for instance an OpenGL-
334 framework a or debugging toolkit.-
335-
336 \value ApplicationSource-
337 The message was generated by the application itself.-
338-
339 \value OtherSource-
340 The message was generated by a source not included in this-
341 enumeration.-
342-
343 \omitvalue LastSource-
344-
345 \value AnySource-
346 This value corresponds to a mask of all possible message sources.-
347*/-
348-
349/*!-
350 \enum QOpenGLDebugMessage::Type-
351-
352 The Type enum defines the type of the debug message.-
353-
354 \value InvalidType-
355 The type of the message is invalid; this is the type of a-
356 default-constructed QOpenGLDebugMessage object.-
357-
358 \value ErrorType-
359 The message represents an error.-
360-
361 \value DeprecatedBehaviorType-
362 The message represents an usage of deprecated behavior.-
363-
364 \value UndefinedBehaviorType-
365 The message represents an usage of undefined behavior.-
366-
367 \value PortabilityType-
368 The message represents an usage of vendor-specific behavior,-
369 that might pose portability concerns.-
370-
371 \value PerformanceType-
372 The message represents a performance issue.-
373-
374 \value OtherType-
375 The message represents a type not included in this-
376 enumeration.-
377-
378 \value MarkerType-
379 The message represents a marker in the debug log.-
380-
381 \value GroupPushType-
382 The message represents a debug group push operation.-
383-
384 \value GroupPopType-
385 The message represents a debug group pop operation.-
386-
387 \omitvalue LastType-
388-
389 \value AnyType-
390 This value corresponds to a mask of all possible message types.-
391*/-
392-
393/*!-
394 \enum QOpenGLDebugMessage::Severity-
395-
396 The Severity enum defines the severity of the debug message.-
397-
398 \value InvalidSeverity-
399 The severity of the message is invalid; this is the severity of a-
400 default-constructed QOpenGLDebugMessage object.-
401-
402 \value HighSeverity-
403 The message has a high severity.-
404-
405 \value MediumSeverity-
406 The message has a medium severity.-
407-
408 \value LowSeverity-
409 The message has a low severity.-
410-
411 \value NotificationSeverity-
412 The message is a notification.-
413-
414 \omitvalue LastSeverity-
415-
416 \value AnySeverity-
417 This value corresponds to a mask of all possible message severities.-
418*/-
419-
420/*!-
421 \property QOpenGLDebugLogger::loggingMode-
422-
423 \brief the logging mode passed to startLogging().-
424-
425 Note that logging must have been started or the value of this property-
426 will be meaningless.-
427-
428 \sa startLogging(), isLogging()-
429*/-
430/*!-
431 \enum QOpenGLDebugLogger::LoggingMode-
432-
433 The LoggingMode enum defines the logging mode of the logger object.-
434-
435 \value AsynchronousLogging-
436 Messages from the OpenGL server are logged asynchronously. This means-
437 that messages can be logged some time after the corresponding OpenGL-
438 actions that caused them, and even be received in an out-of-order-
439 fashion, depending on the OpenGL implementation. This mode has a very low-
440 performance penalty, as OpenGL implementations are heavily threaded-
441 and asynchronous by nature.-
442-
443 \value SynchronousLogging-
444 Messages from the OpenGL server are logged synchronously and-
445 sequentially. This has a severe performance hit, as OpenGL-
446 implementations are very asynchronous by nature; but it's very useful-
447 to debug OpenGL problems, as OpenGL guarantees that the messages-
448 generated by a OpenGL command will be logged before the corresponding-
449 command execution has returned. Therefore, you can install a breakpoint-
450 on the messageLogged() signal and see in the backtrace which OpenGL-
451 command caused it; the only caveat is that if you are using OpenGL from-
452 multiple threads you may need to force direct connection when-
453 connecting to the messageLogged() signal.-
454*/-
455-
456// When using OpenGL ES 2.0, all the necessary GL_KHR_debug constants are-
457// provided in qopengles2ext.h. Unfortunately, newer versions of that file-
458// suffix everything with _KHR which causes extra headache when the goal is-
459// to have a single piece of code that builds in all our target-
460// environments. Therefore, try to detect this and use our custom defines-
461// instead, which we anyway need for OS X.-
462-
463#if defined(GL_KHR_debug) && defined(GL_DEBUG_SOURCE_API_KHR)-
464#define USE_MANUAL_DEFS-
465#endif-
466-
467// Under OSX (at least up to 10.8) we cannot include our copy of glext.h,-
468// but we use the system-wide one, which unfortunately lacks all the needed-
469// defines/typedefs. In order to make the code compile, we just add here-
470// the GL_KHR_debug defines.-
471-
472#ifndef GL_KHR_debug-
473#define GL_KHR_debug 1-
474#define USE_MANUAL_DEFS-
475#endif-
476-
477#ifdef USE_MANUAL_DEFS-
478-
479#ifndef GL_DEBUG_OUTPUT_SYNCHRONOUS-
480#define GL_DEBUG_OUTPUT_SYNCHRONOUS 0x8242-
481#endif-
482#ifndef GL_DEBUG_NEXT_LOGGED_MESSAGE_LENGTH-
483#define GL_DEBUG_NEXT_LOGGED_MESSAGE_LENGTH 0x8243-
484#endif-
485#ifndef GL_DEBUG_CALLBACK_FUNCTION-
486#define GL_DEBUG_CALLBACK_FUNCTION 0x8244-
487#endif-
488#ifndef GL_DEBUG_CALLBACK_USER_PARAM-
489#define GL_DEBUG_CALLBACK_USER_PARAM 0x8245-
490#endif-
491#ifndef GL_DEBUG_SOURCE_API-
492#define GL_DEBUG_SOURCE_API 0x8246-
493#endif-
494#ifndef GL_DEBUG_SOURCE_WINDOW_SYSTEM-
495#define GL_DEBUG_SOURCE_WINDOW_SYSTEM 0x8247-
496#endif-
497#ifndef GL_DEBUG_SOURCE_SHADER_COMPILER-
498#define GL_DEBUG_SOURCE_SHADER_COMPILER 0x8248-
499#endif-
500#ifndef GL_DEBUG_SOURCE_THIRD_PARTY-
501#define GL_DEBUG_SOURCE_THIRD_PARTY 0x8249-
502#endif-
503#ifndef GL_DEBUG_SOURCE_APPLICATION-
504#define GL_DEBUG_SOURCE_APPLICATION 0x824A-
505#endif-
506#ifndef GL_DEBUG_SOURCE_OTHER-
507#define GL_DEBUG_SOURCE_OTHER 0x824B-
508#endif-
509#ifndef GL_DEBUG_TYPE_ERROR-
510#define GL_DEBUG_TYPE_ERROR 0x824C-
511#endif-
512#ifndef GL_DEBUG_TYPE_DEPRECATED_BEHAVIOR-
513#define GL_DEBUG_TYPE_DEPRECATED_BEHAVIOR 0x824D-
514#endif-
515#ifndef GL_DEBUG_TYPE_UNDEFINED_BEHAVIOR-
516#define GL_DEBUG_TYPE_UNDEFINED_BEHAVIOR 0x824E-
517#endif-
518#ifndef GL_DEBUG_TYPE_PORTABILITY-
519#define GL_DEBUG_TYPE_PORTABILITY 0x824F-
520#endif-
521#ifndef GL_DEBUG_TYPE_PERFORMANCE-
522#define GL_DEBUG_TYPE_PERFORMANCE 0x8250-
523#endif-
524#ifndef GL_DEBUG_TYPE_OTHER-
525#define GL_DEBUG_TYPE_OTHER 0x8251-
526#endif-
527#ifndef GL_DEBUG_TYPE_MARKER-
528#define GL_DEBUG_TYPE_MARKER 0x8268-
529#endif-
530#ifndef GL_DEBUG_TYPE_PUSH_GROUP-
531#define GL_DEBUG_TYPE_PUSH_GROUP 0x8269-
532#endif-
533#ifndef GL_DEBUG_TYPE_POP_GROUP-
534#define GL_DEBUG_TYPE_POP_GROUP 0x826A-
535#endif-
536#ifndef GL_DEBUG_SEVERITY_NOTIFICATION-
537#define GL_DEBUG_SEVERITY_NOTIFICATION 0x826B-
538#endif-
539#ifndef GL_MAX_DEBUG_GROUP_STACK_DEPTH-
540#define GL_MAX_DEBUG_GROUP_STACK_DEPTH 0x826C-
541#endif-
542#ifndef GL_DEBUG_GROUP_STACK_DEPTH-
543#define GL_DEBUG_GROUP_STACK_DEPTH 0x826D-
544#endif-
545#ifndef GL_BUFFER-
546#define GL_BUFFER 0x82E0-
547#endif-
548#ifndef GL_SHADER-
549#define GL_SHADER 0x82E1-
550#endif-
551#ifndef GL_PROGRAM-
552#define GL_PROGRAM 0x82E2-
553#endif-
554#ifndef GL_QUERY-
555#define GL_QUERY 0x82E3-
556#endif-
557#ifndef GL_PROGRAM_PIPELINE-
558#define GL_PROGRAM_PIPELINE 0x82E4-
559#endif-
560#ifndef GL_SAMPLER-
561#define GL_SAMPLER 0x82E6-
562#endif-
563#ifndef GL_DISPLAY_LIST-
564#define GL_DISPLAY_LIST 0x82E7-
565#endif-
566#ifndef GL_MAX_LABEL_LENGTH-
567#define GL_MAX_LABEL_LENGTH 0x82E8-
568#endif-
569#ifndef GL_MAX_DEBUG_MESSAGE_LENGTH-
570#define GL_MAX_DEBUG_MESSAGE_LENGTH 0x9143-
571#endif-
572#ifndef GL_MAX_DEBUG_LOGGED_MESSAGES-
573#define GL_MAX_DEBUG_LOGGED_MESSAGES 0x9144-
574#endif-
575#ifndef GL_DEBUG_LOGGED_MESSAGES-
576#define GL_DEBUG_LOGGED_MESSAGES 0x9145-
577#endif-
578#ifndef GL_DEBUG_SEVERITY_HIGH-
579#define GL_DEBUG_SEVERITY_HIGH 0x9146-
580#endif-
581#ifndef GL_DEBUG_SEVERITY_MEDIUM-
582#define GL_DEBUG_SEVERITY_MEDIUM 0x9147-
583#endif-
584#ifndef GL_DEBUG_SEVERITY_LOW-
585#define GL_DEBUG_SEVERITY_LOW 0x9148-
586#endif-
587#ifndef GL_DEBUG_OUTPUT-
588#define GL_DEBUG_OUTPUT 0x92E0-
589#endif-
590#ifndef GL_CONTEXT_FLAG_DEBUG_BIT-
591#define GL_CONTEXT_FLAG_DEBUG_BIT 0x00000002-
592#endif-
593#ifndef GL_STACK_OVERFLOW-
594#define GL_STACK_OVERFLOW 0x0503-
595#endif-
596#ifndef GL_STACK_UNDERFLOW-
597#define GL_STACK_UNDERFLOW 0x0504-
598#endif-
599-
600typedef void (QOPENGLF_APIENTRY *GLDEBUGPROC)(GLenum source,GLenum type,GLuint id,GLenum severity,GLsizei length,const GLchar *message,const GLvoid *userParam);-
601-
602#endif /* USE_MANUAL_DEFS */-
603-
604-
605/*!-
606 \internal-
607*/-
608static QOpenGLDebugMessage::Source qt_messageSourceFromGL(GLenum source)-
609{-
610 switch (source) {-
611 case GL_DEBUG_SOURCE_API:
never executed: case 0x8246:
0
612 return QOpenGLDebugMessage::APISource;
never executed: return QOpenGLDebugMessage::APISource;
0
613 case GL_DEBUG_SOURCE_WINDOW_SYSTEM:
never executed: case 0x8247:
0
614 return QOpenGLDebugMessage::WindowSystemSource;
never executed: return QOpenGLDebugMessage::WindowSystemSource;
0
615 case GL_DEBUG_SOURCE_SHADER_COMPILER:
never executed: case 0x8248:
0
616 return QOpenGLDebugMessage::ShaderCompilerSource;
never executed: return QOpenGLDebugMessage::ShaderCompilerSource;
0
617 case GL_DEBUG_SOURCE_THIRD_PARTY:
never executed: case 0x8249:
0
618 return QOpenGLDebugMessage::ThirdPartySource;
never executed: return QOpenGLDebugMessage::ThirdPartySource;
0
619 case GL_DEBUG_SOURCE_APPLICATION:
never executed: case 0x824A:
0
620 return QOpenGLDebugMessage::ApplicationSource;
never executed: return QOpenGLDebugMessage::ApplicationSource;
0
621 case GL_DEBUG_SOURCE_OTHER:
never executed: case 0x824B:
0
622 return QOpenGLDebugMessage::OtherSource;
never executed: return QOpenGLDebugMessage::OtherSource;
0
623 }-
624-
625 Q_ASSERT_X(false, Q_FUNC_INFO, "Unknown message source from GL");-
626 return QOpenGLDebugMessage::OtherSource;
never executed: return QOpenGLDebugMessage::OtherSource;
0
627}-
628-
629/*!-
630 \internal-
631*/-
632static GLenum qt_messageSourceToGL(QOpenGLDebugMessage::Source source)-
633{-
634 switch (source) {-
635 case QOpenGLDebugMessage::InvalidSource:
never executed: case QOpenGLDebugMessage::InvalidSource:
0
636 break;
never executed: break;
0
637 case QOpenGLDebugMessage::APISource:
never executed: case QOpenGLDebugMessage::APISource:
0
638 return GL_DEBUG_SOURCE_API;
never executed: return 0x8246;
0
639 case QOpenGLDebugMessage::WindowSystemSource:
never executed: case QOpenGLDebugMessage::WindowSystemSource:
0
640 return GL_DEBUG_SOURCE_WINDOW_SYSTEM;
never executed: return 0x8247;
0
641 case QOpenGLDebugMessage::ShaderCompilerSource:
never executed: case QOpenGLDebugMessage::ShaderCompilerSource:
0
642 return GL_DEBUG_SOURCE_SHADER_COMPILER;
never executed: return 0x8248;
0
643 case QOpenGLDebugMessage::ThirdPartySource:
never executed: case QOpenGLDebugMessage::ThirdPartySource:
0
644 return GL_DEBUG_SOURCE_THIRD_PARTY;
never executed: return 0x8249;
0
645 case QOpenGLDebugMessage::ApplicationSource:
never executed: case QOpenGLDebugMessage::ApplicationSource:
0
646 return GL_DEBUG_SOURCE_APPLICATION;
never executed: return 0x824A;
0
647 case QOpenGLDebugMessage::OtherSource:
never executed: case QOpenGLDebugMessage::OtherSource:
0
648 return GL_DEBUG_SOURCE_OTHER;
never executed: return 0x824B;
0
649 case QOpenGLDebugMessage::AnySource:
never executed: case QOpenGLDebugMessage::AnySource:
0
650 break;
never executed: break;
0
651 }-
652-
653 Q_ASSERT_X(false, Q_FUNC_INFO, "Invalid message source");-
654 return GL_DEBUG_SOURCE_OTHER;
never executed: return 0x824B;
0
655}-
656-
657/*!-
658 \internal-
659*/-
660static QString qt_messageSourceToString(QOpenGLDebugMessage::Source source)-
661{-
662 switch (source) {-
663 case QOpenGLDebugMessage::InvalidSource:
never executed: case QOpenGLDebugMessage::InvalidSource:
0
664 return QStringLiteral("InvalidSource");
never executed: return ([]() -> QString { enum { Size = sizeof(u"" "InvalidSource")/2 - 1 }; static const QStaticStringData<Size> qstring_literal = { { { { -1 } }, Size, 0, 0, sizeof(QStringData) }, u"" "InvalidSource" }; QStringDataPtr holder = { qstring_literal.data_ptr() }; const QString qstring_literal_temp(holder); return qstring_literal_temp; }());
never executed: return qstring_literal_temp;
0
665 case QOpenGLDebugMessage::APISource:
never executed: case QOpenGLDebugMessage::APISource:
0
666 return QStringLiteral("APISource");
never executed: return ([]() -> QString { enum { Size = sizeof(u"" "APISource")/2 - 1 }; static const QStaticStringData<Size> qstring_literal = { { { { -1 } }, Size, 0, 0, sizeof(QStringData) }, u"" "APISource" }; QStringDataPtr holder = { qstring_literal.data_ptr() }; const QString qstring_literal_temp(holder); return qstring_literal_temp; }());
never executed: return qstring_literal_temp;
0
667 case QOpenGLDebugMessage::WindowSystemSource:
never executed: case QOpenGLDebugMessage::WindowSystemSource:
0
668 return QStringLiteral("WindowSystemSource");
never executed: return ([]() -> QString { enum { Size = sizeof(u"" "WindowSystemSource")/2 - 1 }; static const QStaticStringData<Size> qstring_literal = { { { { -1 } }, Size, 0, 0, sizeof(QStringData) }, u"" "WindowSystemSource" }; QStringDataPtr holder = { qstring_literal.data_ptr() }; const QString qstring_literal_temp(holder); return qstring_literal_temp; }());
never executed: return qstring_literal_temp;
0
669 case QOpenGLDebugMessage::ShaderCompilerSource:
never executed: case QOpenGLDebugMessage::ShaderCompilerSource:
0
670 return QStringLiteral("ShaderCompilerSource");
never executed: return ([]() -> QString { enum { Size = sizeof(u"" "ShaderCompilerSource")/2 - 1 }; static const QStaticStringData<Size> qstring_literal = { { { { -1 } }, Size, 0, 0, sizeof(QStringData) }, u"" "ShaderCompilerSource" }; QStringDataPtr holder = { qstring_literal.data_ptr() }; const QString qstring_literal_temp(holder); return qstring_literal_temp; }());
never executed: return qstring_literal_temp;
0
671 case QOpenGLDebugMessage::ThirdPartySource:
never executed: case QOpenGLDebugMessage::ThirdPartySource:
0
672 return QStringLiteral("ThirdPartySource");
never executed: return ([]() -> QString { enum { Size = sizeof(u"" "ThirdPartySource")/2 - 1 }; static const QStaticStringData<Size> qstring_literal = { { { { -1 } }, Size, 0, 0, sizeof(QStringData) }, u"" "ThirdPartySource" }; QStringDataPtr holder = { qstring_literal.data_ptr() }; const QString qstring_literal_temp(holder); return qstring_literal_temp; }());
never executed: return qstring_literal_temp;
0
673 case QOpenGLDebugMessage::ApplicationSource:
never executed: case QOpenGLDebugMessage::ApplicationSource:
0
674 return QStringLiteral("ApplicationSource");
never executed: return ([]() -> QString { enum { Size = sizeof(u"" "ApplicationSource")/2 - 1 }; static const QStaticStringData<Size> qstring_literal = { { { { -1 } }, Size, 0, 0, sizeof(QStringData) }, u"" "ApplicationSource" }; QStringDataPtr holder = { qstring_literal.data_ptr() }; const QString qstring_literal_temp(holder); return qstring_literal_temp; }());
never executed: return qstring_literal_temp;
0
675 case QOpenGLDebugMessage::OtherSource:
never executed: case QOpenGLDebugMessage::OtherSource:
0
676 return QStringLiteral("OtherSource");
never executed: return ([]() -> QString { enum { Size = sizeof(u"" "OtherSource")/2 - 1 }; static const QStaticStringData<Size> qstring_literal = { { { { -1 } }, Size, 0, 0, sizeof(QStringData) }, u"" "OtherSource" }; QStringDataPtr holder = { qstring_literal.data_ptr() }; const QString qstring_literal_temp(holder); return qstring_literal_temp; }());
never executed: return qstring_literal_temp;
0
677 case QOpenGLDebugMessage::AnySource:
never executed: case QOpenGLDebugMessage::AnySource:
0
678 return QStringLiteral("AnySource");
never executed: return ([]() -> QString { enum { Size = sizeof(u"" "AnySource")/2 - 1 }; static const QStaticStringData<Size> qstring_literal = { { { { -1 } }, Size, 0, 0, sizeof(QStringData) }, u"" "AnySource" }; QStringDataPtr holder = { qstring_literal.data_ptr() }; const QString qstring_literal_temp(holder); return qstring_literal_temp; }());
never executed: return qstring_literal_temp;
0
679 }-
680-
681 Q_ASSERT_X(false, Q_FUNC_INFO, "Unknown message source");-
682 return QString();
never executed: return QString();
0
683}-
684-
685/*!-
686 \internal-
687*/-
688static QOpenGLDebugMessage::Type qt_messageTypeFromGL(GLenum type)-
689{-
690 switch (type) {-
691 case GL_DEBUG_TYPE_ERROR:
never executed: case 0x824C:
0
692 return QOpenGLDebugMessage::ErrorType;
never executed: return QOpenGLDebugMessage::ErrorType;
0
693 case GL_DEBUG_TYPE_DEPRECATED_BEHAVIOR:
never executed: case 0x824D:
0
694 return QOpenGLDebugMessage::DeprecatedBehaviorType;
never executed: return QOpenGLDebugMessage::DeprecatedBehaviorType;
0
695 case GL_DEBUG_TYPE_UNDEFINED_BEHAVIOR:
never executed: case 0x824E:
0
696 return QOpenGLDebugMessage::UndefinedBehaviorType;
never executed: return QOpenGLDebugMessage::UndefinedBehaviorType;
0
697 case GL_DEBUG_TYPE_PORTABILITY:
never executed: case 0x824F:
0
698 return QOpenGLDebugMessage::PortabilityType;
never executed: return QOpenGLDebugMessage::PortabilityType;
0
699 case GL_DEBUG_TYPE_PERFORMANCE:
never executed: case 0x8250:
0
700 return QOpenGLDebugMessage::PerformanceType;
never executed: return QOpenGLDebugMessage::PerformanceType;
0
701 case GL_DEBUG_TYPE_OTHER:
never executed: case 0x8251:
0
702 return QOpenGLDebugMessage::OtherType;
never executed: return QOpenGLDebugMessage::OtherType;
0
703 case GL_DEBUG_TYPE_MARKER:
never executed: case 0x8268:
0
704 return QOpenGLDebugMessage::MarkerType;
never executed: return QOpenGLDebugMessage::MarkerType;
0
705 case GL_DEBUG_TYPE_PUSH_GROUP:
never executed: case 0x8269:
0
706 return QOpenGLDebugMessage::GroupPushType;
never executed: return QOpenGLDebugMessage::GroupPushType;
0
707 case GL_DEBUG_TYPE_POP_GROUP:
never executed: case 0x826A:
0
708 return QOpenGLDebugMessage::GroupPopType;
never executed: return QOpenGLDebugMessage::GroupPopType;
0
709 }-
710-
711 Q_ASSERT_X(false, Q_FUNC_INFO, "Unknown message type from GL");-
712 return QOpenGLDebugMessage::OtherType;
never executed: return QOpenGLDebugMessage::OtherType;
0
713}-
714-
715/*!-
716 \internal-
717*/-
718static GLenum qt_messageTypeToGL(QOpenGLDebugMessage::Type type)-
719{-
720 switch (type) {-
721 case QOpenGLDebugMessage::InvalidType:
never executed: case QOpenGLDebugMessage::InvalidType:
0
722 break;
never executed: break;
0
723 case QOpenGLDebugMessage::ErrorType:
never executed: case QOpenGLDebugMessage::ErrorType:
0
724 return GL_DEBUG_TYPE_ERROR;
never executed: return 0x824C;
0
725 case QOpenGLDebugMessage::DeprecatedBehaviorType:
never executed: case QOpenGLDebugMessage::DeprecatedBehaviorType:
0
726 return GL_DEBUG_TYPE_DEPRECATED_BEHAVIOR;
never executed: return 0x824D;
0
727 case QOpenGLDebugMessage::UndefinedBehaviorType:
never executed: case QOpenGLDebugMessage::UndefinedBehaviorType:
0
728 return GL_DEBUG_TYPE_UNDEFINED_BEHAVIOR;
never executed: return 0x824E;
0
729 case QOpenGLDebugMessage::PortabilityType:
never executed: case QOpenGLDebugMessage::PortabilityType:
0
730 return GL_DEBUG_TYPE_PORTABILITY;
never executed: return 0x824F;
0
731 case QOpenGLDebugMessage::PerformanceType:
never executed: case QOpenGLDebugMessage::PerformanceType:
0
732 return GL_DEBUG_TYPE_PERFORMANCE;
never executed: return 0x8250;
0
733 case QOpenGLDebugMessage::OtherType:
never executed: case QOpenGLDebugMessage::OtherType:
0
734 return GL_DEBUG_TYPE_OTHER;
never executed: return 0x8251;
0
735 case QOpenGLDebugMessage::MarkerType:
never executed: case QOpenGLDebugMessage::MarkerType:
0
736 return GL_DEBUG_TYPE_MARKER;
never executed: return 0x8268;
0
737 case QOpenGLDebugMessage::GroupPushType:
never executed: case QOpenGLDebugMessage::GroupPushType:
0
738 return GL_DEBUG_TYPE_PUSH_GROUP;
never executed: return 0x8269;
0
739 case QOpenGLDebugMessage::GroupPopType:
never executed: case QOpenGLDebugMessage::GroupPopType:
0
740 return GL_DEBUG_TYPE_POP_GROUP;
never executed: return 0x826A;
0
741 case QOpenGLDebugMessage::AnyType:
never executed: case QOpenGLDebugMessage::AnyType:
0
742 break;
never executed: break;
0
743 }-
744-
745 Q_ASSERT_X(false, Q_FUNC_INFO, "Invalid message type");-
746 return GL_DEBUG_TYPE_OTHER;
never executed: return 0x8251;
0
747}-
748-
749/*!-
750 \internal-
751*/-
752static QString qt_messageTypeToString(QOpenGLDebugMessage::Type type)-
753{-
754 switch (type) {-
755 case QOpenGLDebugMessage::InvalidType:
never executed: case QOpenGLDebugMessage::InvalidType:
0
756 return QStringLiteral("InvalidType");
never executed: return ([]() -> QString { enum { Size = sizeof(u"" "InvalidType")/2 - 1 }; static const QStaticStringData<Size> qstring_literal = { { { { -1 } }, Size, 0, 0, sizeof(QStringData) }, u"" "InvalidType" }; QStringDataPtr holder = { qstring_literal.data_ptr() }; const QString qstring_literal_temp(holder); return qstring_literal_temp; }());
never executed: return qstring_literal_temp;
0
757 case QOpenGLDebugMessage::ErrorType:
never executed: case QOpenGLDebugMessage::ErrorType:
0
758 return QStringLiteral("ErrorType");
never executed: return ([]() -> QString { enum { Size = sizeof(u"" "ErrorType")/2 - 1 }; static const QStaticStringData<Size> qstring_literal = { { { { -1 } }, Size, 0, 0, sizeof(QStringData) }, u"" "ErrorType" }; QStringDataPtr holder = { qstring_literal.data_ptr() }; const QString qstring_literal_temp(holder); return qstring_literal_temp; }());
never executed: return qstring_literal_temp;
0
759 case QOpenGLDebugMessage::DeprecatedBehaviorType:
never executed: case QOpenGLDebugMessage::DeprecatedBehaviorType:
0
760 return QStringLiteral("DeprecatedBehaviorType");
never executed: return ([]() -> QString { enum { Size = sizeof(u"" "DeprecatedBehaviorType")/2 - 1 }; static const QStaticStringData<Size> qstring_literal = { { { { -1 } }, Size, 0, 0, sizeof(QStringData) }, u"" "DeprecatedBehaviorType" }; QStringDataPtr holder = { qstring_literal.data_ptr() }; const QString qstring_literal_temp(holder); return qstring_literal_temp; }());
never executed: return qstring_literal_temp;
0
761 case QOpenGLDebugMessage::UndefinedBehaviorType:
never executed: case QOpenGLDebugMessage::UndefinedBehaviorType:
0
762 return QStringLiteral("UndefinedBehaviorType");
never executed: return ([]() -> QString { enum { Size = sizeof(u"" "UndefinedBehaviorType")/2 - 1 }; static const QStaticStringData<Size> qstring_literal = { { { { -1 } }, Size, 0, 0, sizeof(QStringData) }, u"" "UndefinedBehaviorType" }; QStringDataPtr holder = { qstring_literal.data_ptr() }; const QString qstring_literal_temp(holder); return qstring_literal_temp; }());
never executed: return qstring_literal_temp;
0
763 case QOpenGLDebugMessage::PortabilityType:
never executed: case QOpenGLDebugMessage::PortabilityType:
0
764 return QStringLiteral("PortabilityType");
never executed: return ([]() -> QString { enum { Size = sizeof(u"" "PortabilityType")/2 - 1 }; static const QStaticStringData<Size> qstring_literal = { { { { -1 } }, Size, 0, 0, sizeof(QStringData) }, u"" "PortabilityType" }; QStringDataPtr holder = { qstring_literal.data_ptr() }; const QString qstring_literal_temp(holder); return qstring_literal_temp; }());
never executed: return qstring_literal_temp;
0
765 case QOpenGLDebugMessage::PerformanceType:
never executed: case QOpenGLDebugMessage::PerformanceType:
0
766 return QStringLiteral("PerformanceType");
never executed: return ([]() -> QString { enum { Size = sizeof(u"" "PerformanceType")/2 - 1 }; static const QStaticStringData<Size> qstring_literal = { { { { -1 } }, Size, 0, 0, sizeof(QStringData) }, u"" "PerformanceType" }; QStringDataPtr holder = { qstring_literal.data_ptr() }; const QString qstring_literal_temp(holder); return qstring_literal_temp; }());
never executed: return qstring_literal_temp;
0
767 case QOpenGLDebugMessage::OtherType:
never executed: case QOpenGLDebugMessage::OtherType:
0
768 return QStringLiteral("OtherType");
never executed: return ([]() -> QString { enum { Size = sizeof(u"" "OtherType")/2 - 1 }; static const QStaticStringData<Size> qstring_literal = { { { { -1 } }, Size, 0, 0, sizeof(QStringData) }, u"" "OtherType" }; QStringDataPtr holder = { qstring_literal.data_ptr() }; const QString qstring_literal_temp(holder); return qstring_literal_temp; }());
never executed: return qstring_literal_temp;
0
769 case QOpenGLDebugMessage::MarkerType:
never executed: case QOpenGLDebugMessage::MarkerType:
0
770 return QStringLiteral("MarkerType");
never executed: return ([]() -> QString { enum { Size = sizeof(u"" "MarkerType")/2 - 1 }; static const QStaticStringData<Size> qstring_literal = { { { { -1 } }, Size, 0, 0, sizeof(QStringData) }, u"" "MarkerType" }; QStringDataPtr holder = { qstring_literal.data_ptr() }; const QString qstring_literal_temp(holder); return qstring_literal_temp; }());
never executed: return qstring_literal_temp;
0
771 case QOpenGLDebugMessage::GroupPushType:
never executed: case QOpenGLDebugMessage::GroupPushType:
0
772 return QStringLiteral("GroupPushType");
never executed: return ([]() -> QString { enum { Size = sizeof(u"" "GroupPushType")/2 - 1 }; static const QStaticStringData<Size> qstring_literal = { { { { -1 } }, Size, 0, 0, sizeof(QStringData) }, u"" "GroupPushType" }; QStringDataPtr holder = { qstring_literal.data_ptr() }; const QString qstring_literal_temp(holder); return qstring_literal_temp; }());
never executed: return qstring_literal_temp;
0
773 case QOpenGLDebugMessage::GroupPopType:
never executed: case QOpenGLDebugMessage::GroupPopType:
0
774 return QStringLiteral("GroupPopType");
never executed: return ([]() -> QString { enum { Size = sizeof(u"" "GroupPopType")/2 - 1 }; static const QStaticStringData<Size> qstring_literal = { { { { -1 } }, Size, 0, 0, sizeof(QStringData) }, u"" "GroupPopType" }; QStringDataPtr holder = { qstring_literal.data_ptr() }; const QString qstring_literal_temp(holder); return qstring_literal_temp; }());
never executed: return qstring_literal_temp;
0
775 case QOpenGLDebugMessage::AnyType:
never executed: case QOpenGLDebugMessage::AnyType:
0
776 return QStringLiteral("AnyType");
never executed: return ([]() -> QString { enum { Size = sizeof(u"" "AnyType")/2 - 1 }; static const QStaticStringData<Size> qstring_literal = { { { { -1 } }, Size, 0, 0, sizeof(QStringData) }, u"" "AnyType" }; QStringDataPtr holder = { qstring_literal.data_ptr() }; const QString qstring_literal_temp(holder); return qstring_literal_temp; }());
never executed: return qstring_literal_temp;
0
777 }-
778-
779 Q_ASSERT_X(false, Q_FUNC_INFO, "Unknown message type");-
780 return QString();
never executed: return QString();
0
781}-
782-
783/*!-
784 \internal-
785*/-
786static QOpenGLDebugMessage::Severity qt_messageSeverityFromGL(GLenum severity)-
787{-
788 switch (severity) {-
789 case GL_DEBUG_SEVERITY_HIGH:
never executed: case 0x9146:
0
790 return QOpenGLDebugMessage::HighSeverity;
never executed: return QOpenGLDebugMessage::HighSeverity;
0
791 case GL_DEBUG_SEVERITY_MEDIUM:
never executed: case 0x9147:
0
792 return QOpenGLDebugMessage::MediumSeverity;
never executed: return QOpenGLDebugMessage::MediumSeverity;
0
793 case GL_DEBUG_SEVERITY_LOW:
never executed: case 0x9148:
0
794 return QOpenGLDebugMessage::LowSeverity;
never executed: return QOpenGLDebugMessage::LowSeverity;
0
795 case GL_DEBUG_SEVERITY_NOTIFICATION:
never executed: case 0x826B:
0
796 return QOpenGLDebugMessage::NotificationSeverity;
never executed: return QOpenGLDebugMessage::NotificationSeverity;
0
797 }-
798-
799 Q_ASSERT_X(false, Q_FUNC_INFO, "Unknown message severity from GL");-
800 return QOpenGLDebugMessage::NotificationSeverity;
never executed: return QOpenGLDebugMessage::NotificationSeverity;
0
801}-
802-
803/*!-
804 \internal-
805*/-
806static GLenum qt_messageSeverityToGL(QOpenGLDebugMessage::Severity severity)-
807{-
808 switch (severity) {-
809 case QOpenGLDebugMessage::InvalidSeverity:
never executed: case QOpenGLDebugMessage::InvalidSeverity:
0
810 break;
never executed: break;
0
811 case QOpenGLDebugMessage::HighSeverity:
never executed: case QOpenGLDebugMessage::HighSeverity:
0
812 return GL_DEBUG_SEVERITY_HIGH;
never executed: return 0x9146;
0
813 case QOpenGLDebugMessage::MediumSeverity:
never executed: case QOpenGLDebugMessage::MediumSeverity:
0
814 return GL_DEBUG_SEVERITY_MEDIUM;
never executed: return 0x9147;
0
815 case QOpenGLDebugMessage::LowSeverity:
never executed: case QOpenGLDebugMessage::LowSeverity:
0
816 return GL_DEBUG_SEVERITY_LOW;
never executed: return 0x9148;
0
817 case QOpenGLDebugMessage::NotificationSeverity:
never executed: case QOpenGLDebugMessage::NotificationSeverity:
0
818 return GL_DEBUG_SEVERITY_NOTIFICATION;
never executed: return 0x826B;
0
819 case QOpenGLDebugMessage::AnySeverity:
never executed: case QOpenGLDebugMessage::AnySeverity:
0
820 break;
never executed: break;
0
821 }-
822-
823 Q_ASSERT_X(false, Q_FUNC_INFO, "Invalid message severity");-
824 return GL_DEBUG_SEVERITY_NOTIFICATION;
never executed: return 0x826B;
0
825}-
826-
827/*!-
828 \internal-
829*/-
830static QString qt_messageSeverityToString(QOpenGLDebugMessage::Severity severity)-
831{-
832 switch (severity) {-
833 case QOpenGLDebugMessage::InvalidSeverity:
never executed: case QOpenGLDebugMessage::InvalidSeverity:
0
834 return QStringLiteral("InvalidSeverity");
never executed: return ([]() -> QString { enum { Size = sizeof(u"" "InvalidSeverity")/2 - 1 }; static const QStaticStringData<Size> qstring_literal = { { { { -1 } }, Size, 0, 0, sizeof(QStringData) }, u"" "InvalidSeverity" }; QStringDataPtr holder = { qstring_literal.data_ptr() }; const QString qstring_literal_temp(holder); return qstring_literal_temp; }());
never executed: return qstring_literal_temp;
0
835 case QOpenGLDebugMessage::HighSeverity:
never executed: case QOpenGLDebugMessage::HighSeverity:
0
836 return QStringLiteral("HighSeverity");
never executed: return ([]() -> QString { enum { Size = sizeof(u"" "HighSeverity")/2 - 1 }; static const QStaticStringData<Size> qstring_literal = { { { { -1 } }, Size, 0, 0, sizeof(QStringData) }, u"" "HighSeverity" }; QStringDataPtr holder = { qstring_literal.data_ptr() }; const QString qstring_literal_temp(holder); return qstring_literal_temp; }());
never executed: return qstring_literal_temp;
0
837 case QOpenGLDebugMessage::MediumSeverity:
never executed: case QOpenGLDebugMessage::MediumSeverity:
0
838 return QStringLiteral("MediumSeverity");
never executed: return ([]() -> QString { enum { Size = sizeof(u"" "MediumSeverity")/2 - 1 }; static const QStaticStringData<Size> qstring_literal = { { { { -1 } }, Size, 0, 0, sizeof(QStringData) }, u"" "MediumSeverity" }; QStringDataPtr holder = { qstring_literal.data_ptr() }; const QString qstring_literal_temp(holder); return qstring_literal_temp; }());
never executed: return qstring_literal_temp;
0
839 case QOpenGLDebugMessage::LowSeverity:
never executed: case QOpenGLDebugMessage::LowSeverity:
0
840 return QStringLiteral("LowSeverity");
never executed: return ([]() -> QString { enum { Size = sizeof(u"" "LowSeverity")/2 - 1 }; static const QStaticStringData<Size> qstring_literal = { { { { -1 } }, Size, 0, 0, sizeof(QStringData) }, u"" "LowSeverity" }; QStringDataPtr holder = { qstring_literal.data_ptr() }; const QString qstring_literal_temp(holder); return qstring_literal_temp; }());
never executed: return qstring_literal_temp;
0
841 case QOpenGLDebugMessage::NotificationSeverity:
never executed: case QOpenGLDebugMessage::NotificationSeverity:
0
842 return QStringLiteral("NotificationSeverity");
never executed: return ([]() -> QString { enum { Size = sizeof(u"" "NotificationSeverity")/2 - 1 }; static const QStaticStringData<Size> qstring_literal = { { { { -1 } }, Size, 0, 0, sizeof(QStringData) }, u"" "NotificationSeverity" }; QStringDataPtr holder = { qstring_literal.data_ptr() }; const QString qstring_literal_temp(holder); return qstring_literal_temp; }());
never executed: return qstring_literal_temp;
0
843 case QOpenGLDebugMessage::AnySeverity:
never executed: case QOpenGLDebugMessage::AnySeverity:
0
844 return QStringLiteral("AnySeverity");
never executed: return ([]() -> QString { enum { Size = sizeof(u"" "AnySeverity")/2 - 1 }; static const QStaticStringData<Size> qstring_literal = { { { { -1 } }, Size, 0, 0, sizeof(QStringData) }, u"" "AnySeverity" }; QStringDataPtr holder = { qstring_literal.data_ptr() }; const QString qstring_literal_temp(holder); return qstring_literal_temp; }());
never executed: return qstring_literal_temp;
0
845 }-
846-
847 Q_ASSERT_X(false, Q_FUNC_INFO, "Unknown message severity");-
848 return QString();
never executed: return QString();
0
849}-
850-
851class QOpenGLDebugMessagePrivate : public QSharedData-
852{-
853public:-
854 QOpenGLDebugMessagePrivate();-
855-
856 QString message;-
857 GLuint id;-
858 QOpenGLDebugMessage::Source source;-
859 QOpenGLDebugMessage::Type type;-
860 QOpenGLDebugMessage::Severity severity;-
861};-
862-
863/*!-
864 \internal-
865*/-
866QOpenGLDebugMessagePrivate::QOpenGLDebugMessagePrivate()-
867 : message(),-
868 id(0),-
869 source(QOpenGLDebugMessage::InvalidSource),-
870 type(QOpenGLDebugMessage::InvalidType),-
871 severity(QOpenGLDebugMessage::InvalidSeverity)-
872{-
873}
never executed: end of block
0
874-
875-
876/*!-
877 Constructs a debug message with an empty message string, id set to 0,-
878 source set to InvalidSource, type set to InvalidType, and severity set to-
879 InvalidSeverity.-
880-
881 \note This constructor should not be used to create a debug message;-
882 instead, use the createApplicationMessage() or the createThirdPartyMessage()-
883 static functions.-
884-
885 \sa createApplicationMessage(), createThirdPartyMessage()-
886*/-
887QOpenGLDebugMessage::QOpenGLDebugMessage()-
888 : d(new QOpenGLDebugMessagePrivate)-
889{-
890}
never executed: end of block
0
891-
892/*!-
893 Constructs a debug message as a copy of \a debugMessage.-
894-
895 \sa operator=()-
896*/-
897QOpenGLDebugMessage::QOpenGLDebugMessage(const QOpenGLDebugMessage &debugMessage)-
898 : d(debugMessage.d)-
899{-
900}
never executed: end of block
0
901-
902/*!-
903 Destroys this debug message.-
904*/-
905QOpenGLDebugMessage::~QOpenGLDebugMessage()-
906{-
907}-
908-
909/*!-
910 Assigns the message \a debugMessage to this object, and returns a reference-
911 to the copy.-
912*/-
913QOpenGLDebugMessage &QOpenGLDebugMessage::operator=(const QOpenGLDebugMessage &debugMessage)-
914{-
915 d = debugMessage.d;-
916 return *this;
never executed: return *this;
0
917}-
918-
919/*!-
920 \fn QOpenGLDebugMessage &QOpenGLDebugMessage::operator=(QOpenGLDebugMessage &&debugMessage)-
921-
922 Move-assigns \a debugMessage to this object.-
923*/-
924-
925/*!-
926 \fn void QOpenGLDebugMessage::swap(QOpenGLDebugMessage &debugMessage)-
927-
928 Swaps the message \a debugMessage with this message. This operation is very-
929 fast and never fails.-
930*/-
931-
932/*!-
933 Returns the source of the debug message.-
934*/-
935QOpenGLDebugMessage::Source QOpenGLDebugMessage::source() const-
936{-
937 return d->source;
never executed: return d->source;
0
938}-
939-
940/*!-
941 Returns the type of the debug message.-
942*/-
943QOpenGLDebugMessage::Type QOpenGLDebugMessage::type() const-
944{-
945 return d->type;
never executed: return d->type;
0
946}-
947-
948/*!-
949 Returns the severity of the debug message.-
950*/-
951QOpenGLDebugMessage::Severity QOpenGLDebugMessage::severity() const-
952{-
953 return d->severity;
never executed: return d->severity;
0
954}-
955-
956/*!-
957 Returns the id of the debug message. Ids are generally vendor-specific.-
958*/-
959GLuint QOpenGLDebugMessage::id() const-
960{-
961 return d->id;
never executed: return d->id;
0
962}-
963-
964/*!-
965 Returns the textual message contained by this debug message.-
966*/-
967QString QOpenGLDebugMessage::message() const-
968{-
969 return d->message;
never executed: return d->message;
0
970}-
971-
972/*!-
973 Constructs and returns a debug message with \a text as its text, \a id-
974 as id, \a severity as severity, and \a type as type. The message source-
975 will be set to ApplicationSource.-
976-
977 \sa QOpenGLDebugLogger::logMessage(), createThirdPartyMessage()-
978*/-
979QOpenGLDebugMessage QOpenGLDebugMessage::createApplicationMessage(const QString &text,-
980 GLuint id,-
981 QOpenGLDebugMessage::Severity severity,-
982 QOpenGLDebugMessage::Type type)-
983{-
984 QOpenGLDebugMessage m;-
985 m.d->message = text;-
986 m.d->id = id;-
987 m.d->severity = severity;-
988 m.d->type = type;-
989 m.d->source = ApplicationSource;-
990 return m;
never executed: return m;
0
991}-
992-
993/*!-
994 Constructs and returns a debug message with \a text as its text, \a id-
995 as id, \a severity as severity, and \a type as type. The message source-
996 will be set to ThirdPartySource.-
997-
998 \sa QOpenGLDebugLogger::logMessage(), createApplicationMessage()-
999*/-
1000QOpenGLDebugMessage QOpenGLDebugMessage::createThirdPartyMessage(const QString &text,-
1001 GLuint id,-
1002 QOpenGLDebugMessage::Severity severity,-
1003 QOpenGLDebugMessage::Type type)-
1004{-
1005 QOpenGLDebugMessage m;-
1006 m.d->message = text;-
1007 m.d->id = id;-
1008 m.d->severity = severity;-
1009 m.d->type = type;-
1010 m.d->source = ThirdPartySource;-
1011 return m;
never executed: return m;
0
1012}-
1013-
1014/*!-
1015 Returns \c true if this debug message is equal to \a debugMessage, or false-
1016 otherwise. Two debugging messages are equal if they have the same textual-
1017 message, the same id, the same source, the same type and the same severity.-
1018-
1019 \sa operator!=()-
1020*/-
1021bool QOpenGLDebugMessage::operator==(const QOpenGLDebugMessage &debugMessage) const-
1022{-
1023 return (d == debugMessage.d)
never executed: return (d == debugMessage.d) || (d->id == debugMessage.d->id && d->source == debugMessage.d->source && d->type == debugMessage.d->type && d->severity == debugMessage.d->severity && d->message == debugMessage.d->message);
(d == debugMessage.d)Description
TRUEnever evaluated
FALSEnever evaluated
0
1024 || (d->id == debugMessage.d->id
never executed: return (d == debugMessage.d) || (d->id == debugMessage.d->id && d->source == debugMessage.d->source && d->type == debugMessage.d->type && d->severity == debugMessage.d->severity && d->message == debugMessage.d->message);
d->id == debugMessage.d->idDescription
TRUEnever evaluated
FALSEnever evaluated
0
1025 && d->source == debugMessage.d->source
never executed: return (d == debugMessage.d) || (d->id == debugMessage.d->id && d->source == debugMessage.d->source && d->type == debugMessage.d->type && d->severity == debugMessage.d->severity && d->message == debugMessage.d->message);
d->source == d...sage.d->sourceDescription
TRUEnever evaluated
FALSEnever evaluated
0
1026 && d->type == debugMessage.d->type
never executed: return (d == debugMessage.d) || (d->id == debugMessage.d->id && d->source == debugMessage.d->source && d->type == debugMessage.d->type && d->severity == debugMessage.d->severity && d->message == debugMessage.d->message);
d->type == deb...essage.d->typeDescription
TRUEnever evaluated
FALSEnever evaluated
0
1027 && d->severity == debugMessage.d->severity
never executed: return (d == debugMessage.d) || (d->id == debugMessage.d->id && d->source == debugMessage.d->source && d->type == debugMessage.d->type && d->severity == debugMessage.d->severity && d->message == debugMessage.d->message);
d->severity ==...ge.d->severityDescription
TRUEnever evaluated
FALSEnever evaluated
0
1028 && d->message == debugMessage.d->message);
never executed: return (d == debugMessage.d) || (d->id == debugMessage.d->id && d->source == debugMessage.d->source && d->type == debugMessage.d->type && d->severity == debugMessage.d->severity && d->message == debugMessage.d->message);
d->message == ...age.d->messageDescription
TRUEnever evaluated
FALSEnever evaluated
0
1029}-
1030-
1031/*!-
1032 \fn bool QOpenGLDebugMessage::operator!=(const QOpenGLDebugMessage &debugMessage) const-
1033-
1034 Returns \c true if this message is different from \a debugMessage, or false-
1035 otherwise.-
1036-
1037 \sa operator==()-
1038*/-
1039-
1040#ifndef QT_NO_DEBUG_STREAM-
1041/*!-
1042 \relates QOpenGLDebugMessage-
1043-
1044 Writes the source \a source into the debug object \a debug for debugging-
1045 purposes.-
1046*/-
1047QDebug operator<<(QDebug debug, QOpenGLDebugMessage::Source source)-
1048{-
1049 QDebugStateSaver saver(debug);-
1050 debug.nospace() << "QOpenGLDebugMessage::Source("-
1051 << qt_messageSourceToString(source)-
1052 << ')';-
1053 return debug;
never executed: return debug;
0
1054}-
1055-
1056/*!-
1057 \relates QOpenGLDebugMessage-
1058-
1059 Writes the type \a type into the debug object \a debug for debugging-
1060 purposes.-
1061*/-
1062QDebug operator<<(QDebug debug, QOpenGLDebugMessage::Type type)-
1063{-
1064 QDebugStateSaver saver(debug);-
1065 debug.nospace() << "QOpenGLDebugMessage::Type("-
1066 << qt_messageTypeToString(type)-
1067 << ')';-
1068 return debug;
never executed: return debug;
0
1069}-
1070-
1071/*!-
1072 \relates QOpenGLDebugMessage-
1073-
1074 Writes the severity \a severity into the debug object \a debug for debugging-
1075 purposes.-
1076*/-
1077QDebug operator<<(QDebug debug, QOpenGLDebugMessage::Severity severity)-
1078{-
1079 QDebugStateSaver saver(debug);-
1080 debug.nospace() << "QOpenGLDebugMessage::Severity("-
1081 << qt_messageSeverityToString(severity)-
1082 << ')';-
1083 return debug;
never executed: return debug;
0
1084}-
1085-
1086/*!-
1087 \relates QOpenGLDebugMessage-
1088-
1089 Writes the message \a message into the debug object \a debug for debugging-
1090 purposes.-
1091*/-
1092QDebug operator<<(QDebug debug, const QOpenGLDebugMessage &message)-
1093{-
1094 QDebugStateSaver saver(debug);-
1095 debug.nospace() << "QOpenGLDebugMessage("-
1096 << qt_messageSourceToString(message.source()) << ", "-
1097 << message.id() << ", "-
1098 << message.message() << ", "-
1099 << qt_messageSeverityToString(message.severity()) << ", "-
1100 << qt_messageTypeToString(message.type()) << ')';-
1101 return debug;
never executed: return debug;
0
1102-
1103}-
1104#endif // QT_NO_DEBUG_STREAM-
1105-
1106typedef void (QOPENGLF_APIENTRYP qt_glDebugMessageControl_t)(GLenum source, GLenum type, GLenum severity, GLsizei count, const GLuint *ids, GLboolean enabled);-
1107typedef void (QOPENGLF_APIENTRYP qt_glDebugMessageInsert_t)(GLenum source, GLenum type, GLuint id, GLenum severity, GLsizei length, const GLchar *buf);-
1108typedef void (QOPENGLF_APIENTRYP qt_glDebugMessageCallback_t)(GLDEBUGPROC callback, const void *userParam);-
1109typedef GLuint (QOPENGLF_APIENTRYP qt_glGetDebugMessageLog_t)(GLuint count, GLsizei bufsize, GLenum *sources, GLenum *types, GLuint *ids, GLenum *severities, GLsizei *lengths, GLchar *messageLog);-
1110typedef void (QOPENGLF_APIENTRYP qt_glPushDebugGroup_t)(GLenum source, GLuint id, GLsizei length, const GLchar *message);-
1111typedef void (QOPENGLF_APIENTRYP qt_glPopDebugGroup_t)();-
1112typedef void (QOPENGLF_APIENTRYP qt_glGetPointerv_t)(GLenum pname, GLvoid **params);-
1113-
1114class QOpenGLDebugLoggerPrivate : public QObjectPrivate-
1115{-
1116 Q_DECLARE_PUBLIC(QOpenGLDebugLogger)-
1117public:-
1118 QOpenGLDebugLoggerPrivate();-
1119-
1120 void handleMessage(GLenum source, GLenum type, GLuint id, GLenum severity, GLsizei length, const GLchar *rawMessage);-
1121 void controlDebugMessages(QOpenGLDebugMessage::Sources sources,-
1122 QOpenGLDebugMessage::Types types,-
1123 QOpenGLDebugMessage::Severities severities,-
1124 const QVector<GLuint> &ids,-
1125 const QByteArray &callerName,-
1126 bool enable);-
1127 void _q_contextAboutToBeDestroyed();-
1128-
1129 qt_glDebugMessageControl_t glDebugMessageControl;-
1130 qt_glDebugMessageInsert_t glDebugMessageInsert;-
1131 qt_glDebugMessageCallback_t glDebugMessageCallback;-
1132 qt_glGetDebugMessageLog_t glGetDebugMessageLog;-
1133 qt_glPushDebugGroup_t glPushDebugGroup;-
1134 qt_glPopDebugGroup_t glPopDebugGroup;-
1135 qt_glGetPointerv_t glGetPointerv;-
1136-
1137 GLDEBUGPROC oldDebugCallbackFunction;-
1138 void *oldDebugCallbackParameter;-
1139 QOpenGLContext *context;-
1140 GLint maxMessageLength;-
1141 QOpenGLDebugLogger::LoggingMode loggingMode;-
1142 bool initialized : 1;-
1143 bool isLogging : 1;-
1144 bool debugWasEnabled : 1;-
1145 bool syncDebugWasEnabled : 1;-
1146};-
1147-
1148/*!-
1149 \internal-
1150*/-
1151QOpenGLDebugLoggerPrivate::QOpenGLDebugLoggerPrivate()-
1152 : glDebugMessageControl(0),-
1153 glDebugMessageInsert(0),-
1154 glDebugMessageCallback(0),-
1155 glGetDebugMessageLog(0),-
1156 glPushDebugGroup(0),-
1157 glPopDebugGroup(0),-
1158 oldDebugCallbackFunction(0),-
1159 context(0),-
1160 maxMessageLength(0),-
1161 loggingMode(QOpenGLDebugLogger::AsynchronousLogging),-
1162 initialized(false),-
1163 isLogging(false),-
1164 debugWasEnabled(false),-
1165 syncDebugWasEnabled(false)-
1166{-
1167}
never executed: end of block
0
1168-
1169/*!-
1170 \internal-
1171*/-
1172void QOpenGLDebugLoggerPrivate::handleMessage(GLenum source,-
1173 GLenum type,-
1174 GLuint id,-
1175 GLenum severity,-
1176 GLsizei length,-
1177 const GLchar *rawMessage)-
1178{-
1179 if (oldDebugCallbackFunction)
oldDebugCallbackFunctionDescription
TRUEnever evaluated
FALSEnever evaluated
0
1180 oldDebugCallbackFunction(source, type, id, severity, length, rawMessage, oldDebugCallbackParameter);
never executed: oldDebugCallbackFunction(source, type, id, severity, length, rawMessage, oldDebugCallbackParameter);
0
1181-
1182 QOpenGLDebugMessage message;-
1183-
1184 QOpenGLDebugMessagePrivate *messagePrivate = message.d.data();-
1185 messagePrivate->source = qt_messageSourceFromGL(source);-
1186 messagePrivate->type = qt_messageTypeFromGL(type);-
1187 messagePrivate->id = id;-
1188 messagePrivate->severity = qt_messageSeverityFromGL(severity);-
1189 // not passing the length to fromUtf8, as some bugged OpenGL drivers-
1190 // do not handle the length correctly. Just rely on the message to be NUL terminated.-
1191 messagePrivate->message = QString::fromUtf8(rawMessage);-
1192-
1193 Q_Q(QOpenGLDebugLogger);-
1194 emit q->messageLogged(message);-
1195}
never executed: end of block
0
1196-
1197/*!-
1198 \internal-
1199*/-
1200void QOpenGLDebugLoggerPrivate::controlDebugMessages(QOpenGLDebugMessage::Sources sources,-
1201 QOpenGLDebugMessage::Types types,-
1202 QOpenGLDebugMessage::Severities severities,-
1203 const QVector<GLuint> &ids,-
1204 const QByteArray &callerName,-
1205 bool enable)-
1206{-
1207 if (!initialized) {
!initializedDescription
TRUEnever evaluated
FALSEnever evaluated
0
1208 qWarning("QOpenGLDebugLogger::%s(): object must be initialized before enabling/disabling messages", callerName.constData());-
1209 return;
never executed: return;
0
1210 }-
1211 if (sources == QOpenGLDebugMessage::InvalidSource) {
sources == QOp...:InvalidSourceDescription
TRUEnever evaluated
FALSEnever evaluated
0
1212 qWarning("QOpenGLDebugLogger::%s(): invalid source specified", callerName.constData());-
1213 return;
never executed: return;
0
1214 }-
1215 if (types == QOpenGLDebugMessage::InvalidType) {
types == QOpen...e::InvalidTypeDescription
TRUEnever evaluated
FALSEnever evaluated
0
1216 qWarning("QOpenGLDebugLogger::%s(): invalid type specified", callerName.constData());-
1217 return;
never executed: return;
0
1218 }-
1219 if (severities == QOpenGLDebugMessage::InvalidSeverity) {
severities == ...nvalidSeverityDescription
TRUEnever evaluated
FALSEnever evaluated
0
1220 qWarning("QOpenGLDebugLogger::%s(): invalid severity specified", callerName.constData());-
1221 return;
never executed: return;
0
1222 }-
1223-
1224 QVarLengthArray<GLenum, 8> glSources;-
1225 QVarLengthArray<GLenum, 8> glTypes;-
1226 QVarLengthArray<GLenum, 8> glSeverities;-
1227-
1228 if (ids.count() > 0) {
ids.count() > 0Description
TRUEnever evaluated
FALSEnever evaluated
0
1229 Q_ASSERT(severities == QOpenGLDebugMessage::AnySeverity);-
1230-
1231 // The GL_KHR_debug extension says:-
1232 //-
1233 // - If <count> is greater than zero, then <ids> is an array of <count>-
1234 // message IDs for the specified combination of <source> and <type>. In-
1235 // this case, if <source> or <type> is DONT_CARE, or <severity> is not-
1236 // DONT_CARE, the error INVALID_OPERATION is generated. If <count> is-
1237 // zero, the value if <ids> is ignored.-
1238 //-
1239 // This means we can't convert AnySource or AnyType into DONT_CARE, but we have to roll-
1240 // them into individual sources/types.-
1241-
1242 if (sources == QOpenGLDebugMessage::AnySource) {
sources == QOp...age::AnySourceDescription
TRUEnever evaluated
FALSEnever evaluated
0
1243 sources = QOpenGLDebugMessage::InvalidSource;-
1244 for (uint i = 1; i <= QOpenGLDebugMessage::LastSource; i = i << 1)
i <= QOpenGLDe...ge::LastSourceDescription
TRUEnever evaluated
FALSEnever evaluated
0
1245 sources |= QOpenGLDebugMessage::Source(i);
never executed: sources |= QOpenGLDebugMessage::Source(i);
0
1246 }
never executed: end of block
0
1247-
1248 if (types == QOpenGLDebugMessage::AnyType) {
types == QOpen...ssage::AnyTypeDescription
TRUEnever evaluated
FALSEnever evaluated
0
1249 types = QOpenGLDebugMessage::InvalidType;-
1250 for (uint i = 1; i <= QOpenGLDebugMessage::LastType; i = i << 1)
i <= QOpenGLDe...sage::LastTypeDescription
TRUEnever evaluated
FALSEnever evaluated
0
1251 types |= QOpenGLDebugMessage::Type(i);
never executed: types |= QOpenGLDebugMessage::Type(i);
0
1252 }
never executed: end of block
0
1253 }
never executed: end of block
0
1254-
1255#define CONVERT_TO_GL_DEBUG_MESSAGE_CONTROL_PARAMETERS(type, source, target) \-
1256 if (source == QOpenGLDebugMessage::Any ## type) { \-
1257 target << GL_DONT_CARE; \-
1258 } else { \-
1259 for (uint i = 1; i <= QOpenGLDebugMessage::Last ## type; i = i << 1) \-
1260 if (source.testFlag(QOpenGLDebugMessage:: type (i))) \-
1261 target << qt_message ## type ## ToGL (QOpenGLDebugMessage:: type (i)); \-
1262 }-
1263-
1264 CONVERT_TO_GL_DEBUG_MESSAGE_CONTROL_PARAMETERS(Source, sources, glSources)
never executed: end of block
never executed: glSources << qt_messageSourceToGL (QOpenGLDebugMessage:: Source (i));
never executed: end of block
sources.testFl...:: Source (i))Description
TRUEnever evaluated
FALSEnever evaluated
sources == QOp...age::AnySourceDescription
TRUEnever evaluated
FALSEnever evaluated
i <= QOpenGLDe...ge::LastSourceDescription
TRUEnever evaluated
FALSEnever evaluated
0
1265 CONVERT_TO_GL_DEBUG_MESSAGE_CONTROL_PARAMETERS(Type, types, glTypes)
never executed: end of block
never executed: glTypes << qt_messageTypeToGL (QOpenGLDebugMessage:: Type (i));
never executed: end of block
types.testFlag...ge:: Type (i))Description
TRUEnever evaluated
FALSEnever evaluated
types == QOpen...ssage::AnyTypeDescription
TRUEnever evaluated
FALSEnever evaluated
i <= QOpenGLDe...sage::LastTypeDescription
TRUEnever evaluated
FALSEnever evaluated
0
1266 CONVERT_TO_GL_DEBUG_MESSAGE_CONTROL_PARAMETERS(Severity, severities, glSeverities)
never executed: end of block
never executed: glSeverities << qt_messageSeverityToGL (QOpenGLDebugMessage:: Severity (i));
never executed: end of block
severities.tes... Severity (i))Description
TRUEnever evaluated
FALSEnever evaluated
severities == ...e::AnySeverityDescription
TRUEnever evaluated
FALSEnever evaluated
i <= QOpenGLDe...::LastSeverityDescription
TRUEnever evaluated
FALSEnever evaluated
0
1267#undef CONVERT_TO_GL_DEBUG_MESSAGE_CONTROL_PARAMETERS-
1268-
1269 const GLsizei idCount = ids.count();-
1270 // The GL_KHR_debug extension says that if idCount is 0, idPtr must be ignored.-
1271 // Unfortunately, some bugged drivers do NOT ignore it, so pass NULL in case.-
1272 const GLuint * const idPtr = idCount ? ids.constData() : 0;
idCountDescription
TRUEnever evaluated
FALSEnever evaluated
0
1273-
1274 foreach (GLenum source, glSources)-
1275 foreach (GLenum type, glTypes)-
1276 foreach (GLenum severity, glSeverities)-
1277 glDebugMessageControl(source, type, severity, idCount, idPtr, GLboolean(enable));
never executed: glDebugMessageControl(source, type, severity, idCount, idPtr, GLboolean(enable));
0
1278}
never executed: end of block
0
1279-
1280/*!-
1281 \internal-
1282*/-
1283void QOpenGLDebugLoggerPrivate::_q_contextAboutToBeDestroyed()-
1284{-
1285 Q_ASSERT(context);-
1286-
1287 // Re-make our context current somehow, otherwise stopLogging will fail.-
1288-
1289 // Save the current context and its surface in case we need to set them back-
1290 QOpenGLContext *currentContext = QOpenGLContext::currentContext();-
1291 QSurface *currentSurface = 0;-
1292-
1293 QScopedPointer<QOffscreenSurface> offscreenSurface;-
1294-
1295 if (context != currentContext) {
context != currentContextDescription
TRUEnever evaluated
FALSEnever evaluated
0
1296 // Make our old context current on a temporary surface-
1297 if (currentContext)
currentContextDescription
TRUEnever evaluated
FALSEnever evaluated
0
1298 currentSurface = currentContext->surface();
never executed: currentSurface = currentContext->surface();
0
1299-
1300 offscreenSurface.reset(new QOffscreenSurface);-
1301 offscreenSurface->setFormat(context->format());-
1302 offscreenSurface->create();-
1303 if (!context->makeCurrent(offscreenSurface.data()))
!context->make...urface.data())Description
TRUEnever evaluated
FALSEnever evaluated
0
1304 qWarning("QOpenGLDebugLoggerPrivate::_q_contextAboutToBeDestroyed(): could not make the owning GL context current for cleanup");
never executed: QMessageLogger(__FILE__, 1304, __PRETTY_FUNCTION__).warning("QOpenGLDebugLoggerPrivate::_q_contextAboutToBeDestroyed(): could not make the owning GL context current for cleanup");
0
1305 }
never executed: end of block
0
1306-
1307 Q_Q(QOpenGLDebugLogger);-
1308 q->stopLogging();-
1309-
1310 if (offscreenSurface) {
offscreenSurfaceDescription
TRUEnever evaluated
FALSEnever evaluated
0
1311 // We did change the current context: set it back-
1312 if (currentContext)
currentContextDescription
TRUEnever evaluated
FALSEnever evaluated
0
1313 currentContext->makeCurrent(currentSurface);
never executed: currentContext->makeCurrent(currentSurface);
0
1314 else-
1315 context->doneCurrent();
never executed: context->doneCurrent();
0
1316 }-
1317-
1318 QObject::disconnect(context, SIGNAL(aboutToBeDestroyed()), q, SLOT(_q_contextAboutToBeDestroyed()));-
1319 context = 0;-
1320 initialized = false;-
1321}
never executed: end of block
0
1322-
1323extern "C" {-
1324static void QOPENGLF_APIENTRY qt_opengl_debug_callback(GLenum source,-
1325 GLenum type,-
1326 GLuint id,-
1327 GLenum severity,-
1328 GLsizei length,-
1329 const GLchar *rawMessage,-
1330 const GLvoid *userParam)-
1331{-
1332 QOpenGLDebugLoggerPrivate *loggerPrivate = static_cast<QOpenGLDebugLoggerPrivate *>(const_cast<GLvoid *>(userParam));-
1333 loggerPrivate->handleMessage(source, type, id, severity, length, rawMessage);-
1334}
never executed: end of block
0
1335}-
1336-
1337/*!-
1338 Constructs a new logger object with the given \a parent.-
1339-
1340 \note The object must be initialized before logging can happen.-
1341-
1342 \sa initialize()-
1343*/-
1344QOpenGLDebugLogger::QOpenGLDebugLogger(QObject *parent)-
1345 : QObject(*new QOpenGLDebugLoggerPrivate, parent)-
1346{-
1347 // QOpenGLDebugMessage is going to be mostly used as an argument-
1348 // of a cross thread connection, therefore let's ease the life for the users-
1349 // and register the type for them.-
1350 qRegisterMetaType<QOpenGLDebugMessage>();-
1351}
never executed: end of block
0
1352-
1353/*!-
1354 Destroys the logger object.-
1355*/-
1356QOpenGLDebugLogger::~QOpenGLDebugLogger()-
1357{-
1358 stopLogging();-
1359}
never executed: end of block
0
1360-
1361/*!-
1362 Initializes the object in the current OpenGL context. The context must-
1363 support the \c{GL_KHR_debug} extension for the initialization to succeed.-
1364 The object must be initialized before any logging can happen.-
1365-
1366 It is safe to call this function multiple times from the same context.-
1367-
1368 This function can also be used to change the context of a previously-
1369 initialized object; note that in this case the object must not be logging-
1370 when you call this function.-
1371-
1372 Returns \c true if the logger is successfully initialized; false otherwise.-
1373-
1374 \sa QOpenGLContext-
1375*/-
1376bool QOpenGLDebugLogger::initialize()-
1377{-
1378 QOpenGLContext *context = QOpenGLContext::currentContext();-
1379 if (!context) {
!contextDescription
TRUEnever evaluated
FALSEnever evaluated
0
1380 qWarning("QOpenGLDebugLogger::initialize(): no current OpenGL context found.");-
1381 return false;
never executed: return false;
0
1382 }-
1383-
1384 Q_D(QOpenGLDebugLogger);-
1385 if (d->context == context) {
d->context == contextDescription
TRUEnever evaluated
FALSEnever evaluated
0
1386 // context is non-NULL, d->context is non NULL only on successful initialization.-
1387 Q_ASSERT(d->initialized);-
1388 return true;
never executed: return true;
0
1389 }-
1390-
1391 if (d->isLogging) {
d->isLoggingDescription
TRUEnever evaluated
FALSEnever evaluated
0
1392 qWarning("QOpenGLDebugLogger::initialize(): cannot initialize the object while logging. Please stop the logging first.");-
1393 return false;
never executed: return false;
0
1394 }-
1395-
1396 if (d->context)
d->contextDescription
TRUEnever evaluated
FALSEnever evaluated
0
1397 disconnect(d->context, SIGNAL(aboutToBeDestroyed()), this, SLOT(_q_contextAboutToBeDestroyed()));
never executed: disconnect(d->context, qFlagLocation("2""aboutToBeDestroyed()" "\0" __FILE__ ":" "1397"), this, qFlagLocation("1""_q_contextAboutToBeDestroyed()" "\0" __FILE__ ":" "1397"));
0
1398-
1399 d->initialized = false;-
1400 d->context = 0;-
1401-
1402 if (!context->hasExtension(QByteArrayLiteral("GL_KHR_debug")))
never executed: return ba;
!context->hasE...turn ba; }()))Description
TRUEnever evaluated
FALSEnever evaluated
0
1403 return false;
never executed: return false;
0
1404-
1405 d->context = context;-
1406 connect(d->context, SIGNAL(aboutToBeDestroyed()), this, SLOT(_q_contextAboutToBeDestroyed()));-
1407-
1408#define GET_DEBUG_PROC_ADDRESS(procName) \-
1409 d->procName = reinterpret_cast< qt_ ## procName ## _t >( \-
1410 d->context->getProcAddress(QByteArrayLiteral( #procName )) \-
1411 );-
1412-
1413 GET_DEBUG_PROC_ADDRESS(glDebugMessageControl);
never executed: return ba;
0
1414 GET_DEBUG_PROC_ADDRESS(glDebugMessageInsert);
never executed: return ba;
0
1415 GET_DEBUG_PROC_ADDRESS(glDebugMessageCallback);
never executed: return ba;
0
1416 GET_DEBUG_PROC_ADDRESS(glGetDebugMessageLog);
never executed: return ba;
0
1417 GET_DEBUG_PROC_ADDRESS(glPushDebugGroup);
never executed: return ba;
0
1418 GET_DEBUG_PROC_ADDRESS(glPopDebugGroup);
never executed: return ba;
0
1419-
1420 // Windows' Desktop GL doesn't allow resolution of "basic GL entry points"-
1421 // through wglGetProcAddress-
1422#if defined(Q_OS_WIN) && !defined(QT_OPENGL_ES_2)-
1423 {-
1424 HMODULE handle = static_cast<HMODULE>(QOpenGLContext::openGLModuleHandle());-
1425 if (!handle)-
1426 handle = GetModuleHandleA("opengl32.dll");-
1427 d->glGetPointerv = reinterpret_cast<qt_glGetPointerv_t>(GetProcAddress(handle, QByteArrayLiteral("glGetPointerv")));-
1428 }-
1429#else-
1430 GET_DEBUG_PROC_ADDRESS(glGetPointerv)
never executed: return ba;
0
1431#endif-
1432-
1433#undef GET_DEBUG_PROC_ADDRESS-
1434-
1435 QOpenGLContext::currentContext()->functions()->glGetIntegerv(GL_MAX_DEBUG_MESSAGE_LENGTH, &d->maxMessageLength);-
1436-
1437#ifndef QT_NO_DEBUG-
1438 if (!d->context->format().testOption(QSurfaceFormat::DebugContext)) {
!d->context->f...:DebugContext)Description
TRUEnever evaluated
FALSEnever evaluated
0
1439 qWarning("QOpenGLDebugLogger::initialize(): the current context is not a debug context:\n"-
1440 " this means that the GL may not generate any debug output at all.\n"-
1441 " To avoid this warning, try creating the context with the\n"-
1442 " QSurfaceFormat::DebugContext surface format option.");-
1443 }
never executed: end of block
0
1444#endif // QT_NO_DEBUG-
1445-
1446 d->initialized = true;-
1447 return true;
never executed: return true;
0
1448}-
1449-
1450/*!-
1451 Returns \c true if this object is currently logging, false otherwise.-
1452-
1453 \sa startLogging()-
1454*/-
1455bool QOpenGLDebugLogger::isLogging() const-
1456{-
1457 Q_D(const QOpenGLDebugLogger);-
1458 return d->isLogging;
never executed: return d->isLogging;
0
1459}-
1460-
1461/*!-
1462 Starts logging messages coming from the OpenGL server. When a new message-
1463 is received, the signal messageLogged() is emitted, carrying the logged-
1464 message as argument.-
1465-
1466 \a loggingMode specifies whether the logging must be asynchronous (the default)-
1467 or synchronous.-
1468-
1469 QOpenGLDebugLogger will record the values of \c{GL_DEBUG_OUTPUT} and-
1470 \c{GL_DEBUG_OUTPUT_SYNCHRONOUS} when logging is started, and set them back-
1471 when logging is stopped. Moreover, any user-defined OpenGL debug callback-
1472 installed when this function is invoked will be restored when logging is-
1473 stopped; QOpenGLDebugLogger will ensure that the pre-existing callback will-
1474 still be invoked when logging.-
1475-
1476 \note It's not possible to change the logging mode without stopping and-
1477 starting logging again. This might change in a future version of Qt.-
1478-
1479 \note The object must be initialized before logging can happen.-
1480-
1481 \sa stopLogging(), initialize()-
1482*/-
1483void QOpenGLDebugLogger::startLogging(QOpenGLDebugLogger::LoggingMode loggingMode)-
1484{-
1485 Q_D(QOpenGLDebugLogger);-
1486 if (!d->initialized) {
!d->initializedDescription
TRUEnever evaluated
FALSEnever evaluated
0
1487 qWarning("QOpenGLDebugLogger::startLogging(): object must be initialized before logging can start");-
1488 return;
never executed: return;
0
1489 }-
1490 if (d->isLogging) {
d->isLoggingDescription
TRUEnever evaluated
FALSEnever evaluated
0
1491 qWarning("QOpenGLDebugLogger::startLogging(): this object is already logging");-
1492 return;
never executed: return;
0
1493 }-
1494-
1495 d->isLogging = true;-
1496 d->loggingMode = loggingMode;-
1497-
1498 d->glGetPointerv(GL_DEBUG_CALLBACK_FUNCTION, reinterpret_cast<void **>(&d->oldDebugCallbackFunction));-
1499 d->glGetPointerv(GL_DEBUG_CALLBACK_USER_PARAM, &d->oldDebugCallbackParameter);-
1500-
1501 d->glDebugMessageCallback(&qt_opengl_debug_callback, d);-
1502-
1503 QOpenGLFunctions *funcs = QOpenGLContext::currentContext()->functions();-
1504 d->debugWasEnabled = funcs->glIsEnabled(GL_DEBUG_OUTPUT);-
1505 d->syncDebugWasEnabled = funcs->glIsEnabled(GL_DEBUG_OUTPUT_SYNCHRONOUS);-
1506-
1507 if (d->loggingMode == SynchronousLogging)
d->loggingMode...hronousLoggingDescription
TRUEnever evaluated
FALSEnever evaluated
0
1508 funcs->glEnable(GL_DEBUG_OUTPUT_SYNCHRONOUS);
never executed: funcs->glEnable(0x8242);
0
1509 else-
1510 funcs->glDisable(GL_DEBUG_OUTPUT_SYNCHRONOUS);
never executed: funcs->glDisable(0x8242);
0
1511-
1512 funcs->glEnable(GL_DEBUG_OUTPUT);-
1513}
never executed: end of block
0
1514-
1515/*!-
1516 Returns the logging mode of the object.-
1517-
1518 \sa startLogging()-
1519*/-
1520QOpenGLDebugLogger::LoggingMode QOpenGLDebugLogger::loggingMode() const-
1521{-
1522 Q_D(const QOpenGLDebugLogger);-
1523 return d->loggingMode;
never executed: return d->loggingMode;
0
1524}-
1525-
1526/*!-
1527 Stops logging messages from the OpenGL server.-
1528-
1529 \sa startLogging()-
1530*/-
1531void QOpenGLDebugLogger::stopLogging()-
1532{-
1533 Q_D(QOpenGLDebugLogger);-
1534 if (!d->isLogging)
!d->isLoggingDescription
TRUEnever evaluated
FALSEnever evaluated
0
1535 return;
never executed: return;
0
1536-
1537 QOpenGLContext *currentContext = QOpenGLContext::currentContext();-
1538 if (!currentContext || currentContext != d->context) {
!currentContextDescription
TRUEnever evaluated
FALSEnever evaluated
currentContext != d->contextDescription
TRUEnever evaluated
FALSEnever evaluated
0
1539 qWarning("QOpenGLDebugLogger::stopLogging(): attempting to stop logging with the wrong OpenGL context current");-
1540 return;
never executed: return;
0
1541 }-
1542-
1543 d->isLogging = false;-
1544-
1545 d->glDebugMessageCallback(d->oldDebugCallbackFunction, d->oldDebugCallbackParameter);-
1546-
1547 QOpenGLFunctions *funcs = QOpenGLContext::currentContext()->functions();-
1548 if (!d->debugWasEnabled)
!d->debugWasEnabledDescription
TRUEnever evaluated
FALSEnever evaluated
0
1549 funcs->glDisable(GL_DEBUG_OUTPUT);
never executed: funcs->glDisable(0x92E0);
0
1550-
1551 if (d->syncDebugWasEnabled)
d->syncDebugWasEnabledDescription
TRUEnever evaluated
FALSEnever evaluated
0
1552 funcs->glEnable(GL_DEBUG_OUTPUT_SYNCHRONOUS);
never executed: funcs->glEnable(0x8242);
0
1553 else-
1554 funcs->glDisable(GL_DEBUG_OUTPUT_SYNCHRONOUS);
never executed: funcs->glDisable(0x8242);
0
1555}-
1556-
1557/*!-
1558 Inserts the message \a debugMessage into the OpenGL debug log. This provides-
1559 a way for applications or libraries to insert custom messages that can-
1560 ease the debugging of OpenGL applications.-
1561-
1562 \note \a debugMessage must have QOpenGLDebugMessage::ApplicationSource or-
1563 QOpenGLDebugMessage::ThirdPartySource as its source, and a valid-
1564 type and severity, otherwise it will not be inserted into the log.-
1565-
1566 \note The object must be initialized before logging can happen.-
1567-
1568 \sa initialize()-
1569*/-
1570void QOpenGLDebugLogger::logMessage(const QOpenGLDebugMessage &debugMessage)-
1571{-
1572 Q_D(QOpenGLDebugLogger);-
1573 if (!d->initialized) {
!d->initializedDescription
TRUEnever evaluated
FALSEnever evaluated
0
1574 qWarning("QOpenGLDebugLogger::logMessage(): object must be initialized before logging messages");-
1575 return;
never executed: return;
0
1576 }-
1577 if (debugMessage.source() != QOpenGLDebugMessage::ApplicationSource
debugMessage.s...licationSourceDescription
TRUEnever evaluated
FALSEnever evaluated
0
1578 && debugMessage.source() != QOpenGLDebugMessage::ThirdPartySource) {
debugMessage.s...irdPartySourceDescription
TRUEnever evaluated
FALSEnever evaluated
0
1579 qWarning("QOpenGLDebugLogger::logMessage(): using a message source different from ApplicationSource\n"-
1580 " or ThirdPartySource is not supported by GL_KHR_debug. The message will not be logged.");-
1581 return;
never executed: return;
0
1582 }-
1583 if (debugMessage.type() == QOpenGLDebugMessage::InvalidType
debugMessage.t...e::InvalidTypeDescription
TRUEnever evaluated
FALSEnever evaluated
0
1584 || debugMessage.type() == QOpenGLDebugMessage::AnyType
debugMessage.t...ssage::AnyTypeDescription
TRUEnever evaluated
FALSEnever evaluated
0
1585 || debugMessage.severity() == QOpenGLDebugMessage::InvalidSeverity
debugMessage.s...nvalidSeverityDescription
TRUEnever evaluated
FALSEnever evaluated
0
1586 || debugMessage.severity() == QOpenGLDebugMessage::AnySeverity) {
debugMessage.s...e::AnySeverityDescription
TRUEnever evaluated
FALSEnever evaluated
0
1587 qWarning("QOpenGLDebugLogger::logMessage(): the message has a non-valid type and/or severity. The message will not be logged.");-
1588 return;
never executed: return;
0
1589 }-
1590-
1591 const GLenum source = qt_messageSourceToGL(debugMessage.source());-
1592 const GLenum type = qt_messageTypeToGL(debugMessage.type());-
1593 const GLenum severity = qt_messageSeverityToGL(debugMessage.severity());-
1594 QByteArray rawMessage = debugMessage.message().toUtf8();-
1595 rawMessage.append('\0');-
1596-
1597 if (rawMessage.length() > d->maxMessageLength) {
rawMessage.len...xMessageLengthDescription
TRUEnever evaluated
FALSEnever evaluated
0
1598 qWarning("QOpenGLDebugLogger::logMessage(): message too long, truncating it\n"-
1599 " (%d bytes long, but the GL accepts up to %d bytes)", rawMessage.length(), d->maxMessageLength);-
1600 rawMessage.resize(d->maxMessageLength - 1);-
1601 rawMessage.append('\0');-
1602 }
never executed: end of block
0
1603-
1604 // Don't pass rawMessage.length(), as unfortunately bugged-
1605 // OpenGL drivers will eat the trailing NUL in the message. Just rely-
1606 // on the message being NUL terminated.-
1607 d->glDebugMessageInsert(source,-
1608 type,-
1609 debugMessage.id(),-
1610 severity,-
1611 -1,-
1612 rawMessage.constData());-
1613}
never executed: end of block
0
1614-
1615/*!-
1616 Pushes a debug group with name \a name, id \a id, and source \a source onto-
1617 the debug groups stack. If the group is successfully pushed, OpenGL will-
1618 automatically log a message with message \a name, id \a id, source \a-
1619 source, type QOpenGLDebugMessage::GroupPushType and severity-
1620 QOpenGLDebugMessage::NotificationSeverity.-
1621-
1622 The newly pushed group will inherit the same filtering settings of the-
1623 group that was on the top of the stack; that is, the filtering will not be-
1624 changed by pushing a new group.-
1625-
1626 \note The \a source must either be QOpenGLDebugMessage::ApplicationSource or-
1627 QOpenGLDebugMessage::ThirdPartySource, otherwise the group will not be pushed.-
1628-
1629 \note The object must be initialized before managing debug groups.-
1630-
1631 \sa popGroup(), enableMessages(), disableMessages()-
1632*/-
1633void QOpenGLDebugLogger::pushGroup(const QString &name, GLuint id, QOpenGLDebugMessage::Source source)-
1634{-
1635 Q_D(QOpenGLDebugLogger);-
1636 if (!d->initialized) {
!d->initializedDescription
TRUEnever evaluated
FALSEnever evaluated
0
1637 qWarning("QOpenGLDebugLogger::pushGroup(): object must be initialized before pushing a debug group");-
1638 return;
never executed: return;
0
1639 }-
1640 if (source != QOpenGLDebugMessage::ApplicationSource
source != QOpe...licationSourceDescription
TRUEnever evaluated
FALSEnever evaluated
0
1641 && source != QOpenGLDebugMessage::ThirdPartySource) {
source != QOpe...irdPartySourceDescription
TRUEnever evaluated
FALSEnever evaluated
0
1642 qWarning("QOpenGLDebugLogger::pushGroup(): using a source different from ApplicationSource\n"-
1643 " or ThirdPartySource is not supported by GL_KHR_debug. The group will not be pushed.");-
1644 return;
never executed: return;
0
1645 }-
1646-
1647 QByteArray rawName = name.toUtf8();-
1648 rawName.append('\0');-
1649 if (rawName.length() > d->maxMessageLength) {
rawName.length...xMessageLengthDescription
TRUEnever evaluated
FALSEnever evaluated
0
1650 qWarning("QOpenGLDebugLogger::pushGroup(): group name too long, truncating it\n"-
1651 " (%d bytes long, but the GL accepts up to %d bytes)", rawName.length(), d->maxMessageLength);-
1652 rawName.resize(d->maxMessageLength - 1);-
1653 rawName.append('\0');-
1654 }
never executed: end of block
0
1655-
1656 // Don't pass rawMessage.length(), as unfortunately bugged-
1657 // OpenGL drivers will eat the trailing NUL in the name. Just rely-
1658 // on the name being NUL terminated.-
1659 d->glPushDebugGroup(qt_messageSourceToGL(source), id, -1, rawName.constData());-
1660}
never executed: end of block
0
1661-
1662/*!-
1663 Pops the topmost debug group from the debug groups stack. If the group is-
1664 successfully popped, OpenGL will automatically log a message with message,-
1665 id and source matching those of the popped group, type-
1666 QOpenGLDebugMessage::GroupPopType and severity-
1667 QOpenGLDebugMessage::NotificationSeverity.-
1668-
1669 Popping a debug group will restore the message filtering settings of the-
1670 group that becomes the top of the debug groups stack.-
1671-
1672 \note The object must be initialized before managing debug groups.-
1673-
1674 \sa pushGroup()-
1675*/-
1676void QOpenGLDebugLogger::popGroup()-
1677{-
1678 Q_D(QOpenGLDebugLogger);-
1679 if (!d->initialized) {
!d->initializedDescription
TRUEnever evaluated
FALSEnever evaluated
0
1680 qWarning("QOpenGLDebugLogger::pushGroup(): object must be initialized before popping a debug group");-
1681 return;
never executed: return;
0
1682 }-
1683-
1684 d->glPopDebugGroup();-
1685}
never executed: end of block
0
1686-
1687/*!-
1688 Enables the logging of messages from the given \a sources, of the given \a-
1689 types and with the given \a severities and any message id.-
1690-
1691 The logging will be enabled in the current control group.-
1692-
1693 \sa disableMessages(), pushGroup(), popGroup()-
1694*/-
1695void QOpenGLDebugLogger::enableMessages(QOpenGLDebugMessage::Sources sources,-
1696 QOpenGLDebugMessage::Types types,-
1697 QOpenGLDebugMessage::Severities severities)-
1698{-
1699 Q_D(QOpenGLDebugLogger);-
1700 d->controlDebugMessages(sources,-
1701 types,-
1702 severities,-
1703 QVector<GLuint>(),-
1704 QByteArrayLiteral("enableMessages"),
never executed: return ba;
0
1705 true);-
1706}
never executed: end of block
0
1707-
1708/*!-
1709 Enables the logging of messages with the given \a ids, from the given \a-
1710 sources and of the given \a types and any severity.-
1711-
1712 The logging will be enabled in the current control group.-
1713-
1714 \sa disableMessages(), pushGroup(), popGroup()-
1715*/-
1716void QOpenGLDebugLogger::enableMessages(const QVector<GLuint> &ids,-
1717 QOpenGLDebugMessage::Sources sources,-
1718 QOpenGLDebugMessage::Types types)-
1719{-
1720 Q_D(QOpenGLDebugLogger);-
1721 d->controlDebugMessages(sources,-
1722 types,-
1723 QOpenGLDebugMessage::AnySeverity,-
1724 ids,-
1725 QByteArrayLiteral("enableMessages"),
never executed: return ba;
0
1726 true);-
1727}
never executed: end of block
0
1728-
1729/*!-
1730 Disables the logging of messages with the given \a sources, of the given \a-
1731 types and with the given \a severities and any message id.-
1732-
1733 The logging will be disabled in the current control group.-
1734-
1735 \sa enableMessages(), pushGroup(), popGroup()-
1736*/-
1737void QOpenGLDebugLogger::disableMessages(QOpenGLDebugMessage::Sources sources,-
1738 QOpenGLDebugMessage::Types types,-
1739 QOpenGLDebugMessage::Severities severities)-
1740{-
1741 Q_D(QOpenGLDebugLogger);-
1742 d->controlDebugMessages(sources,-
1743 types,-
1744 severities,-
1745 QVector<GLuint>(),-
1746 QByteArrayLiteral("disableMessages"),
never executed: return ba;
0
1747 false);-
1748}
never executed: end of block
0
1749-
1750/*!-
1751 Disables the logging of messages with the given \a ids, from the given \a-
1752 sources and of the given \a types and any severity.-
1753-
1754 The logging will be disabled in the current control group.-
1755-
1756 \sa enableMessages(), pushGroup(), popGroup()-
1757*/-
1758void QOpenGLDebugLogger::disableMessages(const QVector<GLuint> &ids,-
1759 QOpenGLDebugMessage::Sources sources,-
1760 QOpenGLDebugMessage::Types types)-
1761{-
1762 Q_D(QOpenGLDebugLogger);-
1763 d->controlDebugMessages(sources,-
1764 types,-
1765 QOpenGLDebugMessage::AnySeverity,-
1766 ids,-
1767 QByteArrayLiteral("disableMessages"),
never executed: return ba;
0
1768 false);-
1769}
never executed: end of block
0
1770-
1771/*!-
1772 Reads all the available messages in the OpenGL internal debug log and-
1773 returns them. Moreover, this function will clear the internal debug log,-
1774 so that subsequent invocations will not return messages that were-
1775 already returned.-
1776-
1777 \sa startLogging()-
1778*/-
1779QList<QOpenGLDebugMessage> QOpenGLDebugLogger::loggedMessages() const-
1780{-
1781 Q_D(const QOpenGLDebugLogger);-
1782 if (!d->initialized) {
!d->initializedDescription
TRUEnever evaluated
FALSEnever evaluated
0
1783 qWarning("QOpenGLDebugLogger::loggedMessages(): object must be initialized before reading logged messages");-
1784 return QList<QOpenGLDebugMessage>();
never executed: return QList<QOpenGLDebugMessage>();
0
1785 }-
1786-
1787 static const GLuint maxMessageCount = 128;-
1788 GLuint messagesRead;-
1789 GLenum messageSources[maxMessageCount];-
1790 GLenum messageTypes[maxMessageCount];-
1791 GLuint messageIds[maxMessageCount];-
1792 GLenum messageSeverities[maxMessageCount];-
1793 GLsizei messageLengths[maxMessageCount];-
1794-
1795 QByteArray messagesBuffer;-
1796 messagesBuffer.resize(maxMessageCount * d->maxMessageLength);-
1797-
1798 QList<QOpenGLDebugMessage> messages;-
1799 do {-
1800 messagesRead = d->glGetDebugMessageLog(maxMessageCount,-
1801 GLsizei(messagesBuffer.size()),-
1802 messageSources,-
1803 messageTypes,-
1804 messageIds,-
1805 messageSeverities,-
1806 messageLengths,-
1807 messagesBuffer.data());-
1808-
1809 const char *messagesBufferPtr = messagesBuffer.constData();-
1810 for (GLuint i = 0; i < messagesRead; ++i) {
i < messagesReadDescription
TRUEnever evaluated
FALSEnever evaluated
0
1811 QOpenGLDebugMessage message;-
1812-
1813 QOpenGLDebugMessagePrivate *messagePrivate = message.d.data();-
1814 messagePrivate->source = qt_messageSourceFromGL(messageSources[i]);-
1815 messagePrivate->type = qt_messageTypeFromGL(messageTypes[i]);-
1816 messagePrivate->id = messageIds[i];-
1817 messagePrivate->severity = qt_messageSeverityFromGL(messageSeverities[i]);-
1818 messagePrivate->message = QString::fromUtf8(messagesBufferPtr, messageLengths[i] - 1);-
1819-
1820 messagesBufferPtr += messageLengths[i];-
1821 messages << message;-
1822 }
never executed: end of block
0
1823 } while (messagesRead == maxMessageCount);
never executed: end of block
messagesRead =...axMessageCountDescription
TRUEnever evaluated
FALSEnever evaluated
0
1824-
1825 return messages;
never executed: return messages;
0
1826}-
1827-
1828/*!-
1829 \fn void QOpenGLDebugLogger::messageLogged(const QOpenGLDebugMessage &debugMessage)-
1830-
1831 This signal is emitted when a debug message (wrapped by the \a debugMessage-
1832 argument) is logged from the OpenGL server.-
1833-
1834 Depending on the OpenGL implementation, this signal can be emitted-
1835 from other threads than the one(s) the receiver(s) lives in, and even-
1836 different from the thread the QOpenGLContext in which this object has-
1837 been initialized lives in. Moreover, the signal could be emitted from-
1838 multiple threads at the same time. This is normally not a problem,-
1839 as Qt will utilize a queued connection for cross-thread signal emissions,-
1840 but if you force the connection type to Direct then you must be aware of-
1841 the potential races in the slots connected to this signal.-
1842-
1843 If logging have been started in SynchronousLogging mode, OpenGL guarantees-
1844 that this signal will be emitted from the same thread the QOpenGLContext-
1845 has been bound to, and no concurrent invocations will ever happen.-
1846-
1847 \note Logging must have been started, or this signal will not be emitted.-
1848-
1849 \sa startLogging()-
1850*/-
1851-
1852/*!-
1853 Returns the maximum supported length, in bytes, for the text of the messages-
1854 passed to logMessage(). This is also the maximum length of a debug group-
1855 name, as pushing or popping groups will automatically log a message with-
1856 the debug group name as the message text.-
1857-
1858 If a message text is too long, it will be automatically truncated by-
1859 QOpenGLDebugLogger.-
1860-
1861 \note Message texts are encoded in UTF-8 when they get passed to OpenGL, so-
1862 their size in bytes does not usually match the amount of UTF-16 code units,-
1863 as returned f.i. by QString::length(). (It does if the message contains-
1864 7-bit ASCII only data, which is typical for debug messages.)-
1865*/-
1866qint64 QOpenGLDebugLogger::maximumMessageLength() const-
1867{-
1868 Q_D(const QOpenGLDebugLogger);-
1869 if (!d->initialized) {
!d->initializedDescription
TRUEnever evaluated
FALSEnever evaluated
0
1870 qWarning("QOpenGLDebugLogger::maximumMessageLength(): object must be initialized before reading the maximum message length");-
1871 return -1;
never executed: return -1;
0
1872 }-
1873 return d->maxMessageLength;
never executed: return d->maxMessageLength;
0
1874}-
1875-
1876-
1877QT_END_NAMESPACE-
1878-
1879#include "moc_qopengldebug.cpp"-
Source codeSwitch to Preprocessed file

Generated by Squish Coco Non-Commercial 4.3.0-BETA-master-30-08-2018-4cb69e9