From b05b1eff1c974c897d99f8ae1b3cb480ee39ef67 Mon Sep 17 00:00:00 2001 From: Kenneth Graunke Date: Sat, 2 Nov 2013 19:44:49 -0700 Subject: [PATCH] i965: Track the number of monitors that need OA counters. 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 Reviewed-by: Eric Anholt --- src/mesa/drivers/dri/i965/brw_context.h | 3 +++ .../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 43d0bbf7a5e..cb92b282324 100644 --- a/src/mesa/drivers/dri/i965/brw_context.h +++ b/src/mesa/drivers/dri/i965/brw_context.h @@ -1403,6 +1403,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 850dba78abc..1e04938ad76 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, -- 2.30.2