[Bf-blender-cvs] [9d932b426f0] master: GL: Move MacOS debug callback to gl_debug.cc
Clément Foucault
noreply at git.blender.org
Tue Sep 1 00:30:43 CEST 2020
Commit: 9d932b426f0db9350a3fe49cd5bcf8b25e7cf8bb
Author: Clément Foucault
Date: Mon Aug 31 23:13:35 2020 +0200
Branches: master
https://developer.blender.org/rB9d932b426f0db9350a3fe49cd5bcf8b25e7cf8bb
GL: Move MacOS debug callback to gl_debug.cc
And format to use the same callback as standard debugging layer.
===================================================================
M source/blender/gpu/opengl/gl_batch.cc
M source/blender/gpu/opengl/gl_context.cc
M source/blender/gpu/opengl/gl_context.hh
M source/blender/gpu/opengl/gl_debug.cc
M source/blender/gpu/opengl/gl_debug.hh
===================================================================
diff --git a/source/blender/gpu/opengl/gl_batch.cc b/source/blender/gpu/opengl/gl_batch.cc
index bc951736db3..63547bf190f 100644
--- a/source/blender/gpu/opengl/gl_batch.cc
+++ b/source/blender/gpu/opengl/gl_batch.cc
@@ -36,6 +36,7 @@
#include "gl_batch.hh"
#include "gl_context.hh"
+#include "gl_debug.hh"
#include "gl_primitive.hh"
#include "gl_vertex_array.hh"
diff --git a/source/blender/gpu/opengl/gl_context.cc b/source/blender/gpu/opengl/gl_context.cc
index 7d564004a01..666f2b4756a 100644
--- a/source/blender/gpu/opengl/gl_context.cc
+++ b/source/blender/gpu/opengl/gl_context.cc
@@ -294,37 +294,3 @@ void GLContext::framebuffer_unregister(struct GPUFrameBuffer *fb)
}
/** \} */
-
-/* -------------------------------------------------------------------- */
-/** \name Error Checking
- *
- * This is only useful for implementation that does not support the KHR_debug extension.
- * \{ */
-
-void GLContext::check_error(const char *info)
-{
- GLenum error = glGetError();
-
-#define ERROR_CASE(err) \
- case err: \
- fprintf(stderr, "GL error: %s : %s\n", #err, info); \
- BLI_system_backtrace(stderr); \
- break;
-
- switch (error) {
- ERROR_CASE(GL_INVALID_ENUM)
- ERROR_CASE(GL_INVALID_VALUE)
- ERROR_CASE(GL_INVALID_OPERATION)
- ERROR_CASE(GL_INVALID_FRAMEBUFFER_OPERATION)
- ERROR_CASE(GL_OUT_OF_MEMORY)
- ERROR_CASE(GL_STACK_UNDERFLOW)
- ERROR_CASE(GL_STACK_OVERFLOW)
- case GL_NO_ERROR:
- break;
- default:
- fprintf(stderr, "Unknown GL error: %x : %s", error, info);
- break;
- }
-}
-
-/** \} */
diff --git a/source/blender/gpu/opengl/gl_context.hh b/source/blender/gpu/opengl/gl_context.hh
index 55af7d8f65d..99076fa3d1e 100644
--- a/source/blender/gpu/opengl/gl_context.hh
+++ b/source/blender/gpu/opengl/gl_context.hh
@@ -34,13 +34,6 @@
#include <mutex>
-/* Enabled on MacOS by default since there is no support for debug callbacks. */
-#if defined(DEBUG) && defined(__APPLE__)
-# define GL_CHECK_ERROR(info) GLContext::check_error(info)
-#else
-# define GL_CHECK_ERROR(info)
-#endif
-
namespace blender {
namespace gpu {
diff --git a/source/blender/gpu/opengl/gl_debug.cc b/source/blender/gpu/opengl/gl_debug.cc
index 1300cf4065e..2dc0835adfb 100644
--- a/source/blender/gpu/opengl/gl_debug.cc
+++ b/source/blender/gpu/opengl/gl_debug.cc
@@ -137,4 +137,42 @@ void init_gl_callbacks(void)
/** \} */
+/* -------------------------------------------------------------------- */
+/** \name Error Checking
+ *
+ * This is only useful for implementation that does not support the KHR_debug extension.
+ * \{ */
+
+void check_gl_error(const char *info)
+{
+ GLenum error = glGetError();
+
+#define ERROR_CASE(err) \
+ case err: { \
+ char msg[256]; \
+ SNPRINTF(msg, "%s : %s", #err, info); \
+ debug_callback(0, GL_DEBUG_TYPE_ERROR, 0, GL_DEBUG_SEVERITY_HIGH, 0, msg, NULL); \
+ break; \
+ }
+
+ switch (error) {
+ ERROR_CASE(GL_INVALID_ENUM)
+ ERROR_CASE(GL_INVALID_VALUE)
+ ERROR_CASE(GL_INVALID_OPERATION)
+ ERROR_CASE(GL_INVALID_FRAMEBUFFER_OPERATION)
+ ERROR_CASE(GL_OUT_OF_MEMORY)
+ ERROR_CASE(GL_STACK_UNDERFLOW)
+ ERROR_CASE(GL_STACK_OVERFLOW)
+ case GL_NO_ERROR:
+ break;
+ default:
+ char msg[256];
+ SNPRINTF(msg, "Unknown GL error: %x : %s", error, info);
+ debug_callback(0, GL_DEBUG_TYPE_ERROR, 0, GL_DEBUG_SEVERITY_HIGH, 0, msg, NULL);
+ break;
+ }
+}
+
+/** \} */
+
} // namespace blender::gpu::debug
\ No newline at end of file
diff --git a/source/blender/gpu/opengl/gl_debug.hh b/source/blender/gpu/opengl/gl_debug.hh
index 44cd98b72f3..47c9558f13a 100644
--- a/source/blender/gpu/opengl/gl_debug.hh
+++ b/source/blender/gpu/opengl/gl_debug.hh
@@ -24,6 +24,14 @@ namespace blender {
namespace gpu {
namespace debug {
+/* Enabled on MacOS by default since there is no support for debug callbacks. */
+#if defined(DEBUG) && defined(__APPLE__)
+# define GL_CHECK_ERROR(info) debug::check_gl_error(info)
+#else
+# define GL_CHECK_ERROR(info)
+#endif
+
+void check_gl_error(const char *info);
void init_gl_callbacks(void);
} // namespace debug
More information about the Bf-blender-cvs
mailing list