All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
diagnostic.h
Go to the documentation of this file.
1 //
2 // Copyright 2016 Pixar
3 //
4 // Licensed under the Apache License, Version 2.0 (the "Apache License")
5 // with the following modification; you may not use this file except in
6 // compliance with the Apache License and the following modification to it:
7 // Section 6. Trademarks. is deleted and replaced with:
8 //
9 // 6. Trademarks. This License does not grant permission to use the trade
10 // names, trademarks, service marks, or product names of the Licensor
11 // and its affiliates, except as required to comply with Section 4(c) of
12 // the License and to reproduce the content of the NOTICE file.
13 //
14 // You may obtain a copy of the Apache License at
15 //
16 // http://www.apache.org/licenses/LICENSE-2.0
17 //
18 // Unless required by applicable law or agreed to in writing, software
19 // distributed under the Apache License with the above modification is
20 // distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
21 // KIND, either express or implied. See the Apache License for the specific
22 // language governing permissions and limitations under the Apache License.
23 //
24 #ifndef PXR_IMAGING_GLF_DIAGNOSTIC_H
25 #define PXR_IMAGING_GLF_DIAGNOSTIC_H
26 
28 
29 #include "pxr/pxr.h"
30 #include "pxr/imaging/glf/api.h"
31 #include "pxr/imaging/garch/glApi.h"
32 #include "pxr/base/tf/diagnostic.h"
33 
34 #include <string>
35 #include <cstdint>
36 
37 PXR_NAMESPACE_OPEN_SCOPE
38 
39 
43 #define GLF_POST_PENDING_GL_ERRORS() \
44  GlfPostPendingGLErrors(__ARCH_PRETTY_FUNCTION__)
45 
47 GLF_API
48 void GlfPostPendingGLErrors(std::string const & where = std::string());
49 
52 GLF_API
54 
58 GLF_API
60  GLenum source, GLenum type, GLuint id, GLenum severity,
61  GLsizei length, char const * message, GLvoid const * userParam);
62 
64 GLF_API
65 char const * GlfDebugEnumToString(GLenum debugEnum);
66 
68 #define GLF_GROUP_FUNCTION() \
69  GlfDebugGroup __glf_group_function(__ARCH_PRETTY_FUNCTION__)
70 
72 #define GLF_GROUP_SCOPE(str) \
73  GlfDebugGroup __glf_group_scope(str)
74 
85  public:
87  GLF_API
88  GlfDebugGroup(char const *message);
89 
91  GLF_API
93 
94  GlfDebugGroup() = delete;
95  GlfDebugGroup(GlfDebugGroup const&) = delete;
96  GlfDebugGroup& operator =(GlfDebugGroup const&) = delete;
97 };
98 
100 GLF_API
101 void GlfDebugLabelBuffer(GLuint id, char const *label);
102 
104 GLF_API
105 void GlfDebugLabelShader(GLuint id, char const *label);
106 
108 GLF_API
109 void GlfDebugLabelProgram(GLuint id, char const *label);
110 
116 public:
117  GLF_API
119  GLF_API
120  ~GlfGLQueryObject();
121 
128  GLF_API
129  void Begin(GLenum target);
130 
134  GLF_API
135  void BeginSamplesPassed();
136 
140  GLF_API
142 
146  GLF_API
147  void BeginTimeElapsed();
148 
150  GLF_API
151  void End();
152 
155  GLF_API
156  int64_t GetResult();
157 
160  GLF_API
161  int64_t GetResultNoWait();
162 
163  GlfGLQueryObject(GlfGLQueryObject const&) = delete;
164  GlfGLQueryObject& operator =(GlfGLQueryObject const&) = delete;
165 private:
166  GLuint _id;
167  GLenum _target;
168 };
169 
170 
171 PXR_NAMESPACE_CLOSE_SCOPE
172 
173 #endif
GLF_API int64_t GetResultNoWait()
Return the query result (asynchronous) returns 0 if the result hasn&#39;t been available.
GLF_API ~GlfDebugGroup()
Pops a debug group off the GL api debug trace stack.
GLF_API void GlfDefaultDebugOutputMessageCallback(GLenum source, GLenum type, GLuint id, GLenum severity, GLsizei length, char const *message, GLvoid const *userParam)
A GL debug output message callback method which posts diagnostic errors for messages of type DEBUG_TY...
Low-level utilities for informing users of various internal and external diagnostic conditions...
Represents a GL debug group in Glf.
Definition: diagnostic.h:84
GLF_API void Begin(GLenum target)
Begin query for the given target target has to be one of GL_SAMPLES_PASSED, GL_ANY_SAMPLES_PASSED, GL_ANY_SAMPLES_PASSED_CONSERVATIVE, GL_PRIMITIVES_GENERATED GL_TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN GL_TIME_ELAPSED, GL_TIMESTAMP.
GLF_API void End()
End query.
GLF_API void GlfPostPendingGLErrors(std::string const &where=std::string())
Posts diagnostic errors for all GL errors in the current context.
GLF_API void GlfRegisterDefaultDebugOutputMessageCallback()
Registers GlfDefaultDebugOutputMessageCallback as the debug message callback for the current GL conte...
GLF_API void GlfDebugLabelBuffer(GLuint id, char const *label)
Label a buffer object to improve tracing in the debug output.
GLF_API char const * GlfDebugEnumToString(GLenum debugEnum)
Returns a string representation of debug output enum values.
Represents a GL query object in Glf.
Definition: diagnostic.h:115
GLF_API void GlfDebugLabelShader(GLuint id, char const *label)
Label a shader object to improve tracing in the debug output.
GLF_API int64_t GetResult()
Return the query result (synchronous) stalls CPU until the result becomes available.
GLF_API void GlfDebugLabelProgram(GLuint id, char const *label)
Label a program object to improve tracing in the debug output.
GLF_API void BeginTimeElapsed()
equivalent to Begin(GL_TIME_ELAPSED).
GLF_API void BeginPrimitivesGenerated()
equivalent to Begin(GL_PRIMITIVES_GENERATED).
GLF_API void BeginSamplesPassed()
equivalent to Begin(GL_SAMPLES_PASSED).