profiling: Adds initial UProf accounting to Cogl
This adds gives Cogl a dedicated UProf context which will be linked together with Clutter's context during clutter_init_real(). Initial timers cover _cogl_journal_flush and _cogl_journal_log_quad You can explicitly ask for a report of Cogl statistics by exporting COGL_PROFILE_OUTPUT_REPORT=1 but since the context is linked with Clutter's the statisitcs will also be shown in the automatic Clutter reports.
This commit is contained in:
parent
e9c4a0467b
commit
fbad0a75b6
@ -134,6 +134,8 @@ libclutter_cogl_la_SOURCES = \
|
|||||||
$(srcdir)/cogl-framebuffer.c \
|
$(srcdir)/cogl-framebuffer.c \
|
||||||
$(srcdir)/cogl-matrix-mesa.h \
|
$(srcdir)/cogl-matrix-mesa.h \
|
||||||
$(srcdir)/cogl-matrix-mesa.c \
|
$(srcdir)/cogl-matrix-mesa.c \
|
||||||
|
$(srcdir)/cogl-profile.h \
|
||||||
|
$(srcdir)/cogl-profile.c \
|
||||||
$(NULL)
|
$(NULL)
|
||||||
|
|
||||||
EXTRA_DIST += $(cogl_winsys_sources)
|
EXTRA_DIST += $(cogl_winsys_sources)
|
||||||
|
@ -33,6 +33,7 @@
|
|||||||
#include "cogl-material-private.h"
|
#include "cogl-material-private.h"
|
||||||
#include "cogl-vertex-buffer-private.h"
|
#include "cogl-vertex-buffer-private.h"
|
||||||
#include "cogl-framebuffer-private.h"
|
#include "cogl-framebuffer-private.h"
|
||||||
|
#include "cogl-profile.h"
|
||||||
|
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <gmodule.h>
|
#include <gmodule.h>
|
||||||
@ -535,12 +536,19 @@ _cogl_journal_flush (void)
|
|||||||
(cogl_get_features () & COGL_FEATURE_VBOS) ? FALSE : TRUE;
|
(cogl_get_features () & COGL_FEATURE_VBOS) ? FALSE : TRUE;
|
||||||
CoglHandle framebuffer;
|
CoglHandle framebuffer;
|
||||||
CoglMatrixStack *modelview_stack;
|
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);
|
_COGL_GET_CONTEXT (ctx, NO_RETVAL);
|
||||||
|
|
||||||
if (ctx->journal->len == 0)
|
if (ctx->journal->len == 0)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
COGL_TIMER_START (_cogl_uprof_context, flush_timer);
|
||||||
|
|
||||||
if (G_UNLIKELY (cogl_debug_flags & COGL_DEBUG_BATCHING))
|
if (G_UNLIKELY (cogl_debug_flags & COGL_DEBUG_BATCHING))
|
||||||
g_print ("BATCHING: journal len = %d\n", ctx->journal->len);
|
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->journal, 0);
|
||||||
g_array_set_size (ctx->logged_vertices, 0);
|
g_array_set_size (ctx->logged_vertices, 0);
|
||||||
|
|
||||||
|
COGL_TIMER_STOP (_cogl_uprof_context, flush_timer);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@ -644,9 +654,16 @@ _cogl_journal_log_quad (float x_1,
|
|||||||
int next_entry;
|
int next_entry;
|
||||||
guint32 disable_layers;
|
guint32 disable_layers;
|
||||||
CoglJournalEntry *entry;
|
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_GET_CONTEXT (ctx, NO_RETVAL);
|
||||||
|
|
||||||
|
COGL_TIMER_START (_cogl_uprof_context, log_timer);
|
||||||
|
|
||||||
if (ctx->logged_vertices->len == 0)
|
if (ctx->logged_vertices->len == 0)
|
||||||
_cogl_journal_init ();
|
_cogl_journal_init ();
|
||||||
|
|
||||||
@ -765,5 +782,7 @@ _cogl_journal_log_quad (float x_1,
|
|||||||
if (G_UNLIKELY (cogl_debug_flags & COGL_DEBUG_DISABLE_BATCHING
|
if (G_UNLIKELY (cogl_debug_flags & COGL_DEBUG_DISABLE_BATCHING
|
||||||
|| cogl_debug_flags & COGL_DEBUG_RECTANGLES))
|
|| cogl_debug_flags & COGL_DEBUG_RECTANGLES))
|
||||||
_cogl_journal_flush ();
|
_cogl_journal_flush ();
|
||||||
|
|
||||||
|
COGL_TIMER_STOP (_cogl_uprof_context, log_timer);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
30
cogl/cogl-profile.c
Normal file
30
cogl/cogl-profile.c
Normal file
@ -0,0 +1,30 @@
|
|||||||
|
|
||||||
|
#ifdef COGL_ENABLE_PROFILE
|
||||||
|
|
||||||
|
#include "cogl-profile.h"
|
||||||
|
|
||||||
|
#include <stdlib.h>
|
||||||
|
|
||||||
|
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
|
54
cogl/cogl-profile.h
Normal file
54
cogl/cogl-profile.h
Normal file
@ -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 <uprof.h>
|
||||||
|
|
||||||
|
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__ */
|
||||||
|
|
Loading…
Reference in New Issue
Block a user