For now, we only support these on Gen6+, since that's what currently uses hardware contexts. When we add Ironlake hardware context support, we can add pipeline statistics register support for that as well.
In theory, we could support pipeline statistics counters even without hardware contexts, but it would be annoyingly painful. Signed-off-by: Kenneth Graunke <kenn...@whitecape.org> Cc: Eric Anholt <e...@anholt.net> Cc: Carl Worth <cwo...@cworth.org> Cc: Juha-Pekka Heikkilä <juha-pekka.heikk...@intel.com> --- src/mesa/drivers/dri/i965/brw_context.h | 5 ++ .../drivers/dri/i965/brw_performance_monitor.c | 78 ++++++++++++++++++++++ 2 files changed, 83 insertions(+) diff --git a/src/mesa/drivers/dri/i965/brw_context.h b/src/mesa/drivers/dri/i965/brw_context.h index 927f1e3..6f3236f 100644 --- a/src/mesa/drivers/dri/i965/brw_context.h +++ b/src/mesa/drivers/dri/i965/brw_context.h @@ -1393,6 +1393,11 @@ struct brw_context bool begin_emitted; } query; + struct { + /** A map from pipeline statistics counter IDs to MMIO addresses. */ + const int *statistics_registers; + } perfmon; + int num_atoms; const struct brw_tracked_state **atoms; diff --git a/src/mesa/drivers/dri/i965/brw_performance_monitor.c b/src/mesa/drivers/dri/i965/brw_performance_monitor.c index 34f2aa3..c18664b 100644 --- a/src/mesa/drivers/dri/i965/brw_performance_monitor.c +++ b/src/mesa/drivers/dri/i965/brw_performance_monitor.c @@ -98,7 +98,37 @@ const static struct gl_perf_monitor_group gen5_groups[] = { * Sandybridge: * @{ */ +const static struct gl_perf_monitor_counter gen6_statistics_counters[] = { + COUNTER64("IA_VERTICES_COUNT"), + COUNTER64("IA_PRIMITIVES_COUNT"), + COUNTER64("VS_INVOCATION_COUNT"), + COUNTER64("GS_INVOCATION_COUNT"), + COUNTER64("GS_PRIMITIVES_COUNT"), + COUNTER64("CL_INVOCATION_COUNT"), + COUNTER64("CL_PRIMITIVES_COUNT"), + COUNTER64("PS_INVOCATION_COUNT"), + COUNTER64("PS_DEPTH_COUNT"), + COUNTER64("SO_NUM_PRIMS_WRITTEN"), + COUNTER64("SO_PRIM_STORAGE_NEEDED"), +}; + +/** MMIO register addresses for each pipeline statistics counter. */ +const static int gen6_statistics_register_addresses[] = { + IA_VERTICES_COUNT, + IA_PRIMITIVES_COUNT, + VS_INVOCATION_COUNT, + GS_INVOCATION_COUNT, + GS_PRIMITIVES_COUNT, + CL_INVOCATION_COUNT, + CL_PRIMITIVES_COUNT, + PS_INVOCATION_COUNT, + PS_DEPTH_COUNT, + GEN6_SO_NUM_PRIMS_WRITTEN, + GEN6_SO_PRIM_STORAGE_NEEDED, +}; + const static struct gl_perf_monitor_group gen6_groups[] = { + GROUP("Pipeline Statistics Registers", INT_MAX, gen6_statistics_counters), }; /** @} */ @@ -106,7 +136,53 @@ const static struct gl_perf_monitor_group gen6_groups[] = { * Ivybridge/Baytrail/Haswell: * @{ */ +const static struct gl_perf_monitor_counter gen7_statistics_counters[] = { + COUNTER64("IA_VERTICES_COUNT"), + COUNTER64("IA_PRIMITIVES_COUNT"), + COUNTER64("VS_INVOCATION_COUNT"), + COUNTER64("HS_INVOCATION_COUNT"), + COUNTER64("DS_INVOCATION_COUNT"), + COUNTER64("GS_INVOCATION_COUNT"), + COUNTER64("GS_PRIMITIVES_COUNT"), + COUNTER64("CL_INVOCATION_COUNT"), + COUNTER64("CL_PRIMITIVES_COUNT"), + COUNTER64("PS_INVOCATION_COUNT"), + COUNTER64("PS_DEPTH_COUNT"), + COUNTER64("SO_NUM_PRIMS_WRITTEN (Stream 0)"), + COUNTER64("SO_NUM_PRIMS_WRITTEN (Stream 1)"), + COUNTER64("SO_NUM_PRIMS_WRITTEN (Stream 2)"), + COUNTER64("SO_NUM_PRIMS_WRITTEN (Stream 3)"), + COUNTER64("SO_PRIM_STORAGE_NEEDED (Stream 0)"), + COUNTER64("SO_PRIM_STORAGE_NEEDED (Stream 1)"), + COUNTER64("SO_PRIM_STORAGE_NEEDED (Stream 2)"), + COUNTER64("SO_PRIM_STORAGE_NEEDED (Stream 3)"), +}; + +/** MMIO register addresses for each pipeline statistics counter. */ +const static int gen7_statistics_register_addresses[] = { + IA_VERTICES_COUNT, + IA_PRIMITIVES_COUNT, + VS_INVOCATION_COUNT, + HS_INVOCATION_COUNT, + DS_INVOCATION_COUNT, + GS_INVOCATION_COUNT, + GS_PRIMITIVES_COUNT, + CL_INVOCATION_COUNT, + CL_PRIMITIVES_COUNT, + PS_INVOCATION_COUNT, + PS_DEPTH_COUNT, + GEN7_SO_NUM_PRIMS_WRITTEN(0), + GEN7_SO_NUM_PRIMS_WRITTEN(1), + GEN7_SO_NUM_PRIMS_WRITTEN(2), + GEN7_SO_NUM_PRIMS_WRITTEN(3), + GEN7_SO_PRIM_STORAGE_NEEDED(0), + GEN7_SO_PRIM_STORAGE_NEEDED(1), + GEN7_SO_PRIM_STORAGE_NEEDED(2), + GEN7_SO_PRIM_STORAGE_NEEDED(3), +}; + const static struct gl_perf_monitor_group gen7_groups[] = { + GROUP("Pipeline Statistics Registers", INT_MAX, gen7_statistics_counters), }; /** @} */ @@ -272,8 +348,10 @@ brw_init_performance_monitors(struct brw_context *brw) } else if (brw->gen == 6) { ctx->PerfMonitor.Groups = gen6_groups; ctx->PerfMonitor.NumGroups = ARRAY_SIZE(gen6_groups); + brw->perfmon.statistics_registers = gen6_statistics_register_addresses; } else if (brw->gen == 7) { ctx->PerfMonitor.Groups = gen7_groups; ctx->PerfMonitor.NumGroups = ARRAY_SIZE(gen7_groups); + brw->perfmon.statistics_registers = gen7_statistics_register_addresses; } } -- 1.8.3.2 _______________________________________________ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev