gl/utils: add a function to insert a debug marker

These markers are visible in tools that record the GL function calls
such as apitrace, et al.

Makes it easier to match up GL draw commands with specific elements.
This commit is contained in:
Matthew Waters 2015-08-31 19:18:23 +10:00
parent bfe8e42323
commit 5bf38301e1
2 changed files with 45 additions and 0 deletions

View file

@ -24,6 +24,7 @@
#include <stdio.h>
#include <gst/gst.h>
#include <glib/gprintf.h>
#include "gl.h"
#include "gstglutils.h"
@ -932,3 +933,29 @@ gst_gl_caps_replace_all_caps_features (const GstCaps * caps,
return tmp;
}
#ifndef GST_DISABLE_GST_DEBUG
void
gst_gl_insert_debug_marker (GstGLContext * context, const gchar * format, ...)
{
const GstGLFuncs *gl = context->gl_vtable;
gchar *string;
gint len;
va_list args;
va_start (args, format);
len = g_vasprintf (&string, format, args);
va_end (args);
#if defined (GL_DEBUG_TYPE_MARKER)
if (gl->DebugMessageInsert) {
gl->DebugMessageInsert (GL_DEBUG_SOURCE_THIRD_PARTY, GL_DEBUG_TYPE_MARKER,
0, GL_DEBUG_SEVERITY_LOW, (gsize) len, string);
} else
#endif
if (gl->InsertEventMarker)
gl->InsertEventMarker (len, string);
else if (gl->StringMarker)
gl->StringMarker (len, string);
}
#endif

View file

@ -109,6 +109,24 @@ gsize gst_gl_get_plane_data_size (GstVideoInfo * info, GstVideoAlignment * align
GstCaps * gst_gl_caps_replace_all_caps_features (const GstCaps * caps,
const gchar * feature_name);
#ifndef GST_DISABLE_GST_DEBUG
void gst_gl_insert_debug_marker (GstGLContext * context,
const gchar * format, ...) G_GNUC_PRINTF (2, 3);
#else /* GST_DISABLE_GST_DEBUG */
#if G_HAVE_ISO_VARARGS
#define gst_gl_insert_debug_marker(...) G_STMT_START{ }G_STMT_END
#else /* G_HAVE_ISO_VARARGS */
#if G_HAVE_GNUC_VARARGS
#define gst_gl_insert_debug_marker(args...) G_STMT_START{ }G_STMT_END
#else /* G_HAVE_GNUC_VARARGS */
static inline void
gst_gl_insert_debug_marker (GstGLContext * context, const gchar * format, ...)
{
}
#endif /* G_HAVE_GNUC_VARARGS */
#endif /* G_HAVE_ISO_VARARGS */
#endif /* GST_DISABLE_GST_DEBUG */
G_END_DECLS
#endif /* __GST_GL_UTILS_H__ */