[Mesa-dev] [PATCH 18/27] i965: Track the number of monitors that need OA counters.

Kenneth Graunke kenneth at whitecape.org
Wed Nov 13 17:52:23 PST 2013


Using the OA counters requires some per-batch work.  When starting and
ending a batch, it's useful to know whether any monitors are actually
interested in OA data.

Signed-off-by: Kenneth Graunke <kenneth at whitecape.org>
Cc: Eric Anholt <eric at anholt.net>
Cc: Carl Worth <cworth at cworth.org>
Cc: Juha-Pekka Heikkilä <juha-pekka.heikkila at intel.com>
---
 src/mesa/drivers/dri/i965/brw_context.h             |  3 +++
 src/mesa/drivers/dri/i965/brw_performance_monitor.c | 17 ++++++++++++++++-
 2 files changed, 19 insertions(+), 1 deletion(-)

diff --git a/src/mesa/drivers/dri/i965/brw_context.h b/src/mesa/drivers/dri/i965/brw_context.h
index 289124d..77649cd 100644
--- a/src/mesa/drivers/dri/i965/brw_context.h
+++ b/src/mesa/drivers/dri/i965/brw_context.h
@@ -1397,6 +1397,9 @@ struct brw_context
       /** A map from pipeline statistics counter IDs to MMIO addresses. */
       const int *statistics_registers;
 
+      /** The number of active monitors using OA counters. */
+      unsigned oa_users;
+
       /**
        * Mapping from a uint32_t offset within an OA snapshot to the ID of
        * the counter which MI_REPORT_PERF_COUNT stores there.
diff --git a/src/mesa/drivers/dri/i965/brw_performance_monitor.c b/src/mesa/drivers/dri/i965/brw_performance_monitor.c
index 850dba7..1e04938 100644
--- a/src/mesa/drivers/dri/i965/brw_performance_monitor.c
+++ b/src/mesa/drivers/dri/i965/brw_performance_monitor.c
@@ -518,7 +518,7 @@ void
 brw_dump_perf_monitors(struct brw_context *brw)
 {
    struct gl_context *ctx = &brw->ctx;
-   DBG("Monitors:\n");
+   DBG("Monitors: (OA users = %d)\n", brw->perfmon.oa_users);
    _mesa_HashWalk(ctx->PerfMonitor.Monitors, dump_perf_monitor_callback, brw);
 }
 
@@ -588,6 +588,13 @@ gather_statistics_results(struct brw_context *brw,
 
 /******************************************************************************/
 
+static bool
+monitor_needs_oa(struct brw_context *brw,
+                 struct gl_perf_monitor_object *m)
+{
+   return m->ActiveGroups[OA_COUNTERS];
+}
+
 /**
  * Initialize a monitor to sane starting state; throw away old buffers.
  */
@@ -618,6 +625,10 @@ brw_begin_perf_monitor(struct gl_context *ctx,
 
    reinitialize_perf_monitor(brw, monitor);
 
+   if (monitor_needs_oa(brw, m)) {
+      ++brw->perfmon.oa_users;
+   }
+
    if (monitor_needs_statistics_registers(brw, m)) {
       monitor->pipeline_stats_bo =
          drm_intel_bo_alloc(brw->bufmgr, "perf. monitor stats bo", 4096, 64);
@@ -641,6 +652,10 @@ brw_end_perf_monitor(struct gl_context *ctx,
 
    DBG("End(%d)\n", m->Name);
 
+   if (monitor_needs_oa(brw, m)) {
+      --brw->perfmon.oa_users;
+   }
+
    if (monitor_needs_statistics_registers(brw, m)) {
       /* Take ending snapshots. */
       snapshot_statistics_registers(brw, monitor,
-- 
1.8.3.2



More information about the mesa-dev mailing list