GL: Move MacOS debug callback to gl_debug.cc
And format to use the same callback as standard debugging layer.
This commit is contained in:
@@ -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"
|
||||
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
/** \} */
|
||||
|
||||
@@ -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 {
|
||||
|
||||
|
||||
@@ -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
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user