Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorClément Foucault <foucault.clem@gmail.com>2020-09-14 18:29:28 +0300
committerClément Foucault <foucault.clem@gmail.com>2020-09-14 18:30:25 +0300
commitac63afca7d4564d21577e5a97b692cee71897089 (patch)
tree40d6b595934040ac26f6cbb2670cd09d8aec0198 /source/blender/gpu/opengl/gl_debug.cc
parenta040e8df3669d6e1e6fe4a973cd78366c2cf70a9 (diff)
GL: Make use of the new debug layer
This makes replay analysis inside renderdoc much easier by using the new debug group functionality.
Diffstat (limited to 'source/blender/gpu/opengl/gl_debug.cc')
-rw-r--r--source/blender/gpu/opengl/gl_debug.cc46
1 files changed, 42 insertions, 4 deletions
diff --git a/source/blender/gpu/opengl/gl_debug.cc b/source/blender/gpu/opengl/gl_debug.cc
index 747d8ee2e3e..67d4311750d 100644
--- a/source/blender/gpu/opengl/gl_debug.cc
+++ b/source/blender/gpu/opengl/gl_debug.cc
@@ -30,6 +30,7 @@
#include "BKE_global.h"
+#include "GPU_debug.h"
#include "GPU_platform.h"
#include "glew-mx.h"
@@ -70,7 +71,11 @@ static void APIENTRY debug_callback(GLenum UNUSED(source),
const GLchar *message,
const GLvoid *UNUSED(userParm))
{
- const char format[] = "GPUDebug: %s%s\033[0m\n";
+ if (ELEM(type, GL_DEBUG_TYPE_PUSH_GROUP, GL_DEBUG_TYPE_POP_GROUP)) {
+ /* The debug layer will emit a message each time a debug group is pushed or popped.
+ * We use that for easy command grouping inside frame analyser tools. */
+ return;
+ }
if (TRIM_NVIDIA_BUFFER_INFO &&
GPU_type_matches(GPU_DEVICE_NVIDIA, GPU_OS_ANY, GPU_DRIVER_OFFICIAL) &&
@@ -79,24 +84,29 @@ static void APIENTRY debug_callback(GLenum UNUSED(source),
return;
}
+ const char format[] = "GPUDebug: %s%s%s\033[0m\n";
+
if (ELEM(severity, GL_DEBUG_SEVERITY_LOW, GL_DEBUG_SEVERITY_NOTIFICATION)) {
if (VERBOSE) {
- fprintf(stderr, format, "\033[2m", message);
+ fprintf(stderr, format, "\033[2m", "", message);
}
}
else {
+ char debug_groups[512] = "";
+ GPU_debug_get_groups_names(sizeof(debug_groups), debug_groups);
+
switch (type) {
case GL_DEBUG_TYPE_ERROR:
case GL_DEBUG_TYPE_DEPRECATED_BEHAVIOR:
case GL_DEBUG_TYPE_UNDEFINED_BEHAVIOR:
- fprintf(stderr, format, "\033[31;1mError\033[39m: ", message);
+ fprintf(stderr, format, "\033[31;1mError\033[39m: ", debug_groups, message);
break;
case GL_DEBUG_TYPE_PORTABILITY:
case GL_DEBUG_TYPE_PERFORMANCE:
case GL_DEBUG_TYPE_OTHER:
case GL_DEBUG_TYPE_MARKER: /* KHR has this, ARB does not */
default:
- fprintf(stderr, format, "\033[33;1mWarning\033[39m: ", message);
+ fprintf(stderr, format, "\033[33;1mWarning\033[39m: ", debug_groups, message);
break;
}
@@ -321,3 +331,31 @@ void object_label(GLenum type, GLuint object, const char *name)
/** \} */
} // namespace blender::gpu::debug
+
+namespace blender::gpu {
+
+/* -------------------------------------------------------------------- */
+/** \name Debug Groups
+ *
+ * Useful for debugging through render-doc. This makes all the API calls grouped into "passes".
+ * \{ */
+
+void GLContext::debug_group_begin(const char *name, int index)
+{
+ if ((G.debug & G_DEBUG_GPU) && (GLEW_VERSION_4_3 || GLEW_KHR_debug)) {
+ /* Add 10 to avoid conlision with other indices from other possible callback layers. */
+ index += 10;
+ glPushDebugGroup(GL_DEBUG_SOURCE_APPLICATION, index, -1, name);
+ }
+}
+
+void GLContext::debug_group_end(void)
+{
+ if ((G.debug & G_DEBUG_GPU) && (GLEW_VERSION_4_3 || GLEW_KHR_debug)) {
+ glPopDebugGroup();
+ }
+}
+
+/** \} */
+
+} // namespace blender::gpu