From d1ac02594f7985bdb7f4b215a59f54c51f2624bc Mon Sep 17 00:00:00 2001 From: Robert Bragg Date: Mon, 26 Jul 2010 15:21:18 +0100 Subject: [PATCH] journal: provide more detailed uprof instrumentation This adds more timing around key stages of the journal flushing process. --- cogl/cogl-journal.c | 39 +++++++++++++++++++++++++++++++++++++++ cogl/cogl-material.c | 40 ++++++++++++++++++++++++++++------------ 2 files changed, 67 insertions(+), 12 deletions(-) diff --git a/cogl/cogl-journal.c b/cogl/cogl-journal.c index 39b9ad6e9..c7d8256bd 100644 --- a/cogl/cogl-journal.c +++ b/cogl/cogl-journal.c @@ -196,8 +196,15 @@ _cogl_journal_flush_modelview_and_entries (CoglJournalEntry *batch_start, int batch_len, void *data) { + COGL_STATIC_TIMER (time_flush_modelview_and_entries, + "flush: material+entries", /* parent */ + "flush: modelview+entries", + "The time spent flushing modelview + entries", + 0 /* no application private data */); CoglJournalFlushState *state = data; + COGL_TIMER_START (_cogl_uprof_context, time_flush_modelview_and_entries); + if (G_UNLIKELY (cogl_debug_flags & COGL_DEBUG_BATCHING)) g_print ("BATCHING: modelview batch len = %d\n", batch_len); @@ -279,6 +286,8 @@ _cogl_journal_flush_modelview_and_entries (CoglJournalEntry *batch_start, } state->vertex_offset += (4 * batch_len); + + COGL_TIMER_STOP (_cogl_uprof_context, time_flush_modelview_and_entries); } static gboolean @@ -311,9 +320,16 @@ _cogl_journal_flush_material_and_entries (CoglJournalEntry *batch_start, void *data) { unsigned long enable_flags = 0; + COGL_STATIC_TIMER (time_flush_material_entries, + "flush: texcoords+material+entries", /* parent */ + "flush: material+entries", + "The time spent flushing material + entries", + 0 /* no application private data */); _COGL_GET_CONTEXT (ctx, NO_RETVAL); + COGL_TIMER_START (_cogl_uprof_context, time_flush_material_entries); + if (G_UNLIKELY (cogl_debug_flags & COGL_DEBUG_BATCHING)) g_print ("BATCHING: material batch len = %d\n", batch_len); @@ -339,6 +355,8 @@ _cogl_journal_flush_material_and_entries (CoglJournalEntry *batch_start, } else _cogl_journal_flush_modelview_and_entries (batch_start, batch_len, data); + + COGL_TIMER_STOP (_cogl_uprof_context, time_flush_material_entries); } static gboolean @@ -369,9 +387,17 @@ _cogl_journal_flush_texcoord_vbo_offsets_and_entries ( { CoglJournalFlushState *state = data; int i; + COGL_STATIC_TIMER (time_flush_texcoord_material_entries, + "flush: vbo+texcoords+material+entries", /* parent */ + "flush: texcoords+material+entries", + "The time spent flushing texcoord offsets + material " + "+ entries", + 0 /* no application private data */); _COGL_GET_CONTEXT (ctx, NO_RETVAL); + COGL_TIMER_START (_cogl_uprof_context, time_flush_texcoord_material_entries); + for (i = 0; i < batch_start->n_layers; i++) { GE (glClientActiveTexture (GL_TEXTURE0 + i)); @@ -400,6 +426,7 @@ _cogl_journal_flush_texcoord_vbo_offsets_and_entries ( compare_entry_materials, _cogl_journal_flush_material_and_entries, data); + COGL_TIMER_STOP (_cogl_uprof_context, time_flush_texcoord_material_entries); } static gboolean @@ -425,9 +452,18 @@ _cogl_journal_flush_vbo_offsets_and_entries (CoglJournalEntry *batch_start, CoglHandle indices_handle; CoglVertexBufferIndices *indices; #endif + COGL_STATIC_TIMER (time_flush_vbo_texcoord_material_entries, + "Journal Flush", /* parent */ + "flush: vbo+texcoords+material+entries", + "The time spent flushing vbo + texcoord offsets + " + "material + entries", + 0 /* no application private data */); _COGL_GET_CONTEXT (ctx, NO_RETVAL); + COGL_TIMER_START (_cogl_uprof_context, + time_flush_vbo_texcoord_material_entries); + if (G_UNLIKELY (cogl_debug_flags & COGL_DEBUG_BATCHING)) g_print ("BATCHING: vbo offset batch len = %d\n", batch_len); @@ -495,6 +531,9 @@ _cogl_journal_flush_vbo_offsets_and_entries (CoglJournalEntry *batch_start, state->vbo_offset += (stride * 4 * batch_len); if (G_UNLIKELY (cogl_debug_flags & COGL_DEBUG_JOURNAL)) g_print ("new vbo offset = %lu\n", (unsigned long)state->vbo_offset); + + COGL_TIMER_STOP (_cogl_uprof_context, + time_flush_vbo_texcoord_material_entries); } static gboolean diff --git a/cogl/cogl-material.c b/cogl/cogl-material.c index f4936bf43..435d02d2e 100644 --- a/cogl/cogl-material.c +++ b/cogl/cogl-material.c @@ -3323,14 +3323,27 @@ _cogl_material_equal (CoglMaterial *material0, gboolean skip_gl_color) { unsigned long materials_difference; + gboolean ret; + COGL_STATIC_TIMER (material_equal_timer, + "Mainloop", /* parent */ + "_cogl_material_equal", + "The time spent comparing cogl materials", + 0 /* no application private data */); + + COGL_TIMER_START (_cogl_uprof_context, material_equal_timer); if (material0 == material1) - return TRUE; + { + ret = TRUE; + goto done; + } + + ret = FALSE; /* First check non-sparse properties */ if (material0->real_blend_enable != material1->real_blend_enable) - return FALSE; + goto done; /* Then check sparse properties */ @@ -3347,20 +3360,20 @@ _cogl_material_equal (CoglMaterial *material0, _cogl_material_get_authority (material1, state); if (!cogl_color_equal (&authority0->color, &authority1->color)) - return FALSE; + goto done; } if (!simple_property_equal (material0, material1, materials_difference, COGL_MATERIAL_STATE_LIGHTING, _cogl_material_lighting_state_equal)) - return FALSE; + goto done; if (!simple_property_equal (material0, material1, materials_difference, COGL_MATERIAL_STATE_ALPHA_FUNC, _cogl_material_alpha_state_equal)) - return FALSE; + goto done; /* We don't need to compare the detailed blending state if we know * blending is disabled for both materials. */ @@ -3374,7 +3387,7 @@ _cogl_material_equal (CoglMaterial *material0, _cogl_material_get_authority (material1, state); if (!_cogl_material_blend_state_equal (authority0, authority1)) - return FALSE; + goto done; } /* XXX: we don't need to compare the BLEND_ENABLE state because it's @@ -3391,33 +3404,36 @@ _cogl_material_equal (CoglMaterial *material0, materials_difference, COGL_MATERIAL_STATE_DEPTH, _cogl_material_depth_state_equal)) - return FALSE; + goto done; if (!simple_property_equal (material0, material1, materials_difference, COGL_MATERIAL_STATE_FOG, _cogl_material_fog_state_equal)) - return FALSE; + goto done; if (!simple_property_equal (material0, material1, materials_difference, COGL_MATERIAL_STATE_POINT_SIZE, _cogl_material_point_size_equal)) - return FALSE; + goto done; if (!simple_property_equal (material0, material1, materials_difference, COGL_MATERIAL_STATE_USER_SHADER, _cogl_material_user_shader_equal)) - return FALSE; + goto done; if (!simple_property_equal (material0, material1, materials_difference, COGL_MATERIAL_STATE_LAYERS, _cogl_material_layers_equal)) - return FALSE; + goto done; - return TRUE; + ret = TRUE; +done: + COGL_TIMER_STOP (_cogl_uprof_context, material_equal_timer); + return ret; } void