Mesa (master): r300g: Rudimentary stats, printed on exit.

Corbin Simpson csimpson at kemper.freedesktop.org
Mon Apr 26 07:14:38 PDT 2010


Module: Mesa
Branch: master
Commit: b02f1c86f5bf8b1169776975491c7df929e94e2c
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=b02f1c86f5bf8b1169776975491c7df929e94e2c

Author: Corbin Simpson <MostAwesomeDude at gmail.com>
Date:   Mon Apr 26 07:13:15 2010 -0700

r300g: Rudimentary stats, printed on exit.

Whoo!

---

 src/gallium/drivers/r300/r300_context.c |   11 +++++++++++
 src/gallium/drivers/r300/r300_context.h |    5 +++++
 src/gallium/drivers/r300/r300_cs.h      |    3 +++
 src/gallium/drivers/r300/r300_emit.c    |    3 +++
 4 files changed, 22 insertions(+), 0 deletions(-)

diff --git a/src/gallium/drivers/r300/r300_context.c b/src/gallium/drivers/r300/r300_context.c
index deaa03e..43a4249 100644
--- a/src/gallium/drivers/r300/r300_context.c
+++ b/src/gallium/drivers/r300/r300_context.c
@@ -41,10 +41,21 @@ static void r300_destroy_context(struct pipe_context* context)
 {
     struct r300_context* r300 = r300_context(context);
     struct r300_query* query, * temp;
+    struct r300_atom *atom;
 
     util_blitter_destroy(r300->blitter);
     draw_destroy(r300->draw);
 
+    /* Print stats, if enabled. */
+    if (SCREEN_DBG_ON(r300->screen, DBG_STATS)) {
+        fprintf(stderr, "r300: Stats for context %p:\n", r300);
+        fprintf(stderr, "    : Flushes: %llu\n", r300->flush_counter);
+        foreach(atom, &r300->atom_list) {
+            fprintf(stderr, "    : %s: %llu emits\n",
+                atom->name, atom->counter);
+        }
+    }
+
     /* Free the OQ BO. */
     context->screen->resource_destroy(context->screen, r300->oqbo);
 
diff --git a/src/gallium/drivers/r300/r300_context.h b/src/gallium/drivers/r300/r300_context.h
index 1e4fd9e..b6e2059 100644
--- a/src/gallium/drivers/r300/r300_context.h
+++ b/src/gallium/drivers/r300/r300_context.h
@@ -45,6 +45,8 @@ struct r300_atom {
     struct r300_atom *prev, *next;
     /* Name, for debugging. */
     const char* name;
+    /* Stat counter. */
+    uint64_t counter;
     /* Opaque state. */
     void* state;
     /* Emit the state to the context. */
@@ -435,6 +437,9 @@ struct r300_context {
     /* upload managers */
     struct u_upload_mgr *upload_vb;
     struct u_upload_mgr *upload_ib;
+
+    /* Stat counter. */
+    uint64_t flush_counter;
 };
 
 /* Convenience cast wrapper. */
diff --git a/src/gallium/drivers/r300/r300_cs.h b/src/gallium/drivers/r300/r300_cs.h
index 96f2825..996a4f4 100644
--- a/src/gallium/drivers/r300/r300_cs.h
+++ b/src/gallium/drivers/r300/r300_cs.h
@@ -157,6 +157,9 @@
         DBG(cs_context_copy, DBG_CS, "r300: FLUSH_CS in %s (%s:%d)\n\n", __FUNCTION__, \
                 __FILE__, __LINE__); \
     } \
+    if (SCREEN_DBG_ON(r300->screen, DBG_STATS)) { \
+        r300->flush_counter++; \
+    } \
     cs_winsys->flush_cs(cs_winsys); \
 } while (0)
 
diff --git a/src/gallium/drivers/r300/r300_emit.c b/src/gallium/drivers/r300/r300_emit.c
index a6716db..2816c35 100644
--- a/src/gallium/drivers/r300/r300_emit.c
+++ b/src/gallium/drivers/r300/r300_emit.c
@@ -1187,6 +1187,9 @@ void r300_emit_dirty_state(struct r300_context* r300)
     foreach(atom, &r300->atom_list) {
         if (atom->dirty) {
             atom->emit(r300, atom->size, atom->state);
+            if (SCREEN_DBG_ON(r300->screen, DBG_STATS)) {
+                atom->counter++;
+            }
             atom->dirty = FALSE;
         }
     }



More information about the mesa-commit mailing list