diff --git a/clutter/clutter-main.c b/clutter/clutter-main.c index 5efa31126..7e9ae5e87 100644 --- a/clutter/clutter-main.c +++ b/clutter/clutter-main.c @@ -1542,6 +1542,13 @@ clutter_init_real (GError **error) _clutter_feature_init (); #ifdef CLUTTER_ENABLE_PROFILE + { + UProfContext *cogl_context; + cogl_context = uprof_find_context ("Cogl"); + if (cogl_context) + uprof_context_link (_clutter_uprof_context, cogl_context); + } + if (clutter_profile_flags & CLUTTER_PROFILE_PICKING_ONLY) _clutter_profile_suspend (); #endif diff --git a/clutter/cogl/cogl/Makefile.am b/clutter/cogl/cogl/Makefile.am index 5ef3c3b9c..7d78106f5 100644 --- a/clutter/cogl/cogl/Makefile.am +++ b/clutter/cogl/cogl/Makefile.am @@ -134,6 +134,8 @@ libclutter_cogl_la_SOURCES = \ $(srcdir)/cogl-framebuffer.c \ $(srcdir)/cogl-matrix-mesa.h \ $(srcdir)/cogl-matrix-mesa.c \ + $(srcdir)/cogl-profile.h \ + $(srcdir)/cogl-profile.c \ $(NULL) EXTRA_DIST += $(cogl_winsys_sources) diff --git a/clutter/cogl/cogl/cogl-journal.c b/clutter/cogl/cogl/cogl-journal.c index db406ea9c..fbb419a90 100644 --- a/clutter/cogl/cogl/cogl-journal.c +++ b/clutter/cogl/cogl/cogl-journal.c @@ -33,6 +33,7 @@ #include "cogl-material-private.h" #include "cogl-vertex-buffer-private.h" #include "cogl-framebuffer-private.h" +#include "cogl-profile.h" #include #include @@ -535,12 +536,19 @@ _cogl_journal_flush (void) (cogl_get_features () & COGL_FEATURE_VBOS) ? FALSE : TRUE; CoglHandle framebuffer; CoglMatrixStack *modelview_stack; + COGL_STATIC_TIMER (flush_timer, + "Mainloop", /* parent */ + "Journal Flush", + "The time spent flushing the Cogl journal", + 0 /* no application private data */); _COGL_GET_CONTEXT (ctx, NO_RETVAL); if (ctx->journal->len == 0) return; + COGL_TIMER_START (_cogl_uprof_context, flush_timer); + if (G_UNLIKELY (cogl_debug_flags & COGL_DEBUG_BATCHING)) g_print ("BATCHING: journal len = %d\n", ctx->journal->len); @@ -608,6 +616,8 @@ _cogl_journal_flush (void) g_array_set_size (ctx->journal, 0); g_array_set_size (ctx->logged_vertices, 0); + + COGL_TIMER_STOP (_cogl_uprof_context, flush_timer); } static void @@ -644,9 +654,16 @@ _cogl_journal_log_quad (float x_1, int next_entry; guint32 disable_layers; CoglJournalEntry *entry; + COGL_STATIC_TIMER (log_timer, + "Mainloop", /* parent */ + "Journal Log", + "The time spent logging in the Cogl journal", + 0 /* no application private data */); _COGL_GET_CONTEXT (ctx, NO_RETVAL); + COGL_TIMER_START (_cogl_uprof_context, log_timer); + if (ctx->logged_vertices->len == 0) _cogl_journal_init (); @@ -765,5 +782,7 @@ _cogl_journal_log_quad (float x_1, if (G_UNLIKELY (cogl_debug_flags & COGL_DEBUG_DISABLE_BATCHING || cogl_debug_flags & COGL_DEBUG_RECTANGLES)) _cogl_journal_flush (); + + COGL_TIMER_STOP (_cogl_uprof_context, log_timer); } diff --git a/clutter/cogl/cogl/cogl-profile.c b/clutter/cogl/cogl/cogl-profile.c new file mode 100644 index 000000000..e17acda38 --- /dev/null +++ b/clutter/cogl/cogl/cogl-profile.c @@ -0,0 +1,30 @@ + +#ifdef COGL_ENABLE_PROFILE + +#include "cogl-profile.h" + +#include + +UProfContext *_cogl_uprof_context; + + +static void __attribute__ ((constructor)) +cogl_uprof_constructor (void) +{ + _cogl_uprof_context = uprof_context_new ("Cogl"); +} + +static void __attribute__ ((destructor)) +cogl_uprof_destructor (void) +{ + if (getenv ("COGL_PROFILE_OUTPUT_REPORT")) + { + UProfReport *report = uprof_report_new ("Cogl report"); + uprof_report_add_context (report, _cogl_uprof_context); + uprof_report_print (report); + uprof_report_unref (report); + } + uprof_context_unref (_cogl_uprof_context); +} + +#endif diff --git a/clutter/cogl/cogl/cogl-profile.h b/clutter/cogl/cogl/cogl-profile.h new file mode 100644 index 000000000..302b146c1 --- /dev/null +++ b/clutter/cogl/cogl/cogl-profile.h @@ -0,0 +1,54 @@ +/* + * Cogl + * + * An object oriented GL/GLES Abstraction/Utility Layer + * + * Copyright (C) 2007,2008,2009 Intel Corporation. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 02111-1307, USA. + */ + +#ifndef __COGL_PROFILE_H__ +#define __COGL_PROFILE_H__ + + +#ifdef COGL_ENABLE_PROFILE + +#include + +extern UProfContext *_cogl_uprof_context; + +#define COGL_STATIC_TIMER UPROF_STATIC_TIMER +#define COGL_STATIC_COUNTER UPROF_STATIC_COUNTER +#define COGL_COUNTER_INC UPROF_COUNTER_INC +#define COGL_COUNTER_DEC UPROF_COUNTER_DEC +#define COGL_TIMER_START UPROF_TIMER_START +#define COGL_TIMER_STOP UPROF_TIMER_STOP + +#else + +#define COGL_STATIC_TIMER(A,B,C,D,E) extern void _cogl_dummy_decl (void) +#define COGL_STATIC_COUNTER(A,B,C,D) extern void _cogl_dummy_decl (void) +#define COGL_COUNTER_INC(A,B) G_STMT_START{ (void)0; }G_STMT_END +#define COGL_COUNTER_DEC(A,B) G_STMT_START{ (void)0; }G_STMT_END +#define COGL_TIMER_START(A,B) G_STMT_START{ (void)0; }G_STMT_END +#define COGL_TIMER_STOP(A,B) G_STMT_START{ (void)0; }G_STMT_END + + +#endif + +#endif /* __COGL_PROFILE_H__ */ + diff --git a/configure.ac b/configure.ac index bc681f9e6..93f0b5473 100644 --- a/configure.ac +++ b/configure.ac @@ -701,7 +701,7 @@ AS_CASE([$enable_profile], [yes], [ if test "x$GCC" = "xyes"; then PKG_CHECK_MODULES([PROFILE_DEP], [uprof-0.2]) - CLUTTER_PROFILE_CFLAGS=" -DCLUTTER_ENABLE_PROFILE $PROFILE_DEP_CFLAGS" + CLUTTER_PROFILE_CFLAGS=" -DCLUTTER_ENABLE_PROFILE -DCOGL_ENABLE_PROFILE $PROFILE_DEP_CFLAGS" CLUTTER_PROFILE_LDFLAGS=" $PROFILE_DEP_LIBS" if test "x$enable_debug" = "xyes"; then CLUTTER_PROFILE_CFLAGS+=" -DUPROF_DEBUG"