glcontext: don't enable GL debug for messages that won't be logged

This is an optimization to avoid pointless string processing.
This commit is contained in:
Matthew Waters 2016-02-16 13:58:42 +11:00
parent effe132310
commit 02262a20e8
2 changed files with 67 additions and 19 deletions

View file

@ -67,9 +67,7 @@
#include "eagl/gstglcontext_eagl.h" #include "eagl/gstglcontext_eagl.h"
#endif #endif
extern void GSTGLAPI _gst_gl_debug_callback (GLenum source, GLenum type, extern void _gst_gl_debug_enable (GstGLContext * context);
GLuint id, GLenum severity, GLsizei length, const gchar * message,
gpointer user_data);
static GPrivate current_context_key; static GPrivate current_context_key;
@ -186,6 +184,7 @@ _context_share_group_is_shared (struct ContextShareGroup *share)
#define GST_CAT_DEFAULT gst_gl_context_debug #define GST_CAT_DEFAULT gst_gl_context_debug
GST_DEBUG_CATEGORY (GST_CAT_DEFAULT); GST_DEBUG_CATEGORY (GST_CAT_DEFAULT);
GST_DEBUG_CATEGORY_STATIC (gst_gl_debug);
#define gst_gl_context_parent_class parent_class #define gst_gl_context_parent_class parent_class
G_DEFINE_ABSTRACT_TYPE (GstGLContext, gst_gl_context, GST_TYPE_OBJECT); G_DEFINE_ABSTRACT_TYPE (GstGLContext, gst_gl_context, GST_TYPE_OBJECT);
@ -303,6 +302,7 @@ _init_debug (void)
if (g_once_init_enter (&_init)) { if (g_once_init_enter (&_init)) {
GST_DEBUG_CATEGORY_INIT (gst_gl_context_debug, "glcontext", 0, GST_DEBUG_CATEGORY_INIT (gst_gl_context_debug, "glcontext", 0,
"glcontext element"); "glcontext element");
GST_DEBUG_CATEGORY_INIT (gst_gl_debug, "gldebug", 0, "OpenGL Debugging");
g_once_init_leave (&_init, 1); g_once_init_leave (&_init, 1);
} }
} }
@ -1086,7 +1086,6 @@ gst_gl_context_create_thread (GstGLContext * context)
{ {
GstGLContextClass *context_class; GstGLContextClass *context_class;
GstGLWindowClass *window_class; GstGLWindowClass *window_class;
GstGLFuncs *gl;
GstGLAPI compiled_api, user_api, gl_api, display_api; GstGLAPI compiled_api, user_api, gl_api, display_api;
gchar *api_string; gchar *api_string;
gchar *compiled_api_s; gchar *compiled_api_s;
@ -1122,7 +1121,6 @@ gst_gl_context_create_thread (GstGLContext * context)
} }
} }
gl = context->gl_vtable;
compiled_api = _compiled_api (); compiled_api = _compiled_api ();
compiled_api_s = gst_gl_api_to_string (compiled_api); compiled_api_s = gst_gl_api_to_string (compiled_api);
@ -1210,15 +1208,9 @@ gst_gl_context_create_thread (GstGLContext * context)
context->priv->alive = TRUE; context->priv->alive = TRUE;
if (gl->DebugMessageCallback) {
#if !defined(GST_DISABLE_GST_DEBUG) #if !defined(GST_DISABLE_GST_DEBUG)
GST_INFO_OBJECT (context, "Enabling GL context debugging"); _gst_gl_debug_enable (context);
/* enable them all */
gl->DebugMessageControl (GL_DONT_CARE, GL_DONT_CARE, GL_DONT_CARE, 0, 0,
GL_TRUE);
gl->DebugMessageCallback (_gst_gl_debug_callback, context);
#endif #endif
}
if (other_context) { if (other_context) {
GST_DEBUG_OBJECT (context, "Unreffing other_context %" GST_PTR_FORMAT, GST_DEBUG_OBJECT (context, "Unreffing other_context %" GST_PTR_FORMAT,

View file

@ -89,6 +89,7 @@ GST_DEBUG_CATEGORY_STATIC (gst_performance);
#define GST_CAT_DEFAULT gst_gl_debug #define GST_CAT_DEFAULT gst_gl_debug
GST_DEBUG_CATEGORY_STATIC (GST_CAT_DEFAULT); GST_DEBUG_CATEGORY_STATIC (GST_CAT_DEFAULT);
GST_DEBUG_CATEGORY_STATIC (default_debug); GST_DEBUG_CATEGORY_STATIC (default_debug);
GST_DEBUG_CATEGORY_STATIC (gst_gl_marker_debug);
static void static void
_init_debug (void) _init_debug (void)
@ -97,8 +98,10 @@ _init_debug (void)
if (g_once_init_enter (&_init)) { if (g_once_init_enter (&_init)) {
GST_DEBUG_CATEGORY_GET (gst_performance, "GST_PERFORMANCE"); GST_DEBUG_CATEGORY_GET (gst_performance, "GST_PERFORMANCE");
GST_DEBUG_CATEGORY_INIT (gst_gl_debug, "gldebug", 0, "OpenGL Debugging"); GST_DEBUG_CATEGORY_GET (gst_gl_debug, "gldebug");
GST_DEBUG_CATEGORY_GET (default_debug, "default"); GST_DEBUG_CATEGORY_GET (default_debug, "default");
GST_DEBUG_CATEGORY_INIT (gst_gl_marker_debug, "gldebugmarker", 0,
"OpenGL Markers");
g_once_init_leave (&_init, 1); g_once_init_leave (&_init, 1);
} }
} }
@ -238,12 +241,7 @@ _debug_type_to_string (GLenum type)
} }
} }
/* silence the compiler... */ static void GSTGLAPI
G_GNUC_INTERNAL void GSTGLAPI _gst_gl_debug_callback (GLenum source,
GLenum type, GLuint id, GLenum severity, GLsizei length,
const gchar * message, gpointer user_data);
void GSTGLAPI
_gst_gl_debug_callback (GLenum source, GLenum type, GLuint id, GLenum severity, _gst_gl_debug_callback (GLenum source, GLenum type, GLuint id, GLenum severity,
GLsizei length, const gchar * message, gpointer user_data) GLsizei length, const gchar * message, gpointer user_data)
{ {
@ -276,6 +274,58 @@ _gst_gl_debug_callback (GLenum source, GLenum type, GLuint id, GLenum severity,
} }
} }
G_GNUC_INTERNAL void _gst_gl_debug_enable (GstGLContext * context);
G_GNUC_INTERNAL void
_gst_gl_debug_enable (GstGLContext * context)
{
const GstGLFuncs *gl = context->gl_vtable;
GstDebugLevel level;
GLenum debug_types[8];
guint i, n = 0;
_init_debug ();
if (!gl->DebugMessageCallback) {
GST_CAT_INFO_OBJECT (gst_gl_context_debug, context,
"No debugging support available");
return;
}
level = gst_debug_category_get_threshold (gst_gl_debug);
g_print ("level: %u\n", level);
if (level < GST_LEVEL_ERROR) {
GST_CAT_INFO_OBJECT (gst_gl_context_debug, context,
"Disabling GL context debugging (gldebug category debug level < error)");
return;
}
GST_CAT_INFO_OBJECT (gst_gl_context_debug, context,
"Enabling GL context debugging");
gl->DebugMessageCallback (_gst_gl_debug_callback, context);
if (level >= GST_LEVEL_DEBUG) {
/* enable them all */
gl->DebugMessageControl (GL_DONT_CARE, GL_DONT_CARE, GL_DONT_CARE, 0, 0,
GL_TRUE);
} else {
if (level >= GST_LEVEL_FIXME) {
debug_types[n++] = GL_DEBUG_TYPE_DEPRECATED_BEHAVIOR;
debug_types[n++] = GL_DEBUG_TYPE_PORTABILITY;
}
if (level >= GST_LEVEL_ERROR) {
debug_types[n++] = GL_DEBUG_TYPE_ERROR;
debug_types[n++] = GL_DEBUG_TYPE_UNDEFINED_BEHAVIOR;
}
g_assert (n < G_N_ELEMENTS (debug_types));
for (i = 0; i < n; i++) {
gl->DebugMessageControl (GL_DONT_CARE, debug_types[i], GL_DONT_CARE,
0, 0, GL_TRUE);
}
}
}
void void
gst_gl_insert_debug_marker (GstGLContext * context, const gchar * format, ...) gst_gl_insert_debug_marker (GstGLContext * context, const gchar * format, ...)
{ {
@ -284,6 +334,10 @@ gst_gl_insert_debug_marker (GstGLContext * context, const gchar * format, ...)
gint len; gint len;
va_list args; va_list args;
/* are we enabled */
if (gst_debug_category_get_threshold (gst_gl_marker_debug) < GST_LEVEL_FIXME)
return;
va_start (args, format); va_start (args, format);
len = gst_info_vasprintf (&string, format, args); len = gst_info_vasprintf (&string, format, args);
va_end (args); va_end (args);
@ -398,4 +452,6 @@ gst_gl_async_debug_store_log_msg (GstGLAsyncDebug * ad, GstDebugCategory * cat,
va_end (varargs); va_end (varargs);
} }
} }
#else
G_GNUC_INTERNAL void _gst_gl_debug_enable (GstGLContext * context);
#endif #endif