• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 //
2 // Copyright 2015 The ANGLE Project Authors. All rights reserved.
3 // Use of this source code is governed by a BSD-style license that can be
4 // found in the LICENSE file.
5 //
6 
7 // Debug.h: Defines debug state used for GL_KHR_debug
8 
9 #ifndef LIBANGLE_DEBUG_H_
10 #define LIBANGLE_DEBUG_H_
11 
12 #include "angle_gl.h"
13 #include "common/PackedEnums.h"
14 #include "common/angleutils.h"
15 #include "libANGLE/AttributeMap.h"
16 
17 #include <deque>
18 #include <string>
19 #include <vector>
20 
21 namespace gl
22 {
23 class Context;
24 
25 class LabeledObject
26 {
27   public:
~LabeledObject()28     virtual ~LabeledObject() {}
29     virtual void setLabel(const Context *context, const std::string &label) = 0;
30     virtual const std::string &getLabel() const                             = 0;
31 };
32 
33 class Debug : angle::NonCopyable
34 {
35   public:
36     Debug(bool initialDebugState);
37     ~Debug();
38 
39     void setMaxLoggedMessages(GLuint maxLoggedMessages);
40 
41     void setOutputEnabled(bool enabled);
42     bool isOutputEnabled() const;
43 
44     void setOutputSynchronous(bool synchronous);
45     bool isOutputSynchronous() const;
46 
47     void setCallback(GLDEBUGPROCKHR callback, const void *userParam);
48     GLDEBUGPROCKHR getCallback() const;
49     const void *getUserParam() const;
50 
51     void insertMessage(GLenum source,
52                        GLenum type,
53                        GLuint id,
54                        GLenum severity,
55                        const std::string &message,
56                        gl::LogSeverity logSeverity) const;
57     void insertMessage(GLenum source,
58                        GLenum type,
59                        GLuint id,
60                        GLenum severity,
61                        std::string &&message,
62                        gl::LogSeverity logSeverity) const;
63 
64     void setMessageControl(GLenum source,
65                            GLenum type,
66                            GLenum severity,
67                            std::vector<GLuint> &&ids,
68                            bool enabled);
69     size_t getMessages(GLuint count,
70                        GLsizei bufSize,
71                        GLenum *sources,
72                        GLenum *types,
73                        GLuint *ids,
74                        GLenum *severities,
75                        GLsizei *lengths,
76                        GLchar *messageLog);
77     size_t getNextMessageLength() const;
78     size_t getMessageCount() const;
79 
80     void pushGroup(GLenum source, GLuint id, std::string &&message);
81     void popGroup();
82     size_t getGroupStackDepth() const;
83 
84   private:
85     bool isMessageEnabled(GLenum source, GLenum type, GLuint id, GLenum severity) const;
86 
87     void pushDefaultGroup();
88 
89     struct Message
90     {
91         GLenum source;
92         GLenum type;
93         GLuint id;
94         GLenum severity;
95         std::string message;
96     };
97 
98     struct Control
99     {
100         Control();
101         ~Control();
102         Control(const Control &other);
103 
104         GLenum source;
105         GLenum type;
106         GLenum severity;
107         std::vector<GLuint> ids;
108         bool enabled;
109     };
110 
111     struct Group
112     {
113         Group();
114         ~Group();
115         Group(const Group &other);
116 
117         GLenum source;
118         GLuint id;
119         std::string message;
120 
121         std::vector<Control> controls;
122     };
123 
124     bool mOutputEnabled;
125     GLDEBUGPROCKHR mCallbackFunction;
126     const void *mCallbackUserParam;
127     mutable std::deque<Message> mMessages;
128     GLuint mMaxLoggedMessages;
129     bool mOutputSynchronous;
130     std::vector<Group> mGroups;
131 };
132 }  // namespace gl
133 
134 namespace egl
135 {
136 class LabeledObject
137 {
138   public:
~LabeledObject()139     virtual ~LabeledObject() {}
140     virtual void setLabel(EGLLabelKHR label) = 0;
141     virtual EGLLabelKHR getLabel() const     = 0;
142 };
143 
144 class Debug : angle::NonCopyable
145 {
146   public:
147     Debug();
148 
149     void setCallback(EGLDEBUGPROCKHR callback, const AttributeMap &attribs);
150     EGLDEBUGPROCKHR getCallback() const;
151     bool isMessageTypeEnabled(MessageType type) const;
152 
153     void insertMessage(EGLenum error,
154                        const char *command,
155                        MessageType messageType,
156                        EGLLabelKHR threadLabel,
157                        EGLLabelKHR objectLabel,
158                        const std::string &message) const;
159 
160   private:
161     EGLDEBUGPROCKHR mCallback;
162     angle::PackedEnumBitSet<MessageType> mEnabledMessageTypes;
163 };
164 }  // namespace egl
165 #endif  // LIBANGLE_DEBUG_H_
166