gl/utils: add a function to insert a debug marker
authorMatthew Waters <matthew@centricular.com>
Mon, 31 Aug 2015 09:18:23 +0000 (19:18 +1000)
committerMatthew Waters <matthew@centricular.com>
Mon, 28 Sep 2015 06:47:00 +0000 (16:47 +1000)
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.

gst-libs/gst/gl/gstglutils.c
gst-libs/gst/gl/gstglutils.h

index 0c0642a..2091f4d 100644 (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
index ee606e0..90ddd8e 100644 (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__ */