[Cogl] [PATCH] journal: avoiding some _cogl_matrix_entry_get()'s

Robert Bragg robert at sixbynine.org
Thu Apr 19 03:47:42 PDT 2012


From: Robert Bragg <robert at linux.intel.com>

When uploading the vertices the journal calls _cogl_matrix_entry_get()
to get a CoglMatrix for each journal entry so that it can so a software
transform. Since _cogl_matrix_entry_get() can be a performance hot-spot
and since it's trivial to keep track of the last CoglMatrixEntry seen we
now avoid repeatedly calling _cogl_matrix_entry_get() for sequential
entries with the same transform.
---
 cogl/cogl-journal.c |    6 ++++--
 1 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/cogl/cogl-journal.c b/cogl/cogl-journal.c
index d177ca1..04460a9 100644
--- a/cogl/cogl-journal.c
+++ b/cogl/cogl-journal.c
@@ -1061,6 +1061,8 @@ upload_vertices (CoglJournal *journal,
   float *vout;
   int entry_num;
   int i;
+  CoglMatrixEntry *last_modelview_entry = NULL;
+  CoglMatrix modelview;
 
   g_assert (needed_vbo_len);
 
@@ -1098,7 +1100,6 @@ upload_vertices (CoglJournal *journal,
       else
         {
           float v[8];
-          CoglMatrix modelview;
 
           v[0] = vin[0];
           v[1] = vin[1];
@@ -1109,7 +1110,8 @@ upload_vertices (CoglJournal *journal,
           v[6] = vin[array_stride];
           v[7] = vin[1];
 
-          _cogl_matrix_entry_get (entry->modelview_entry, &modelview);
+          if (entry->modelview_entry != last_modelview_entry)
+            _cogl_matrix_entry_get (entry->modelview_entry, &modelview);
           cogl_matrix_transform_points (&modelview,
                                         2, /* n_components */
                                         sizeof (float) * 2, /* stride_in */
-- 
1.7.7.6



More information about the Cogl mailing list