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

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