intel/perf: refactor gen_perf_end_query into gen_perf
authorMark Janes <mark.a.janes@intel.com>
Fri, 28 Jun 2019 22:11:20 +0000 (15:11 -0700)
committerMark Janes <mark.a.janes@intel.com>
Thu, 8 Aug 2019 04:33:56 +0000 (21:33 -0700)
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
src/intel/perf/gen_perf.c
src/intel/perf/gen_perf.h
src/mesa/drivers/dri/i965/brw_performance_query.c

index 26f6da88d90ac3bf27e71c08e0c5e4e4af3e2619..76caefe6bd01932f20410deca59a3ed48809ee47 100644 (file)
@@ -44,6 +44,8 @@
 #define FILE_DEBUG_FLAG DEBUG_PERFMON
 #define MI_RPC_BO_SIZE              4096
 #define MI_FREQ_START_OFFSET_BYTES  (3072)
+#define MI_RPC_BO_END_OFFSET_BYTES  (MI_RPC_BO_SIZE / 2)
+#define MI_FREQ_END_OFFSET_BYTES    (3076)
 
 #define MAP_READ  (1 << 0)
 #define MAP_WRITE (1 << 1)
@@ -1283,3 +1285,55 @@ gen_perf_begin_query(struct gen_perf_context *perf_ctx,
 
    return true;
 }
+
+void
+gen_perf_end_query(struct gen_perf_context *perf_ctx,
+                   struct gen_perf_query_object *query)
+{
+   struct gen_perf_config *perf_cfg = perf_ctx->perf;
+
+   /* Ensure that the work associated with the queried commands will have
+    * finished before taking our query end counter readings.
+    *
+    * For more details see comment in brw_begin_perf_query for
+    * corresponding flush.
+    */
+  perf_cfg->vtbl.emit_mi_flush(perf_ctx->ctx);
+
+   switch (query->queryinfo->kind) {
+   case GEN_PERF_QUERY_TYPE_OA:
+   case GEN_PERF_QUERY_TYPE_RAW:
+
+      /* NB: It's possible that the query will have already been marked
+       * as 'accumulated' if an error was seen while reading samples
+       * from perf. In this case we mustn't try and emit a closing
+       * MI_RPC command in case the OA unit has already been disabled
+       */
+      if (!query->oa.results_accumulated) {
+         /* Take an ending OA counter snapshot. */
+         perf_cfg->vtbl.capture_frequency_stat_register(perf_ctx->ctx, query->oa.bo,
+                                                     MI_FREQ_END_OFFSET_BYTES);
+         perf_cfg->vtbl.emit_mi_report_perf_count(perf_ctx->ctx, query->oa.bo,
+                                             MI_RPC_BO_END_OFFSET_BYTES,
+                                             query->oa.begin_report_id + 1);
+      }
+
+      --perf_ctx->n_active_oa_queries;
+
+      /* NB: even though the query has now ended, it can't be accumulated
+       * until the end MI_REPORT_PERF_COUNT snapshot has been written
+       * to query->oa.bo
+       */
+      break;
+
+   case GEN_PERF_QUERY_TYPE_PIPELINE:
+      gen_perf_snapshot_statistics_registers(perf_ctx->ctx, perf_cfg, query,
+                                             STATS_BO_END_OFFSET_BYTES);
+      --perf_ctx->n_active_pipeline_stats_queries;
+      break;
+
+   default:
+      unreachable("Unknown query type");
+      break;
+   }
+}
index 212a4094620e292ffba8c64ad4ccd2c9af1618f1..4ca449c36a7d61a9f887d88cb9e1d948d61d014c 100644 (file)
@@ -619,5 +619,7 @@ void gen_perf_dec_n_users(struct gen_perf_context *perfquery);
 
 bool gen_perf_begin_query(struct gen_perf_context *perf_ctx,
                           struct gen_perf_query_object *query);
+void gen_perf_end_query(struct gen_perf_context *perf_ctx,
+                        struct gen_perf_query_object *query);
 
 #endif /* GEN_PERF_H */
index 18b78ba034ab06f1cf95ad879f8da734e3ec91a9..e088220207f83ac5ac6dd2fff753d03a779bde4f 100644 (file)
@@ -657,51 +657,7 @@ brw_end_perf_query(struct gl_context *ctx,
    struct gen_perf_context *perf_ctx = &brw->perf_ctx;
 
    DBG("End(%d)\n", o->Id);
-
-   /* Ensure that the work associated with the queried commands will have
-    * finished before taking our query end counter readings.
-    *
-    * For more details see comment in brw_begin_perf_query for
-    * corresponding flush.
-    */
-   perf_cfg->vtbl.emit_mi_flush(perf_ctx->ctx);
-
-   switch (obj->queryinfo->kind) {
-   case GEN_PERF_QUERY_TYPE_OA:
-   case GEN_PERF_QUERY_TYPE_RAW:
-
-      /* NB: It's possible that the query will have already been marked
-       * as 'accumulated' if an error was seen while reading samples
-       * from perf. In this case we mustn't try and emit a closing
-       * MI_RPC command in case the OA unit has already been disabled
-       */
-      if (!obj->oa.results_accumulated) {
-         /* Take an ending OA counter snapshot. */
-         perf_cfg->vtbl.capture_frequency_stat_register(perf_ctx->ctx, obj->oa.bo,
-                                                        MI_FREQ_END_OFFSET_BYTES);
-         brw->vtbl.emit_mi_report_perf_count(perf_ctx->ctx, obj->oa.bo,
-                                             MI_RPC_BO_END_OFFSET_BYTES,
-                                             obj->oa.begin_report_id + 1);
-      }
-
-      --perf_ctx->n_active_oa_queries;
-
-      /* NB: even though the query has now ended, it can't be accumulated
-       * until the end MI_REPORT_PERF_COUNT snapshot has been written
-       * to query->oa.bo
-       */
-      break;
-
-   case GEN_PERF_QUERY_TYPE_PIPELINE:
-      gen_perf_snapshot_statistics_registers(brw, perf_cfg, obj,
-                                             STATS_BO_END_OFFSET_BYTES);
-      --perf_ctx->n_active_pipeline_stats_queries;
-      break;
-
-   default:
-      unreachable("Unknown query type");
-      break;
-   }
+   gen_perf_end_query(perf_ctx, obj);
 }
 
 static void